mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 05:24:30 +01:00
illucat
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
; http://docs.platformio.org/page/projectconf.html
|
; http://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
env_default = button
|
env_default = illucat
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ class Button : public Sprocket {
|
|||||||
Task btnTask;
|
Task btnTask;
|
||||||
MeshNet* net;
|
MeshNet* net;
|
||||||
int pin;
|
int pin;
|
||||||
|
int warnlevel = 0;
|
||||||
Button(SprocketConfig cfg) : Sprocket(cfg) {}
|
Button(SprocketConfig cfg) : Sprocket(cfg) {}
|
||||||
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
||||||
pin = D2;
|
pin = D2;
|
||||||
pinMode(pin, INPUT_PULLUP);
|
pinMode(pin, INPUT_PULLUP);
|
||||||
net = static_cast<MeshNet*>(network);
|
net = static_cast<MeshNet*>(network);
|
||||||
net->mesh.onReceive(bind(&Button::receivedCallback,this, _1, _2));
|
net->mesh.onReceive(bind(&Button::receivedCallback,this, _1, _2));
|
||||||
btnTask.set(TASK_MILLISECOND * 500, TASK_FOREVER,
|
btnTask.set(TASK_MILLISECOND * 250, TASK_FOREVER,
|
||||||
bind(&Button::readPin, this, net));
|
bind(&Button::readPin, this, net));
|
||||||
scheduler->addTask(btnTask);
|
scheduler->addTask(btnTask);
|
||||||
btnTask.enable();
|
btnTask.enable();
|
||||||
@@ -27,8 +28,9 @@ class Button : public Sprocket {
|
|||||||
|
|
||||||
void readPin(MeshNet* network){
|
void readPin(MeshNet* network){
|
||||||
if(digitalRead(pin)){
|
if(digitalRead(pin)){
|
||||||
Serial.println("btn pressed");
|
Serial.println("warnlevel: " + String(warnlevel));
|
||||||
network->broadcast("EE1B2E");
|
warnlevel++;
|
||||||
|
network->broadcast(String(warnlevel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class Illucat : public Sprocket {
|
|||||||
NeoPattern* pixels;
|
NeoPattern* pixels;
|
||||||
Illucat(SprocketConfig cfg, NeoPixelConfig pixelCfg) : Sprocket(cfg) {
|
Illucat(SprocketConfig cfg, NeoPixelConfig pixelCfg) : Sprocket(cfg) {
|
||||||
pixels = new NeoPattern(pixelCfg.length, pixelCfg.pin, NEO_GRB + NEO_KHZ800, [](int pixels){});
|
pixels = new NeoPattern(pixelCfg.length, pixelCfg.pin, NEO_GRB + NEO_KHZ800, [](int pixels){});
|
||||||
|
pixels->begin();
|
||||||
|
pixels->setBrightness(64);
|
||||||
}
|
}
|
||||||
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
||||||
net = static_cast<MeshNet*>(network);
|
net = static_cast<MeshNet*>(network);
|
||||||
|
|||||||
Reference in New Issue
Block a user