working led color cycling
This commit is contained in:
parent
9f889cd1a9
commit
161352f0ca
@ -8,6 +8,9 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
default_envs = esp32c3_supermini
|
||||
|
||||
[env:esp12e]
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
@ -26,9 +29,30 @@ lib_deps =
|
||||
devyte/ESPAsyncDNSServer@^1.0.0
|
||||
me-no-dev/ESPAsyncUDP
|
||||
makuna/NeoPixelBus @ ^2.8.0
|
||||
|
||||
|
||||
lib_ldf_mode = chain+
|
||||
monitor_filters = default, esp8266_exception_decoder
|
||||
monitor_filters =
|
||||
default
|
||||
esp8266_exception_decoder
|
||||
board_build.filesystem = littlefs
|
||||
board_build.f_cpu = 80000000L
|
||||
|
||||
[env:esp32c3_supermini]
|
||||
; platform = espressif32
|
||||
; board = esp32-c3-devkitm-1
|
||||
|
||||
; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5
|
||||
; board = lolin_c3_mini
|
||||
|
||||
board = dfrobot_beetle_esp32c3
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
monitor_speed = 460800
|
||||
lib_deps =
|
||||
fastled/FastLED@^3.7.0
|
||||
|
||||
; [env:dfrobot_beetle_esp32c3]
|
||||
; platform = espressif32
|
||||
; board = dfrobot_beetle_esp32c3
|
||||
; framework = arduino
|
||||
; lib_deps =
|
||||
; fastled/FastLED@^3.7.0
|
||||
@ -1,4 +1,7 @@
|
||||
#define INCLUDE_LED
|
||||
#ifdef INCLUDE_LED
|
||||
#include "Led.h"
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
@ -6,21 +9,32 @@
|
||||
#define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
|
||||
|
||||
// #define ENABLE_MQTT
|
||||
#define ENABLE_WIFI
|
||||
// #define ENABLE_WIFI
|
||||
// #define ENABLE_FS
|
||||
// #define ENABLE_PINFINDER
|
||||
|
||||
// #include <TaskScheduler.h>
|
||||
|
||||
#ifdef ENABLE_MQTT
|
||||
#include "MQTT.h"
|
||||
#include "Wifi.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WIFI
|
||||
#include "Wifi.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FS
|
||||
#include "FS.h"
|
||||
#include <LittleFS.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_PINFINDER
|
||||
#include "PinFinder.h"
|
||||
#endif
|
||||
|
||||
|
||||
void feedWatchdog(){
|
||||
ESP.wdtFeed();
|
||||
// ESP.wdtFeed();
|
||||
}
|
||||
|
||||
bool blinkStatus = false;
|
||||
@ -29,6 +43,7 @@ void blink(){
|
||||
digitalWrite(LED_BUILTIN, blinkStatus);
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_LED
|
||||
CRGB colorTable[] = {
|
||||
CRGB::Red,
|
||||
CRGB::Blue,
|
||||
@ -90,6 +105,7 @@ void colors(){
|
||||
Serial.printf("colorIndex: %d\n", colorIndex);
|
||||
jumpTo(colorTable[colorIndex]);
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
|
||||
@ -98,10 +114,12 @@ void setup() {
|
||||
|
||||
delay(500);
|
||||
|
||||
#ifdef ENABLE_FS
|
||||
if(!LittleFS.begin()){
|
||||
Serial.println("LittleFS Mount Failed");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// runner.init();
|
||||
@ -115,17 +133,22 @@ void setup() {
|
||||
PinFinder_setup();
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_LED
|
||||
Led_setup();
|
||||
|
||||
jumpTo(CRGB(0xFF00FF));
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WIFI
|
||||
Wifi_setup();
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_LED
|
||||
jumpTo(CRGB(0x00FFFF));
|
||||
|
||||
jumpTo(CRGB(0x000000));
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MQTT
|
||||
MQTT_setup();
|
||||
#endif
|
||||
@ -133,13 +156,16 @@ void setup() {
|
||||
OTA_setup();
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_LED
|
||||
jumpTo(CRGB(0x00FFFF));
|
||||
#endif
|
||||
|
||||
// ESP.wdtEnable(10000);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
#ifdef ENABLE_MQTT
|
||||
MQTT_loop();
|
||||
#endif
|
||||
@ -152,13 +178,18 @@ void loop() {
|
||||
PinFinder_loop();
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_LED
|
||||
colors();
|
||||
#endif
|
||||
|
||||
delay(2000);
|
||||
delay(1000);
|
||||
|
||||
return;
|
||||
|
||||
sleep(2000);
|
||||
|
||||
// Led_loop();
|
||||
|
||||
return;
|
||||
|
||||
String command;
|
||||
|
||||
@ -174,6 +205,8 @@ void loop() {
|
||||
String name = command.substring(0, index);
|
||||
Serial.print("Have command name: ");
|
||||
Serial.println(name);
|
||||
|
||||
#ifdef INCLUDE_LED
|
||||
if(name.equals("c")){
|
||||
//c:0xff4000
|
||||
//c:0xff0000
|
||||
@ -193,6 +226,7 @@ void loop() {
|
||||
|
||||
jumpTo(target);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -46,9 +46,9 @@ void displayLed(){
|
||||
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
||||
// Serial.printf("Led 2:%02d 0x%02x%02x%02x\n", index, strip2[index].r, strip2[index].g, strip2[index].b);
|
||||
}
|
||||
auto before = micros64();
|
||||
auto before = micros();
|
||||
FastLED.show();
|
||||
auto after = micros64();
|
||||
auto after = micros();
|
||||
Serial.printf("FastLED.show took %d micros\n", after - before);
|
||||
#endif
|
||||
|
||||
@ -116,7 +116,7 @@ void Led_setup(){
|
||||
// analogWriteRange(255);
|
||||
|
||||
#ifdef LED_FASTLED
|
||||
// FastLED.addLeds<WS2812B, PIN_STRIP1>(strip2, STRIP_LENGTH);
|
||||
FastLED.addLeds<WS2812B, PIN_STRIP1>(strip2, STRIP_LENGTH);
|
||||
FastLED.addLeds<WS2812B, PIN_STRIP2>(strip2, STRIP_LENGTH);
|
||||
#endif
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
#include <NeoPixelBus.h>
|
||||
#endif
|
||||
|
||||
#define PIN_STRIP1 4
|
||||
#define PIN_STRIP2 5
|
||||
#define PIN_STRIP1 3
|
||||
#define PIN_STRIP2 4
|
||||
|
||||
#define STRIP_LENGTH 46
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#ifdef ENABLE_MQTT
|
||||
#include "MQTT.h"
|
||||
|
||||
#include <PubSubClient.h>
|
||||
@ -115,3 +116,4 @@ void MQTT_loop(){
|
||||
}
|
||||
client.loop();
|
||||
}
|
||||
#endif
|
||||
@ -4,14 +4,18 @@
|
||||
|
||||
char pins[] = {
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
20,
|
||||
21,
|
||||
};
|
||||
void PinFinder_setup(){
|
||||
for(int index=0; index < sizeof(pins); index++){
|
||||
@ -26,7 +30,7 @@ void PinFinder_loop(){
|
||||
auto pin = pins[index];
|
||||
Serial.printf("Setting pin %d high\n", pin);
|
||||
digitalWrite(pin, HIGH);
|
||||
delay(1000);
|
||||
delay(100);
|
||||
Serial.printf("Setting pin %d low\n", pin);
|
||||
digitalWrite(pin, LOW);
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
#ifdef ENABLE_WIFI
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
#include <ESPAsync_WiFiManager.h>
|
||||
@ -40,3 +42,4 @@ void Wifi_setup(){
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user