-
Had some success with the test bed code below.
Be good if you could verify the result.Setting the update and search time to 120s and baud rate to 120s:
After the GPS has settled down and established its first fix I can see a cylcle of about 40-50s at 31mA and about 70s at 7.8mA. Increasing the period will increase the time it consumes the 7.8mA. So there is a trade off in terms of how recent you want the last fix to be. The 120s setting will effectively average the consumption out to 15mA - but that will double the battery life when GPS is on. My requirement is to get a GRID REF when walking and I dont mind it ot was 2 minutes ago. At 15mA average consumption you would get about 20hrs time with the GPS on all day as opposed to 10hrs using the PMS/SuperE mode./* test bed for working out lowest power consumption, with workable GPS Load into IDE and upload code to RAM when connected to watch */ Bangle.on('GPS-raw',function (d) { if (d[0]=="$") return; if (d.startsWith("\xB5\x62\x05\x01")) print("GPS ACK"); else if (d.startsWith("\xB5\x62\x05\x00")) print("GPS NACK"); // 181,98 sync chars else print("GPS",E.toUint8Array(d).join(",")); }); function writeGPScmd(cmd) { var d = [0xB5,0x62]; // sync chars d = d.concat(cmd); var a=0,b=0; for (var i=2;i<d.length;i++) { a += d[i]; b += a; } d.push(a&255,b&255); console.log(d); Serial1.write(d); } // quick hack function wait(ms){ var start = new Date().getTime(); var end = start; while(end < start + ms) { end = new Date().getTime(); } } function UBX_CFG_PMS() { // UBX-CFG-PMS - enable power management - Super-E writeGPScmd([0x06,0x86, // msg class + type 8,0,//length 0x00,0x03, 0,0, 0,0, 0,0]); } function UBX_CFG_INTERVAL(period, ontime) { writeGPScmd([0x06,0x86, // msg class + type 8,0, //length //v0, interval period ontime reserved 0x00, 0x02, period, 0, ontime, 0, 0, 0 ]); // the values are little endian, least significant byte first } /* * set update baud rate * * the setting is in milliseconds in 2 bytes, max 65 seconds * we are passing in a value in seconds * we set the most significant byte only * 8 seconds ~ 8192ms 0x2000, 0x20 = 32 = 4*8 * */ function UBX_CFG_RATE(rate) { rate = (rate * 4) % 256; //console.log("rate=" + rate); writeGPScmd([0x06,0x08, // class, id 0x06, 0, // length 0x00, rate, // b0: 8192ms 0x2000, 0x00FF (~65sec) 0x01, 0x00, // b2: 0x01, 0x00]); // b4: timeref GPS } /* * Save configuration otherwise it will reset when the GPS wakes up * */ function UBX_CFG_SAVE() { writeGPScmd([0x06, 0x09, // class id 0x0D, 0x00, // length 0x00, 0x00, 0x00, 0x00, // clear mask 0xFF, 0xFF, 0x00, 0x00, // save mask 0x00, 0x00, 0x00, 0x00, // load mask 0x07]); // b2=eeprom b1=flash b0=bat backed ram // code on github had 7 - all 3 set ? } /* * Reset to factory settings using clear mask in UBX_CFG_CFG * https://portal.u-blox.com/s/question/0D52p0000925T00CAE/ublox-max-m8q-getting-stuck-when-sleeping-with-extint-pin-control */ function UBX_CFG_RESET() { writeGPScmd([0x06, 0x09, // class id 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, // clear mask 0x00, 0x00, 0x00, 0x00, // save mask 0xFF, 0xFF, 0x00, 0x00, // load mask 0x17]); } // convert an integer to an array of bytes function int_2_bytes( x ){ var bytes = []; var i = 4; do { bytes[--i] = x & (255); x = x>>8; } while (i); return bytes; } /* * Extended Power Management * update and search are in seconds * * https://github.com/thasti/utrak/blob/master/gps.c */ function UBX_CFG_PM2(update,search) { var u = int_2_bytes(update*1000); var s = int_2_bytes(search*1000); writeGPScmd([0x06, 0x3B, /* class id */ 44, 0, /* length */ 0x01, 0x00, 0x00, 0x00, /* v1, reserved 1..3 */ 0x00, 0x10, 0x00, 0x00, /* on/off-mode, update ephemeris */ // little endian, lsb first //0x30, 0x75, 0x00, 0x00, /* update period, ms, 120s=00 01 D4 C0, 30s= 00 00 75 30 */ //0x88, 0x13, 0x00, 0x00, /* search period, ms, 120s, 20s = 00 00 4E 20, 5s = 13 88 */ u[3], u[2], u[1], u[0], /* update period, ms, 120s=00 01 D4 C0, 30s= 00 00 75 30 */ s[3], s[2], s[1], s[0], /* search period, ms, 120s, 20s = 00 00 4E 20, 5s = 13 88 */ 0x00, 0x00, 0x00, 0x00, /* grid offset */ 0x00, 0x00, /* on-time after first fix */ 0x01, 0x00, /* minimum acquisition time */ 0x00, 0x00, 0x00, 0x00, /* reserved 4,5 */ 0x00, 0x00, 0x00, 0x00, /* reserved 6 */ 0x00, 0x00, 0x00, 0x00, /* reserved 7 */ 0x00, 0x00, 0x00, 0x00, /* reserved 8,9,10 */ 0x00, 0x00, 0x00, 0x00]); /* reserved 11 */ } // enable power saving mode, after configured with PM2 function UBX_CFG_RXM() { writeGPScmd([0x06, 0x11, /* UBX-CFG-RXM */ 2, 0, /* length */ 0x08, 0x01]); /* reserved, enable power save mode */ } function onGPS(fix) { console.log(fix); } function setupGPS() { Bangle.setGPSPower(1); UBX_CFG_RESET(); wait(100); //UBX_CFG_INTERVAL(30,25); //wait(20); UBX_CFG_PM2(120,120); wait(20); UBX_CFG_RATE(60); wait(20); UBX_CFG_RXM(); wait(20); UBX_CFG_SAVE(); wait(20); Bangle.on('GPS',onGPS); } // call setupGPS(); to run test // Bangle.setGPSPower(0); to end test
-
The moded Bangle has arrived. Just loading it up with the software etc.
Noticed that the firmware is 2.05.
I tried to update the firmware but had trouble selecting the firmware.zip file from downloads. What my phone does is show me a list of contents of the zip but no other options.Will the different firmware make much difference to the tests ?
-
The following code works fine in the emulator.
g.drawImage(atob("GBjCAP////+rStqvAAAAAAAAAAAqqAAAAAKv+oAAACtVV+gAAKVVXvoAApVV6/6AAlVXv/+AC1VXv6/gCVVVvu/gKValqnroLt7pfVV4L5vpVVV4LtulVX14LquVX6p4K6+lar5oC//te/tgC//5Xq3gAv/pVdWAAr/tVVaAAK/lVVoAACvlVegAAAKv+oAAAAAqqAAAAAAAAAAA"),40,40);
But when I try to load it as a clock face for multiclock it fails.
(() => { function getFace(){ function draw() { g.reset(); g.drawImage(atob("GBjCAP////+rStqvAAAAAAAAAAAqqAAAAAKv+oAAACtVV+gAAKVVXvoAApVV6/6AAlVXv/+AC1VXv6/gCVVVvu/gKValqnroLt7pfVV4L5vpVVV4LtulVX14LquVX6p4K6+lar5oC//te/tgC//5Xq3gAv/pVdWAAr/tVVaAAK/lVVoAACvlVegAAAKv+oAAAAAqqAAAAAAAAAAA"),40,40); } return {init:draw}; } return getFace; })();
the error message I get is:
Uncaught Error: Expecting first argument to a valid Image at line 1 col 251 ...oAAAAAqqAAAAAAAAAAA"),40,40); ^ in function "init" called from line 1 col 52 ...le.drawWidgets();face.init();intervalRefSec=setInterval(face... ^ in function "startdraw" called from line 1 col 102 ...e=FACES[iface]();startdraw(); ^ in function called from system >
Any ideas what I am doing wrong ?
-
-
From various bits of code I was found on the web I think the sequence has to be something like.
UBX_CFG_RESET(); // do a factory reset to ensure my setup is taken wait(20); UBX_CFG_INTERVAL(29,5); // PMS wait(20); UBX_CFG_PM2(); // with same intervals but in ms instead of seconds wait(20); UBX_CFG_RATE(17); // set the rate but may not be required wait(20); UBX_CFG_SAVE(); // save the configuration as it gets reset on wake up wait(5);
-
My gpsservice now has a settings.json file in which I store "service": true/false.
Most of the settings examples call the reload() function on the widget but really all I want to do is save the values.
I notice that when you exit the settings App this causes the widget to be restarted.
I dont think its a good idea to call reload() inside the draw() function.Is there a way to call reload() when the widget is restarted such that it determine its state and what to do ?
Also I would ideally want to call the Bangle object to determine if GPS is on or not, rather than try and track it through variables in the widget. -
-
Any chance you could try my UBX-CFG-PM2() I got most of the code from the link in the comments and adjusted the timings I wanted.
I got the bytes from the code at:
https://github.com/thasti/utrak/blob/master/gps.c/* * NOT TRIED, NOT TESTED YET * https://github.com/thasti/utrak/blob/master/gps.c */ function UBX_CFG_PM2() { writeGPScmd([0x06, 0x3B, /* class id */ 44, 0, /* length */ 0x01, 0x00, 0x00, 0x00, /* v1, reserved 1..3 */ 0x00, 0x10, 0x00, 0x00, /* on/off-mode, update ephemeris */ // little endian, lsb first 0x30, 0x75, 0x00, 0x00, /* update period, ms, 120s=00 01 D4 C0, 30s= 00 00 75 30 */ 0x20, 0x4E, 0x00, 0x00, /* search period, ms, 120s, 20s = 00 00 4E 20 */ 0x00, 0x00, 0x00, 0x00, /* grid offset */ 0x00, 0x00, /* on-time after first fix */ 0x01, 0x00, /* minimum acquisition time */ 0x00, 0x00, 0x00, 0x00, /* reserved 4,5 */ 0x00, 0x00, 0x00, 0x00, /* reserved 6 */ 0x00, 0x00, 0x00, 0x00, /* reserved 7 */ 0x00, 0x00, 0x00, 0x00, /* reserved 8,9,10 */ 0x00, 0x00, 0x00, 0x00]); /* reserved 11 */ };
-
-
I agree. In my code widget I have drafted functions marked NEW/NOT TESTED I have done the code for UBX-CFG-PM2(), not been able to test yet. I read the above comment in the datasheet a while back but did not understand what it meant. I now understand that UBX-CFG-PMS is mean't to be a superset for power management. Hovever PMS seems a bit redundant when it sounds like you have to fill in PM2 as well. One of the power management PDFs shows a chart saying you can get 2ms when using a 10s interval period - the holy grail I guess.
-
-
-
Here's my test bed code (based on your test code). I just load it into the IDE and test via the command line. Hoping some of the PM2 functions does the trick, though I can see lots of questions on the web on how to get this to work. I am switching evenings between writing bits of code and reading the datasheet and doing a test session on another day.
/* test bed for working out lowest power consumption, with workable GPS Load into IDE and upload code to RAM when connected to watch */ Bangle.on('GPS-raw',function (d) { if (d[0]=="$") return; if (d.startsWith("\xB5\x62\x05\x01")) print("GPS ACK"); else if (d.startsWith("\xB5\x62\x05\x00")) print("GPS NACK"); // 181,98 sync chars else print("GPS",E.toUint8Array(d).join(",")); }); function writeGPScmd(cmd) { var d = [0xB5,0x62]; // sync chars d = d.concat(cmd); var a=0,b=0; for (var i=2;i<d.length;i++) { a += d[i]; b += a; } d.push(a&255,b&255); console.log(d); Serial1.write(d); } // quick hack function wait(ms){ var start = new Date().getTime(); var end = start; while(end < start + ms) { end = new Date().getTime(); } } function UBX_CFG_PMS() { // UBX-CFG-PMS - enable power management - Super-E writeGPScmd([0x06,0x86, // msg class + type 8,0,//length 0x00,0x03, 0,0, 0,0, 0,0]); } function UBX_CFG_INTERVAL(period, ontime) { writeGPScmd([0x06,0x86, // msg class + type 8,0, //length //v0, interval period ontime reserved 0x00, 0x02, period, 0, ontime, 0, 0, 0 ]); // the values are little endian, least significant byte first } /* * set update baud rate * * the setting is in milliseconds in 2 bytes, max 65 seconds * we are passing in a value in seconds * we set the most significant byte only * 8 seconds ~ 8192ms 0x2000, 0x20 = 32 = 4*8 * */ function UBX_CFG_RATE(rate) { rate = (rate * 4) % 256; console.log("rate=" + rate); writeGPScmd([0x06,0x08, // class, id 0x06, 0, // length 0x00, rate, // b0: 8192ms 0x2000, 0x00FF (~65sec) 0x01, 0x00, // b2: 0x01, 0x00]); // b4: timeref GPS } /* * Save configuration otherwise it will reset when the GPS wakes up * */ function UBX_CFG_SAVE() { writeGPScmd([0x06, 0x09, // class id 0x0D, 0x00, // length 0x00, 0x00, 0x00, 0x00, // clear mask 0xFF, 0xFF, 0x00, 0x00, // save mask 0x00, 0x00, 0x00, 0x00, // load mask 0x01]); // b2=eeprom b1=flash b0=bat backed ram // code on github had 7 - all 3 set ? } function onGPS(fix) { console.log(fix); } Bangle.setGPSPower(1); UBX_CFG_INTERVAL(30,5); wait(20); UBX_CFG_RATE(8); wait(20); UBX_CFG_SAVE(); Bangle.on('GPS',onGPS);
I am hoping if you can test connected to a milliamp meter on the bench you might be able to find the right sequence to get to the magic 2mA current usage. I am looking for a usable fix update between 30-60 seconds. This is why I have set UBX_CFG_PM2 to 30 and 20 seconds for the update and search times (though as I say, yet to try these new functions, I have just drafted them out tonight).
-
Here is the last version of my widget. Not yet checked into git. I dont think I have low power working yet. Have been looking at other code across the web, github etc. I have added some new functions tonight but they are not tested yet. I've not yet spent the time of the settings file so to switch on and off have using command line whne connected through the IDE.
WIDGETS.gpsservice.gps_power_on();
The Widget.
(() => { var have_fix = false; var fixToggle = false; // toggles once for each reading var gps_power = false; var last_fix = { fix: 0, alt: 0, lat: 0, lon: 0, speed: 0, time: 0, satellites: 0 }; function gps_get_fix() { return last_fix; } function gps_get_status() { return gps_power;} function gps_power_on() { have_fix = false; fixToggle = false; gps_power = true; setupGPS(); } function gps_power_off() { Bangle.setGPSPower(0); gps_power = false; have_fix = false; fixToggle = false; gps_power = false; last_fix.fix = 0; } // quick hack function wait(ms){ var start = new Date().getTime(); var end = start; while(end < start + ms) { end = new Date().getTime(); } } function setupGPS() { Bangle.setGPSPower(1); wait(20); UBX_CFG_INTERVAL(29,5); wait(20); UBX_CFG_RATE(17); wait(20); UBX_CFG_SAVE(); wait(5); Bangle.on('GPS', onGPS); } // NEW NOT TRIED YET function setupGPS_PMS2() { Bangle.setGPSPower(1); wait(20); UBX_CFG_RESET(); wait(100);//wait for effect //Set power mode / interval mode UBX_CFG_PM2(); wait(20); //save UBX_CFG_SAVE(); wait(20); Bangle.on('GPS', onGPS); } function writeGPScmd(cmd) { var d = [0xB5,0x62]; // sync chars d = d.concat(cmd); var a=0,b=0; for (var i=2;i<d.length;i++) { a += d[i]; b += a; } d.push(a&255,b&255); //console.log(d); Serial1.write(d); } // UBX-CFG-PMS - enable power management - Super-E function UBX_CFG_PMS() { writeGPScmd([0x06,0x86, // msg class + type 8,0,//length 0x00,0x03, 0,0, 0,0, 0,0]); } function UBX_CFG_INTERVAL(period, ontime) { writeGPScmd([0x06,0x86, // msg class + type 8,0, //length //v0, interval period ontime reserved 0x00, 0x02, period, 0, ontime, 0, 0, 0 ]); // the values are little endian, least significant byte first } /* * NOT TRIED, NOT TESTED YET * https://github.com/thasti/utrak/blob/master/gps.c */ function UBX_CFG_PM2() { writeGPScmd([0x06, 0x3B, /* class id */ 44, 0, /* length */ 0x01, 0x00, 0x00, 0x00, /* v1, reserved 1..3 */ 0x00, 0x10, 0x00, 0x00, /* on/off-mode, update ephemeris */ // little endian, lsb first 0x30, 0x75, 0x00, 0x00, /* update period, ms, 120s=00 01 D4 C0, 30s= 00 00 75 30 */ 0x20, 0x4E, 0x00, 0x00, /* search period, ms, 120s, 20s = 00 00 4E 20 */ 0x00, 0x00, 0x00, 0x00, /* grid offset */ 0x00, 0x00, /* on-time after first fix */ 0x01, 0x00, /* minimum acquisition time */ 0x00, 0x00, 0x00, 0x00, /* reserved 4,5 */ 0x00, 0x00, 0x00, 0x00, /* reserved 6 */ 0x00, 0x00, 0x00, 0x00, /* reserved 7 */ 0x00, 0x00, 0x00, 0x00, /* reserved 8,9,10 */ 0x00, 0x00, 0x00, 0x00]); /* reserved 11 */ }; /* * set update baud rate * * the setting is in milliseconds in 2 bytes, max 65 seconds * we are passing in a value in seconds * we set the most significant byte only * 8 seconds ~ 8192ms 0x2000, 0x20 = 32 = 4*8 * */ function UBX_CFG_RATE(rate) { rate = (rate * 4) % 256; //console.log("rate=" + rate); writeGPScmd([0x06,0x08, // class, id 0x06, 0, // length 0x00, rate, // b0: 8192ms 0x2000, 0x00FF (~65sec) 0x01, 0x00, // b2: 0x01, 0x00]); // b4: timeref GPS } /* * Save configuration otherwise it will reset when the GPS wakes up * */ function UBX_CFG_SAVE() { writeGPScmd([0x06, 0x09, // class id 0x0D, 0x00, // length 0x00, 0x00, 0x00, 0x00, // clear mask 0xFF, 0xFF, 0x00, 0x00, // save mask 0x00, 0x00, 0x00, 0x00, // load mask // 0x01]); // b2=eeprom b1=flash b0=bat backed ram 0x07]); // b2=eeprom b1=flash b0=bat backed ram // code on github had 7 - all 3 set ? } /* * NOT TRIED, NOT TESTED * Reset to factory settings using clear mask in UBX_CFG_CFG * https://portal.u-blox.com/s/question/0D52p0000925T00CAE/ublox-max-m8q-getting-stuck-when-sleeping-with-extint-pin-control */ function UBX_CFG_RESET() { writeGPScmd([0x06, 0x09, // class id 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, // clear mask 0x00, 0x00, 0x00, 0x00, // save mask 0xFF, 0xFF, 0x00, 0x00, // load mask 0x17]); } // draw the widget function draw() { g.reset(); g.drawImage(atob("GBgCAAAAAAAAAAQAAAAAAD8AAAAAAP/AAAAAAP/wAAAAAH/8C9AAAB/8L/QAAAfwv/wAAAHS//wAAAAL//gAAAAf/+AAAAAf/4AAAAL//gAAAAD/+DwAAAB/Uf8AAAAfA//AAAACAf/wAAAAAH/0AAAAAB/wAAAAAAfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"),this.x,this.y); if (gps_power && have_fix) { g.setColor("#00FF00"); g.drawImage(fixToggle ? atob("CgoCAAAAA0AAOAAD5AAPwAAAAAAAAAAAAAAAAA==") : atob("CgoCAAABw0AcOAHj5A8PwHwAAvgAB/wABUAAAA=="),this.x,this.y+14); } else { g.setColor("#0000FF"); if (fixToggle) g.setFont("6x8").drawString("?",this.x,this.y+14); } } function onGPS(fix) { fixToggle = !fixToggle; WIDGETS["gpsservice"].draw(); last_fix.satellites = fix.satellites; /* * If we have a fix record it, we will get another soon. Apps * will see the timestamp of the last fix and be able to work out * if it is stale. This means an App will always have the last * known fix, and we avoid saying no fix all the time. * */ if (fix.fix) { last_fix.fix = fix.fix; last_fix.alt = fix.alt; last_fix.lat = fix.lat; last_fix.lon = fix.lon; last_fix.speed = fix.speed; last_fix.time = fix.time; } } // redraw when the LCD turns on Bangle.on('lcdPower', function(on) { if (on) WIDGETS["gpsservice"].draw(); }); // add the widget WIDGETS["gpsservice"]={ area:"tl", width:24, draw:draw, gps_power_on:gps_power_on, gps_power_off:gps_power_off, gps_get_status:gps_get_status, gps_get_fix:gps_get_fix }; })(); enter code here
As a client I have defined a watch face for multiclock.
(() => { function getFace(){ //var img = require("heatshrink").decompress(atob("mEwghC/AH4AKg9wC6t3u4uVC6wWBI6t3uJeVuMQCqcBLisAi4XLxAABFxAXKgc4DBAuBRhQXEDAq7MmYXEwBHEXZYXFGAOqAAKDMmczC4mIC62CC50PC4JIBkQABiIvRmURAAUSjQXSFwMoxGKC6CRFwUSVYgXLPIgXXwMYegoXLJAYXCGBnzGA0hPQIwMgYwGC6gwCC4ZIMC4gYBC604C4ZISmcRVgapQAAMhC6GIJIwXCMBcIxGDDBAuLC4IwGAARGMAAQWGmAXPJQoWMC4pwCCpoXJAB4XXAH4A/ABQA=")); var nofix = 0; function formatTime(now) { var fd = now.toUTCString().split(" "); return fd[4]; } function timeSince(t) { var hms = t.split(":"); var now = new Date(); var sn = 3600*(now.getHours()) + 60*(now.getMinutes()) + 1*(now.getSeconds()); var st = 3600*(hms[0]) + 60*(hms[1]) + 1*(hms[2]); return (sn - st); } function draw() { var gps_on = false; var fix = { fix: 0, alt: 0, lat: 0, lon: 0, speed: 0, time: 0, satellites: 0 }; var y_line = 26; var y_start = 46; var x_start = 10; // only attempt to get gps fix if gpsservuce is loaded if (WIDGETS.gpsservice !== undefined) { fix = WIDGETS.gpsservice.gps_get_fix(); gps_on = WIDGETS.gpsservice.gps_get_status(); } g.reset(); g.clearRect(0,24,239,239); if (fix.fix) { var time = formatTime(fix.time); var age = timeSince(time); g.setFontAlign(-1, -1); g.setFont("6x8"); g.setFontVector(22); g.drawString("Alt: " + fix.alt +" m", x_start, y_start, true); g.drawString("Lat: "+ fix.lat, x_start, y_start + y_line, true); g.drawString("Lon: " + fix.lon, x_start, y_start + 2*y_line, true); g.drawString("Time: " + time, x_start, y_start + 3*y_line, true); g.drawString("Age(s): " + age, x_start, y_start + 4*y_line, true); g.drawString("Satellites: " + fix.satellites, x_start, y_start + 5*y_line, true); } else if (gps_on) { g.setFontAlign(0, 1); g.setFont("6x8", 2); g.drawString("Waiting for GPS 0.02", 120, 80); nofix = (nofix+1) % 4; g.drawString(".".repeat(nofix) + " ".repeat(4-nofix), 120, 120); g.setFontAlign(0,0); g.drawString(fix.satellites + " satellites", 120, 100); } else if (!gps_on) { g.setFontAlign(0, 0); g.setFont("6x8", 3); g.drawString("GPS is off", g.getWidth()/2, g.getWidth()/2); } } function onSecond(){ var t = new Date(); if ((t.getSeconds() % 5) === 0) draw(); } return {init:draw, tick:onSecond}; } return getFace; })();
I will probably have another hack-fest on Wednesday night, get the settings working.
-
Found this useful bit code code for configuring a UBX GPS via python.
https://github.com/Korving-F/ublox/blob/master/ublox/ubx.py -
-
-
More experimentation tonight. I can confirm that the UBX_CFG_2MIN() function will get an ACK response from the GPS. However thats not enough as the GPS still sends a fix every 1-2 seconds. The rate appears to be controlled by UBX_CFG_RATE(). So I tried the function below.
// header class id // 0xB5 0x62 0x06 0x08 function UBX_CFG_RATE() { writeGPScmd([0x06,0x08, // class, id 0x06, // length 0x00, 0x20, // b0: 8192ms ie 0x2000, 0x00FF (~65sec) 0x01, 0x00, // b2: 0x01, 0x00]); // b4: timeref GPS }
This gets neither an ACK or a NACK so I assume that the GPS does not like the format or checksum and is ignoring it.
I found the following python code at:
[https://community.emlid.com/t/change-sampling-frequency-of-gps/421/2]def ubx_change_rate(self): msg = [0xb5, 0x62, 0x06, 0x08, 0x06, 0x00, 0x64, 0x00, 0x01, 0x00, 0x01, 0x00, 0x7A, 0x12] self.bus.xfer2(msg)
But when I look at the bytes it does not match the datasheet.
But I tried it anyway, stripping out the sync bytes and CRC, but that did not get a response. -
Bangle is programmed in Javascript which is now a well established mainstream programming language. There are 100s of tutorials across the web. Google 'how to define a list in javascript' and a stackoverflow article will be in the results.
https://stackoverflow.com/questions/5868850/creating-list-of-objects-in-javascript.
I can only do basic javascript but have lots of programming experience in other languages. If this is your first exposure to programming then I would suggest writing some simple loops and drawing things on the screen. This will give you instant feedback. One of my reasons for getting a Bangle Js is because it will force me to learn and write in Javascript.
I think the github code could be a bit more commented to make it easier to follow for new people. There seem to be a pretty helpful bunch of people on this forum so just ask away.
-
I am wanting to test various low power options for the GPS.
It would be useful if I could see how the battery current is going up / down with different options. The alternative is quite long tests to before I can see how things are holding out.
Wondering if there might be a peek() mechanism to grab this from the firmware ?
-
Hi. I tested the ActivePedometer at lunch time and walked about 1.5 miles.
My Amizfit bip registered 3089 steps. The Active Pedometer registered 1316.
Part of the walk was a 1 mile circular route that I know is approx 2000 steps on a Fitbit and
1950 on the Amixfit.Looking at the settings, everything looks fine. I could change threshold to 15 steps as I think 30 excludes going up and down the stairs.
Step sens.: Step Sensitivity. How sensitive should the sted detection be? This changes sensitivity in step detection in the firmware. Standard in firmware: 80.
What does this setting mean in practice ? I guess I could try 40 and see what the impact is.
Not sure if this is defect or a tuning issue at this stage.thanks
Hugh -
Yeah. Pull request made.
I managed to test with a ped.face.js clock face. Using the following code.
() => { function getFace(){ function draw() { let steps = -1; let show_steps = false; // only attempt to get steps if activepedom is loaded if (WIDGETS.activepedom !== undefined) { steps = WIDGETS.activepedom.getSteps(); show_steps = true; } var d = new Date(); var da = d.toString().split(" "); var time = da[4].substr(0,5); g.reset(); g.clearRect(0,24,239,239); g.setFont("Vector", 80); g.setColor(1,1,1); // white g.setFontAlign(0, -1); g.drawString(time, g.getWidth()/2, 60); if (show_steps) { g.setColor(0,255,0); // green g.setFont("Vector", 60); g.drawString(steps, g.getWidth()/2, 160); } } function onSecond(){ draw(); } return {init:draw, tick:onSecond}; } return getFace; })();
There are probably improvements that can be made to the above code. EG it flickers.
I also triedfunction onSecond(){ var t = new Date(); if ((t.getSeconds() % 5) === 0) draw(); }
I can see from the other multiclock examples that there are better ways of writing the display to avoid flicker.
I attempted to check ped.js into github multiclock/ped.js but when I updated the json file, my personal App loader would not show the latest version id ?
This works even better.