Skip to content

Commit

Permalink
ESP32: properly negate button value, and ensure setWatch works ok
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Dec 14, 2024
1 parent e76a71b commit 640b45e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions boards/ESP32.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
};
devices = {
'LED1' : { 'pin' : 'D2' },
'BTN1' : { 'pin' : 'D0', "inverted":1, 'pinstate' : 'IN_PULLUP' }
'BTN1' : { 'pin' : 'D0' }
};

# left-right, or top-bottom order
Expand Down Expand Up @@ -182,7 +182,7 @@ def get_pins():
pinutils.findpin(pins, "PD25", True)["functions"]["DAC_OUT1"]=0;
pinutils.findpin(pins, "PD26", True)["functions"]["DAC_OUT2"]=0;

pinutils.findpin(pins, "PD0", True)["functions"]["LED_1"]=0;
pinutils.findpin(pins, "PD0", True)["functions"]["NEGATED"]=0; # BTN1 negate

pinutils.findpin(pins, "PD10", True)["functions"]["USART0_TX"]=0;
pinutils.findpin(pins, "PD16", True)["functions"]["USART2_RX"]=0;
Expand Down
5 changes: 3 additions & 2 deletions targets/esp32/jshardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@ void jshKickWatchDog() {
*/
bool CALLED_FROM_INTERRUPT jshGetWatchedPinState(IOEventFlags eventFlag) { // can be called at interrupt time
gpio_num_t gpioNum = pinToESP32Pin((Pin)(eventFlag-EV_EXTI0));
bool level = gpio_get_level(gpioNum);
return level;
bool value = gpio_get_level(gpioNum);
if (pinInfo[gpioNum].port & JSH_PIN_NEGATED) value=!value;
return value;
}


Expand Down

0 comments on commit 640b45e

Please sign in to comment.