Mainly testing the new eslabsCurses API

This commit is contained in:
2025-12-06 22:26:46 +00:00
parent 7245e09cd7
commit ce15563aee
5 changed files with 91 additions and 38 deletions
+2
View File
@@ -17,6 +17,8 @@ build_flags = -Iinclude/
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-issue
-std=gnu++17 -std=gnu++17
build_unflags = -std=gnu++11
# -Ilib/u8g2/csrc # -Ilib/u8g2/csrc
# -Ilib/u8g2/cppsrc # -Ilib/u8g2/cppsrc
board_build.arduino.memory_type = qio_opi board_build.arduino.memory_type = qio_opi
+1
View File
@@ -0,0 +1 @@
#include "communication.h"
+6
View File
@@ -0,0 +1,6 @@
#ifndef __COMMUNICATION__
#define __COMMUNICATION__
int router();
#endif
+1 -1
View File
@@ -15,7 +15,7 @@ struct __attribute__((packed)) IdentificationPacket {
}; };
void initIdentificationPacket(IdentificationPacket* packet, const char* name, void initIdentificationPacket(IdentificationPacket* packet, const char* name,
uint8_t id); uint8_t id);
void sendIdentificationPacket(IdentificationPacket* packet); void sendIdentificationPacket(IdentificationPacket* packet);
#endif #endif
+81 -37
View File
@@ -8,6 +8,8 @@ to have more ways to run analytics
*/ */
#include "UIComponent.h" #include "UIComponent.h"
#include "values.h"
#include "windowPool.h"
#include "UIScreen.h" #include "UIScreen.h"
#include "UIDecorations.h" #include "UIDecorations.h"
#include "UIDimensions.h" #include "UIDimensions.h"
@@ -54,22 +56,22 @@ Arduino_ESP32RGBPanel *panel = new Arduino_ESP32RGBPanel(
Arduino_GFX *gfx = new Arduino_RGB_Display(TFT_HOR_RES, TFT_VER_RES, panel, 16); Arduino_GFX *gfx = new Arduino_RGB_Display(TFT_HOR_RES, TFT_VER_RES, panel, 16);
// HardwareSerial debugSerial(1); // HardwareSerial debugSerial(1);
Curses::Screen mainSreen( Curses::Screen mainScreen(
gfx, gfx,
UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES), UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES),
UIDecorations() UIDecorations()
); );
// UIelements // UIelements
UIDecorations *gearTextDecor = new UIDecorations(); // UIDecorations *gearTextDecor = new UIDecorations();
UIString gearText(gfx, UIDimensions(0, 0, 0, 0), gearTextDecor, (char *)"Gear"); // UIString gearText(gfx, UIDimensions(0, 0, 0, 0), gearTextDecor, (char *)"Gear");
//
UIElement mainWindow( // UIElement mainWindow(
gfx, // gfx,
UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES), // UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES),
gearTextDecor, // gearTextDecor,
(char*)"MAIN WINDOW" // (char*)"MAIN WINDOW"
); // );
void setup() { void setup() {
psramInit(); psramInit();
@@ -84,35 +86,68 @@ void setup() {
Serial2.print(F("* Initiating display\r\n")); Serial2.print(F("* Initiating display\r\n"));
initialDisplaySetup(gfx); initialDisplaySetup(gfx);
// Setup the gear text box // Only setup the main screen after initializing the Serial2
// gearTextDecor->textSize = 7; mainScreen.Setup("Main Window");
// gearText.dims.height =
// calculateHeight(gearTextDecor->titleSize, gearTextDecor->textSize, 1);
// gearText.dims.width = calculateWidth(gearTextDecor->textSize, 2);
// gearText.drawBox();
// gearText.Update("Disconnected");
mainWindow.drawBox();
int16_t childID = mainWindow.AddChild(); // Grab a handle for the main window of the screen
if (!childID) { UIElement* mainWindow = mainScreen.mainWindowHandle;
mainWindow->drawBox();
int16_t childID = mainWindow->AddChild(STRING);
if (childID < 0) {
Serial2.println("Failed to add new window!"); Serial2.println("Failed to add new window!");
} else { } else {
Serial2.print("Successfully added a new window: "); Serial2.print("Successfully added a new window: ");
Serial2.println(childID); Serial2.println(childID);
UIElement* childComponent = mainWindow.GetChild(childID); UIElement* childComponent = mainWindow->GetChild(childID);
childComponent->SetTitle((char*)"%s [%2d]", (const char*)"Child Window", childID); childComponent->SetTitle((char*)"%s [%2d]", (const char*)"Child Window", childID);
childComponent->decor = gearTextDecor; childComponent->SetUIDecorations(UIDecorations());
childComponent->display = mainSreen.display; childComponent->SetUIDimensions(UIDimensions(20, 20, 300, 300));
childComponent->dims.x = 30; childComponent->SetDisplay(mainScreen.display);
childComponent->dims.y = 30;
childComponent->dims.width = 300;
childComponent->dims.height = 300;
childComponent->drawBox(); childComponent->drawBox();
} }
childID = mainWindow->AddChild(STRING);
if (childID < 0) {
Serial2.println("Failed to add new window!");
} else {
Serial2.print("Successfully added a new window: ");
Serial2.println(childID);
UIElement* childComponent = mainWindow->GetChild(childID);
childComponent->SetTitle((char*)"%s [%2d]", (const char*)"Second Child", childID);
childComponent->SetUIDecorations(UIDecorations());
childComponent->SetUIDimensions(UIDimensions(330, 20, 300, 300));
childComponent->SetDisplay(mainScreen.display);
childComponent->drawBox();
}
mainWindow->RemoveChild(1);
childID = mainWindow->AddChild(STRING);
if (childID < 0) {
Serial2.println("Failed to add new window!");
} else {
Serial2.print("Successfully added a new window: ");
Serial2.println(childID);
UIElement* childComponent = mainWindow->GetChild(childID);
childComponent->SetTitle((char*)"%s [%2d]", (const char*)"Third Child", childID);
childComponent->SetUIDecorations(UIDecorations());
childComponent->SetUIDimensions(UIDimensions(20, 20, 300, 300));
childComponent->SetDisplay(mainScreen.display);
childComponent->drawBox();
}
WindowPool::PrintInUse();
delay(500); delay(500);
Serial2.println("* Ready for loop"); Serial2.println("* Ready for loop");
} }
@@ -132,17 +167,26 @@ void loop(void) {
if (Serial.available() >= 1) { if (Serial.available() >= 1) {
uint8_t cmd = Serial.read(); uint8_t cmd = Serial.read();
if (cmd == CmdRequestID) { switch (cmd) {
Serial2.println("Got identification request!"); case CmdRequestID:
// gearText.Update("Connecting"); Serial2.println("Got identification request!");
// gearText.Update("Connecting");
IdentificationPacket papers; IdentificationPacket papers;
initIdentificationPacket(&papers, ESLABS_DEVICE_NAME, ESLABS_DEVICE_ID); initIdentificationPacket(&papers, ESLABS_DEVICE_NAME, ESLABS_DEVICE_ID);
sendIdentificationPacket(&papers); sendIdentificationPacket(&papers);
} else if (cmd == CmdAckID) { break;
Serial2.println("Got ack!"); case CmdAckID:
// gearText.Update("Connected"); Serial2.println("Got ack!");
gotAck = true;; // gearText.Update("Connected");
gotAck = true;;
break;
case NewWindow:
Serial2.println("Received request to create window");
break;
case DestroyWindow:
Serial2.println("Received request to destroy window");
break;
} }
} }