|
discoLight
|
#include "CommandQueue.h"#include <thread>#include "LightController.h"#include "NetworkCommands.h"
This code is developed as part of the MSOE SWE4211 Real Time Systems course, but can be freely used by others.
SWE4211 Real Time Systems is a required course for students studying the discipline of software engineering.
This Software is provided under the License on an "AS IS" basis and without warranties of any kind concerning the Software, including without limitation merchantability, fitness for a particular purpose, absence of defects or errors, accuracy, and non-infringement of intellectual property rights other than copyright. This disclaimer of warranty is an essential part of the License and a condition for the grant of any rights to this Software.
This class is a controller for a light. It runs as a periodic task and manages the light based upon incoming commands from its command queue and the state of a pushbutton. The brightness of the light is controlled with software pulse width modulation (PWM): during each period the light is turned on for a fraction of the period given by the duty cycle, and is then turned off for the remainder of the period.