Closed cwilling closed 1 year ago
Thanks! For the array, please could you use jsvIterator
instead?
JsvIterator it;
jsvIteratorNew(&it, array, JSIF_DEFINED_ARRAY_ElEMENTS);
while (jsvIteratorHasElement(&it)) {
... jsvIteratorGetValue(&it);
jsvIteratorNext(&it);
}
jsvIteratorFree(&it);
There are some plans to change the way arrays are stored eventually (to make them a tree), so when doing that using LastChild would break.
OK, using JsvIterator now.
That was quick! But sorry - just spotted some other minor things...
pinSum = (uint64_t)pow(2, pin);
be pinSum = 1<<pin;
in the two places where it's done? There's no need to drag in double arithmetic for it when a shift will do.Pin pin = jshGetPinFromVar(jsvIteratorGetValue(&it));
will actually cause a memory leak because the return value from jsvIteratorGetValue isn't unlocked. It's not a big deal as we're shutting everything down, but it's not good practise esp if someone copy/pastes it for something else. All you need to do is change it to jshGetPinFromVarAndUnLock(jsvIteratorGetValue(&it));
Done. Thanks for the tips.
Great! Thanks!
An array of RTC enabled GPIOs can be used to wake from deep sleep. Example code:
// Flash LED1 (while awake) var on = false; setInterval(function() { on = !on; LED1.write(on); }, 500);
// Every 10secs, sleep until any of pinArray is pressed setInterval(function() { var pinArray = [D4,D15];
ESP32.deepSleepExt1(pinArray, 1); }, 10000);