Skip to content

Commit 81b6e49

Browse files
committed
Bangle.js: Add Bangle.setOptions({stepCounterDisabled:bool}) to disable the step counter
1 parent 4652584 commit 81b6e49

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Bangle.js: Updated built-in Layout.js with some minor fixes
33
STM32: Ensure setDeepSleep(1) will only sleep if there are no active PWM outputs
44
Pin.getInfo().negated now set if pin negated in firmware
5+
Bangle.js: Add Bangle.setOptions({stepCounterDisabled:bool}) to disable the step counter
56

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

libs/banglejs/jswrap_bangle.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ int twistTimeout = 1000;
910910

911911
/// Current steps since reset
912912
uint32_t stepCounter;
913+
/// Set if steps from the step counter should be ignored
914+
bool stepCounterDisabled = false;
913915
/// What state was the touchscreen last in
914916
typedef enum {
915917
TS_NONE = 0,
@@ -1650,7 +1652,7 @@ void peripheralPollHandler() {
16501652
// we've come out of powersave, reset the algorithm
16511653
stepcount_init();
16521654
}
1653-
if (powerSaveTimer < POWER_SAVE_TIMEOUT) {
1655+
if ((powerSaveTimer < POWER_SAVE_TIMEOUT) && !stepCounterDisabled) {
16541656
// only do step counting if power save is off (otherwise accel interval is too low - also wastes power)
16551657
int newSteps = stepcount_new(accMagSquared);
16561658
if (newSteps>0) {
@@ -2742,6 +2744,7 @@ call `E.kickWatchdog()` from your code or the watch will reset after ~5 seconds.
27422744
* `seaLevelPressure` (Bangle.js 2) Default 1013.25 millibars - this is used when calculating altitude from pressure sensor values from `Bangle.getPressure`/`pressure` events.
27432745
* `lcdBufferPtr` (Bangle.js 2 2v21+) Return a pointer to the first pixel of the 3 bit graphics buffer used by Bangle.js for the screen (stride = 178 bytes)
27442746
* `lcdDoubleRefresh` (Bangle.js 2 2v22+) If enabled, pulses EXTCOMIN twice per poll interval (avoids off-axis flicker)
2747+
* `stepCounterDisabled` (Bangle.js 2v29+) If set, this stops steps from being counted
27452748
27462749
Where accelerations are used they are in internal units, where `8192 = 1g`
27472750
@@ -2800,6 +2803,7 @@ JsVar * _jswrap_banglejs_setOptions(JsVar *options, bool createObject) {
28002803
{"gestureMinLength", JSV_INTEGER, &accelGestureMinLength},
28012804
{"stepCounterThresholdLow", JSV_INTEGER, &stepCounterThresholdLow},
28022805
{"stepCounterThresholdHigh", JSV_INTEGER, &stepCounterThresholdHigh},
2806+
{"stepCounterDisabled", JSV_BOOLEAN, &stepCounterDisabled},
28032807
{"twistThreshold", JSV_INTEGER, &twistThreshold},
28042808
{"twistTimeout", JSV_INTEGER, &twistTimeout},
28052809
{"twistMaxY", JSV_INTEGER, &twistMaxY},

0 commit comments

Comments
 (0)