2fb: replace literals with defines

This commit is contained in:
Xiretza 2022-08-16 20:47:45 +02:00
parent 741e0ee5b3
commit a7e864b4fb

View file

@ -56,6 +56,9 @@ const int tclose = 3;
const int beeper = A5; const int beeper = A5;
#define MODE_OPEN_STATE 0
#define MODE_PING_STATE 1
void setLeds() { void setLeds() {
if (pingtimer >= 0) { if (pingtimer >= 0) {
if (hsopen) { // If space is not closed, beep three times with if (hsopen) { // If space is not closed, beep three times with
@ -245,10 +248,10 @@ void readServerStatus(int mode) {
Serial.println(""); Serial.println("");
} }
switch (mode) { switch (mode) {
case 0: case MODE_OPEN_STATE:
setRoom(1); setRoom(1);
break; break;
case 1: case MODE_PING_STATE:
if (debug) { if (debug) {
Serial.println("Wink Wink"); Serial.println("Wink Wink");
} }
@ -264,10 +267,10 @@ void readServerStatus(int mode) {
Serial.println(""); Serial.println("");
} }
switch (mode) { switch (mode) {
case 0: case MODE_OPEN_STATE:
setRoom(0); setRoom(0);
break; break;
case 1: case MODE_PING_STATE:
if (debug) { if (debug) {
Serial.println("No Wink"); Serial.println("No Wink");
} }
@ -312,7 +315,7 @@ void TriggerServerReq(String req, int mode) {
} }
void RequestState() { void RequestState() {
TriggerServerReq("GET /api/status-s.php", 0); TriggerServerReq("GET /api/status-s.php", MODE_OPEN_STATE);
} }
// Status LED pins // Status LED pins
@ -352,17 +355,17 @@ void readButtons() {
if ((digitalRead(topen) == LOW) && (hsopen != 1)) { if ((digitalRead(topen) == LOW) && (hsopen != 1)) {
// startEthernet(); // startEthernet();
setRoom(2); setRoom(2);
TriggerServerReq("POST /api/update.php?open=true&apikey=" UPDATE_API_KEY, 0); TriggerServerReq("POST /api/update.php?open=true&apikey=" UPDATE_API_KEY, MODE_OPEN_STATE);
} }
if ((digitalRead(tclose) == LOW) && (hsopen != 0)) { if ((digitalRead(tclose) == LOW) && (hsopen != 0)) {
// startEthernet(); // startEthernet();
setRoom(2); setRoom(2);
TriggerServerReq("POST /api/update.php?open=false&apikey=" UPDATE_API_KEY, 0); TriggerServerReq("POST /api/update.php?open=false&apikey=" UPDATE_API_KEY, MODE_OPEN_STATE);
} }
} }
void RequestPing() { void RequestPing() {
TriggerServerReq("POST /api/ping-get.php?apikey=" PING_GET_API_KEY, 1); TriggerServerReq("POST /api/ping-get.php?apikey=" PING_GET_API_KEY, MODE_PING_STATE);
} }
void launchUpdate() { void launchUpdate() {