Merge branch 'master' into master

This commit is contained in:
Jelmer
2023-05-15 20:42:40 +02:00
committed by GitHub
13 changed files with 76 additions and 1479 deletions

View File

@@ -10,6 +10,7 @@ const WAKEUP_REASON_WDT_RESET = 0xFE;
const contentModes = ["Static image", "Current date", "Counting days", "Counting hours", "Current weather", "Firmware update", "Memo text", "Image url", "Weather forecast", "RSS feed", "QR code", "Calendar", "Remote AP"];
const models = ["1.54\" 152x152px", "2.9\" 296x128px", "4.2\" 400x300px"];
models[240] = "Segmented tag"
const displaySizeLookup = { 0: [152, 152], 1: [128, 296], 2: [400, 300] };
const colorTable = { 0: [255, 255, 255], 1: [0, 0, 0], 2: [255, 0, 0], 3: [255, 0, 0] };
const contentModeOptions = [];
@@ -425,6 +426,9 @@ function processQueue() {
ctx.putImageData(imageData, 0, 0);
processQueue();
})
.catch (error => {
processQueue();
});
}

View File

@@ -1,11 +1,11 @@
#include <Arduino.h>
#include <LittleFS.h>
#include "makeimage.h"
#include <time.h>
#include "tag_db.h"
#define DISABLE_ALL_LIBRARY_WARNINGS
#include <TFT_eSPI.h>
#include "makeimage.h"
#include "tag_db.h"
struct contentTypes {
uint16_t id;
String name;

View File

@@ -1,6 +1,7 @@
#include <Arduino.h>
#ifdef HAS_RGB_LED
#define FASTLED_INTERNAL
#include <FastLED.h>
#endif

View File

@@ -12,6 +12,7 @@ void wsErr(String text);
void wsSendTaginfo(uint8_t mac[6]);
void wsSendSysteminfo();
void wsSendAPitem(struct APlist* apitem);
uint8_t wsClientCount();
extern uint64_t swap64(uint64_t x);
extern AsyncWebSocket ws;

View File

@@ -34,11 +34,15 @@ board_build.f_cpu = 240000000L
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
board_build.partitions = default.csv
build_unflags =
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags =
-D OPENEPAPERLINK_MINI_AP_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
-D CONFIG_SPIRAM_USE_MALLOC=y
-D CONFIG_SPIRAM_USE_MALLOC=1
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
;-D DEBUG_VERSION
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
;-D HAS_USB
@@ -61,8 +65,8 @@ build_src_filter =
board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 327680
board_upload.maximum_ram_size = 2097152
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB
@@ -77,14 +81,16 @@ board_build.partitions = default_16MB.csv
build_unflags =
-D ARDUINO_USB_MODE=1
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags =
-D OPENEPAPERLINK_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
-D CONFIG_SPIRAM_USE_MALLOC=y
-D CONFIG_SPIRAM_USE_MALLOC=1
-D HAS_USB
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D FLASHER_AP_SS=4
-D FLASHER_AP_CLK=5

File diff suppressed because it is too large Load Diff

View File

@@ -7,12 +7,14 @@
#include <locale.h>
#include <rssClass.h>
#include <time.h>
#include <LittleFS.h>
#include "U8g2_for_TFT_eSPI.h"
#include "commstructs.h"
#include "makeimage.h"
#include "newproto.h"
#include "qrcode.h"
#include "tag_db.h"
#include "settings.h"
#include "web.h"
@@ -58,7 +60,7 @@ void contentRunner() {
uint16_t minutesUntilNextUpdate = 0;
minutesUntilNextUpdate = (taginfo->nextupdate - now) / 60;
if (minutesUntilNextUpdate > MIN_RESPONSE_TIME) minutesUntilNextUpdate = MIN_RESPONSE_TIME;
if (minutesUntilNextUpdate > 1) {
if (minutesUntilNextUpdate > 1 && wsClientCount() == 0) {
taginfo->pendingIdle = minutesUntilNextUpdate;
if (taginfo->isExternal == false) prepareIdleReq(src, minutesUntilNextUpdate);
}

View File

@@ -1,6 +1,7 @@
#include <Arduino.h>
#ifdef HAS_RGB_LED
#define FASTLED_INTERNAL
#include <FastLED.h>
#endif
@@ -81,6 +82,10 @@ const uint16_t gamma12[256] = {
void addToRGBQueue(struct ledInstructionRGB* rgb, bool requeue) {
rgb->reQueue = requeue;
if (!rgbLedQueue) {
delete rgb;
return;
}
BaseType_t queuestatus = xQueueSend(rgbLedQueue, &rgb, 0);
if (queuestatus == pdFALSE) {
delete rgb;

View File

@@ -38,15 +38,42 @@ void timeTask(void* parameter) {
}
void setup() {
// starts the led task/state machine
xTaskCreate(ledTask, "ledhandler", 2000, NULL, 2, NULL);
vTaskDelay(10/portTICK_PERIOD_MS);
// show a nice pattern to indicate the AP is booting / waiting for WiFi setup
#ifdef HAS_RGB_LED
showColorPattern(CRGB::Aqua, CRGB::Green, CRGB::Blue);
#endif
#ifdef OPENEPAPERLINK_MINI_AP_PCB
APEnterEarlyReset();
// this allows us to view the booting process. After connecting to USB, you have 3 seconds to open a terminal on the COM port
// this allows us to view the booting process. After the device showing up, you have 3 seconds to open a terminal on the COM port
vTaskDelay(3000 / portTICK_PERIOD_MS);
#ifdef DEBUG_VERSION
// Specifically for the Mini-version (using an ESP32-S2), use another serial port for debug output. Makes it possible to see core dumps
Serial0.begin(115200, SERIAL_8N1, 38, 37);
Serial0.printf("Started debug output...\n");
Serial0.setDebugOutput(true);
#endif
#endif
Serial.begin(115200);
Serial.print(">\n");
psramInit();
#ifdef BOARD_HAS_PSRAM
if (!psramInit()) {
Serial.printf("This build of the AP expects PSRAM, but we couldn't find/init any. Something is terribly wrong here! System halted.");
#ifdef HAS_RGB_LED
showColorPattern(CRGB::Yellow, CRGB::Red, CRGB::Red);
#endif
while (1) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
};
heap_caps_malloc_extmem_enable(64);
#endif
Serial.println("\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
@@ -73,18 +100,13 @@ void setup() {
}
#ifdef HAS_USB
// We'll need to start the 'usbflasher' task for boards with a second (USB) port. This can be used as a 'flasher' interface, using a python script on the host
xTaskCreate(usbFlasherTask, "usbflasher", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
#endif
xTaskCreate(ledTask, "ledhandler", 5000, NULL, 2, NULL);
configTzTime("CET-1CEST,M3.5.0,M10.5.0/3", "0.nl.pool.ntp.org", "europe.pool.ntp.org", "time.nist.gov");
// https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
#ifdef HAS_RGB_LED
showColorPattern(CRGB::Aqua, CRGB::Green, CRGB::Blue);
#endif
initAPconfig();
updateBrightnessFromConfig();
@@ -95,12 +117,10 @@ void setup() {
#ifdef HAS_RGB_LED
rgbIdle();
#endif
loadDB("/current/tagDB.json");
xTaskCreate(APTask, "AP Process", 10000, NULL, 2, NULL);
xTaskCreate(webSocketSendProcess, "ws", 5000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(timeTask, "timed tasks", 10000, NULL, 2, NULL);
xTaskCreate(APTask, "AP Process", 6000, NULL, 2, NULL);
xTaskCreate(webSocketSendProcess, "ws", 2000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(timeTask, "timed tasks", 12000, NULL, 2, NULL);
}
void loop() {

View File

@@ -165,6 +165,8 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
wsLog("firmware upload pending");
taginfo->filename = *filename;
taginfo->len = filesize;
clearPending(taginfo);
taginfo->pending = true;
}
struct pendingData pending = {0};
@@ -330,6 +332,7 @@ void processXferComplete(struct espXferComplete* xfc, bool local) {
if (taginfo != nullptr) {
memcpy(taginfo->md5, taginfo->md5pending, sizeof(taginfo->md5pending));
clearPending(taginfo);
taginfo->wakeupReason = 0;
}
wsSendTaginfo(mac);
if (local) udpsync.netProcessXferComplete(xfc);

View File

@@ -124,7 +124,7 @@ bool waitCmdReply() {
#endif
#endif
void APEnterEarlyReset(){
void APEnterEarlyReset() {
pinMode(AP_RESET_PIN, OUTPUT);
digitalWrite(AP_RESET_PIN, LOW);
}
@@ -601,8 +601,8 @@ bool bringAPOnline() {
}
void APTask(void* parameter) {
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(rxSerialTask, "rxSerialTask", 4000, NULL, configMAX_PRIORITIES - 4, NULL);
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 3000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(rxSerialTask, "rxSerialTask", 1750, NULL, configMAX_PRIORITIES - 4, NULL);
#if (AP_PROCESS_PORT == FLASHER_AP_PORT)
AP_SERIAL_PORT.begin(115200, SERIAL_8N1, FLASHER_AP_RXD, FLASHER_AP_TXD);
@@ -650,7 +650,7 @@ void APTask(void* parameter) {
Serial.printf("We're going to try to update the AP's FW in\n");
flashCountDown(30);
Serial.printf("\n");
notifySegmentedFlash();
apInfo.isOnline = false;
apInfo.state = AP_STATE_FLASHING;
if (doAPUpdate(apInfo.type)) {

View File

@@ -7,6 +7,7 @@
#include "tag_db.h"
#include "web.h"
#include "serialap.h"
#include "udp.h"
#define UDPIP IPAddress(239, 10, 0, 1)
#define UDPPORT 16033
@@ -128,7 +129,7 @@ void UDPcomm::getAPList() {
wsSendAPitem(&APitem);
if (APconfig["channel"].as<int>() == 0) {
xTaskCreate(autoselect, "autoselect", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(autoselect, "autoselect", 5000, NULL, configMAX_PRIORITIES - 10, NULL);
}
uint8_t buffer[sizeof(struct APlist) + 1];
@@ -163,4 +164,4 @@ void UDPcomm::netSendDataAvail(struct pendingData* pending) {
buffer[0] = PKT_AVAIL_DATA_REQ;
memcpy(buffer + 1, pending, sizeof(struct pendingData));
udp.writeTo(buffer, sizeof(buffer), UDPIP, UDPPORT);
}
}

View File

@@ -187,6 +187,10 @@ void wsSendAPitem(struct APlist* apitem) {
if (wsMutex) xSemaphoreGive(wsMutex);
}
uint8_t wsClientCount() {
return ws.count();
}
void init_web() {
LittleFS.begin(true);