Lighmodes working
This commit is contained in:
parent
25baa3a5bb
commit
f6059e5bb2
@ -3,7 +3,7 @@
|
|||||||
#define NUM_LEDS 40
|
#define NUM_LEDS 40
|
||||||
#define PIN_STRIP 17
|
#define PIN_STRIP 17
|
||||||
bool shouldUpdateLights = false;
|
bool shouldUpdateLights = false;
|
||||||
int lightMode = 0;
|
uint8_t lightMode = 0;
|
||||||
|
|
||||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, PIN_STRIP, NEO_GRB + NEO_KHZ800);
|
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, PIN_STRIP, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
@ -60,21 +60,27 @@ void lightBackFront() {
|
|||||||
|
|
||||||
void updateLights() {
|
void updateLights() {
|
||||||
if(lightActive) {
|
if(lightActive) {
|
||||||
|
Serial.println("light active");
|
||||||
switch(lightMode) {
|
switch(lightMode) {
|
||||||
case 0:
|
case 0:
|
||||||
lightBackFront();
|
lightBackFront();
|
||||||
|
Serial.println("normal");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
lightBlinkers(true); // left
|
lightBlinkers(true); // left
|
||||||
|
Serial.println("blink");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
lightBlinkers(false); // right
|
lightBlinkers(false); // right
|
||||||
|
Serial.println("plink");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
lightPolice();
|
lightPolice();
|
||||||
|
Serial.println("plice");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
Serial.println("light inactive");
|
||||||
lightOff();
|
lightOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ uint8_t sendSpeedDecimals = 0;
|
|||||||
long lastPacket = 0;
|
long lastPacket = 0;
|
||||||
|
|
||||||
bool isConnected = false;
|
bool isConnected = false;
|
||||||
|
uint8_t oldOptions = 0;
|
||||||
#define FANS_AUTO 0
|
#define FANS_AUTO 0
|
||||||
#define FANS_ON 1
|
#define FANS_ON 1
|
||||||
#define FANS_OFF 2
|
#define FANS_OFF 2
|
||||||
@ -63,13 +63,14 @@ int fanMode = FANS_AUTO;
|
|||||||
|
|
||||||
#include "lights.h"
|
#include "lights.h"
|
||||||
void setBoardOptions(uint8_t options) {
|
void setBoardOptions(uint8_t options) {
|
||||||
if(lightActive != (options >> 4) & 1) {
|
if(options != oldOptions) {
|
||||||
lightActive = (options >> 4) & 1;
|
oldOptions = options;
|
||||||
shouldUpdateLights = true;
|
shouldUpdateLights = true;
|
||||||
|
Serial.println("true2");
|
||||||
}
|
}
|
||||||
|
|
||||||
lightMode = options & 3;
|
lightMode = options & 3;
|
||||||
|
lightActive = (options >> 3) & 1;
|
||||||
fanMode = (options >> 2) & 3;
|
fanMode = (options >> 2) & 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,8 @@ void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) {
|
|||||||
// Could check mac here for some security
|
// Could check mac here for some security
|
||||||
writeServos(recData[0], recData[1]);
|
writeServos(recData[0], recData[1]);
|
||||||
setBoardOptions(recData[2]);
|
setBoardOptions(recData[2]);
|
||||||
|
Serial.print("recieved: ");
|
||||||
|
Serial.println(recData[2], BIN);
|
||||||
display.clear();
|
display.clear();
|
||||||
char buf[25];
|
char buf[25];
|
||||||
sprintf(buf, "1: %i | 2: %i", recData[0], recData[1]);
|
sprintf(buf, "1: %i | 2: %i", recData[0], recData[1]);
|
||||||
@ -311,7 +313,6 @@ void setup() {
|
|||||||
Serial.println("ESPNow Init Failed");
|
Serial.println("ESPNow Init Failed");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
|
|
||||||
|
|
||||||
// Once ESPNow is successfully Init, we will register for recv CB to
|
// Once ESPNow is successfully Init, we will register for recv CB to
|
||||||
// get recv packer info.
|
// get recv packer info.
|
||||||
|
Loading…
Reference in New Issue
Block a user