made website working
This commit is contained in:
@@ -30,10 +30,11 @@ void Connection::handle() {
|
||||
}
|
||||
|
||||
void Connection::onNetworkerPacket(Packet packet) {
|
||||
debugger.sendPacket(packet.id, packet.command, packet.data);
|
||||
|
||||
// Handle Lights
|
||||
if (strcmp(packet.id, "main_light") == 0) {
|
||||
if (strcmp(packet.id, "ambiance_light") == 0) {
|
||||
debugger.sendPacket(packet.id, packet.command, packet.data);
|
||||
|
||||
RFTransmit::handlePacket(&networker, packet.id, packet.command, packet.data);
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <NewRemoteTransmitter.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#define RF_SEND_PIN 11
|
||||
|
||||
@@ -19,11 +20,13 @@ void RFTransmit::handlePacket(SimpleSerialProtocol *endpoint, char* id, char* ac
|
||||
if(strcmp(id, "ambiance_light") == 0){
|
||||
if (strcmp(action, "on") == 0){
|
||||
RFTransmit::send(0, rf_type_switch, rf_switch_on);
|
||||
Screen::display(id, "ON");
|
||||
endpoint->sendPacket("access", "update_state", "bool;ambiance_light;true");
|
||||
}
|
||||
|
||||
if (strcmp(action, "off") == 0){
|
||||
RFTransmit::send(0, rf_type_switch, rf_switch_off);
|
||||
Screen::display(id, "OFF");
|
||||
endpoint->sendPacket("access", "update_state", "bool;ambiance_light;false");
|
||||
}
|
||||
}
|
||||
@@ -32,11 +35,13 @@ void RFTransmit::handlePacket(SimpleSerialProtocol *endpoint, char* id, char* ac
|
||||
if(strcmp(id, "main_group") == 0){
|
||||
if (strcmp(action, "on") == 0){
|
||||
RFTransmit::send(0, rf_type_switchgroup, rf_switch_on);
|
||||
Screen::display(id, "ON");
|
||||
endpoint->sendPacket("access", "update_state", "bool;ambiance_light;true");
|
||||
}
|
||||
|
||||
if (strcmp(action, "off") == 0){
|
||||
RFTransmit::send(0, rf_type_switchgroup, rf_switch_off);
|
||||
Screen::display(id, "OFF");
|
||||
endpoint->sendPacket("access", "update_state", "bool;ambiance_light;false");
|
||||
}
|
||||
}
|
||||
|
@@ -12,8 +12,8 @@ namespace Screen{
|
||||
|
||||
void Screen::init(){
|
||||
lcd.begin();
|
||||
// Print a message to the LCD.
|
||||
lcd.backlight();
|
||||
|
||||
lcd.setCursor(3,0);
|
||||
lcd.print("CrabbyHome");
|
||||
lcd.setCursor(3,1);
|
||||
@@ -24,6 +24,8 @@ void Screen::display(char* title, char* text){
|
||||
int titleSize = strlen(title);
|
||||
int textSize = strlen(text);
|
||||
lcd.clear();
|
||||
lcd.display();
|
||||
lcd.backlight();
|
||||
|
||||
// check if text fits in screen
|
||||
if(titleSize <= 16){
|
||||
@@ -37,4 +39,8 @@ void Screen::display(char* title, char* text){
|
||||
lcd.setCursor(offset, 1);
|
||||
}
|
||||
lcd.print(text);
|
||||
delay(1000);
|
||||
|
||||
lcd.noBacklight();
|
||||
lcd.noDisplay();
|
||||
}
|
@@ -10,12 +10,9 @@ void setup() {
|
||||
Connection::init();
|
||||
Temperature::init();
|
||||
Screen::init();
|
||||
RFTransmit::send(1, "switchgroup", "true");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
// delay(500);
|
||||
Connection::handle();
|
||||
}
|
Reference in New Issue
Block a user