• Hi. Looking forward to my Bangle.js next year. I was trying out the emulator, but when I try to run any code that references LED1, I get the error:

    Uncaught ReferenceError: "LED1" is not defined

    Is there anything I can do about that? There also was something similar when BTN was referenced in any code.

    Thanks very much in advance for any help, Yours, Tony.

  • Fri 2019.11.29

    http://www.espruino.com/Bangle.js
    Heading
    LED
    'There are no LEDs on Bangle.js - so there are no built-in LED variables.'

    Hi Tony @user106108

    While we are all excited about the new Bangle.js product launch and the availability to test some sample code snippets now, we may be too excited on what functionality we may expect. The emulator is a brand new (past week) playground on which to test sample snippets. Most emulated functionality will be up to the community to provide as that would be up to the imagination of each individual.


    For others that are reading along:

    I presume these are the links that were started with:

    http://www.espruino.com/Bangle.js
    https://www.espruino.com/ide/emulator.ht­ml

    I followed the instructions as stated in #53 verbatim:

    forum post   http://forum.espruino.com/conversations/­340531/?offset=50#comment15003640

    To confirm, did that snippet sample run without error for you also?



    Even though there aren't defined LED labels, simulated output might be done as follows:


    Now on to your specific situation;

    'but when I try to run any code that references LED1, I get the error:
    Uncaught ReferenceError: "LED1" is not defined'

    'Is there anything I can do about that?'

    Create a definition to replace the missing LED1? What exactly is trying to be accomplished? Trying to add LED simulation on the dial perhaps?

    As the sample using buttons does execute, as we are able to observe from L1 that there is an array of defined button constants, BTN1 thru BTN5

    (I'm purposely not reposting that line here so that viewers will take a look there ref #53)

    So, what does the label definition for LED1 appear like in the code referenced in #1 above? Posting could help others assist here.

    Gordon also mentions in #56 how to go about making individualized edits and improvements. Links there. Looking at the GitHub source (link in #56) also reveals that currently there aren't labels for the LEDs. That it where the individual edit functionality is added.

    One really simple idea - add to end of sample snippet in #53

    // var LED = [LED1];  // not used ref definition only
    var state = true;
    var detectBtnPress = false;
    
    
    function stateLED( state ) {
      
      var illum = "";
      // ternary conditional
      illum = state ? "on" : "off";
      console.log( "The LED is: " + illum ); 
    }
    
    
    // To test (place appropriately for user expectations - just before L9 in #53):
        // toggle after each button press
        detectBtnPress = detectBtnPress ? false : true;
        stateLED( detectBtnPress );
    
    // Output
    The LED is: on
    The LED is: off
    



    I'll edit and update with new detail as I learn it.

About

Avatar for user106108 @user106108 started