-
Thanks Gordon. Nice to interact with you. Massive thanks for getting this product / concept to market fantastic achievement.
I did originally try the /widpedom/widget.js but found the numbers in the widget display rather small. I then attempted just the edit the widget.js file and upload to storage, but should have followed the setup your own App store via github mechanism.
The current step count is stored in stp_today and was not sure if this is a global variable so I could access from another App.
I tried >stp_today in the IDE and got undefined. I wonder if all I would need to do is create a getTodaysSteps() function in the widget and that would give me the ability to grab what I need for a larger display of the count.
-
Here is a screenshot of my proof of concept steps watch face. This reads the last log line from the ActivePedomiter CSV log file. The code needs polishing up. For example there is a 1 second delay while the log file gets read. The code only needs to read the last data, so maybe some optimision might be possible. Also need to handle the log file not being present and a hint to use
the ActivePedominter App.I managed to write the code below to ped2.face.js to Storage and when the multiclock reloads this face gets added. Obviously this is not the correct way. Need to setup my github / bootloader.
(() => { function getFace(){ function getArrayFromCSV(file, column) { var history = 86400000; // 28800000=8h 43200000=12h //86400000=24h i = 0; array = []; now = new Date(); while ((nextLine = file.readLine())) { //as long as there is a next line if(nextLine) { dataSplitted = nextLine.split(','); //split line, diff = now - dataSplitted[0]; //calculate difference between now and stored time if (diff <= history) { //only entries from the last x ms array.push(dataSplitted[column]); } } i++; } return array; } function draw() { const storage = require("Storage"); let now = new Date(); let month = now.getMonth() + 1; if (month < 10) month = "0" + month; let filename = "activepedom" + now.getFullYear() + month + now.getDate() + ".data"; let csvFile = storage.open(filename, "r"); let data = getArrayFromCSV(csvFile, 1); let steps = data[data.length-1]; csvFile = undefined; data = undefined; if (steps > 99999){ steps = steps % 100000; // cap to five digits + comma = 6 characters } let stps = steps.toString(); g.reset(); g.clearRect(0,24,239,239); g.setFont("Vector",48); g.setColor(1,1,1); // white g.drawString("Steps",50,24,true); g.setColor(0,255,0); g.drawString(stps,50,96,true); } function onSecond(){ var t = new Date(); if (t.getSeconds() === 0) draw(); } return {init:draw, tick:onSecond}; } return getFace; })();
-
I think from a future proofing / maintaince point of view having a hidden widget that provided a service would be a good thing. This would enable the display aspects to be seperate from the service aspect. I like the widgets but they are just too small for me to see practically so I will need to produce a bigger screen for looking at the data I am interested in.
Is writing to "storage" a good way to share data between Apps / Widgets ? For example I could clone the GPS tracking App and get it to just write the contents of the last fix into a 1 line CSV file. Would this be considered hacky is there a better way to do it without getting over complicated ?
-
Got my Bangle JS today - been playing with it for hours and doing a bit of tinkering.
I tried the Active Pedometer which also comes with a Widget. I find the text on the Widgets too small to read even with glasses on. Ideally when I am walking up a mountain in the pouring rain and my glasses are all steamed up I would like to be able to see how many steps I have done without the glasses, so the fonts will need to be large.
I tried to change the font size on the widget but my upload crashed the watch so had to delete the App and start again.
In the meantime I looked at the way Multiclock works. This has the concepted of a xx.face.js file which then gets picked up as a screen that can be cycled to using BTN1/BTN3, which is a much nicer interface for moving between Apps.
I thought it would be great to just have a psuedu clock / screen that just showed.
| Steps |
| 7899 |
I though there might be an easy way to do this (just pick up a global variable).
BUT when I have looked at the activepedom/widget.js I can see that the bulk of the processing / logging and correction is done inside the widget ? It appears that widgets are being treated as daemons/services with no seperation of the display logic from the actual processing.
Obviously it would be better if I did not have to replicate the entire code of widget.js just to get the value of todays steps. I guess I could just read the latest value out of the log file.
Is there a software design issue here with the widget concept ? Should we be thinking in terms of having some sort of store / registry for common output variables so that other simpler code can then just handle the display part ?
Does anyone have any thoughts on this ?
Thanks
Hugh -
Had a closer look at the code and the datasheet.
I might be a bit further along on answering my original question.
I dont have my watch yet so cant really test/* UBX-CFG-PMS - enable power management - Super-E period and ontime are ignored and set to 0 in 1hz mode See: UBX-13003221 - R21 page 243, for format of config message */ function UBX_CFG_PMS() { writeGPScmd([0x06,0x86, // msg class + type 8,0,//length //v0, 1hz period ontime reserved 0x00, 0x03, 0, 0, 0, 0, 0, 0 ]); } /* UBX_CFG_2MIN - enable power management, Interval type: 2 min period (0x78), 7s On time FIXME: need to enable Enable waitTimeFix feature ? See: UBX-13003221 - R21 page 243, for format of config message */ function UBX_CFG_2MIN() { writeGPScmd([0x06,0x86, // msg class + type 8,0, //length //v0, interval period ontime reserved 0x00, 0x02, 0x78, 0, 0x07, 0, 0, 0 ]); // the values are little endian, least significant byte first }
There are some example interval setups in
section 13.2.4.3 of the datasheet:Use update periods of 30 minutes
Scenario: Get a position fix once every 30 minutes and acquire a fix needed for timing products.
Solution: Set mode of operation to PSMOO. Set updatePeriod to 1800 seconds.
Set the search period to 120 seconds. Enable waitTimeFix feature" -
Thanks for the response. I think I had seen the AppNote before, but was not able to make the
connection with the code in GPS-comms.js. Its a great bit of code, just needs a few more comments
to explain what it is doing.What I would like to acheive is to have a OS GRID ref showing as a widget or a line of TEXT in the front screen of the watch. Normally GPS will be switched off so the grid ref line will be skipped
and not displayed. When I do a new fell walk it is useful to have a grid ref every now and then.
Using a 1:25000 OS map you can only really only see a 6 digit OS grid ref and that puts you in a 100m square which is good enough for general map reading. Say I walk at a speed of 4km/hr; thats 67m per minute. So I'd be happy to take a GPS update between 1-2 minutes apart. When I stop and look at the watch I would only have to wait a max of 2 mins before the GRID REF was refreshed. I could have a little coundown value that would show me how many seconds ago the GRID REF was updated.What I read in the AppNote:
Power Management Considerations for u-blox 7 and M8 GNSS receivers (UBX-13005162 - R01) Page 6:Smallest average current consumption is obviously achieved when the update period is long
Section 2.3.1 shows a chart, with PSMOD set to 30seconds the average power consumption is 2mA.
The question is how to set this value using the Bangle JS framework.
Once I understand how to use the code in GPS-comms.js I can try a few experiments, to see what is practical.
I see Gordon has requested votes on the next in depth tutorial, so I have upvoted for a GPS tutorial.
Back to more studying of GPS-comms.js against the datasheet, I guess I am going to
end up knowing more about GPS than expected. -
Apologies for posting again. My original post was in New Projects which I realise was the wrong place.
I have question around power management options for the GPS and how to minimise power consumption over frequency of updates.
In GPS-comms.js on github I can see:
function UBX_CFG_PMS() { // UBX-CFG-PMS - enable power management - Super-E writeGPScmd([0x06,0x86, // msg class + type 8,0,//length 0x00,0x03/*1hz*/, 0,0, 0,0, 0,0]); }
Could someone explain what the parameters mean ?
How could I set the GPS to only look for an update every 120 seconds ?
Thanks
Hugh -
I tried it out. I am setup in Github now.
https://github.com/hughbarney/BangleApps/commit/39829faf26a956243a8f9aa1fb4d6f42c2a43280
I tried to update the Active Pedometer widget but each time I found it crashed the watch and I had to delete it through the App Loader.
I could be making a stupid mistake. I'm not that familiar with the javascript syntax (still learning, though I have a decent naughts and crosses programme working), it looks like you are adding a public function to the widget within the list of properties.