Continuing developing the new lib for the UI
This commit is contained in:
@@ -20,3 +20,5 @@ uploadfs:
|
|||||||
update:
|
update:
|
||||||
pio -f -c vim update
|
pio -f -c vim update
|
||||||
|
|
||||||
|
cleanESlabs:
|
||||||
|
rm -rf .pio/libdeps/esp32-s3-devkitc-1/eslabsCurses
|
||||||
|
|||||||
+45
-8
@@ -7,6 +7,10 @@ TODO:
|
|||||||
to have more ways to run analytics
|
to have more ways to run analytics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "UIComponent.h"
|
||||||
|
#include "UIScreen.h"
|
||||||
|
#include "UIDecorations.h"
|
||||||
|
#include "UIDimensions.h"
|
||||||
#include "communication/commands.h"
|
#include "communication/commands.h"
|
||||||
#include "communication/packets.h"
|
#include "communication/packets.h"
|
||||||
#include "communication/identificationPacket.h"
|
#include "communication/identificationPacket.h"
|
||||||
@@ -50,11 +54,23 @@ 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(
|
||||||
|
gfx,
|
||||||
|
UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES),
|
||||||
|
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(
|
||||||
|
gfx,
|
||||||
|
UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES),
|
||||||
|
gearTextDecor,
|
||||||
|
(char*)"MAIN WINDOW"
|
||||||
|
);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
psramInit();
|
psramInit();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@@ -69,12 +85,33 @@ void setup() {
|
|||||||
initialDisplaySetup(gfx);
|
initialDisplaySetup(gfx);
|
||||||
|
|
||||||
// Setup the gear text box
|
// Setup the gear text box
|
||||||
gearTextDecor->textSize = 7;
|
// gearTextDecor->textSize = 7;
|
||||||
gearText.dims.height =
|
// gearText.dims.height =
|
||||||
calculateHeight(gearTextDecor->titleSize, gearTextDecor->textSize, 1);
|
// calculateHeight(gearTextDecor->titleSize, gearTextDecor->textSize, 1);
|
||||||
gearText.dims.width = calculateWidth(gearTextDecor->textSize, 2);
|
// gearText.dims.width = calculateWidth(gearTextDecor->textSize, 2);
|
||||||
gearText.drawBox();
|
// gearText.drawBox();
|
||||||
gearText.Update("Disconnected");
|
// gearText.Update("Disconnected");
|
||||||
|
mainWindow.drawBox();
|
||||||
|
|
||||||
|
int16_t childID = mainWindow.AddChild();
|
||||||
|
if (!childID) {
|
||||||
|
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*)"Child Window", childID);
|
||||||
|
childComponent->decor = gearTextDecor;
|
||||||
|
childComponent->display = mainSreen.display;
|
||||||
|
childComponent->dims.x = 30;
|
||||||
|
childComponent->dims.y = 30;
|
||||||
|
childComponent->dims.width = 300;
|
||||||
|
childComponent->dims.height = 300;
|
||||||
|
|
||||||
|
childComponent->drawBox();
|
||||||
|
}
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial2.println("* Ready for loop");
|
Serial2.println("* Ready for loop");
|
||||||
@@ -97,14 +134,14 @@ void loop(void) {
|
|||||||
uint8_t cmd = Serial.read();
|
uint8_t cmd = Serial.read();
|
||||||
if (cmd == CmdRequestID) {
|
if (cmd == CmdRequestID) {
|
||||||
Serial2.println("Got identification request!");
|
Serial2.println("Got identification request!");
|
||||||
gearText.Update("Connecting");
|
// 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) {
|
} else if (cmd == CmdAckID) {
|
||||||
Serial2.println("Got ack!");
|
Serial2.println("Got ack!");
|
||||||
gearText.Update("Connected");
|
// gearText.Update("Connected");
|
||||||
gotAck = true;;
|
gotAck = true;;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user