Skip to content

Commit b565549

Browse files
committed
Pin.getInfo().negated now set if pin negated in firmware
1 parent 655d377 commit b565549

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
: Array.sort: fix issue where *some* sorts of 10+ items could cause the array not to be GC'd
22
Bangle.js: Updated built-in Layout.js with some minor fixes
3+
STM32: Ensure setDeepSleep(1) will only sleep if there are no active PWM outputs
4+
Pin.getInfo().negated now set if pin negated in firmware
35

46
2v28 : Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]`
57
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)

src/jswrap_pin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ Get information about this pin and its capabilities. Of the form:
282282
{
283283
"port" : "A", // the Pin's port on the chip
284284
"num" : 12, // the Pin's number
285+
"negated" : (2v29+) // true if the pin is negated in firmware, field missing if not
285286
"mode" : (2v25+) // string: the pin's mode (same as Pin.getMode())
286287
"output" : (2v25+) // 0/1: the state of the pin's output register
287288
"in_addr" : 0x..., // (if available) the address of the pin's input address in bit-banded memory (can be used with peek)
@@ -309,9 +310,12 @@ JsVar *jswrap_pin_getInfo(
309310
buf[1] = 0;
310311
jsvObjectSetChildAndUnLock(obj, "port", jsvNewFromString(buf));
311312
jsvObjectSetChildAndUnLock(obj, "num", jsvNewFromInteger(inf->pin-JSH_PIN0));
313+
if (inf->port&JSH_PIN_NEGATED)
314+
jsvObjectSetChildAndUnLock(obj, "negated", jsvNewFromBool(true));
312315
JshPinState state = jshPinGetState(pin);
313316
jsvObjectSetChildAndUnLock(obj, "mode", jshGetPinStateString(state));
314317
jsvObjectSetChildAndUnLock(obj, "output", jsvNewFromInteger((state&JSHPINSTATE_PIN_IS_ON)?1:0));
318+
315319
#ifdef STM32
316320
volatile uint32_t *addr;
317321
addr = jshGetPinAddress(pin, JSGPAF_INPUT);

0 commit comments

Comments
 (0)