Spidey Wall is the name for a physical wall lit up by multiple addressable LED strips. This program is an LPC1768 web server to control the wall from a browser.
Dependencies: EthernetInterfacePlusHostname RdWebServer mbed-rtos mbed
This project is part of a Light-Wall using addressable LED strips (WS2801). I have published a few posts on my blog about the construction of the wall and building a game to play on it (PacMan). I have also had a guest post from a friend who has set his children the task of producing some interesting animations. The original post is http://robdobson.com/2015/07/spidey-wall/
So far, however, I hadn't fully connected the physical (and electronic) wall with the web-browser creations to drive it. This project is hopefully the final link. A fast and reliable web server using REST commands to drive the 1686 LEDs in the Spidey Wall from code running in a browser (say on an iPad while you are playing a game).
The approach taken here results in the ability to control the RGB values of all 1686 LEDs at a rate of 20 frames per second.
A blog post describing the whole thing is here:
http://robdobson.com/2015/08/a-reliable-mbed-webserver/
Idler.cpp@6:8df79fe1afcd, 2015-09-03 (annotated)
- Committer:
- Bobty
- Date:
- Thu Sep 03 20:17:23 2015 +0000
- Revision:
- 6:8df79fe1afcd
- Parent:
- 5:910909f34907
Fixed an unforeseen problem with messages not aligned on RGB boundaries; Fixed potential hanging pointer problem in colourconverters; Changed Idle screen to a set of colourful snakes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bobty | 5:910909f34907 | 1 | |
Bobty | 5:910909f34907 | 2 | #include "Idler.h" |
Bobty | 5:910909f34907 | 3 | |
Bobty | 5:910909f34907 | 4 | DigitalOut* Idler::_pStatusLed = NULL; |
Bobty | 6:8df79fe1afcd | 5 | bool Idler::_isRunning = false; |
Bobty | 5:910909f34907 | 6 | bool Idler::_isIdle = true; |
Bobty | 5:910909f34907 | 7 | unsigned int Idler::_stepCount = 0; |
Bobty | 5:910909f34907 | 8 | DrawingManager* Idler::_pDrawingManager = NULL; |
Bobty | 5:910909f34907 | 9 | Ticker Idler::_idleTicker; |
Bobty | 5:910909f34907 | 10 | Timer Idler::_idleTimer; |
Bobty | 5:910909f34907 | 11 | |
Bobty | 5:910909f34907 | 12 | const int IDLE_TIMEOUT = 10; // N seconds of no REST commands -> idle |
Bobty | 5:910909f34907 | 13 | |
Bobty | 5:910909f34907 | 14 | Idler::Idler(DigitalOut* pStatusLed, DrawingManager* pDrawingManager) |
Bobty | 5:910909f34907 | 15 | { |
Bobty | 5:910909f34907 | 16 | _pStatusLed = pStatusLed; |
Bobty | 5:910909f34907 | 17 | _pDrawingManager = pDrawingManager; |
Bobty | 5:910909f34907 | 18 | _idleTicker.attach(&tick, 0.1); |
Bobty | 5:910909f34907 | 19 | } |
Bobty | 5:910909f34907 | 20 | |
Bobty | 6:8df79fe1afcd | 21 | void Idler::start() |
Bobty | 6:8df79fe1afcd | 22 | { |
Bobty | 6:8df79fe1afcd | 23 | _isRunning = true; |
Bobty | 6:8df79fe1afcd | 24 | } |
Bobty | 6:8df79fe1afcd | 25 | |
Bobty | 5:910909f34907 | 26 | void Idler::tick() |
Bobty | 5:910909f34907 | 27 | { |
Bobty | 6:8df79fe1afcd | 28 | // Check if we are running |
Bobty | 6:8df79fe1afcd | 29 | if (!_isRunning) |
Bobty | 6:8df79fe1afcd | 30 | return; |
Bobty | 6:8df79fe1afcd | 31 | |
Bobty | 5:910909f34907 | 32 | // Check if idle |
Bobty | 5:910909f34907 | 33 | if (!_isIdle) |
Bobty | 5:910909f34907 | 34 | { |
Bobty | 5:910909f34907 | 35 | // Check time since last notIdle |
Bobty | 5:910909f34907 | 36 | if (_idleTimer.read() < IDLE_TIMEOUT) |
Bobty | 5:910909f34907 | 37 | return; |
Bobty | 5:910909f34907 | 38 | |
Bobty | 5:910909f34907 | 39 | // Now idle again |
Bobty | 5:910909f34907 | 40 | _idleTimer.stop(); |
Bobty | 5:910909f34907 | 41 | _isIdle = true; |
Bobty | 5:910909f34907 | 42 | } |
Bobty | 5:910909f34907 | 43 | |
Bobty | 5:910909f34907 | 44 | // Blink LED |
Bobty | 5:910909f34907 | 45 | *_pStatusLed = !(*_pStatusLed); |
Bobty | 5:910909f34907 | 46 | |
Bobty | 5:910909f34907 | 47 | // Step through display |
Bobty | 5:910909f34907 | 48 | _pDrawingManager->DisplayIdle(_stepCount); |
Bobty | 5:910909f34907 | 49 | _stepCount++; |
Bobty | 5:910909f34907 | 50 | } |
Bobty | 5:910909f34907 | 51 | |
Bobty | 5:910909f34907 | 52 | void Idler::notIdle() |
Bobty | 5:910909f34907 | 53 | { |
Bobty | 5:910909f34907 | 54 | _isIdle = false; |
Bobty | 5:910909f34907 | 55 | *_pStatusLed = false; |
Bobty | 5:910909f34907 | 56 | _idleTimer.reset(); |
Bobty | 5:910909f34907 | 57 | _idleTimer.start(); |
Bobty | 5:910909f34907 | 58 | _stepCount = 0; |
Bobty | 5:910909f34907 | 59 | } |