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/ /media/uploads/Bobty/20130722_112945_img_9674_62895-1184x1579.jpg

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

Committer:
Bobty
Date:
2015-09-03
Revision:
6:8df79fe1afcd
Parent:
5:910909f34907

File content as of revision 6:8df79fe1afcd:


#include "Idler.h"

DigitalOut* Idler::_pStatusLed = NULL;
bool Idler::_isRunning = false;
bool Idler::_isIdle = true;
unsigned int Idler::_stepCount = 0;
DrawingManager* Idler::_pDrawingManager = NULL;
Ticker Idler::_idleTicker;
Timer Idler::_idleTimer;

const int IDLE_TIMEOUT = 10; // N seconds of no REST commands -> idle

Idler::Idler(DigitalOut* pStatusLed, DrawingManager* pDrawingManager)
{
    _pStatusLed = pStatusLed;
    _pDrawingManager = pDrawingManager;
    _idleTicker.attach(&tick, 0.1);
}

void Idler::start()
{
    _isRunning = true;
}

void Idler::tick()
{
    // Check if we are running
    if (!_isRunning)
        return;
        
    // Check if idle
    if (!_isIdle)
    {
        // Check time since last notIdle
        if (_idleTimer.read() < IDLE_TIMEOUT)
            return;
        
        // Now idle again
        _idleTimer.stop();
        _isIdle = true;
    }

    // Blink LED
    *_pStatusLed = !(*_pStatusLed);
    
    // Step through display
    _pDrawingManager->DisplayIdle(_stepCount);
    _stepCount++;
}

void Idler::notIdle()
{
    _isIdle = false;
    *_pStatusLed = false;
    _idleTimer.reset();
    _idleTimer.start();
    _stepCount = 0;
}