-
• #2
I guess you could hijack the
setGPSPower
function:Bangle.setGPSPower=((gps)=>((on,app)=>{ const old = Bangle.isGPSOn(); gps.apply(Bangle, arguments); const now = Bangle.isGPSOn(); if (old!==now) Bangle.emit('power', 'GPS', now, app); }))(Bangle.setGPSPower) Bangle.on('power', (what, on, app) => console.log(`${what} turned ${on ? 'on' : 'off'} ${app ? 'by '+app : ''}`));
Edit: but yes, built-in events would be nice.
-
• #5
I think it'd be a good idea, but I have a lot of other stuff to get done so it's not high up my priority list. Of course if someone wants to add a PR :)
-
• #6
Thanks will add it as a feature request for when you are stuck for something to do :)
I do appreciate this is not a high priority.
I think it would be really useful to have a power event generated when one of the peripherals devices is switched on; especially the power hungry devices like GPS and Heart Rate Monitor.
Although there is Bangle.isGPSOn() etc, these have to be polled.
I wrote a GPS status widget and the only way to make it switch is for a draw event to get triggered such that it will check the value of Bangle.isGPSOn(). In my own apps I have to poke the widget to redraw otherwise there could be a delay before the widget lights to show that the GPS is on an drawing power. It would be much nicer to be able to write a widget that listenned to an Bangle.on('power',,) event, and such widgets would potentially be more responsive.