{"id":20279073,"url":"https://github.com/t-vk/ledstripsimulator","last_synced_at":"2025-04-11T06:18:10.206Z","repository":{"id":107367243,"uuid":"63286686","full_name":"T-vK/LedStripSimulator","owner":"T-vK","description":"Simulates an LED strip and allows very NeoPixel-like access","archived":false,"fork":false,"pushed_at":"2021-09-13T11:12:24.000Z","size":352,"stargazers_count":29,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T06:18:04.608Z","etag":null,"topics":["adafruit-neopixel","javascript","led-strip","simpulator","simulator","ws2812b"],"latest_commit_sha":null,"homepage":"https://t-vk.github.io/LedStripSimulator/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/T-vK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-13T23:36:19.000Z","updated_at":"2025-03-10T05:40:59.000Z","dependencies_parsed_at":"2023-05-17T06:31:01.222Z","dependency_job_id":null,"html_url":"https://github.com/T-vK/LedStripSimulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2FLedStripSimulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2FLedStripSimulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2FLedStripSimulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-vK%2FLedStripSimulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/T-vK","download_url":"https://codeload.github.com/T-vK/LedStripSimulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351396,"owners_count":21089272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adafruit-neopixel","javascript","led-strip","simpulator","simulator","ws2812b"],"created_at":"2024-11-14T13:28:01.290Z","updated_at":"2025-04-11T06:18:10.192Z","avatar_url":"https://github.com/T-vK.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LedStripSimulator\nSimulates an LED strip and allows very NeoPixel-like access\n\n## Ready to use online simulator\n[Click here for a ready-to-use online simulator](https://t-vk.github.io/LedStripSimulator/)\n\n## Screenshot\n![Screenshot](screenshot.jpg)\n\n## Requirements\nYour browser needs:  \n- HTML: HTML5\n- CSS: CSS3\n- JavaScript: ECMAScript6\nThe newest version of Firefox/Chrome/Opera/Safari/Edge should work fine.\n\n## Usage\nYou'll wirte your code in JavaScript. But the syntax of original Adafruit_NeoPixel c++ class is simlulated as good as possible.  \nYour original C++ code could for example translate like this:  \n*C++*\n``` c++\n#define PIN 10;\n#define NUM_LEDS = 60;\nAdafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);\n\nvoid setup() {\n  strip.begin();\n  strip.show();\n  \n  strip.setPixelColor(0, Color(255,0,0));\n  strip.show();\n}\n```\n*JavaScript*\n``` javascript\nvar PIN = 10;\nvar NUM_LEDS = 60;\nvar strip = new Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);\n\nfunction setup() {\n  strip.begin();\n  strip.show();\n  \n  strip.setPixelColor(0, Color(255,0,0));\n  strip.show();\n}\n```\n\n### Ported Arduino functions/callbacks\nI implemented the functions `millis()`, `micros()`, `delay()` as well as the callback fucntions `setup()` and `loop()`.  \nAbout `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).\n\n# DIY\n## Basic setup without the editor and jquery/bootstrap dependency\n- Create a new folder\n- copy Adafruit_NeoPixel.js into the folder\n- copy Adafruit_NeoPixel.css into the folder\n- create a new .html file with the following contents:\n``` html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"Adafruit_NeoPixel.css\"\u003e\n  \u003cscript src=\"Adafruit_NeoPixel.js\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    //Your code goes here\n    //For example:\n    //function setup() {\n    //  \n    //}\n    //function loop() {\n    //  \n    //}\n  \u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- 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. --\u003e\n  \u003cdiv class=\"ledStrip\" data-pin=\"10\"\u003e\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### Full example\nThe BasicExample.html file contains an example.  \n``` html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"Adafruit_NeoPixel.css\"\u003e\n  \u003cscript src=\"Adafruit_NeoPixel.js\"\u003e\u003c/script\u003e\n  \u003cscript\u003e\n    //USER\n    const PIN = 10\n    const NUM_LEDS = 60\n    const BRIGHTNESS = 255\n\n    //ws2812b, arduino pro mini\n    var strip = new Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800)\n\n    function setup() {\n      strip.setBrightness(BRIGHTNESS)\n      strip.begin()\n      strip.show()\n    }\n\n    var red = strip.Color(255, 0, 0)\n    var yellow = strip.Color(255, 255, 0)\n    var blue = strip.Color(0, 0, 255)\n    var colors = [red,yellow,blue]\n    var currentColorIndex = 0\n    \n    function loop() {\n      var animationDone = colorWipe(colors[currentColorIndex])\n      if (animationDone)\n          currentColorIndex = (currentColorIndex\u003e=colors.length-1 ? 0 : currentColorIndex+1)\n    }\n\n    \n    function colorWipe(color) { \n      var now = millis()\n      if (now \u003e colorWipe.lastUpdate+colorWipe.delay) {\n        strip.setPixelColor(colorWipe.currentLed, color)\n        strip.show()\n        colorWipe.currentLed = colorWipe.currentLed\u003e=strip.numPixels()-1 ? 0 : colorWipe.currentLed+1\n        colorWipe.lastUpdate = now\n        \n        if (colorWipe.currentLed === 0)\n            return true;\n      }\n      return false\n    } //c++-like static variables for this fucntion:\n    colorWipe.delay = 10\n    colorWipe.lastUpdate = 0\n    colorWipe.currentLed = 0\n    \u003c/script\u003e\n\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cdiv class=\"ledStrip\" data-pin=\"10\"\u003e\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-vk%2Fledstripsimulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft-vk%2Fledstripsimulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-vk%2Fledstripsimulator/lists"}