All Projects → T-vK → LedStripSimulator

T-vK / LedStripSimulator

Licence: other
Simulates an LED strip and allows very NeoPixel-like access

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to LedStripSimulator

Simulator
📱 Navigate to your app folders quickly
Stars: ✭ 216 (+730.77%)
Mutual labels:  simulator
SS3D
Space Station 3D, another remake of SS13, but with an extra D.
Stars: ✭ 180 (+592.31%)
Mutual labels:  simulator
glow worm luciferin
Bias Lighting and Ambient Light firmware, designed for Firefly Luciferin.
Stars: ✭ 96 (+269.23%)
Mutual labels:  ws2812b
Iosdebugdatabase
make it easy to debug databases in iOS applications iOS debug database
Stars: ✭ 219 (+742.31%)
Mutual labels:  simulator
SiEPIC Photonics Package
A Python (v3.6.5) package that provides a set of basic functions commonly used in integrated photonics.
Stars: ✭ 22 (-15.38%)
Mutual labels:  simulator
snmpman
Easy massive SNMP-agent simulation with the use of simple YAML files
Stars: ✭ 28 (+7.69%)
Mutual labels:  simulator
Survivor
Toolset for SV simulation, comparison and filtering
Stars: ✭ 180 (+592.31%)
Mutual labels:  simulator
clearth
Test automation tool for Clearing, Settlement and Back-Office Systems
Stars: ✭ 26 (+0%)
Mutual labels:  simulator
HomeStatusDisplay
Show smart home status information sent via MQTT using RGB LEDs.
Stars: ✭ 21 (-19.23%)
Mutual labels:  ws2812b
emvpt
Minimum Viable Payment Terminal
Stars: ✭ 20 (-23.08%)
Mutual labels:  simulator
Forth Cpu
A Forth CPU and System on a Chip, based on the J1, written in VHDL
Stars: ✭ 244 (+838.46%)
Mutual labels:  simulator
Mipt Mips
Cycle-accurate pre-silicon simulator of RISC-V and MIPS CPUs
Stars: ✭ 250 (+861.54%)
Mutual labels:  simulator
yates
YATES (Yet Another Traffic Engineering System)
Stars: ✭ 46 (+76.92%)
Mutual labels:  simulator
Record Ios Simulator
A script to start and stop video recordings from the iOS Simulator as easily as taking a screenshot.
Stars: ✭ 218 (+738.46%)
Mutual labels:  simulator
Mitty
Seven Bridges Genomics aligner/caller debugging and analysis tools
Stars: ✭ 13 (-50%)
Mutual labels:  simulator
Elfi
ELFI - Engine for Likelihood-Free Inference
Stars: ✭ 208 (+700%)
Mutual labels:  simulator
ai-learning-environments
List of environments and competitions for RL and AI training
Stars: ✭ 14 (-46.15%)
Mutual labels:  simulator
OpenBTE
Phonon Boltzmann Transport Equation
Stars: ✭ 31 (+19.23%)
Mutual labels:  simulator
CubeSatSim
CubeSatSim, the AMSAT CubeSat Simulator
Stars: ✭ 201 (+673.08%)
Mutual labels:  simulator
awesome-ws2812
A curated list of awesome resources for ws2812 LED strips and matrices
Stars: ✭ 84 (+223.08%)
Mutual labels:  ws2812b

LedStripSimulator

Simulates an LED strip and allows very NeoPixel-like access

Ready to use online simulator

Click here for a ready-to-use online simulator

Screenshot

Screenshot

Requirements

Your browser needs:

  • HTML: HTML5
  • CSS: CSS3
  • JavaScript: ECMAScript6 The newest version of Firefox/Chrome/Opera/Safari/Edge should work fine.

Usage

You'll wirte your code in JavaScript. But the syntax of original Adafruit_NeoPixel c++ class is simlulated as good as possible.
Your original C++ code could for example translate like this:
C++

#define PIN 10;
#define NUM_LEDS = 60;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show();
  
  strip.setPixelColor(0, Color(255,0,0));
  strip.show();
}

JavaScript

var PIN = 10;
var NUM_LEDS = 60;
var strip = new Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

function setup() {
  strip.begin();
  strip.show();
  
  strip.setPixelColor(0, Color(255,0,0));
  strip.show();
}

Ported Arduino functions/callbacks

I implemented the functions millis(), micros(), delay() as well as the callback fucntions setup() and loop().
About delay(): Use it wisely. It will freeze it's thread while it is running. To prevent UI or whole browser freezing, run your code in a new thread (worker).

DIY

Basic setup without the editor and jquery/bootstrap dependency

  • Create a new folder
  • copy Adafruit_NeoPixel.js into the folder
  • copy Adafruit_NeoPixel.css into the folder
  • create a new .html file with the following contents:
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="Adafruit_NeoPixel.css">
  <script src="Adafruit_NeoPixel.js"></script>
  <script>
    //Your code goes here
    //For example:
    //function setup() {
    //  
    //}
    //function loop() {
    //  
    //}
  </script>
</head>
<body>
  <!-- In this section you can create new led strips. Remember to define a different "data-pin" for every led strip and use the pin numbers in your code. -->
  <div class="ledStrip" data-pin="10"></div>
</body>
</html>

Full example

The BasicExample.html file contains an example.

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="Adafruit_NeoPixel.css">
  <script src="Adafruit_NeoPixel.js"></script>
  <script>
    //USER
    const PIN = 10
    const NUM_LEDS = 60
    const BRIGHTNESS = 255

    //ws2812b, arduino pro mini
    var strip = new Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800)

    function setup() {
      strip.setBrightness(BRIGHTNESS)
      strip.begin()
      strip.show()
    }

    var red = strip.Color(255, 0, 0)
    var yellow = strip.Color(255, 255, 0)
    var blue = strip.Color(0, 0, 255)
    var colors = [red,yellow,blue]
    var currentColorIndex = 0
    
    function loop() {
      var animationDone = colorWipe(colors[currentColorIndex])
      if (animationDone)
          currentColorIndex = (currentColorIndex>=colors.length-1 ? 0 : currentColorIndex+1)
    }

    
    function colorWipe(color) { 
      var now = millis()
      if (now > colorWipe.lastUpdate+colorWipe.delay) {
        strip.setPixelColor(colorWipe.currentLed, color)
        strip.show()
        colorWipe.currentLed = colorWipe.currentLed>=strip.numPixels()-1 ? 0 : colorWipe.currentLed+1
        colorWipe.lastUpdate = now
        
        if (colorWipe.currentLed === 0)
            return true;
      }
      return false
    } //c++-like static variables for this fucntion:
    colorWipe.delay = 10
    colorWipe.lastUpdate = 0
    colorWipe.currentLed = 0
    </script>

</head>
<body>
  <div class="ledStrip" data-pin="10"></div>
</body>
</html>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].