Fixed teh window create method
This commit is contained in:
+8
-39
@@ -19,10 +19,10 @@ to have more ways to run analytics
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "values.h"
|
#include "values.h"
|
||||||
#include "windowPool.h"
|
#include "windowPool.h"
|
||||||
|
#include "methods/methods.h"
|
||||||
// #include "UIDrawing.h"
|
// #include "UIDrawing.h"
|
||||||
#include "UIString.h"
|
#include "UIString.h"
|
||||||
// #include "UITable.h"
|
// #include "UITable.h"
|
||||||
// #include "data.h"
|
|
||||||
#include "displaySetup.h"
|
#include "displaySetup.h"
|
||||||
#include "esp32-hal-psram.h"
|
#include "esp32-hal-psram.h"
|
||||||
// #include "ui.h"
|
// #include "ui.h"
|
||||||
@@ -156,24 +156,6 @@ uint64_t lastDataRead = 0;
|
|||||||
|
|
||||||
bool gotAck = false;
|
bool gotAck = false;
|
||||||
|
|
||||||
struct UICreateWindowPacket {
|
|
||||||
uint16_t x0;
|
|
||||||
uint16_t y0;
|
|
||||||
uint16_t width;
|
|
||||||
uint16_t height;
|
|
||||||
char title[32]; // Note: we optimize this type of data transfer if necessary
|
|
||||||
// we are sending 32 - len(title) extra bytes everytime
|
|
||||||
};
|
|
||||||
|
|
||||||
void printUIWindowPacket(UICreateWindowPacket *win) {
|
|
||||||
LOG_INFO(F("New window:\n"));
|
|
||||||
LOG_INFO(F(" X0 : %d\n"), win->x0);
|
|
||||||
LOG_INFO(F(" Y0 : %d\n"), win->y0);
|
|
||||||
LOG_INFO(F(" Width : %d\n"), win->width);
|
|
||||||
LOG_INFO(F(" Height: %d\n"), win->height);
|
|
||||||
LOG_INFO(F(" Title : %s\n"), win->title);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t lastSent = 0;
|
uint64_t lastSent = 0;
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
uint64_t cur = millis();
|
uint64_t cur = millis();
|
||||||
@@ -201,29 +183,16 @@ void loop(void) {
|
|||||||
WalkieTalkie::SendData(&papers);
|
WalkieTalkie::SendData(&papers);
|
||||||
break;
|
break;
|
||||||
case CmdCreateWindow: {
|
case CmdCreateWindow: {
|
||||||
// Here we parse the payload a a UIWindowPacket
|
uint8_t newWindowID = CreateWindow::Create(payload, &mainScreen);
|
||||||
UICreateWindowPacket win;
|
if (newWindowID < 0) {
|
||||||
memcpy(&win, payload, sizeof(UICreateWindowPacket));
|
|
||||||
printUIWindowPacket(&win);
|
|
||||||
|
|
||||||
UIElement *mainWindow = mainScreen.mainWindowHandle;
|
|
||||||
|
|
||||||
int16_t childID = mainWindow->AddChild(STRING);
|
|
||||||
if (childID < 0) {
|
|
||||||
LOG_WARN(F("Failed to add new window!\n"));
|
LOG_WARN(F("Failed to add new window!\n"));
|
||||||
} else {
|
break;
|
||||||
LOG_INFO(F("Successfully added a new window: %d\n"), childID);
|
|
||||||
|
|
||||||
UIElement *childComponent = mainWindow->GetChild(childID);
|
|
||||||
|
|
||||||
childComponent->SetTitle((char *)"%s [%2d]", (const char *)win.title, childID);
|
|
||||||
childComponent->SetUIDecorations(UIDecorations());
|
|
||||||
childComponent->SetUIDimensions(UIDimensions(20, 20, 300, 300));
|
|
||||||
childComponent->SetDisplay(mainScreen.display);
|
|
||||||
|
|
||||||
childComponent->drawBox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO(F("Successfully added a new window: %d\n"), newWindowID);
|
||||||
|
|
||||||
|
// Now we return the ID of this new window - esdi should expect it
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#include "methods.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "UIComponent.h"
|
||||||
|
#include "UIScreen.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace CreateWindow {
|
||||||
|
void printUIWindowPacket(UICreateWindowPacket *win) {
|
||||||
|
LOG_INFO(F("New window:\n"));
|
||||||
|
LOG_INFO(F(" X0 : %d\n"), win->x0);
|
||||||
|
LOG_INFO(F(" Y0 : %d\n"), win->y0);
|
||||||
|
LOG_INFO(F(" Width : %d\n"), win->width);
|
||||||
|
LOG_INFO(F(" Height: %d\n"), win->height);
|
||||||
|
LOG_INFO(F(" Title : %s\n"), win->title);
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t Create(uint8_t *payload, Curses::Screen *mainScreen) {
|
||||||
|
// Load the payload into a struct
|
||||||
|
CreateWindow::UICreateWindowPacket win;
|
||||||
|
memcpy(&win, payload, sizeof(CreateWindow::UICreateWindowPacket));
|
||||||
|
printUIWindowPacket(&win);
|
||||||
|
|
||||||
|
UIElement *mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
int16_t childID = mainWindow->AddChild(STRING);
|
||||||
|
if (childID < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIElement *childComponent = mainWindow->GetChild(childID);
|
||||||
|
|
||||||
|
childComponent->SetTitle((char *)"%s [%2d]", (const char *)win.title, childID);
|
||||||
|
childComponent->SetUIDecorations(UIDecorations());
|
||||||
|
childComponent->SetUIDimensions(UIDimensions(win.x0, win.y0, win.width, win.height));
|
||||||
|
childComponent->SetDisplay(mainScreen->display);
|
||||||
|
|
||||||
|
childComponent->drawBox();
|
||||||
|
|
||||||
|
return childID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace DestroyWindow {
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef __METHODS__
|
||||||
|
#define __METHODS__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "UIScreen.h"
|
||||||
|
|
||||||
|
namespace CreateWindow {
|
||||||
|
struct UICreateWindowPacket {
|
||||||
|
uint16_t x0;
|
||||||
|
uint16_t y0;
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
char title[32]; // Note: we optimize this type of data transfer if necessary
|
||||||
|
// we are sending 32 - len(title) extra bytes everytime
|
||||||
|
};
|
||||||
|
|
||||||
|
void printUIWindowPacket(UICreateWindowPacket *win);
|
||||||
|
int8_t Create(uint8_t *payload, Curses::Screen *mainScreen);
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace DestroyWindow {
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+26
-27
@@ -1,27 +1,26 @@
|
|||||||
#include "ui.h"
|
// #include "ui.h"
|
||||||
#include "HardwareSerial.h"
|
// #include "HardwareSerial.h"
|
||||||
#include "data.h"
|
// #include <cstdint>
|
||||||
#include <cstdint>
|
//
|
||||||
|
// DashUI::DashUI() {}
|
||||||
DashUI::DashUI() {}
|
//
|
||||||
|
// void DashUI::Update(DataPacket *p) {
|
||||||
void DashUI::Update(DataPacket *p) {
|
// this->barTacho->Update(p->rpm);
|
||||||
this->barTacho->Update(p->rpm);
|
// this->digiTacho->Update(p->rpm);
|
||||||
this->digiTacho->Update(p->rpm);
|
// this->digiSpeedo->Update(p->speed);
|
||||||
this->digiSpeedo->Update(p->speed);
|
// this->digiGear->Update(p->gear);
|
||||||
this->digiGear->Update(p->gear);
|
// this->lapDelta->Update(p->DeltaToBestLap);
|
||||||
this->lapDelta->Update(p->DeltaToBestLap);
|
// this->bestLap->Update(p->bestLapTime);
|
||||||
this->bestLap->Update(p->bestLapTime);
|
// this->curLap->Update(p->currLapTime);
|
||||||
this->curLap->Update(p->currLapTime);
|
// this->lastLap->Update(p->lastLapTime);
|
||||||
this->lastLap->Update(p->lastLapTime);
|
// this->fuelConsumption->Update(p->FuelEst);
|
||||||
this->fuelConsumption->Update(p->FuelEst);
|
// this->brakeBias->Update(p->brakeBias);
|
||||||
this->brakeBias->Update(p->brakeBias);
|
//
|
||||||
|
// for (int row = 0; row < ROWS; row++) {
|
||||||
for (int row = 0; row < ROWS; row++) {
|
// this->relative->tableData[row * COLUMNS + 0]->Update(p->standings[row].Lap);
|
||||||
this->relative->tableData[row * COLUMNS + 0]->Update(p->standings[row].Lap);
|
// this->relative->tableData[row * COLUMNS + 1]->Update(
|
||||||
this->relative->tableData[row * COLUMNS + 1]->Update(
|
// p->standings[row].DriverName);
|
||||||
p->standings[row].DriverName);
|
// this->relative->tableData[row * COLUMNS + 2]->Update(
|
||||||
this->relative->tableData[row * COLUMNS + 2]->Update(
|
// p->standings[row].TimeBehindString);
|
||||||
p->standings[row].TimeBehindString);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
#ifndef __DASH_DISPLAY_UI
|
// #ifndef __DASH_DISPLAY_UI
|
||||||
#define __DASH_DISPLAY_UI
|
// #define __DASH_DISPLAY_UI
|
||||||
|
//
|
||||||
#include "Arduino_GFX.h"
|
// #include "Arduino_GFX.h"
|
||||||
#include "UIString.h"
|
// #include "UIString.h"
|
||||||
#include "UITable.h"
|
// #include "UITable.h"
|
||||||
#include "UIBar.h"
|
// #include "UIBar.h"
|
||||||
#include "data.h"
|
// #include "data.h"
|
||||||
|
//
|
||||||
struct DashUI {
|
// struct DashUI {
|
||||||
UIBar *barTacho;
|
// UIBar *barTacho;
|
||||||
UIString *digiTacho;
|
// UIString *digiTacho;
|
||||||
UIString *digiSpeedo;
|
// UIString *digiSpeedo;
|
||||||
UIString *digiGear;
|
// UIString *digiGear;
|
||||||
UIString *lapDelta;
|
// UIString *lapDelta;
|
||||||
UIString *bestLap;
|
// UIString *bestLap;
|
||||||
UIString *lastLap;
|
// UIString *lastLap;
|
||||||
UIString *curLap;
|
// UIString *curLap;
|
||||||
UIString *fuelTank;
|
// UIString *fuelTank;
|
||||||
UIString *fuelConsumption;
|
// UIString *fuelConsumption;
|
||||||
UIString *brakeBias;
|
// UIString *brakeBias;
|
||||||
UITable *relative;
|
// UITable *relative;
|
||||||
|
//
|
||||||
DashUI();
|
// DashUI();
|
||||||
void Update(DataPacket *p);
|
// void Update(DataPacket *p);
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
#endif
|
// #endif
|
||||||
|
|||||||
Reference in New Issue
Block a user