mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 05:06:39 +01:00
fixed incompatibility, broke something else
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
#include <FastLED.h>
|
||||
#endif
|
||||
|
||||
void ledTask(void* parameter);
|
||||
void shortBlink(CRGB cname);
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
void shortBlink(CRGB cname);
|
||||
#endif
|
||||
@@ -46,19 +46,19 @@
|
||||
|
||||
#if (PINOUT == SIMPLE_AP)
|
||||
/* Lolin32 lite connections to AP tag*/
|
||||
#define RXD1 16
|
||||
#define TXD1 17
|
||||
|
||||
#define FLASHER_AP_SS 5
|
||||
#define FLASHER_AP_CLK 18
|
||||
#define FLASHER_AP_MOSI 23
|
||||
#define FLASHER_AP_MISO 19
|
||||
#define FLASHER_AP_RESET 2
|
||||
#define FLASHER_AP_POWER 13
|
||||
//#define FLASHER_AP_POWER 13
|
||||
#define FLASHER_AP_POWER2 15
|
||||
#define FLASHER_AP_TXD 17
|
||||
#define FLASHER_AP_RXD 16
|
||||
//#define FLASHER_AP_TXD 17
|
||||
//#define FLASHER_AP_RXD 16
|
||||
#define FLASHER_AP_TEST -1
|
||||
#define FLASHER_AP_TXD 12
|
||||
#define FLASHER_AP_RXD 13
|
||||
#define FLASHER_AP_POWER 25
|
||||
|
||||
#define FLASHER_LED 22
|
||||
#endif
|
||||
|
||||
@@ -172,7 +172,7 @@ void performDeviceFlash() {
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
zbs->set_power(1);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
//interfaceWorking = zbs.begin();
|
||||
interfaceWorking = zbs->begin(FLASHER_AP_SS, FLASHER_AP_CLK, FLASHER_AP_MOSI, FLASHER_AP_MISO, FLASHER_AP_RESET, FLASHER_AP_POWER, 8000000);
|
||||
if (!interfaceWorking) {
|
||||
Serial.print("I wasn't able to connect to a ZBS tag, please check wiring and definitions in the settings.h file.\n");
|
||||
return;
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
#include <FastLED.h>
|
||||
#endif
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
QueueHandle_t rgbLedQueue;
|
||||
|
||||
QueueHandle_t ledQueue;
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
QueueHandle_t rgbLedQueue;
|
||||
|
||||
struct ledInstructionRGB {
|
||||
CRGB ledColor;
|
||||
uint16_t fadeTime;
|
||||
uint16_t length;
|
||||
};
|
||||
|
||||
CRGB leds[1];
|
||||
#endif
|
||||
|
||||
struct ledInstruction {
|
||||
uint16_t value;
|
||||
uint16_t fadeTime;
|
||||
@@ -64,7 +73,9 @@ const uint16_t gamma12[256] = {
|
||||
3502, 3540, 3578, 3616, 3654, 3693, 3732, 3771, 3810, 3850,
|
||||
3890, 3930, 3971, 4013, 4054, 4095};
|
||||
|
||||
CRGB leds[1];
|
||||
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
|
||||
void addToRGBQueue(struct ledInstructionRGB* rgb) {
|
||||
BaseType_t queuestatus = xQueueSend(rgbLedQueue, &rgb, 0);
|
||||
@@ -73,13 +84,6 @@ void addToRGBQueue(struct ledInstructionRGB* rgb) {
|
||||
}
|
||||
}
|
||||
|
||||
void addToMonoQueue(struct ledInstruction* mono) {
|
||||
BaseType_t queuestatus = xQueueSend(ledQueue, &mono, 0);
|
||||
if (queuestatus == pdFALSE) {
|
||||
delete mono;
|
||||
}
|
||||
}
|
||||
|
||||
void addFadeColor(CRGB cname) {
|
||||
struct ledInstructionRGB* rgb = new struct ledInstructionRGB;
|
||||
rgb->ledColor = cname;
|
||||
@@ -88,13 +92,6 @@ void addFadeColor(CRGB cname) {
|
||||
addToRGBQueue(rgb);
|
||||
}
|
||||
|
||||
void addFadeMono(uint8_t value) {
|
||||
struct ledInstruction* mono = new struct ledInstruction;
|
||||
mono->value = value;
|
||||
mono->fadeTime = 750;
|
||||
mono->length = 0;
|
||||
addToMonoQueue(mono);
|
||||
}
|
||||
|
||||
void shortBlink(CRGB cname) {
|
||||
struct ledInstructionRGB* rgb = new struct ledInstructionRGB;
|
||||
@@ -118,14 +115,9 @@ void shortBlink(CRGB cname) {
|
||||
void showRGB() {
|
||||
FastLED.show();
|
||||
}
|
||||
void showMono(uint8_t brightness) {
|
||||
ledcWrite(7, gamma12[brightness]);
|
||||
}
|
||||
|
||||
volatile uint16_t rgbIdlePeriod = 800;
|
||||
volatile uint16_t monoIdlePeriod = 900;
|
||||
volatile CRGB rgbIdleColor = CRGB::Green;
|
||||
uint8_t monoValue = 0;
|
||||
volatile uint16_t rgbIdlePeriod = 800;
|
||||
|
||||
void rgbIdleStep() {
|
||||
static bool dirUp = true;
|
||||
@@ -150,6 +142,33 @@ void rgbIdleStep() {
|
||||
showRGB();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void addToMonoQueue(struct ledInstruction* mono) {
|
||||
BaseType_t queuestatus = xQueueSend(ledQueue, &mono, 0);
|
||||
if (queuestatus == pdFALSE) {
|
||||
delete mono;
|
||||
}
|
||||
}
|
||||
|
||||
void addFadeMono(uint8_t value) {
|
||||
struct ledInstruction* mono = new struct ledInstruction;
|
||||
mono->value = value;
|
||||
mono->fadeTime = 750;
|
||||
mono->length = 0;
|
||||
addToMonoQueue(mono);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void showMono(uint8_t brightness) {
|
||||
ledcWrite(7, gamma12[brightness]);
|
||||
}
|
||||
volatile uint16_t monoIdlePeriod = 900;
|
||||
|
||||
uint8_t monoValue = 0;
|
||||
|
||||
|
||||
void monoIdleStep() {
|
||||
static bool dirUp = true;
|
||||
@@ -175,11 +194,24 @@ void monoIdleStep() {
|
||||
}
|
||||
|
||||
void ledTask(void* parameter) {
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
FastLED.addLeds<WS2812B, FLASHER_RGB_LED, GRB>(leds, 1); // GRB ordering is typical
|
||||
leds[0] = CRGB::Blue;
|
||||
showRGB();
|
||||
|
||||
rgbLedQueue = xQueueCreate(30, sizeof(struct ledInstructionRGB*));
|
||||
|
||||
struct ledInstructionRGB* rgb = nullptr;
|
||||
// open with a nice RGB crossfade
|
||||
addFadeColor(CRGB::Red);
|
||||
addFadeColor(CRGB::Green);
|
||||
addFadeColor(CRGB::Blue);
|
||||
addFadeColor(CRGB::Red);
|
||||
addFadeColor(CRGB::Green);
|
||||
addFadeColor(CRGB::Blue);
|
||||
CRGB oldColor = CRGB::Black;
|
||||
uint16_t rgbInstructionFadeTime = 0;
|
||||
#endif
|
||||
|
||||
ledQueue = xQueueCreate(30, sizeof(struct ledInstruction*));
|
||||
|
||||
digitalWrite(FLASHER_LED, HIGH);
|
||||
@@ -187,31 +219,20 @@ void ledTask(void* parameter) {
|
||||
ledcSetup(7, 9500, 12); // 141251 okay // 101251 okay
|
||||
ledcAttachPin(FLASHER_LED, 7);
|
||||
|
||||
struct ledInstructionRGB* rgb = nullptr;
|
||||
struct ledInstruction* monoled = nullptr;
|
||||
|
||||
// open with a nice RGB crossfade
|
||||
addFadeColor(CRGB::Red);
|
||||
addFadeColor(CRGB::Green);
|
||||
addFadeColor(CRGB::Blue);
|
||||
addFadeColor(CRGB::Red);
|
||||
addFadeColor(CRGB::Green);
|
||||
addFadeColor(CRGB::Blue);
|
||||
|
||||
addFadeMono(255);
|
||||
addFadeMono(127);
|
||||
addFadeMono(255);
|
||||
addFadeMono(0);
|
||||
|
||||
CRGB oldColor = CRGB::Black;
|
||||
|
||||
uint8_t oldBrightness = 0;
|
||||
|
||||
uint16_t rgbInstructionFadeTime = 0;
|
||||
|
||||
uint16_t monoInstructionFadeTime = 0;
|
||||
|
||||
while (1) {
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
// handle RGB led instructions
|
||||
if (rgb == nullptr) {
|
||||
// fetch a led instruction
|
||||
@@ -240,7 +261,7 @@ void ledTask(void* parameter) {
|
||||
rgb = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// handle flasher LED (single color)
|
||||
if (monoled == nullptr) {
|
||||
BaseType_t q = xQueueReceive(ledQueue, &monoled, 1);
|
||||
|
||||
@@ -58,7 +58,7 @@ void setup() {
|
||||
Serial.printf("Total PSRAM: %d", ESP.getPsramSize());
|
||||
Serial.printf("Free PSRAM: %d", ESP.getFreePsram());
|
||||
|
||||
#if (HAS_USB == 1)
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
xTaskCreate(usbFlasherTask, "flasher", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,11 +1,31 @@
|
||||
#include <Arduino.h>
|
||||
#include "powermgt.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef SIMPLE_AP
|
||||
void simpleAPPower(bool state) {
|
||||
pinMode(FLASHER_AP_POWER, INPUT);
|
||||
pinMode(FLASHER_AP_POWER2, INPUT);
|
||||
digitalWrite(FLASHER_AP_POWER, state);
|
||||
digitalWrite(FLASHER_AP_POWER2, state);
|
||||
pinMode(FLASHER_AP_POWER, OUTPUT);
|
||||
pinMode(FLASHER_AP_POWER2, OUTPUT);
|
||||
}
|
||||
#endif
|
||||
|
||||
// On the OpenEPaperLink board, there is no in-rush current limiting. The tags that can be connected to the board can have significant capacity, which,
|
||||
// when drained, will cause the 3v3 rail to sag enough to reset the ESP32. This is obviously not great. To prevent this from happening, we ramp up/down the
|
||||
// voltage with PWM. Ramping down really is unnecessary, as the board has a resistor to dump the charge into.
|
||||
void rampTagPower(uint8_t pin, bool up) {
|
||||
pinMode(FLASHER_AP_SS, INPUT);
|
||||
pinMode(FLASHER_AP_CLK, INPUT);
|
||||
pinMode(FLASHER_AP_MOSI, INPUT);
|
||||
pinMode(FLASHER_AP_MISO, INPUT);
|
||||
pinMode(FLASHER_AP_RESET, OUTPUT);
|
||||
digitalWrite(FLASHER_AP_RESET, HIGH);
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
if (up) {
|
||||
ledcSetup(0, 152000, 8); // 141251 okay // 101251 okay
|
||||
ledcWrite(0, 254);
|
||||
@@ -23,4 +43,10 @@ void rampTagPower(uint8_t pin, bool up) {
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, HIGH);
|
||||
}
|
||||
#endif
|
||||
#ifdef SIMPLE_AP
|
||||
simpleAPPower(false);
|
||||
delay(500);
|
||||
simpleAPPower(up);
|
||||
#endif
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "settings.h"
|
||||
#include "web.h"
|
||||
#include "zbs_interface.h"
|
||||
#include "powermgt.h"
|
||||
|
||||
#define ZBS_RX_WAIT_HEADER 0
|
||||
#define ZBS_RX_WAIT_PKT_LEN 1
|
||||
@@ -90,6 +91,7 @@ uint8_t pktindex = 0;
|
||||
char lastchar = 0;
|
||||
uint8_t charindex = 0;
|
||||
uint64_t waitingForVersion = 0;
|
||||
uint8_t crashcounter = 0;
|
||||
uint16_t version;
|
||||
|
||||
void ShortRXWaitLoop() {
|
||||
@@ -200,25 +202,12 @@ void SerialRXLoop() {
|
||||
break;
|
||||
case ZBS_RX_WAIT_VER:
|
||||
waitingForVersion = 0;
|
||||
crashcounter = 0;
|
||||
cmdbuffer[charindex] = lastchar;
|
||||
charindex++;
|
||||
if (charindex == 4) {
|
||||
charindex = 0;
|
||||
version = (uint16_t)strtoul(cmdbuffer, NULL, 16);
|
||||
/*
|
||||
uint16_t fsversion;
|
||||
lookupFirmwareFile(fsversion);
|
||||
if ((fsversion) && (version != fsversion)) {
|
||||
Serial.printf("ZBS/Zigbee FW version: %04X, version on SPIFFS: %04X\n", version, fsversion);
|
||||
Serial.printf("Performing flash update in about 30 seconds");
|
||||
vTaskDelay(30000 / portTICK_PERIOD_MS);
|
||||
performDeviceFlash();
|
||||
} else if (!fsversion) {
|
||||
Serial.println("No ZBS/Zigbee FW binary found on SPIFFS, please upload a zigbeebase000X.bin - format binary to enable flashing");
|
||||
} else {
|
||||
Serial.printf("ZBS/Zigbee FW version: %04X\n", version);
|
||||
}
|
||||
*/
|
||||
RXState = ZBS_RX_WAIT_HEADER;
|
||||
}
|
||||
break;
|
||||
@@ -229,13 +218,14 @@ void SerialRXLoop() {
|
||||
extern uint8_t* getDataForFile(File* file);
|
||||
|
||||
void zbsRxTask(void* parameter) {
|
||||
Serial1.begin(230400, SERIAL_8N1, RXD1, TXD1);
|
||||
Serial1.begin(228571, SERIAL_8N1, FLASHER_AP_RXD, FLASHER_AP_TXD);
|
||||
|
||||
simplePowerOn();
|
||||
rampTagPower(FLASHER_AP_POWER, true);
|
||||
bool firstrun = true;
|
||||
|
||||
Serial1.print("VER?");
|
||||
waitingForVersion = esp_timer_get_time();
|
||||
|
||||
while (1) {
|
||||
SerialRXLoop();
|
||||
|
||||
@@ -245,14 +235,21 @@ void zbsRxTask(void* parameter) {
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
|
||||
if (waitingForVersion) {
|
||||
if (esp_timer_get_time() - waitingForVersion > 10000*1000ULL) {
|
||||
if (esp_timer_get_time() - waitingForVersion > 5000*1000ULL) {
|
||||
waitingForVersion = 0;
|
||||
//performDeviceFlash();
|
||||
Serial.println("I wasn't able to connect to a ZBS tag, trying to reboot the tag.");
|
||||
Serial.println("If this problem persists, please check wiring and definitions in the settings.h file, and presence of the right firmware");
|
||||
simplePowerOn();
|
||||
wsErr("The AP tag crashed. Restarting tag, regenerating all pending info.");
|
||||
refreshAllPending();
|
||||
wsLog("AP doesn't respond... "+String(crashcounter + 1));
|
||||
if (++crashcounter >= 4) {
|
||||
crashcounter = 0;
|
||||
Serial.println("I wasn't able to connect to a ZBS tag, trying to reboot the tag.");
|
||||
Serial.println("If this problem persists, please check wiring and definitions in the settings.h file, and presence of the right firmware");
|
||||
rampTagPower(FLASHER_AP_POWER, false);
|
||||
vTaskDelay(2/portTICK_PERIOD_MS);
|
||||
rampTagPower(FLASHER_AP_POWER, true);
|
||||
wsErr("The AP tag crashed. Restarting tag, regenerating all pending info.");
|
||||
refreshAllPending();
|
||||
} else {
|
||||
Ping();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,4 +268,4 @@ void zbsRxTask(void* parameter) {
|
||||
firstrun = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
@@ -13,10 +12,10 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager/tree/feature_asyncwebserver
|
||||
|
||||
#include "commstructs.h"
|
||||
#include "leds.h"
|
||||
#include "newproto.h"
|
||||
#include "settings.h"
|
||||
#include "tag_db.h"
|
||||
#include "leds.h"
|
||||
|
||||
extern uint8_t data_to_send[];
|
||||
|
||||
@@ -52,7 +51,9 @@ void webSocketSendProcess(void *parameter) {
|
||||
}
|
||||
|
||||
void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) {
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
shortBlink(CRGB::BlueViolet);
|
||||
#endif
|
||||
switch (type) {
|
||||
case WS_EVT_CONNECT:
|
||||
// client connected
|
||||
@@ -159,14 +160,12 @@ void wsSendSysteminfo() {
|
||||
}
|
||||
|
||||
void wsSendTaginfo(uint8_t mac[6]) {
|
||||
|
||||
String json = "";
|
||||
json = tagDBtoJson(mac);
|
||||
|
||||
xSemaphoreTake(wsMutex, portMAX_DELAY);
|
||||
ws.textAll(json);
|
||||
xSemaphoreGive(wsMutex);
|
||||
|
||||
}
|
||||
|
||||
void init_web() {
|
||||
@@ -208,7 +207,7 @@ void init_web() {
|
||||
|
||||
server.serveStatic("/current", LittleFS, "/current/");
|
||||
server.serveStatic("/", LittleFS, "/www/").setDefaultFile("index.html");
|
||||
|
||||
|
||||
server.on(
|
||||
"/imgupload", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
request->send(200);
|
||||
@@ -220,15 +219,15 @@ void init_web() {
|
||||
if (request->hasParam("mac")) {
|
||||
String dst = request->getParam("mac")->value();
|
||||
uint8_t mac[6];
|
||||
if (sscanf(dst.c_str(), "%02X%02X%02X%02X%02X%02X", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])==6) {
|
||||
if (sscanf(dst.c_str(), "%02X%02X%02X%02X%02X%02X", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) == 6) {
|
||||
json = tagDBtoJson(mac);
|
||||
}
|
||||
} else {
|
||||
uint8_t startPos=0;
|
||||
uint8_t startPos = 0;
|
||||
if (request->hasParam("pos")) {
|
||||
startPos = atoi(request->getParam("pos")->value().c_str());
|
||||
}
|
||||
json = tagDBtoJson(nullptr,startPos);
|
||||
json = tagDBtoJson(nullptr, startPos);
|
||||
}
|
||||
request->send(200, "application/json", json);
|
||||
});
|
||||
@@ -245,8 +244,8 @@ void init_web() {
|
||||
taginfo->modeConfigJson = request->getParam("modecfgjson", true)->value();
|
||||
taginfo->contentMode = atoi(request->getParam("contentmode", true)->value().c_str());
|
||||
taginfo->nextupdate = 0;
|
||||
//memset(taginfo->md5, 0, 16 * sizeof(uint8_t));
|
||||
//memset(taginfo->md5pending, 0, 16 * sizeof(uint8_t));
|
||||
// memset(taginfo->md5, 0, 16 * sizeof(uint8_t));
|
||||
// memset(taginfo->md5pending, 0, 16 * sizeof(uint8_t));
|
||||
wsSendTaginfo(mac);
|
||||
saveDB("/current/tagDB.json");
|
||||
request->send(200, "text/plain", "Ok, saved");
|
||||
|
||||
5
esp32_fw/.gitignore
vendored
Normal file
5
esp32_fw/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
Reference in New Issue
Block a user