Move to new folder in preparation for more controllers
This commit is contained in:
parent
bcea2ee550
commit
ae3c20b59d
18 changed files with 59 additions and 4 deletions
10
lighting/.vscode/extensions.json
vendored
Normal file
10
lighting/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
52
lighting/.vscode/settings.json
vendored
Normal file
52
lighting/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
39
lighting/include/README
Normal file
39
lighting/include/README
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
46
lighting/lib/README
Normal file
46
lighting/lib/README
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
32
lighting/platformio.ini
Normal file
32
lighting/platformio.ini
Normal file
|
@ -0,0 +1,32 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
; [env:lolin32_lite]
|
||||
; platform = espressif32
|
||||
; board = lolin32_lite
|
||||
; framework = arduino
|
||||
|
||||
[env:lolin32]
|
||||
platform = espressif32
|
||||
board = lolin32
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
board_build.partitions = huge_app.csv
|
||||
;upload_port = /dev/ttyUSB0
|
||||
;monitor_port = /dev/ttyUSB0
|
||||
|
||||
; [env:nanoatmega328new]
|
||||
; platform = atmelavr
|
||||
; board = nanoatmega328new
|
||||
; framework = arduino
|
||||
; upload_port = /dev/ttyUSB0
|
||||
; monitor_speed = 115200
|
||||
; monitor_port = /dev/ttyUSB0
|
||||
|
25
lighting/src/BluetoothLEDCallback.cpp
Normal file
25
lighting/src/BluetoothLEDCallback.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef BluetoothLEDCallback_cpp
|
||||
#define BluetoothLEDCallback_cpp
|
||||
|
||||
#include "BluetoothLightControl.cpp"
|
||||
#include <BLEUtils.h>
|
||||
|
||||
class BluetoothLEDCallback : public BLECharacteristicCallbacks {
|
||||
BluetoothLightControl *_lightControl;
|
||||
std::string _payload;
|
||||
|
||||
void onWrite(BLECharacteristic *characteristic) {
|
||||
_payload = characteristic->getValue();
|
||||
_lightControl->action(_payload);
|
||||
characteristic->setValue(_payload);
|
||||
characteristic->indicate();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
BluetoothLEDCallback(BluetoothLightControl *lightControl){
|
||||
_lightControl = lightControl;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
35
lighting/src/BluetoothLightControl.cpp
Normal file
35
lighting/src/BluetoothLightControl.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef BluetoothLightControl_cpp
|
||||
#define BluetoothLightControl_cpp
|
||||
|
||||
#include "LedManager.cpp"
|
||||
#include <map>
|
||||
|
||||
class BluetoothLightControl{
|
||||
LedManager *_leds;
|
||||
|
||||
unsigned long convertBytesToUnsignedLong(byte byte1, byte byte2, byte byte3, byte byte4) {
|
||||
return (unsigned long)byte1 << 24 | (unsigned long)byte2 << 16 | (unsigned long)byte3 << 8 | (unsigned long)byte4;
|
||||
}
|
||||
|
||||
public:
|
||||
BluetoothLightControl(LedManager *leds){
|
||||
_leds = leds;
|
||||
}
|
||||
|
||||
void action(std::string input){
|
||||
if (input.length() <= 0)
|
||||
return;
|
||||
|
||||
auto data = input.data();
|
||||
for (int i = 0; i < input.length(); i += 10) {
|
||||
byte id = data[i];
|
||||
bool on = data[i + 1] == 1;
|
||||
float brightness = convertBytesToUnsignedLong(data[i + 2], data[i + 3], data[i + 4], data[i + 5])/100.0f;
|
||||
unsigned long timer = convertBytesToUnsignedLong(data[i + 6], data[i + 7], data[i + 8], data[i + 9]);
|
||||
|
||||
_leds->setLedProperties(id, on, brightness, timer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
53
lighting/src/BluetoothService.cpp
Normal file
53
lighting/src/BluetoothService.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef BluetoothService_cpp
|
||||
#define BluetoothService_cpp
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <BLEDevice.h>
|
||||
#include <BLEServer.h>
|
||||
|
||||
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
|
||||
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
|
||||
|
||||
class BLEAdvertisingRestartCallback: public BLEServerCallbacks {
|
||||
void onConnect(BLEServer* server) {
|
||||
BLEDevice::getAdvertising()->start();
|
||||
}
|
||||
};
|
||||
|
||||
class BluetoothService {
|
||||
const char *_serviceName;
|
||||
BLECharacteristicCallbacks *_callbacks;
|
||||
BLEServer *_server;
|
||||
BLEService *_service;
|
||||
BLECharacteristic *_characteristic;
|
||||
|
||||
public:
|
||||
BluetoothService(const char* serviceName, BLECharacteristicCallbacks* callbacks) {
|
||||
_serviceName = serviceName;
|
||||
_callbacks = callbacks;
|
||||
}
|
||||
|
||||
void init() {
|
||||
BLEDevice::init(_serviceName);
|
||||
//BLEDevice::setMTU(517);
|
||||
_server = BLEDevice::createServer();
|
||||
_service = _server->createService(SERVICE_UUID);
|
||||
_server->setCallbacks(new BLEAdvertisingRestartCallback());
|
||||
|
||||
_characteristic = _service->createCharacteristic(CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_INDICATE);
|
||||
_characteristic->setCallbacks(_callbacks);
|
||||
}
|
||||
|
||||
void start() {
|
||||
_service->start();
|
||||
|
||||
BLEAdvertising *advertising = BLEDevice::getAdvertising();
|
||||
advertising->addServiceUUID(SERVICE_UUID);
|
||||
advertising->setScanResponse(true);
|
||||
advertising->setMinPreferred(0x06); // functions that help with iPhone connections issue
|
||||
advertising->setMinPreferred(0x12);
|
||||
BLEDevice::startAdvertising();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
41
lighting/src/EspNowControl.cpp
Normal file
41
lighting/src/EspNowControl.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef EspNowControl_cpp
|
||||
#define EspNowControl_cpp
|
||||
|
||||
#include <esp_now.h>
|
||||
#include <WiFi.h>
|
||||
#include "LedManager.cpp"
|
||||
|
||||
class EspNowControl {
|
||||
typedef struct payload {
|
||||
int id;
|
||||
bool on;
|
||||
float brightness;
|
||||
unsigned long timer;
|
||||
} payload;
|
||||
|
||||
static LedManager *_leds;
|
||||
|
||||
static void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
|
||||
payload data;
|
||||
memcpy(&data, incomingData, sizeof(data));
|
||||
_leds->setLedProperties(data.id, data.on, data.brightness, data.timer);
|
||||
}
|
||||
|
||||
EspNowControl();
|
||||
|
||||
public:
|
||||
static bool init(LedManager *leds) {
|
||||
_leds = leds;
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
if (esp_now_init() != ESP_OK)
|
||||
return false;
|
||||
|
||||
esp_now_register_recv_cb(OnDataRecv);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
76
lighting/src/LED.cpp
Normal file
76
lighting/src/LED.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#ifndef LED_cpp
|
||||
#define LED_cpp
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "LEDOutput.cpp"
|
||||
|
||||
class LED {
|
||||
std::string _name;
|
||||
LEDOutput* _output;
|
||||
bool _on;
|
||||
unsigned long _fadeDurationOn, _fadeDurationOff, _fadeStart, _fadeEnd;
|
||||
float _brightness;
|
||||
|
||||
unsigned long getFadeDuration(){
|
||||
return _on ? _fadeDurationOn : _fadeDurationOff;
|
||||
}
|
||||
|
||||
unsigned long getRemainingFadeTime(){
|
||||
unsigned long now = millis();
|
||||
return _fadeEnd >= now ? constrain(_fadeEnd - now, 0, getFadeDuration()) : 0;
|
||||
}
|
||||
|
||||
float getMultiplier() {
|
||||
float value = getRemainingFadeTime() / (float)getFadeDuration();
|
||||
return _brightness - value;
|
||||
}
|
||||
|
||||
float getOutputMultiplier(){
|
||||
float value = getMultiplier();
|
||||
return _on ? value : _brightness - value;
|
||||
}
|
||||
|
||||
void reset(bool on){
|
||||
if (on == _on)
|
||||
return;
|
||||
float oldMultiplier = getMultiplier();
|
||||
_on = on;
|
||||
_fadeStart = millis();
|
||||
_fadeEnd = _fadeStart + (getFadeDuration() * oldMultiplier);
|
||||
}
|
||||
|
||||
public:
|
||||
LED(std::string name, LEDOutput* output, unsigned long fadeDurationOn, unsigned long fadeDurationOff) {
|
||||
_name = name;
|
||||
_output = output;
|
||||
_fadeDurationOn = fadeDurationOn;
|
||||
_fadeDurationOff = fadeDurationOff;
|
||||
_brightness = 1.0f;
|
||||
}
|
||||
|
||||
std::string getName(){
|
||||
return _name;
|
||||
}
|
||||
|
||||
void on(){
|
||||
reset(true);
|
||||
}
|
||||
|
||||
void off(){
|
||||
reset(false);
|
||||
}
|
||||
|
||||
void toggle(){
|
||||
reset(!_on);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
_output->writeFraction(getOutputMultiplier());
|
||||
}
|
||||
|
||||
void setBrightness(float brightness){
|
||||
_brightness = brightness;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
33
lighting/src/LEDOutput.cpp
Normal file
33
lighting/src/LEDOutput.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef LEDOutput_cpp
|
||||
#define LEDOutput_cpp
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define LED_OUTPUT_FREQUENCY 490
|
||||
#define LED_OUTPUT_RESOLUTION 15
|
||||
#define LED_OUTPUT_PWM_RANGE 32767
|
||||
|
||||
class LEDOutput {
|
||||
unsigned int _channel;
|
||||
bool _invert;
|
||||
|
||||
public:
|
||||
LEDOutput(unsigned int channel, bool invert = false) {
|
||||
_channel = channel;
|
||||
_invert = invert;
|
||||
ledcSetup(channel, LED_OUTPUT_FREQUENCY, LED_OUTPUT_RESOLUTION);
|
||||
}
|
||||
|
||||
void attach(unsigned int pin){
|
||||
ledcAttachPin(pin, _channel);
|
||||
}
|
||||
|
||||
void writeFraction(float fraction){
|
||||
auto value = fraction * LED_OUTPUT_PWM_RANGE;
|
||||
if (_invert)
|
||||
value = LED_OUTPUT_PWM_RANGE - value;
|
||||
ledcWrite(_channel, value);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
48
lighting/src/LedManager.cpp
Normal file
48
lighting/src/LedManager.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef LedManager_cpp
|
||||
#define LedManager_cpp
|
||||
|
||||
#include "LED.cpp"
|
||||
#include "TimerManager.cpp"
|
||||
#include <map>
|
||||
#include <functional>
|
||||
|
||||
class LedManager {
|
||||
TimerManager *_timers;
|
||||
std::map<int, LED *> _leds;
|
||||
|
||||
public:
|
||||
LedManager(TimerManager *timers) {
|
||||
_timers = timers;
|
||||
}
|
||||
|
||||
void registerLEDs(int id, LED *leds) {
|
||||
_leds[id] = leds;
|
||||
_timers->add(id, [&]() { leds->off(); });
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (auto iterator = _leds.begin(); iterator != _leds.end(); ++iterator) {
|
||||
auto leds = iterator->second;
|
||||
leds->loop();
|
||||
}
|
||||
}
|
||||
|
||||
void setLedProperties(int id, bool on, float brightness, unsigned long timer) {
|
||||
if (!_leds.count(id))
|
||||
return;
|
||||
|
||||
auto led = _leds.find(id)->second;
|
||||
|
||||
led->setBrightness(brightness);
|
||||
|
||||
if (on)
|
||||
led->on();
|
||||
else
|
||||
led->off();
|
||||
|
||||
if (timer > 0)
|
||||
_timers->reset(id, timer);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
38
lighting/src/Timer.cpp
Normal file
38
lighting/src/Timer.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef Timer_cpp
|
||||
#define Timer_cpp
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
|
||||
class Timer{
|
||||
private:
|
||||
unsigned long _interval, _lastTick;
|
||||
std::function<void()> _callback;
|
||||
bool _running;
|
||||
|
||||
public:
|
||||
Timer(std::function<void()> callback){
|
||||
_callback = callback;
|
||||
_running = false;
|
||||
}
|
||||
|
||||
void reset(unsigned long interval){
|
||||
_interval = interval;
|
||||
_lastTick = millis();
|
||||
_running = true;
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (!_running)
|
||||
return;
|
||||
|
||||
unsigned long tick = millis();
|
||||
|
||||
if (tick - _lastTick >= _interval){
|
||||
_callback();
|
||||
_running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
32
lighting/src/TimerManager.cpp
Normal file
32
lighting/src/TimerManager.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef TimerManager_cpp
|
||||
#define TimerManager_cpp
|
||||
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include "Timer.cpp"
|
||||
|
||||
class TimerManager{
|
||||
std::map<int, Timer*> _timers;
|
||||
|
||||
public:
|
||||
|
||||
void add(int id, std::function<void()> callback){
|
||||
_timers[id] = new Timer(callback);
|
||||
}
|
||||
|
||||
void reset(int id, unsigned long interval){
|
||||
if (!_timers.count(id))
|
||||
return;
|
||||
_timers.find(id)->second->reset(interval);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
for(auto iterator = _timers.begin(); iterator != _timers.end(); ++iterator)
|
||||
{
|
||||
auto timer = iterator->second;
|
||||
timer->loop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
39
lighting/src/TouchInput.cpp
Normal file
39
lighting/src/TouchInput.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef TouchInput_cpp
|
||||
#define TouchInput_cpp
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
|
||||
class TouchInput {
|
||||
const unsigned int _debounceDelay = 50;
|
||||
|
||||
int _pin, _touchThreshold;
|
||||
std::function<void()> _callback;
|
||||
unsigned long _touchStart;
|
||||
bool _currentTouchValue, _prevTouchValue;
|
||||
|
||||
public:
|
||||
TouchInput(int pin, int touchThreshold, std::function<void()> callback){
|
||||
_pin = pin;
|
||||
_touchThreshold = touchThreshold;
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
void loop(){
|
||||
bool touching = touchRead(_pin) <= _touchThreshold;
|
||||
|
||||
if (_prevTouchValue != touching) {
|
||||
_touchStart = millis();
|
||||
}
|
||||
|
||||
if (millis() - _touchStart >= _debounceDelay && touching != _currentTouchValue){
|
||||
_currentTouchValue = touching;
|
||||
if (touching)
|
||||
_callback();
|
||||
}
|
||||
|
||||
_prevTouchValue = touching;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
75
lighting/src/main.cpp
Normal file
75
lighting/src/main.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "LED.cpp"
|
||||
#include "BluetoothLEDCallback.cpp"
|
||||
#include "BluetoothLightControl.cpp"
|
||||
#include "BluetoothService.cpp"
|
||||
#include "EspNowControl.cpp"
|
||||
#include "LedManager.cpp"
|
||||
#include "TimerManager.cpp"
|
||||
#include "TouchInput.cpp"
|
||||
#include <Arduino.h>
|
||||
|
||||
LedManager *EspNowControl::_leds = 0; // WTF, C++?
|
||||
|
||||
#define FADE_IN_DURATION 500
|
||||
#define FADE_OUT_DURATION 1000
|
||||
|
||||
LEDOutput _seatingLedOutput(0, true);
|
||||
LED _seatingLeds("seating", &_seatingLedOutput, FADE_IN_DURATION, FADE_OUT_DURATION);
|
||||
LEDOutput _kitchenLedOutput(1, true);
|
||||
LED _kitchenLeds("kitchen", &_kitchenLedOutput, FADE_IN_DURATION, FADE_OUT_DURATION);
|
||||
LEDOutput _bathroomLedOutput(2, true);
|
||||
LED _bathroomLeds("bathroom", &_bathroomLedOutput, FADE_IN_DURATION, FADE_OUT_DURATION);
|
||||
|
||||
LEDOutput _awningLedOutput(3);
|
||||
LED _awningLeds("awning", &_awningLedOutput, FADE_IN_DURATION, FADE_OUT_DURATION);
|
||||
|
||||
LEDOutput _cabLedOutput(4);
|
||||
LED _cabLeds("cab", &_cabLedOutput, FADE_IN_DURATION, FADE_OUT_DURATION);
|
||||
|
||||
TimerManager _timers;
|
||||
LedManager _leds(&_timers);
|
||||
BluetoothLightControl _bluetoothLightControl(&_leds);
|
||||
BluetoothLEDCallback _btCallback(&_bluetoothLightControl);
|
||||
BluetoothService _btService("Van Lights", &_btCallback);
|
||||
TouchInput _mainTouchInput(33, 9, []() {
|
||||
_seatingLeds.toggle();
|
||||
_kitchenLeds.toggle();
|
||||
_bathroomLeds.toggle();
|
||||
});
|
||||
// TouchInput _cabTouchInput(32, 1, []() {
|
||||
// _cabLeds.toggle();
|
||||
// });
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
_seatingLedOutput.attach(16);
|
||||
_seatingLedOutput.attach(17);
|
||||
|
||||
_kitchenLedOutput.attach(5);
|
||||
_kitchenLedOutput.attach(18);
|
||||
_kitchenLedOutput.attach(23);
|
||||
|
||||
_bathroomLedOutput.attach(19);
|
||||
|
||||
_awningLedOutput.attach(22);
|
||||
|
||||
_cabLedOutput.attach(4);
|
||||
|
||||
_leds.registerLEDs(1, &_seatingLeds);
|
||||
_leds.registerLEDs(2, &_kitchenLeds);
|
||||
_leds.registerLEDs(3, &_bathroomLeds);
|
||||
_leds.registerLEDs(4, &_awningLeds);
|
||||
_leds.registerLEDs(5, &_cabLeds);
|
||||
|
||||
_btService.init();
|
||||
_btService.start();
|
||||
EspNowControl::init(&_leds);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
_timers.loop();
|
||||
_leds.loop();
|
||||
_mainTouchInput.loop();
|
||||
//_cabTouchInput.loop();
|
||||
}
|
11
lighting/test/README
Normal file
11
lighting/test/README
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
Loading…
Add table
Add a link
Reference in a new issue