More work on system page
This commit is contained in:
parent
322ae30858
commit
9d395c719a
|
@ -60,7 +60,7 @@ void initKeys(CommonData &commonData) {
|
|||
|
||||
#ifdef HARDWARE_V21
|
||||
// Keypad functions for original OBP60 hardware
|
||||
int readKeypad(uint thSensitivity) {
|
||||
int readKeypad(GwLog* logger, uint thSensitivity) {
|
||||
|
||||
// Touch sensor values
|
||||
// 35000 - Not touched
|
||||
|
@ -110,14 +110,14 @@ void initKeys(CommonData &commonData) {
|
|||
keypad[6] = 0;
|
||||
}
|
||||
// Nothing touched
|
||||
if(keypad[1] == 0 && keypad[2] == 0 && keypad[3] == 0 && keypad[4] == 0 && keypad[5] == 0 && keypad[6] == 0){
|
||||
/* if(keypad[1] == 0 && keypad[2] == 0 && keypad[3] == 0 && keypad[4] == 0 && keypad[5] == 0 && keypad[6] == 0){
|
||||
keypad[0] = 1;
|
||||
}
|
||||
else{
|
||||
keypad[0] = 0;
|
||||
}
|
||||
} */
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
if(i > 0){
|
||||
// Convert keypad to keycode
|
||||
if(keypad[i] == 1){
|
||||
|
@ -141,15 +141,17 @@ void initKeys(CommonData &commonData) {
|
|||
}
|
||||
// Detect a very short keynumber (10ms)
|
||||
if (millis() > starttime + 10 && keycode == keycodeold && keylock == true) {
|
||||
logger->logDebug(GwLog::LOG,"Very short 20ms key touch: %d", keycode);
|
||||
|
||||
// Process only valid keys
|
||||
if(keycode == 1 || keycode == 6){
|
||||
//if(keycode == 1 || keycode == 6){
|
||||
keycode2 = keycode;
|
||||
}
|
||||
// Clear by unvalid keys
|
||||
else{
|
||||
keycode2 = 0;
|
||||
keycodeold2 = 0;
|
||||
}
|
||||
//}
|
||||
// Clear by invalid keys
|
||||
//else{
|
||||
// keycode2 = 0;
|
||||
// keycodeold2 = 0;
|
||||
//}
|
||||
}
|
||||
// Timeout for very short pressed key
|
||||
if(millis() > starttime + 200){
|
||||
|
@ -157,6 +159,7 @@ void initKeys(CommonData &commonData) {
|
|||
}
|
||||
// Detect a short keynumber (200ms)
|
||||
if (keyoff == false && millis() > starttime + 200 && keycode == keycodeold && keylock == true) {
|
||||
logger->logDebug(GwLog::LOG,"Short 200ms key touch: %d", keycode);
|
||||
keystatus = keycode;
|
||||
keycode = 0;
|
||||
keycodeold = 0;
|
||||
|
@ -170,11 +173,17 @@ void initKeys(CommonData &commonData) {
|
|||
|
||||
// System page with key 5 and 4 in fast series
|
||||
if (keycode2 == 5 && keycodeold2 == 4) {
|
||||
logger->logDebug(GwLog::LOG,"Keycode for system page");
|
||||
keycode = 0;
|
||||
keycodeold = 0;
|
||||
keycode2 = 0;
|
||||
keycodeold2 = 0;
|
||||
keystatus = 12;
|
||||
buzzer(TONE4, 50);
|
||||
delay(30);
|
||||
buzzer(TONE4, 50);
|
||||
delay(30);
|
||||
buzzer(TONE4, 50);
|
||||
}
|
||||
|
||||
// Key lock with key 1 and 6 or 6 and 1 in fast series
|
||||
|
@ -252,7 +261,7 @@ void initKeys(CommonData &commonData) {
|
|||
}
|
||||
|
||||
// Keypad functions for OBP60 clone (thSensitivity is inactiv)
|
||||
int readKeypad(uint thSensitivity) {
|
||||
int readKeypad(GwLog* logger, uint thSensitivity) {
|
||||
pinMode(UP, INPUT);
|
||||
pinMode(DOWN, INPUT);
|
||||
pinMode(CONF, INPUT);
|
||||
|
|
|
@ -2,36 +2,74 @@
|
|||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
#include "images/logo64.xbm"
|
||||
#include <esp_clk.h>
|
||||
|
||||
/*
|
||||
* Special system page, called directly with fast key sequence 5,4
|
||||
* Out of normal page order.
|
||||
*/
|
||||
|
||||
class PageSystem : public Page{
|
||||
bool keylock = false;
|
||||
class PageSystem : public Page
|
||||
{
|
||||
uint64_t chipid;
|
||||
bool simulation;
|
||||
String env_sensor;
|
||||
String buzzer_mode;
|
||||
uint8_t buzzer_power;
|
||||
String cpuspeed;
|
||||
|
||||
public:
|
||||
char mode = 'N'; // (N)ormal, (D)evice list
|
||||
|
||||
public:
|
||||
PageSystem(CommonData &common){
|
||||
common.logger->logDebug(GwLog::LOG,"Show PageSystem");
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageSystem");
|
||||
chipid = ESP.getEfuseMac();
|
||||
simulation = common.config->getBool(common.config->useSimuData);
|
||||
env_sensor = common.config->getString(common.config->useEnvSensor);
|
||||
buzzer_mode = common.config->getString(common.config->buzzerMode);
|
||||
buzzer_power = common.config->getInt(common.config->buzzerPower);
|
||||
cpuspeed = common.config->getString(common.config->cpuSpeed);
|
||||
// useRTC off oder typ
|
||||
// useGPS off oder typ
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
commonData->keydata[0].label = "EXIT";
|
||||
commonData->keydata[1].label = "MODE";
|
||||
commonData->keydata[2].label = "";
|
||||
commonData->keydata[3].label = "";
|
||||
commonData->keydata[4].label = "STBY";
|
||||
commonData->keydata[5].label = "ILUM";
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
// do *NOT* handle key #1 this handled by obp60task as exit
|
||||
|
||||
// Switch display mode
|
||||
if (key == 2) {
|
||||
if (mode == 'N') {
|
||||
mode = 'D';
|
||||
} else {
|
||||
mode = 'N';
|
||||
}
|
||||
if (hasFRAM) fram.write(FRAM_VOLTAGE_MODE, mode);
|
||||
return 0;
|
||||
}
|
||||
// Code for keylock
|
||||
if (key == 11) {
|
||||
keylock = !keylock;
|
||||
commonData->keylock = !commonData->keylock;
|
||||
return 0;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(CommonData &commonData, PageData &pageData){
|
||||
GwConfigHandler *config = commonData.config;
|
||||
GwLog *logger=commonData.logger;
|
||||
virtual void displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Get config data
|
||||
String displaycolor = config->getString(config->displaycolor);
|
||||
String backlightMode = config->getString(config->backlight);
|
||||
String flashLED = config->getString(config->flashLED);
|
||||
|
||||
// Optical warning by limit violation (unused)
|
||||
|
@ -46,35 +84,59 @@ class PageSystem : public Page{
|
|||
// Draw page
|
||||
//***********************************************************
|
||||
|
||||
// Set colors
|
||||
int fgcolor = GxEPD_BLACK;
|
||||
int bgcolor = GxEPD_WHITE;
|
||||
if (displaycolor != "Normal") {
|
||||
fgcolor = GxEPD_WHITE;
|
||||
bgcolor = GxEPD_BLACK;
|
||||
}
|
||||
const uint16_t y0 = 120; // data table starts here
|
||||
|
||||
// Set display in partial refresh mode
|
||||
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
||||
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||
getdisplay().setCursor(20, 60);
|
||||
getdisplay().print("System Information and Settings");
|
||||
if (mode == 'N') {
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||
getdisplay().setCursor(20, 50);
|
||||
getdisplay().print("System Information");
|
||||
|
||||
// Key Layout
|
||||
getdisplay().setTextColor(fgcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
if (keylock == false) {
|
||||
getdisplay().setCursor(10, 290);
|
||||
getdisplay().print("[STBY]");
|
||||
if (String(backlightMode) == "Control by Key") {
|
||||
getdisplay().setCursor(343, 290);
|
||||
getdisplay().print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else {
|
||||
getdisplay().setCursor(130, 290);
|
||||
getdisplay().print(" [ Keylock active ]");
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
|
||||
char ssid[23];
|
||||
snprintf(ssid, 23, "MCUDEVICE-%04X%08X", (uint16_t)(chipid >> 32), (uint32_t)chipid);
|
||||
getdisplay().setCursor(20, 70);
|
||||
getdisplay().print(ssid);
|
||||
getdisplay().setCursor(20, 100);
|
||||
getdisplay().print("Press STBY for white page and standby");
|
||||
|
||||
getdisplay().setCursor(2, y0);
|
||||
getdisplay().print("Simulation:");
|
||||
getdisplay().setCursor(140, y0);
|
||||
getdisplay().print(simulation ? "on" : "off");
|
||||
|
||||
getdisplay().setCursor(202, y0);
|
||||
getdisplay().print("Wifi:");
|
||||
getdisplay().setCursor(340, y0);
|
||||
getdisplay().print("on");
|
||||
|
||||
getdisplay().setCursor(2, y0 + 16);
|
||||
getdisplay().print("Environment:");
|
||||
getdisplay().setCursor(140, y0 + 16);
|
||||
getdisplay().print(env_sensor);
|
||||
|
||||
getdisplay().setCursor(2, y0 + 32);
|
||||
getdisplay().print("Buzzer:");
|
||||
getdisplay().setCursor(140, y0 + 32);
|
||||
getdisplay().print(buzzer_mode);
|
||||
|
||||
getdisplay().setCursor(2, y0 + 48);
|
||||
getdisplay().print("CPU speed:");
|
||||
getdisplay().setCursor(140, y0 + 48);
|
||||
getdisplay().print(cpuspeed);
|
||||
getdisplay().print(" ");
|
||||
int cpu_freq = esp_clk_cpu_freq();
|
||||
getdisplay().print(String(cpu_freq));
|
||||
|
||||
getdisplay().drawXBitmap(320, 25, logo64_bits, logo64_width, logo64_height, commonData->fgcolor);
|
||||
} else {
|
||||
// NMEA2000 device list
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||
getdisplay().setCursor(20, 50);
|
||||
getdisplay().print("NMEA2000 device list");
|
||||
}
|
||||
|
||||
// Update display
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#define logo64_width 64
|
||||
#define logo64_height 64
|
||||
static unsigned char logo64_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xc1,
|
||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xc0, 0xc1, 0x7f, 0xf8, 0x01, 0xfe,
|
||||
0x00, 0x00, 0xc0, 0xc1, 0x1f, 0xe0, 0x01, 0xfc, 0x00, 0x00, 0xe0, 0xc1,
|
||||
0x0f, 0xc3, 0xf1, 0xf8, 0x00, 0x00, 0xf0, 0xc1, 0xc7, 0x8f, 0xf1, 0xf9,
|
||||
0x00, 0x00, 0xf8, 0xc1, 0xc7, 0x8f, 0xf1, 0xf9, 0x00, 0x00, 0xf8, 0xc1,
|
||||
0xe7, 0x9f, 0xf1, 0xf8, 0x00, 0x00, 0xfc, 0xc1, 0xe7, 0x9f, 0x01, 0xfc,
|
||||
0x00, 0x00, 0xfe, 0xc1, 0xe7, 0x9f, 0x01, 0xfe, 0x00, 0x00, 0xfe, 0xc1,
|
||||
0xc7, 0x8f, 0xf1, 0xff, 0x00, 0x00, 0xff, 0xc1, 0xc7, 0x8f, 0xf1, 0xff,
|
||||
0x00, 0x80, 0xff, 0xc1, 0x8f, 0xc7, 0xf1, 0xff, 0x00, 0x80, 0xff, 0xc1,
|
||||
0x1f, 0xe0, 0xf1, 0xff, 0x00, 0xc0, 0xff, 0xc1, 0x7f, 0xf8, 0xf1, 0xff,
|
||||
0x00, 0xe0, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xc1,
|
||||
0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0xf8, 0xff, 0xc1, 0x0f, 0xe0, 0xf8, 0xfc, 0x00, 0xfc, 0xff, 0xc1,
|
||||
0x0f, 0xe0, 0xf8, 0xfc, 0x00, 0xfc, 0xff, 0xc1, 0xcf, 0xff, 0xf0, 0xfc,
|
||||
0x00, 0xfe, 0xff, 0xc1, 0xcf, 0xff, 0xe0, 0xfc, 0x00, 0xff, 0xff, 0xc1,
|
||||
0xcf, 0xff, 0xe4, 0xfc, 0x00, 0xff, 0xff, 0xc1, 0x0f, 0xe0, 0xc4, 0xfc,
|
||||
0x80, 0xff, 0xff, 0xc1, 0x0f, 0xe0, 0xcc, 0xfc, 0xc0, 0xff, 0xff, 0xc1,
|
||||
0xcf, 0xff, 0x8c, 0xfc, 0xe0, 0xff, 0xff, 0xc1, 0xcf, 0xff, 0x9c, 0xfc,
|
||||
0xe0, 0xff, 0xff, 0xc1, 0xcf, 0xff, 0x1c, 0xfc, 0xf0, 0xff, 0xff, 0xc1,
|
||||
0xcf, 0xff, 0x3c, 0xfc, 0xf8, 0xff, 0xff, 0xc1, 0x0f, 0xe0, 0x7c, 0xfc,
|
||||
0xf8, 0xff, 0xff, 0xc1, 0x0f, 0xe0, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xc1,
|
||||
0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff,
|
||||
0xfe, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3c, 0x00, 0x00, 0x38, 0x00, 0x04, 0x00, 0x00, 0x44, 0x00, 0x10, 0x48,
|
||||
0x00, 0x00, 0x00, 0x01, 0x44, 0x86, 0x7b, 0x48, 0x67, 0xc4, 0xf0, 0x77,
|
||||
0x3c, 0x09, 0x12, 0x38, 0x91, 0x24, 0x09, 0x11, 0x44, 0xc9, 0x13, 0x08,
|
||||
0x91, 0xe4, 0x09, 0x61, 0x44, 0x49, 0x12, 0x08, 0x91, 0x24, 0x08, 0x41,
|
||||
0x3c, 0xc6, 0x73, 0x08, 0x61, 0xc4, 0x71, 0x77, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
@ -127,7 +127,7 @@ void keyboardTask(void *param){
|
|||
|
||||
// Loop for keyboard task
|
||||
while (true){
|
||||
keycode = readKeypad(data->sensitivity);
|
||||
keycode = readKeypad(data->logger, data->sensitivity);
|
||||
//send a key event
|
||||
if(keycode != 0){
|
||||
xQueueSend(data->queue, &keycode, 0);
|
||||
|
@ -471,6 +471,9 @@ void OBP60Task(GwApi *api){
|
|||
//####################################################################################
|
||||
|
||||
bool systemPage = false;
|
||||
//PageDescription *description = allPages.find("System");
|
||||
// PageStruct syspagestruct;
|
||||
Page *syspage = allPages.pages[0]->creator(commonData);
|
||||
while (true){
|
||||
delay(100); // Delay 100ms (loop time)
|
||||
|
||||
|
@ -519,11 +522,15 @@ void OBP60Task(GwApi *api){
|
|||
if (keyboardMessage == 12) {
|
||||
LOG_DEBUG(GwLog::LOG, "Calling system page");
|
||||
systemPage = true; // System page is out of band
|
||||
currentPage = allPages.pages[0]->creator(commonData);
|
||||
currentPage = syspage;
|
||||
syspage->setupKeys();
|
||||
}
|
||||
else {
|
||||
systemPage = false;
|
||||
currentPage = pages[pageNumber].page;
|
||||
if (systemPage && keyboardMessage == 1) {
|
||||
// exit system mode with exit key number 1
|
||||
systemPage = false;
|
||||
currentPage = pages[pageNumber].page;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPage) {
|
||||
|
@ -585,8 +592,7 @@ void OBP60Task(GwApi *api){
|
|||
}
|
||||
else{
|
||||
setBacklightLED(0, COLOR_BLUE); // Backlight LEDs off (blue without britghness)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -652,14 +658,14 @@ void OBP60Task(GwApi *api){
|
|||
}
|
||||
|
||||
// Call the particular page
|
||||
Page *currentPage;
|
||||
//Page *currentPage;
|
||||
if (systemPage) {
|
||||
currentPage = allPages.pages[0]->creator(commonData);
|
||||
displayFooter(commonData);
|
||||
PageData sysparams;
|
||||
currentPage->displayPage(commonData, sysparams);
|
||||
syspage->displayPage(sysparams);
|
||||
}
|
||||
else {
|
||||
currentPage = pages[pageNumber].page;
|
||||
Page *currentPage = pages[pageNumber].page;
|
||||
if (currentPage == NULL){
|
||||
LOG_DEBUG(GwLog::ERROR,"page number %d not found",pageNumber);
|
||||
// Error handling for missing page
|
||||
|
|
Loading…
Reference in New Issue