cool demo for stm32f4discovery/Espruino

Posted on
  • Just got espruino running on a stm32f4discovery I ordered and received today... I'm a backer on kickstarter, but am beyond the "impatient developer" level...LOL!

    Anyway, here's a cool little demo you can run on the the f4discovery board:

    var i = 1000, run = true;
    function flashLights() {
    	LED4.write(false);
    	LED1.write(true);
    	setTimeout(function () {
    		LED1.write(false);
    		LED2.write(true);
    		setTimeout(function () {
    			LED2.write(false);
    			LED3.write(true);
    			setTimeout(function () {
    				LED3.write(false);
    				LED4.write(true);
    				setTimeout(function () {
    					if (run) {
    						flashLights();
    					}
    				}, i);
    			}, i);
    		}, i);
    	}, i);
    }
    flashLights();
    

    After executing it runs each of the leds in a circle with the given wait time between each flash. In the console you can modify the i variable to alter the flash rate while it's running. Then to stop it just put run=false. Once you get below i=70 you can't even really tell which direction they're flashing in they're going so fast!

    Cheers,
    Austin

  • Bug noted, thanks Austin! If you add a blank line between the normal text and the three backticks at the start of your code block, it'll work fine for now.

  • It does have a blank line... I tried 2 blank lines (before and after) and that didn't seem to help either. Initially I had the tick marks on separate lines from the code, tried without whitespace didnt help either... It always fun to "work out the kinks" in new software :)

  • Strange, I posted it here without issue just copying and pasting from your code:

    https://meta.microcosm.app/conversations/183/?&limit=25#comment934

    But I'll take another look tomorrow.

  • not exactly sure what I changed this time I didn't try before, but it seems to be working now! Thanks

  • an apostrophe & a double quotation mark seems to show up as a question mark

  • Saturday's are for fixing bugs ;)

    We're using https://github.com/russross/blackfriday for markdown processing and it has a range of flags to enable/disable various features.

    We've now enabled Github Flavored Markdown for things like code blocks.

    And I've since disabled SmartyPants which attempts to do horrible "smart quotes" and which was turning single quotes into question marks.

    We're very receptive to any and all feedback, and are monitoring all of the sites we're running for issues. So feel free to let us know via the https://meta.microcosm.app site of any issues you find.

    We'd rather not pollute Gordon's space with forum questions, and keep this space focused on Espruino stuff. Especially as both @motter and I were in on the Kickstarter and are looking forward to nerding out and seeing what we can do with those.

  • haha yea, and my Saturday has been playing with the discovery board and Espruino and loving it so far! ok, if I see anything else I post over there... thanks!

  • Update for Espruino board since it only has 3 lights... Also added ability to stop and restart it. Change the value of i to control how fast the lights change (in milliseconds), by default run=true, setting to false will stop it. You can now resume by setting run=true again. Enjoy!

    var i = 1000, run = true;
    function flashLights() {
        LED3.write(false);
        LED1.write(true);
        setTimeout(function () {
            LED1.write(false);
            LED2.write(true);
            setTimeout(function () {
                LED2.write(false);
                LED3.write(true);
                setTimeout(function () {
    				if (run) {
    					flashLights();
                    } else {
                      var checkForRestart = setInterval(function () {
                        if (run) {
                          clearInterval(checkForRestart);
                          flashLights();
                        }
                      }, 500);
                    }
                }, i);
            }, i);
        }, i);
    }
    flashLights();
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

cool demo for stm32f4discovery/Espruino

Posted by Avatar for Austin @Austin

Actions