Skip to content

Commit

Permalink
fix: pin reference on wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
LasaleFamine committed Feb 22, 2024
1 parent 11aa444 commit 9a399f3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.vscode/ipch
build
.DS_Store
src/src.ino
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ButtinoRAK",
"version": "0.1.3",
"version": "0.1.4",
"description": "Library for the Lualtek Button handler for RAK devices",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ButtinoRAK
version=0.1.3
version=0.1.4
author=Lualtek
maintainer=Lualtek <[email protected]>
sentence=Library for the Lualtek Button handler for RAK devices
Expand Down
11 changes: 7 additions & 4 deletions src/ButtinoRAK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
int counterClick = 0;
unsigned long lastClickTime = 0;
unsigned long startLongPressTime = 0;
int __pin;

void wakeupCallback()
{
Expand All @@ -11,7 +12,7 @@ void wakeupCallback()

startLongPressTime = millis();
// Check if reboot is requested while long pressing
while (digitalRead(BUTTINORAK_PIN) == LOW)
while (digitalRead(__pin) == LOW)
{
if (millis() - startLongPressTime > BUTTINORAK_REBOOT_DELAY)
{
Expand Down Expand Up @@ -40,11 +41,11 @@ void wakeupCallback()
counterClick = 0;
while (1)
{
api.system.sleep.setup(RUI_WAKEUP_FALLING_EDGE, BUTTINORAK_PIN);
api.system.sleep.setup(RUI_WAKEUP_FALLING_EDGE, __pin);
api.system.sleep.all(0); // Set to sleep forever.
pinMode(BUTTINORAK_PIN, INPUT_PULLUP);
pinMode(__pin, INPUT_PULLUP);
delay(BUTTINORAK_REBOOT_DELAY); // Long press to turn off/on, the long press time is 5s.
if (digitalRead(BUTTINORAK_PIN) == LOW)
if (digitalRead(__pin) == LOW)
{
BUTTINOLOG(F("ButtinoRAK .wakeupCallback()"), "Long pressed, rebooting...");
api.system.reboot();
Expand All @@ -64,13 +65,15 @@ ButtinoRAK::ButtinoRAK()
void ButtinoRAK::begin(int pin = BUTTINORAK_PIN)
{
_pin = pin;
__pin = _pin;
pinMode(LED_BUILTIN, OUTPUT);
pinMode(_pin, INPUT_PULLUP);
}

void ButtinoRAK::begin()
{
_pin = BUTTINORAK_PIN;
__pin = _pin;
pinMode(LED_BUILTIN, OUTPUT);
pinMode(_pin, INPUT_PULLUP);
}

0 comments on commit 9a399f3

Please sign in to comment.