• 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.

  • 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.

  • @Gordon whats your view on this?

  • @rigrig I don't intend to do anything like that anytime soon, BUT I really liked the concept here, thanks for the idea in general.

  • 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 :)

  • 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.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Bangle.on('power' ..) or maybe Bangle.event.gpspower etc

Posted by Avatar for HughB @HughB

Actions