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@5:910909f34907, 2015-09-01 (annotated)
- Committer:
- Bobty
- Date:
- Tue Sep 01 15:53:52 2015 +0000
- Revision:
- 5:910909f34907
- Child:
- 6:8df79fe1afcd
Added an idle handler so there is something to show when nothing is being sent over HTTP
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 | 5:910909f34907 | 5 | bool Idler::_isIdle = true; |
Bobty | 5:910909f34907 | 6 | unsigned int Idler::_stepCount = 0; |
Bobty | 5:910909f34907 | 7 | DrawingManager* Idler::_pDrawingManager = NULL; |
Bobty | 5:910909f34907 | 8 | Ticker Idler::_idleTicker; |
Bobty | 5:910909f34907 | 9 | Timer Idler::_idleTimer; |
Bobty | 5:910909f34907 | 10 | |
Bobty | 5:910909f34907 | 11 | const int IDLE_TIMEOUT = 10; // N seconds of no REST commands -> idle |
Bobty | 5:910909f34907 | 12 | |
Bobty | 5:910909f34907 | 13 | Idler::Idler(DigitalOut* pStatusLed, DrawingManager* pDrawingManager) |
Bobty | 5:910909f34907 | 14 | { |
Bobty | 5:910909f34907 | 15 | _pStatusLed = pStatusLed; |
Bobty | 5:910909f34907 | 16 | _pDrawingManager = pDrawingManager; |
Bobty | 5:910909f34907 | 17 | _idleTicker.attach(&tick, 0.1); |
Bobty | 5:910909f34907 | 18 | } |
Bobty | 5:910909f34907 | 19 | |
Bobty | 5:910909f34907 | 20 | void Idler::tick() |
Bobty | 5:910909f34907 | 21 | { |
Bobty | 5:910909f34907 | 22 | // Check if idle |
Bobty | 5:910909f34907 | 23 | if (!_isIdle) |
Bobty | 5:910909f34907 | 24 | { |
Bobty | 5:910909f34907 | 25 | // Check time since last notIdle |
Bobty | 5:910909f34907 | 26 | if (_idleTimer.read() < IDLE_TIMEOUT) |
Bobty | 5:910909f34907 | 27 | return; |
Bobty | 5:910909f34907 | 28 | |
Bobty | 5:910909f34907 | 29 | // Now idle again |
Bobty | 5:910909f34907 | 30 | _idleTimer.stop(); |
Bobty | 5:910909f34907 | 31 | _isIdle = true; |
Bobty | 5:910909f34907 | 32 | } |
Bobty | 5:910909f34907 | 33 | |
Bobty | 5:910909f34907 | 34 | // Blink LED |
Bobty | 5:910909f34907 | 35 | *_pStatusLed = !(*_pStatusLed); |
Bobty | 5:910909f34907 | 36 | |
Bobty | 5:910909f34907 | 37 | // Step through display |
Bobty | 5:910909f34907 | 38 | _pDrawingManager->DisplayIdle(_stepCount); |
Bobty | 5:910909f34907 | 39 | _stepCount++; |
Bobty | 5:910909f34907 | 40 | } |
Bobty | 5:910909f34907 | 41 | |
Bobty | 5:910909f34907 | 42 | void Idler::notIdle() |
Bobty | 5:910909f34907 | 43 | { |
Bobty | 5:910909f34907 | 44 | _isIdle = false; |
Bobty | 5:910909f34907 | 45 | *_pStatusLed = false; |
Bobty | 5:910909f34907 | 46 | _idleTimer.reset(); |
Bobty | 5:910909f34907 | 47 | _idleTimer.start(); |
Bobty | 5:910909f34907 | 48 | _stepCount = 0; |
Bobty | 5:910909f34907 | 49 | } |