• This seems pretty basic.

    If I save a "program" to flash, will it execute again to reload the functions and watches if the battery is changed?

    Thanks

    var presses = 0;
    clearWatch();
    clearTimeout();
    clearInterval();
    
    flashingLedInterval=0;
    
    setWatch(function() {
      presses++;
      console.log("Pressed");
      NRF.setAdvertising({
        0x1811 : [presses],
        0x180F : [E.getBattery()],
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, BTN, { edge:"rising", repeat:true, debounce:25 });
    
    
    // Interval to update advertising values
    setInterval(function() {
      NRF.setAdvertising({
        0x1811 : [presses],
        0x180F : [E.getBattery()],
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, 30000);    // 30 sec
    
    function startFlashing(pin, period) {
      var on = false;
      flashingLedInterval = setInterval(function() {
        on = !on;
        digitalWrite(pin, on);
      }, period);
    }
    
    function stopFlashing(pin) {
      clearInterval(flashingLedInterval);
      digitalWrite(pin, off);
    }
    
  • If I save a "program" to flash, will it execute again to reload the functions and watches if the battery is changed?

    Yes, if you upload this code to flash via WebIDE it is permanently saved in Storage as ".bootcde" file and gets executed from top to bottom at boot time. If this suits you, it is as simple as that, you don't need anything else.

About

Avatar for fanoush @fanoush started