-
I'm thinking about how to improve navigation to waypoints and routes and what is / what is not possible.
Did some experiments with the GPS against my Garmin eTrex and noticed at one point I seemed to be suddenly 20m from my previous position when in fact I was standing still. The eTrex kept solid but the UBLUX GPS wobbles a fair amount.
I wrote some code that set the GPS in SuperE mode and waited for at least 2 fixes then started to log the distance, average and max distance between subsequent fixes. The results are below:
distance: 3 avg=3.36624203821 max_dist 18 >Bangle.setGPSPower(0); =false >
So it might be necessary in some situations to use a rolling average of 3-5 fixes (when stationary).
-
-
-
-
Hi there, my bangle had a bit of a meltdown today. I noticed this morning that I could not get into the ActivePedom settings to look at the sensitivity value, just would not go into the settings. Then went to a 3 mile walk with Walkers Watch running GPS / grid ref on and GPS recorder on. When got back could not display a the GPS log from GPS recorder, just came up with a low memory issue in RED. Did a BTN1+BTN2 reboot a few times, no luck. Decided to try a compact - which ran for ages but was NOT interrupted. When it can back it said 'no clock found'. BTN2 would respond and went into TapeLauncher but there appeared to only be about 4 apps (possibly the info files had got lost).
Connected through IDE and could see the App files were all there. There was however a very large file of about 300KB see screenshot. When downloaded it looked like a concatenation of all files. Decided to rebuild my Bangle, using the App Loader, Delate all apps and install defaults. Then installed favourites.
I then tried another Compact which did not end after 10 minutes and reset the watch. This time no apparent issues though.
To be fair I have put my watch through its paces, I have tried almost every App and doing lots of tests and development, manually wrting info files for new apps, getting things wrong etc, so I might have provoked these issues. No necessarily a bad thing to completely reinstall the watch after a week of tinkering :)
Just wondering if there might be an issue with compact on 2.08.167?
-
-
Wonderful.
I think we have a problem with the calling of the GPSSetup functions through promises. Everything looks like it works BUT in practice it looks like the settings do not take effect. This is a bit of uncertainty principle with this issues when you go looking for it - its not there.
What I observed last night.
1) Went out for a walk with GPS setup in PSMOO mode with updates every 120s. Decided I wanted to test the display of speed so I reran the App to SuperE mode so that I could get an update every second. When the GPS got a fix it shutdown and slept for 100+ seconds as if PSMOO mode was operating. I went home and checked the code - no the code is correct. I uncommented log_debug() and ran connected to the IDE - everything seemed to work fine. Disconnected and repeated the experiments to find that though 'Configuring GPS' was displayed I was not getting 1s updates in what I thought was SuperE mode.
2) Installed the old GPSservice App and switched between power options a couple of times and observed the expected frequecy of the updates - no issues.
My only conclusion is that something unknown is going on when we use the Promise / delay() way of sequencing the setup functions.
To fully reproduce
1) Ensure GPS has been on and established satellites and a fix using the GPS Info App.
2) Switch off that App and now use GPS Time
3) If you think that the Power mode is PSMOO then after 120s the Time on GPS Time display should stop updating for approx 100+ seconds and then start again.
4) Now try switching modes again using GPSSetup and repeat and observe behaviour.
5) Confirm that repeating with GPS Service does not have the same problem (it uses the evil wait() hack). -
-
-
Thanks Gordon, what should be done with the now redundant gpsservice widget ?
Should I delete the directory and filesd in gpsservice and remove gps.js and osref.js from multiclock ?I have made myself a clock like osref.js that allows me to turn the GPS on / off through button presses, still perfecting it and will do a pull request for that soon.
-
Aha - cracked it. In order for this to work, the PowerOff GPS has to be part of the promise chain otherwise the GPS will be powered off before any of the setup functions get called.
This log shows that the GPS was getting powered off before the config functions had been called.
1612911680439.88598632812 : loadSettings() 1612911680515.14233398437 : [object Object] 1612911688460.4853515625 : exitSetup() 1612911688462.83520507812 : [object Object] 1612911689101.75122070312 : setupGPS() PSMOO 1612911689108.15991210937 : Powering GPS Off 1612911689112.61547851562 : UBX_CFG_RESET() ERROR: Invalid RX or TX pins 1612911689242.68139648437 : UBX_CFG_PM2() ERROR: Invalid RX or TX pins 1612911689335.45483398437 : UBX_CFG_RXM() ERROR: Invalid RX or TX pins 1612911689370.275390625 : UBX_CFG_SAVE() ERROR: Invalid RX or TX pins > > >
Now using this code:
function setupPSMOO() { log_debug("setupGPS() PSMOO"); Promise.resolve().then(function() { UBX_CFG_RESET(); return delay(100); }).then(function() { UBX_CFG_PM2(settings.update, settings.search); return delay(20); }).then(function() { UBX_CFG_RXM(); return delay(20); }).then(function() { UBX_CFG_SAVE(); return delay(20); }).then(function() { log_debug("Powering GPS Off"); /* * must be part of the promise chain to ensure that * setup does not return and powerOff before config functions * have run * */ Bangle.setGPSPower(0); return delay(20); }); }
I can see everything working properly.
1612912276800.58569335937 : loadSettings() 1612912276876.20825195312 : [object Object] 1612912286403.42993164062 : exitSetup() 1612912286405.77978515625 : [object Object] 1612912287045.123046875 : setupGPS() PSMOO 1612912287053.27124023437 : UBX_CFG_RESET() 1612912287181.38403320312 : UBX_CFG_PM2() 1612912287272.99780273437 : UBX_CFG_RXM() 1612912287307.84887695312 : UBX_CFG_SAVE() 1612912287355.33422851562 : Powering GPS Off >
Yeah - getting code ready for pull request. Many thanks for all you help @Gordon.
-
GPS Setup is pretty much ready. I have most of the code in my repository.
Switched to using promises and noticed that I dont think the delay() function is working as expected.LOG USING EXISTING (hacky loop) METHOD
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v08.167 (c) 2019 G.Williams 1612906951505.60473632812 : loadSettings() 1612906951580.55590820312 : [object Object] 1612906960116.4140625 : exitSetup() 1612906960118.94702148437 : [object Object] 1612906960754.65869140625 : setupGPS() PSMOO <<== time between 1612906961038.22802734375 : Powering GPS Off <<== is 284ms see 'Configuring GPS' message
CONSOLE LOG USING PROMISES
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v08.167 (c) 2019 G.Williams 1612907245516.38134765625 : loadSettings() 1612907245591.24096679687 : [object Object] 1612907262076.53149414062 : exitSetup() 1612907262078.91186523437 : [object Object] 1612907262716.82080078125 : setupGPS() PSMOO <<== time between 1612907262723.29052734375 : Powering GPS Off <<== is 7ms ERROR: Invalid RX or TX pins ERROR: Invalid RX or TX pins ERROR: Invalid RX or TX pins ERROR: Invalid RX or TX pins >
The 4 ERROR: Invalid RX or TX pins messages look like they are a response to config commands being sent too fast to the GPS. Also the time between calling setupGPS() and 'Powering off GPS' log message is only 7ms with the promises code.
-
-
Here's the solution I have come up with for turning the BTN2 short press into a long press. I start a timer and when I have held the button long enough I make the Bangle buzz, then I can release the button. If the button is released too early there is no buzz. I cancell the timer on release of BTN2. This works quite nicely, it mean you just hold BTN2 until the buzz then release. This will stop going into the launcher by accidently catching BTN2 with your sleeve etc. But it still allows you to get into the launcher if you want to.
// start a timer and buzz whenn held long enough function firstPressed() { firstPress = getTime(); pressTimer = setInterval(longPressCheck, 1500); } // if you release too soon there is no buzz as timer is cleared function thenReleased() { var dur = getTime() - firstPress; if (pressTimer) { clearInterval(pressTimer); pressTimer = undefined; } if ( dur >= 1.5 ) Bangle.showLauncher(); } // when you feel the buzzer you know you have done a long press function longPressCheck() { Bangle.buzz(); if (pressTimer) { clearInterval(pressTimer); pressTimer = undefined; } } var pressTimer; // make BTN require a long press (1.5 seconds) to switch to launcher setWatch(firstPressed, BTN2,{repeat:true,edge:"rising"}); setWatch(thenReleased, BTN2,{repeat:true,edge:"falling"});
-
-
-
so to investigate the chaining of these setTimeout()s I decide to generalise the problem to:
function func() { func_1(); wait(delay_1); func_2(); wait(delay_2); func_3(); wait(delay_3); func_4(); wait(delay_4); }
which can be implemented as....
const delay_1 = 1000; const delay_2 = 3000; const delay_3 = 5000; const delay_4 = 7000; function func_1() {console.log("func_1 " + new Date().toString().split(" ")[4]);} function func_2() {console.log("func_2 " + new Date().toString().split(" ")[4]);} function func_3() {console.log("func_3 " + new Date().toString().split(" ")[4]);} function func_4() {console.log("func_4 " + new Date().toString().split(" ")[4]);} function func() { console.log("START: " + new Date().toString().split(" ")[4]); func_1(); setTimeout(function() { func_2(); setTimeout(function() { func_3(); setTimeout(function() { func_4(); setTimeout(function() { // no op console.log("END: " + new Date().toString().split(" ")[4]); }, delay_4); }, delay_3); }, delay_2); }, delay_1); } func();
when run through the emulator I can see that this works.
> >START: 00:02:41 func_1 00:02:41 > func_2 00:02:43 func_3 00:02:47 func_4 00:02:53 END: 00:03:01 >
But it is ugly as sin :(
-
So to answer your question - what is wait() - it was a hack that I knew would one day need to be discussed. Its the bad bit of code below:
// quick hack function wait(ms){ var start = new Date().getTime(); var end = start; while(end < start + ms) { end = new Date().getTime(); } }
What is really needed is a yield(ms) function that gracefully yields but comes back to the same thread in ms time.
So the question is how to code using timers something like this:
function setupPSMOO() { log_debug("setupGPS() PSMOO"); UBX_CFG_RESET(); wait(100); UBX_CFG_PM2(settings.update, settings.search); wait(20); UBX_CFG_RXM(); wait(20); UBX_CFG_SAVE(); wait(20); }
-
Have ended up with the hybrid approach below. Nothing gets displayed with the code block you suugested. With E.showMessage("Configuring GPS") on its own, it flashes on screen and is gone very quickly. The approach below gives long enough to see the message.
function exitSetup() { log_debug("exitSetup()"); if (settings_changed) { log_debug(settings); E.showMessage("Configuring GPS"); setTimeout(function() { setupGPS(); setTimeout(function() { load() }, 500); }, 750); } else { load(); }; }
-
Thanks for you help @Gordon. I am back up and running. Have fixed the above issue. Just installed the App through MyLoader and got a correct .info file as below.
{"id":"tapelauncher","name":"Tape Launcher","type":"launch","src":"tapelauncher.app.js","icon":"tapelauncher.img","version":"0.02","files":"tapelauncher.info,tapelauncher.app.js,tapelauncher.img"}
Maybe there is a need for the Travis CI tests to look for App entries that dont match the id properly in the apps.json file.
I wondering what the recommended way to switch to a different loader is meant to be ? So far I have had to delete the others in order to get a different one to work.
-
I wonder if there is no src element as the name of the app is different to the id in the apps.json file.
I will get this fixed. Just hoping it is not going to cause upgrade issues. Does an install through the AppLoader site first delete all the files as per the info file on the Bangle storage and then install them again from the github location? If so then I think there wont be any complications if I change all the entries to say tapelaucher.{ "id": "tapelauncher", "name": "Tape Launcher", "icon": "icon.png", "version":"0.01", "description": "An App launcher, icons displayed in a horizontal tape, swipe or use buttons", "readme": "README.md", "tags": "tool,system,launcher", "type":"launch", "storage": [ {"name":"tapelaunch.app.js","url":"app.js"}, {"name":"tapelaunch.img","url":"icon.js","evaluate":true} ] },
-
I have 3 launchers on my bangle with .info files as below.
None of them will launch by Bangle.showLauncher().dtlaunch.info
{"id":"dtlaunch","name":"Desktop Launcher","type":"launch","src":"dtlaunch.app.js","icon":"dtlaunch.img","version":"0.03","files":"dtlaunch.info,dtlaunch.app.js,dtlaunch.img"}
and launch.info
{"id":"launch","name":"Launcher","type":"launch","src":"launch.app.js","sortorder":-10,"version":"0.04","files":"launch.info,launch.app.js"}
and tapelauncher.info
{"id":"tapelauncher","name":"Tape Launcher","type":"launch","version":"0.01","files":"tapelauncher.info,tapelaunch.app.js,tapelaunch.img"}
-
-
Hi there.
I deleted one of the launchers on the bangle and now Bangle.showLauncher() will not run.
I can run one of the launchers by starting it through the IDE but its like the bangle can no longer find a launcher ? I am on v2.08.167 firmware.How does the Bangle know which launcher to select if you have more than one installed.
Hugh
I didn't use the AGPS but I had previously been doing a lot of testing with the GPS on so it should have been warmed up to recent satelite positions. I am assuming here that AGPS just speeds up the first satelite aquisition phase and once you have had a recent fix (last 5-10 minutes) it does not take very long to get a fix again and at that point AGPS would not make any difference ? I can still see this kind of behaviour when I stand on a spot I can see the lat/lon switching around which is why I wrote some code to work out the average and max differences between 2 fixes from the same spot.