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