Compare commits

..

No commits in common. "bb73ecedfb48478c8a5164e555d2960d853c30c1" and "aca3b506ab8ddc0acb56db371456a5fea6ed687e" have entirely different histories.

5 changed files with 16 additions and 60 deletions

View File

@ -3,3 +3,4 @@
#define GPIO_BLUE 16
#define GPIO_COOLWHITE 15
#define GPIO_WARMWHITE 19
#define BOARD "ESP32"

View File

@ -1,5 +0,0 @@
#define GPIO_RED 5
#define GPIO_GREEN 6
#define GPIO_BLUE 7
#define GPIO_COOLWHITE 20
#define GPIO_WARMWHITE 21

View File

@ -3,3 +3,4 @@
#define GPIO_BLUE 15
#define GPIO_COOLWHITE 4
#define GPIO_WARMWHITE 5
#define BOARD "ESP8266"

View File

@ -10,17 +10,12 @@
[platformio]
;default_envs = esp32doit-devkit-v1
default_envs = esp32-c3-devkitm-1
;default_envs = nodemcuv2
;default_envs = huzzah
default_envs = huzzah
[common]
build_flags =
-D DEBUG=true
-D BOARD_ESP32_DEV=1
-D BOARD_ESP32_C3=2
-D BOARD_ESP8266_DEV=3
-D BOARD_ESP8266_HUZZAH=4
lib_deps =
tzapu/WiFiManager@^2.0.17
@ -29,46 +24,26 @@ platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
;upload_protocol = espota
;upload_port = 192.168.2.217
upload_port = COM7
upload_protocol = espota
upload_port = 192.168.2.217
;upload_port = COM7
build_flags =
-D JAJ_BOARD_TARGET=BOARD_ESP32_DEV
${common.build_flags}
lib_deps =
${common.lib_deps}
lib_compat_mode = strict
[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
;upload_protocol = espota
;upload_port = 192.168.2.217
upload_port = COM9
board_build.flash_mode = dio
build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D JAJ_BOARD_TARGET=BOARD_ESP32_C3
${common.build_flags}
lib_deps =
${common.lib_deps}
lib_compat_mode = strict
[env:nodemcuv2]
platform = https://github.com/platformio/platform-espressif8266.git
board = nodemcuv2
framework = arduino
upload_protocol = espota
upload_port = 192.168.2.242
upload_port = 192.168.2.238
;upload_port = COM6
upload_speed = 115200
monitor_speed = 115200
build_flags =
-D JAJ_BOARD_TARGET=BOARD_ESP8266_DEV
${common.build_flags}
lib_deps =
${common.lib_deps}
@ -82,7 +57,6 @@ upload_port = COM6
upload_speed = 115200
monitor_speed = 115200
build_flags =
-D JAJ_BOARD_TARGET=BOARD_ESP8266_HUZZAH
${common.build_flags}
lib_deps =
${common.lib_deps}

View File

@ -2,22 +2,10 @@
#include <WiFiManager.h>
#include <ArduinoOTA.h>
#if defined(ARDUINO_ARCH_ESP32)
#if (JAJ_BOARD_TARGET == BOARD_ESP32_C3)
#include <esp32c3.h>
#define BOARD "ESP32C3"
#elif (JAJ_BOARD_TARGET == BOARD_ESP32_DEV)
#include <esp32.h>
#define BOARD "ESP32"
#endif
#include <WiFi.h>
#include <HTTPClient.h>
#elif defined(ARDUINO_ARCH_ESP8266)
#if (JAJ_BOARD_TARGET == BOARD_ESP8266_HUZZAH)
#define BOARD "ESP8266-Huzzah"
#elif (JAJ_BOARD_TARGET == BOARD_ESP8266_DEV)
#define BOARD "ESP8266-DevKit"
#endif
#include <esp8266.h>
#include <esp8266.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
@ -63,9 +51,6 @@ extern const uint8_t gamma8[];
volatile bool blueInitState = false;
volatile unsigned long blueToggleCount;
// nextStatusMillis is global so we can reset it inside the process message function if needed
unsigned long nextStatusMillis = 0;
// Struct for storing color value sets
// Colors are obvious. restDuration is how long to rest on this color.
struct colorTriplet {
@ -141,7 +126,7 @@ void inline blueBlinkISR(void) {
#endif
}
void sendDeviceStatus() {
unsigned long sendDeviceStatus() {
if ( DEBUG ) Serial.println("Sending device status");
WiFiClient client;
HTTPClient http;
@ -160,7 +145,7 @@ void sendDeviceStatus() {
}
}
http.end();
nextStatusMillis = millis() + 600000; // 10 minutes
return millis();
}
// Set up our initial states and WiFi
@ -205,7 +190,6 @@ void setup() {
#endif
analogWrite(GPIO_BLUE, 0);
sendDeviceStatus();
nextStatusMillis = millis() + 600000; // 10 minutes
ArduinoOTA.onStart([]() {
analogWrite(GPIO_RED, 0);
analogWrite(GPIO_GREEN, 0);
@ -289,7 +273,7 @@ bool processMessage() {
memcpy(&messageTargetID, (char*)buff + 13, 4);
// If this packet isn't destined for ID=0 (all targets) or ID=TARGET_ID (our ID) then stop processing
if ( (myTargetID != 0 ) && (messageTargetID != 0) && ((messageTargetID & myTargetID) == 0) ) {
if ( (myTargetID != 0 ) && (messageTargetID != 0) && (messageTargetID != myTargetID) ) {
if ( DEBUG ) Serial.println("Got packet for different ID! Mine=" + String(myTargetID) + " Target=" + String(messageTargetID));
return false;
}
@ -413,7 +397,7 @@ bool processMessage() {
if ( command == CMD_UPDATESTATUS ) {
sendDeviceStatus();
if ( DEBUG ) Serial.println("Status update requested");
return false;
return true;
}
return false;
@ -426,6 +410,7 @@ void loop() {
static short redLevel = 0, greenLevel = 0, blueLevel = 0;
static bool newColor = false;
unsigned long nowMillis = millis();
static unsigned long nextStatusMillis = millis() + 600000; // 10 minutes
static unsigned long nextRampMillis;
static unsigned long rampStartMillis;
static unsigned long restingEndMillis;
@ -446,7 +431,7 @@ void loop() {
}
if ( nowMillis >= nextStatusMillis ) {
sendDeviceStatus();
nextStatusMillis = sendDeviceStatus() + 600000; // 10 minutes
}
// Check to see if we have a new packet waiting and parse it out if we do