mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-03-28 18:06:37 +01:00
Compare commits
5 Commits
66e71acac3
...
e33f908187
| Author | SHA1 | Date | |
|---|---|---|---|
| e33f908187 | |||
|
|
065a9807d2 | ||
|
|
98c318f055 | ||
| 97fcebdcb7 | |||
| a6fd3ef599 |
@@ -835,7 +835,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
|
|||||||
result.cvalue = dplace;
|
result.cvalue = dplace;
|
||||||
}
|
}
|
||||||
//########################################################
|
//########################################################
|
||||||
else if (value->getFormat() == "formatXdr:A:D"){
|
else if ((value->getFormat() == "formatXdr:A:D") || ((value->getFormat() == "formatXdr:A:rd"))){
|
||||||
double angle = 0;
|
double angle = 0;
|
||||||
if (usesimudata == false) {
|
if (usesimudata == false) {
|
||||||
angle = value->value;
|
angle = value->value;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "images/logo64.xbm"
|
#include "images/logo64.xbm"
|
||||||
#include <esp32/clk.h>
|
#include <esp32/clk.h>
|
||||||
#include "qrcode.h"
|
#include "qrcode.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifdef BOARD_OBP40S3
|
#ifdef BOARD_OBP40S3
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
@@ -37,9 +38,11 @@ private:
|
|||||||
String buzzer_mode;
|
String buzzer_mode;
|
||||||
uint8_t buzzer_power;
|
uint8_t buzzer_power;
|
||||||
String cpuspeed;
|
String cpuspeed;
|
||||||
|
String powermode;
|
||||||
String rtc_module;
|
String rtc_module;
|
||||||
String gps_module;
|
String gps_module;
|
||||||
String env_module;
|
String env_module;
|
||||||
|
String flashLED;
|
||||||
|
|
||||||
String batt_sensor;
|
String batt_sensor;
|
||||||
String solar_sensor;
|
String solar_sensor;
|
||||||
@@ -48,15 +51,445 @@ private:
|
|||||||
double homelat;
|
double homelat;
|
||||||
double homelon;
|
double homelon;
|
||||||
|
|
||||||
char mode = 'N'; // (N)ormal, (S)ettings, (D)evice list, (C)ard
|
char mode = 'N'; // (N)ormal, (S)ettings, (C)onfiguration, (D)evice list, c(A)rd
|
||||||
|
|
||||||
|
#ifdef PATCH_N2K
|
||||||
|
struct device {
|
||||||
|
uint64_t NAME;
|
||||||
|
uint8_t id;
|
||||||
|
char hex_name[17];
|
||||||
|
uint16_t manuf_code;
|
||||||
|
const char *model;
|
||||||
|
};
|
||||||
|
std::vector<device> devicelist;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void incMode() {
|
||||||
|
if (mode == 'N') { // Normal
|
||||||
|
mode = 'S';
|
||||||
|
} else if (mode == 'S') { // Settings
|
||||||
|
mode = 'C';
|
||||||
|
} else if (mode == 'C') { // Config
|
||||||
|
mode = 'D';
|
||||||
|
} else if (mode == 'D') { // Device list
|
||||||
|
if (use_sdcard) {
|
||||||
|
mode = 'A'; // SD-Card
|
||||||
|
} else {
|
||||||
|
mode = 'N';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mode = 'N';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void decMode() {
|
||||||
|
if (mode == 'N') {
|
||||||
|
if (use_sdcard) {
|
||||||
|
mode = 'A'; // SD-Card
|
||||||
|
} else {
|
||||||
|
mode = 'D'; // Device list
|
||||||
|
}
|
||||||
|
} else if (mode == 'S') { // Settings
|
||||||
|
mode = 'N';
|
||||||
|
} else if (mode == 'C') { // Config
|
||||||
|
mode = 'S';
|
||||||
|
} else if (mode == 'D') { // Device list
|
||||||
|
mode = 'C';
|
||||||
|
} else {
|
||||||
|
mode = 'D';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayModeNormal() {
|
||||||
|
// Default system page view
|
||||||
|
|
||||||
|
uint16_t y0 = 155;
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
getdisplay().setCursor(8, 48);
|
||||||
|
getdisplay().print("System Information");
|
||||||
|
|
||||||
|
getdisplay().drawXBitmap(320, 25, logo64_bits, logo64_width, logo64_height, commonData->fgcolor);
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
|
||||||
|
char ssid[13];
|
||||||
|
snprintf(ssid, 13, "%04X%08X", (uint16_t)(chipid >> 32), (uint32_t)chipid);
|
||||||
|
displayBarcode(String(ssid), 320, 200, 2);
|
||||||
|
getdisplay().setCursor(8, 70);
|
||||||
|
getdisplay().print(String("MCUDEVICE-") + String(ssid));
|
||||||
|
|
||||||
|
getdisplay().setCursor(8, 95);
|
||||||
|
getdisplay().print("Firmware version: ");
|
||||||
|
getdisplay().setCursor(150, 95);
|
||||||
|
getdisplay().print(VERSINFO);
|
||||||
|
|
||||||
|
getdisplay().setCursor(8, 113);
|
||||||
|
getdisplay().print("Board version: ");
|
||||||
|
getdisplay().setCursor(150, 113);
|
||||||
|
getdisplay().print(BOARDINFO);
|
||||||
|
getdisplay().print(String(" HW ") + String(PCBINFO));
|
||||||
|
|
||||||
|
getdisplay().setCursor(8, 131);
|
||||||
|
getdisplay().print("Display version: ");
|
||||||
|
getdisplay().setCursor(150, 131);
|
||||||
|
getdisplay().print(DISPLAYINFO);
|
||||||
|
getdisplay().print("; GxEPD2 v");
|
||||||
|
getdisplay().print(GXEPD2INFO);
|
||||||
|
|
||||||
|
getdisplay().setCursor(8, 265);
|
||||||
|
#ifdef BOARD_OBP60S3
|
||||||
|
getdisplay().print("Press STBY to enter deep sleep mode");
|
||||||
|
#endif
|
||||||
|
#ifdef BOARD_OBP40S3
|
||||||
|
getdisplay().print("Press wheel to enter deep sleep mode");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Flash memory size
|
||||||
|
uint32_t flash_size = ESP.getFlashChipSize();
|
||||||
|
getdisplay().setCursor(8, y0);
|
||||||
|
getdisplay().print("FLASH:");
|
||||||
|
getdisplay().setCursor(90, y0);
|
||||||
|
getdisplay().print(String(flash_size / 1024) + String(" kB"));
|
||||||
|
|
||||||
|
// PSRAM memory size
|
||||||
|
uint32_t psram_size = ESP.getPsramSize();
|
||||||
|
getdisplay().setCursor(8, y0 + 16);
|
||||||
|
getdisplay().print("PSRAM:");
|
||||||
|
getdisplay().setCursor(90, y0 + 16);
|
||||||
|
getdisplay().print(String(psram_size / 1024) + String(" kB"));
|
||||||
|
|
||||||
|
// FRAM available / status
|
||||||
|
getdisplay().setCursor(8, y0 + 32);
|
||||||
|
getdisplay().print("FRAM:");
|
||||||
|
getdisplay().setCursor(90, y0 + 32);
|
||||||
|
getdisplay().print(hasFRAM ? "available" : "not found");
|
||||||
|
|
||||||
|
#ifdef BOARD_OBP40S3
|
||||||
|
// SD-Card
|
||||||
|
getdisplay().setCursor(8, y0 + 48);
|
||||||
|
getdisplay().print("SD-Card:");
|
||||||
|
getdisplay().setCursor(90, y0 + 48);
|
||||||
|
if (hasSDCard) {
|
||||||
|
uint64_t cardsize = ((uint64_t) sdcard->csd.capacity) * sdcard->csd.sector_size / (1024 * 1024);
|
||||||
|
getdisplay().printf("%llu MB", cardsize);
|
||||||
|
} else {
|
||||||
|
getdisplay().print("off");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Uptime
|
||||||
|
int64_t uptime = esp_timer_get_time() / 1000000;
|
||||||
|
String uptime_unit;
|
||||||
|
if (uptime < 120) {
|
||||||
|
uptime_unit = " seconds";
|
||||||
|
} else {
|
||||||
|
if (uptime < 2 * 3600) {
|
||||||
|
uptime /= 60;
|
||||||
|
uptime_unit = " minutes";
|
||||||
|
} else if (uptime < 2 * 3600 * 24) {
|
||||||
|
uptime /= 3600;
|
||||||
|
uptime_unit = " hours";
|
||||||
|
} else {
|
||||||
|
uptime /= 86400;
|
||||||
|
uptime_unit = " days";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getdisplay().setCursor(8, y0 + 80);
|
||||||
|
getdisplay().print("Uptime:");
|
||||||
|
getdisplay().setCursor(90, y0 + 80);
|
||||||
|
getdisplay().print(uptime);
|
||||||
|
getdisplay().print(uptime_unit);
|
||||||
|
|
||||||
|
// CPU speed config / active
|
||||||
|
getdisplay().setCursor(202, y0);
|
||||||
|
getdisplay().print("CPU speed:");
|
||||||
|
getdisplay().setCursor(300, y0);
|
||||||
|
getdisplay().print(cpuspeed);
|
||||||
|
getdisplay().print(" / ");
|
||||||
|
int cpu_freq = esp_clk_cpu_freq() / 1000000;
|
||||||
|
getdisplay().print(String(cpu_freq));
|
||||||
|
|
||||||
|
// total RAM free
|
||||||
|
int Heap_free = esp_get_free_heap_size();
|
||||||
|
getdisplay().setCursor(202, y0 + 16);
|
||||||
|
getdisplay().print("Total free:");
|
||||||
|
getdisplay().setCursor(300, y0 + 16);
|
||||||
|
getdisplay().print(String(Heap_free));
|
||||||
|
|
||||||
|
// RAM free for task
|
||||||
|
int RAM_free = uxTaskGetStackHighWaterMark(NULL);
|
||||||
|
getdisplay().setCursor(202, y0 + 32);
|
||||||
|
getdisplay().print("Task free:");
|
||||||
|
getdisplay().setCursor(300, y0 + 32);
|
||||||
|
getdisplay().print(String(RAM_free));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayModeConfig() {
|
||||||
|
// Configuration interface
|
||||||
|
|
||||||
|
uint16_t x0 = 16;
|
||||||
|
uint16_t y0 = 80;
|
||||||
|
uint16_t dy = 20;
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
getdisplay().setCursor(8, 48);
|
||||||
|
getdisplay().print("System configuration");
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
|
||||||
|
getdisplay().setCursor(x0, y0);
|
||||||
|
getdisplay().print("CPU speed: 80 | 160 | 240");
|
||||||
|
getdisplay().setCursor(x0, y0 + 1 * dy);
|
||||||
|
getdisplay().print("Power mode: Max | 5V | Min");
|
||||||
|
getdisplay().setCursor(x0, y0 + 2 * dy);
|
||||||
|
getdisplay().print("Accesspoint: On | Off");
|
||||||
|
|
||||||
|
// TODO Change NVRAM-preferences settings here
|
||||||
|
getdisplay().setCursor(x0, y0 + 4 * dy);
|
||||||
|
getdisplay().print("Simulation: On | Off");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayModeSettings() {
|
||||||
|
// View some of the current settings
|
||||||
|
|
||||||
|
const uint16_t x0 = 8;
|
||||||
|
const uint16_t y0 = 72;
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
getdisplay().setCursor(x0, 48);
|
||||||
|
getdisplay().print("System settings");
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
|
||||||
|
// left column
|
||||||
|
getdisplay().setCursor(x0, y0);
|
||||||
|
getdisplay().print("Simulation:");
|
||||||
|
getdisplay().setCursor(120, y0);
|
||||||
|
getdisplay().print(simulation ? "on" : "off");
|
||||||
|
|
||||||
|
getdisplay().setCursor(x0, y0 + 16);
|
||||||
|
getdisplay().print("Environment:");
|
||||||
|
getdisplay().setCursor(120, y0 + 16);
|
||||||
|
getdisplay().print(env_module);
|
||||||
|
|
||||||
|
getdisplay().setCursor(x0, y0 + 32);
|
||||||
|
getdisplay().print("Buzzer:");
|
||||||
|
getdisplay().setCursor(120, y0 + 32);
|
||||||
|
getdisplay().print(buzzer_mode);
|
||||||
|
|
||||||
|
getdisplay().setCursor(x0, y0 + 64);
|
||||||
|
getdisplay().print("GPS:");
|
||||||
|
getdisplay().setCursor(120, y0 + 64);
|
||||||
|
getdisplay().print(gps_module);
|
||||||
|
|
||||||
|
getdisplay().setCursor(x0, y0 + 80);
|
||||||
|
getdisplay().print("RTC:");
|
||||||
|
getdisplay().setCursor(120, y0 + 80);
|
||||||
|
getdisplay().print(rtc_module);
|
||||||
|
|
||||||
|
getdisplay().setCursor(x0, y0 + 96);
|
||||||
|
getdisplay().print("Wifi:");
|
||||||
|
getdisplay().setCursor(120, y0 + 96);
|
||||||
|
getdisplay().print(commonData->status.wifiApOn ? "on" : "off");
|
||||||
|
|
||||||
|
// Home location
|
||||||
|
getdisplay().setCursor(x0, y0 + 128);
|
||||||
|
getdisplay().print("Home Lat.:");
|
||||||
|
getdisplay().setCursor(120, y0 + 128);
|
||||||
|
getdisplay().print(formatLatitude(homelat));
|
||||||
|
getdisplay().setCursor(x0, y0 + 144);
|
||||||
|
getdisplay().print("Home Lon.:");
|
||||||
|
getdisplay().setCursor(120, y0 + 144);
|
||||||
|
getdisplay().print(formatLongitude(homelon));
|
||||||
|
|
||||||
|
// Power
|
||||||
|
getdisplay().setCursor(x0, y0 + 176);
|
||||||
|
getdisplay().print("Power mode:");
|
||||||
|
getdisplay().setCursor(120, y0 + 176);
|
||||||
|
getdisplay().print(powermode);
|
||||||
|
|
||||||
|
// right column
|
||||||
|
getdisplay().setCursor(202, y0);
|
||||||
|
getdisplay().print("Batt. sensor:");
|
||||||
|
getdisplay().setCursor(320, y0);
|
||||||
|
getdisplay().print(batt_sensor);
|
||||||
|
|
||||||
|
// Solar sensor
|
||||||
|
getdisplay().setCursor(202, y0 + 16);
|
||||||
|
getdisplay().print("Solar sensor:");
|
||||||
|
getdisplay().setCursor(320, y0 + 16);
|
||||||
|
getdisplay().print(solar_sensor);
|
||||||
|
|
||||||
|
// Generator sensor
|
||||||
|
getdisplay().setCursor(202, y0 + 32);
|
||||||
|
getdisplay().print("Gen. sensor:");
|
||||||
|
getdisplay().setCursor(320, y0 + 32);
|
||||||
|
getdisplay().print(gen_sensor);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// Gyro sensor (rotation)
|
||||||
|
getdisplay().setCursor(202, y0 + 48);
|
||||||
|
getdisplay().print("Rot. sensor:");
|
||||||
|
getdisplay().setCursor(320, y0 + 48);
|
||||||
|
getdisplay().print(rot_sensor);
|
||||||
|
|
||||||
|
// Temp.-sensor
|
||||||
|
// Power Mode
|
||||||
|
|
||||||
|
#ifdef BOARD_OBP60S3
|
||||||
|
// Backlight infos
|
||||||
|
getdisplay().setCursor(202, y0 + 64);
|
||||||
|
getdisplay().print("Backlight:");
|
||||||
|
getdisplay().setCursor(320, y0 + 64);
|
||||||
|
getdisplay().printf("%d%%", commonData->backlight.brightness);
|
||||||
|
// TODO test function with OBP60 device
|
||||||
|
getdisplay().setCursor(202, y0 + 80);
|
||||||
|
getdisplay().print("Bl color:");
|
||||||
|
getdisplay().setCursor(320, y0 + 80);
|
||||||
|
getdisplay().print(commonData->backlight.color.toName());
|
||||||
|
getdisplay().setCursor(202, y0 + 96);
|
||||||
|
getdisplay().print("Bl mode:");
|
||||||
|
getdisplay().setCursor(320, y0 + 96);
|
||||||
|
getdisplay().print(commonData->backlight.mode);
|
||||||
|
// TODO Buzzer mode and power
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayModeSDCard() {
|
||||||
|
|
||||||
|
// SD Card info
|
||||||
|
uint16_t x0 = 20;
|
||||||
|
uint16_t y0 = 72;
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
getdisplay().setCursor(8, 48);
|
||||||
|
getdisplay().print("SD Card info");
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
getdisplay().setCursor(x0, y0);
|
||||||
|
#ifdef BOARD_OBP60S3
|
||||||
|
// This mode should not be callable by devices without card hardware
|
||||||
|
// In case of accidential reaching this, display a friendly message
|
||||||
|
getdisplay().print("This mode is not indended to be reached!\n");
|
||||||
|
getdisplay().print("There's nothing to see here. Move on.");
|
||||||
|
#endif
|
||||||
|
#ifdef BOARD_OBP40S3
|
||||||
|
getdisplay().print("Work in progress...");
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
this code should go somewhere else. only for testing purposes here
|
||||||
|
identify card as OBP-Card:
|
||||||
|
magic.dat
|
||||||
|
version.dat
|
||||||
|
readme.txt
|
||||||
|
IMAGES/
|
||||||
|
CHARTS/
|
||||||
|
LOGS/
|
||||||
|
DATA/
|
||||||
|
hint: file access with fopen, fgets, fread, fclose
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Simple test for magic file in root
|
||||||
|
getdisplay().setCursor(x0, y0 + 32);
|
||||||
|
String file_magic = MOUNT_POINT "/magic.dat";
|
||||||
|
commonData->logger->logDebug(GwLog::LOG, "Test magicfile: %s", file_magic.c_str());
|
||||||
|
struct stat st;
|
||||||
|
if (stat(file_magic.c_str(), &st) == 0) {
|
||||||
|
getdisplay().printf("File %s exists", file_magic.c_str());
|
||||||
|
} else {
|
||||||
|
getdisplay().printf("File %s not found", file_magic.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Root directory check
|
||||||
|
DIR* dir = opendir(MOUNT_POINT);
|
||||||
|
int dy = 0;
|
||||||
|
if (dir != NULL) {
|
||||||
|
commonData->logger->logDebug(GwLog::LOG, "Root directory: %s", MOUNT_POINT);
|
||||||
|
struct dirent* entry;
|
||||||
|
while (((entry = readdir(dir)) != NULL) and (dy < 140)) {
|
||||||
|
getdisplay().setCursor(x0, y0 + 64 + dy);
|
||||||
|
getdisplay().print(entry->d_name);
|
||||||
|
// type 1 is file, type 2 is dir
|
||||||
|
if (entry->d_type == 2) {
|
||||||
|
getdisplay().print("/");
|
||||||
|
}
|
||||||
|
dy += 20;
|
||||||
|
commonData->logger->logDebug(GwLog::DEBUG, " %s type %d", entry->d_name, entry->d_type);
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
} else {
|
||||||
|
commonData->logger->logDebug(GwLog::LOG, "Failed to open root directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayModeDevicelist() {
|
||||||
|
// NMEA2000 device list
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
getdisplay().setCursor(8, 48);
|
||||||
|
getdisplay().print("NMEA2000 device list");
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
getdisplay().setCursor(20, 70);
|
||||||
|
getdisplay().print("RxD: ");
|
||||||
|
getdisplay().print(String(commonData->status.n2kRx));
|
||||||
|
getdisplay().setCursor(120, 70);
|
||||||
|
getdisplay().print("TxD: ");
|
||||||
|
getdisplay().print(String(commonData->status.n2kTx));
|
||||||
|
|
||||||
|
#ifdef PATCH_N2K
|
||||||
|
uint16_t x0 = 20;
|
||||||
|
uint16_t y0 = 100;
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold10pt8b);
|
||||||
|
getdisplay().setCursor(x0, y0);
|
||||||
|
getdisplay().print("ID");
|
||||||
|
getdisplay().setCursor(x0 + 50, y0);
|
||||||
|
getdisplay().print("Model");
|
||||||
|
getdisplay().setCursor(x0 + 250, y0);
|
||||||
|
getdisplay().print("Manuf.");
|
||||||
|
getdisplay().drawLine(18, y0 + 4, 360 , y0 + 4 , commonData->fgcolor);
|
||||||
|
|
||||||
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
y0 = 120;
|
||||||
|
uint8_t n_dev = 0;
|
||||||
|
for (const device& item : devicelist) {
|
||||||
|
if (n_dev > 8) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
getdisplay().setCursor(x0, y0 + n_dev * 20);
|
||||||
|
getdisplay().print(item.id);
|
||||||
|
getdisplay().setCursor(x0 + 50, y0 + n_dev * 20);
|
||||||
|
getdisplay().print(item.model);
|
||||||
|
getdisplay().setCursor(x0 + 250, y0 + n_dev * 20);
|
||||||
|
getdisplay().print(item.manuf_code);
|
||||||
|
n_dev++;
|
||||||
|
}
|
||||||
|
getdisplay().setCursor(x0, y0 + (n_dev + 1) * 20);
|
||||||
|
if (n_dev == 0) {
|
||||||
|
getdisplay().printf("no devices found on bus");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
getdisplay().drawLine(18, y0 + n_dev * 20, 360 , y0 + n_dev * 20, commonData->fgcolor);
|
||||||
|
getdisplay().printf("%d devices of %d in total", n_dev, devicelist.size());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
getdisplay().setCursor(20, 100);
|
||||||
|
getdisplay().print("NMEA2000 not exposed to obp60 task");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageSystem(CommonData &common){
|
PageSystem(CommonData &common){
|
||||||
commonData = &common;
|
commonData = &common;
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageSystem");
|
commonData->logger->logDebug(GwLog::LOG,"Instantiate PageSystem");
|
||||||
if (hasFRAM) {
|
if (hasFRAM) {
|
||||||
mode = fram.read(FRAM_SYSTEM_MODE);
|
mode = fram.read(FRAM_SYSTEM_MODE);
|
||||||
common.logger->logDebug(GwLog::DEBUG, "Loaded mode '%c' from FRAM", mode);
|
commonData->logger->logDebug(GwLog::DEBUG, "Loaded mode '%c' from FRAM", mode);
|
||||||
}
|
}
|
||||||
chipid = ESP.getEfuseMac();
|
chipid = ESP.getEfuseMac();
|
||||||
simulation = common.config->getBool(common.config->useSimuData);
|
simulation = common.config->getBool(common.config->useSimuData);
|
||||||
@@ -67,6 +500,7 @@ public:
|
|||||||
buzzer_mode.toLowerCase();
|
buzzer_mode.toLowerCase();
|
||||||
buzzer_power = common.config->getInt(common.config->buzzerPower);
|
buzzer_power = common.config->getInt(common.config->buzzerPower);
|
||||||
cpuspeed = common.config->getString(common.config->cpuSpeed);
|
cpuspeed = common.config->getString(common.config->cpuSpeed);
|
||||||
|
powermode = common.config->getString(common.config->powerMode);
|
||||||
env_module = common.config->getString(common.config->useEnvSensor);
|
env_module = common.config->getString(common.config->useEnvSensor);
|
||||||
rtc_module = common.config->getString(common.config->useRTC);
|
rtc_module = common.config->getString(common.config->useRTC);
|
||||||
gps_module = common.config->getString(common.config->useGPS);
|
gps_module = common.config->getString(common.config->useGPS);
|
||||||
@@ -76,6 +510,7 @@ public:
|
|||||||
rot_sensor = common.config->getString(common.config->useRotSensor);
|
rot_sensor = common.config->getString(common.config->useRotSensor);
|
||||||
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
||||||
homelon = common.config->getString(common.config->homeLON).toDouble();
|
homelon = common.config->getString(common.config->homeLON).toDouble();
|
||||||
|
flashLED = common.config->getString(common.config->flashLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupKeys() {
|
void setupKeys() {
|
||||||
@@ -92,19 +527,7 @@ public:
|
|||||||
// Switch display mode
|
// Switch display mode
|
||||||
commonData->logger->logDebug(GwLog::LOG, "System keyboard handler");
|
commonData->logger->logDebug(GwLog::LOG, "System keyboard handler");
|
||||||
if (key == 2) {
|
if (key == 2) {
|
||||||
if (mode == 'N') {
|
incMode();
|
||||||
mode = 'S';
|
|
||||||
} else if (mode == 'S') {
|
|
||||||
mode = 'D';
|
|
||||||
} else if (mode == 'D') {
|
|
||||||
if (hasSDCard) {
|
|
||||||
mode = 'C';
|
|
||||||
} else {
|
|
||||||
mode = 'N';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mode = 'N';
|
|
||||||
}
|
|
||||||
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
|
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -129,8 +552,13 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef BOARD_OBP40S3
|
#ifdef BOARD_OBP40S3
|
||||||
// grab cursor keys to disable page navigation
|
// use cursor keys for local mode navigation
|
||||||
if (key == 9 or key == 10) {
|
if (key == 9) {
|
||||||
|
incMode();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (key == 10) {
|
||||||
|
decMode();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// standby / deep sleep
|
// standby / deep sleep
|
||||||
@@ -168,305 +596,64 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
void displayNew(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
#ifdef BOARD_OBP60S3
|
||||||
GwLog *logger = commonData->logger;
|
// Clear optical warning
|
||||||
|
if (flashLED == "Limit Violation") {
|
||||||
// Get config data
|
|
||||||
String flashLED = config->getString(config->flashLED);
|
|
||||||
|
|
||||||
// Optical warning by limit violation (unused)
|
|
||||||
if(String(flashLED) == "Limit Violation"){
|
|
||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
setFlashLED(false);
|
setFlashLED(false);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Logging boat values
|
#ifdef PATCH_N2K
|
||||||
logger->logDebug(GwLog::LOG, "Drawing at PageSystem, Mode=%c", mode);
|
// load current device list
|
||||||
|
tN2kDeviceList *pDevList = pageData.api->getN2kDeviceList();
|
||||||
|
// TODO check if changed
|
||||||
|
if (pDevList->ReadResetIsListUpdated()) {
|
||||||
|
// only reload if changed
|
||||||
|
devicelist.clear();
|
||||||
|
for (uint8_t i = 0; i <= 252; i++) {
|
||||||
|
const tNMEA2000::tDevice *d = pDevList->FindDeviceBySource(i);
|
||||||
|
if (d == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
device dev;
|
||||||
|
dev.id = i;
|
||||||
|
dev.NAME = d->GetName();
|
||||||
|
snprintf(dev.hex_name, sizeof(dev.hex_name), "%08X%08X", (uint32_t)(dev.NAME >> 32), (uint32_t)(dev.NAME & 0xFFFFFFFF));
|
||||||
|
dev.manuf_code = d->GetManufacturerCode();
|
||||||
|
dev.model = d->GetModelID();
|
||||||
|
devicelist.push_back(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
// Draw page
|
int displayPage(PageData &pageData){
|
||||||
//***********************************************************
|
|
||||||
|
|
||||||
uint16_t x0 = 8; // left column
|
// Logging page information
|
||||||
uint16_t y0 = 48; // data table starts here
|
commonData->logger->logDebug(GwLog::LOG, "Drawing at PageSystem, Mode=%c", mode);
|
||||||
|
|
||||||
// Set display in partial refresh mode
|
// Set display in partial refresh mode
|
||||||
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
||||||
|
|
||||||
if (mode == 'N') {
|
// call current system page
|
||||||
|
switch (mode) {
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
case 'N':
|
||||||
getdisplay().setCursor(8, 48);
|
displayModeNormal();
|
||||||
getdisplay().print("System Information");
|
break;
|
||||||
|
case 'S':
|
||||||
getdisplay().drawXBitmap(320, 25, logo64_bits, logo64_width, logo64_height, commonData->fgcolor);
|
displayModeSettings();
|
||||||
|
break;
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
case 'C':
|
||||||
y0 = 155;
|
displayModeConfig();
|
||||||
|
break;
|
||||||
char ssid[13];
|
case 'A':
|
||||||
snprintf(ssid, 13, "%04X%08X", (uint16_t)(chipid >> 32), (uint32_t)chipid);
|
displayModeSDCard();
|
||||||
displayBarcode(String(ssid), 320, 200, 2);
|
break;
|
||||||
getdisplay().setCursor(8, 70);
|
case 'D':
|
||||||
getdisplay().print(String("MCUDEVICE-") + String(ssid));
|
displayModeDevicelist();
|
||||||
|
break;
|
||||||
getdisplay().setCursor(8, 95);
|
|
||||||
getdisplay().print("Firmware version: ");
|
|
||||||
getdisplay().setCursor(150, 95);
|
|
||||||
getdisplay().print(VERSINFO);
|
|
||||||
|
|
||||||
getdisplay().setCursor(8, 113);
|
|
||||||
getdisplay().print("Board version: ");
|
|
||||||
getdisplay().setCursor(150, 113);
|
|
||||||
getdisplay().print(BOARDINFO);
|
|
||||||
getdisplay().print(String(" HW ") + String(PCBINFO));
|
|
||||||
|
|
||||||
getdisplay().setCursor(8, 131);
|
|
||||||
getdisplay().print("Display version: ");
|
|
||||||
getdisplay().setCursor(150, 131);
|
|
||||||
getdisplay().print(DISPLAYINFO);
|
|
||||||
getdisplay().print("; GxEPD2 v");
|
|
||||||
getdisplay().print(GXEPD2INFO);
|
|
||||||
|
|
||||||
getdisplay().setCursor(8, 265);
|
|
||||||
#ifdef BOARD_OBP60S3
|
|
||||||
getdisplay().print("Press STBY to enter deep sleep mode");
|
|
||||||
#endif
|
|
||||||
#ifdef BOARD_OBP40S3
|
|
||||||
getdisplay().print("Press wheel to enter deep sleep mode");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Flash memory size
|
|
||||||
uint32_t flash_size = ESP.getFlashChipSize();
|
|
||||||
getdisplay().setCursor(8, y0);
|
|
||||||
getdisplay().print("FLASH:");
|
|
||||||
getdisplay().setCursor(90, y0);
|
|
||||||
getdisplay().print(String(flash_size / 1024) + String(" kB"));
|
|
||||||
|
|
||||||
// PSRAM memory size
|
|
||||||
uint32_t psram_size = ESP.getPsramSize();
|
|
||||||
getdisplay().setCursor(8, y0 + 16);
|
|
||||||
getdisplay().print("PSRAM:");
|
|
||||||
getdisplay().setCursor(90, y0 + 16);
|
|
||||||
getdisplay().print(String(psram_size / 1024) + String(" kB"));
|
|
||||||
|
|
||||||
// FRAM available / status
|
|
||||||
getdisplay().setCursor(8, y0 + 32);
|
|
||||||
getdisplay().print("FRAM:");
|
|
||||||
getdisplay().setCursor(90, y0 + 32);
|
|
||||||
getdisplay().print(hasFRAM ? "available" : "not found");
|
|
||||||
|
|
||||||
#ifdef BOARD_OBP40S3
|
|
||||||
// SD-Card
|
|
||||||
getdisplay().setCursor(8, y0 + 48);
|
|
||||||
getdisplay().print("SD-Card:");
|
|
||||||
getdisplay().setCursor(90, y0 + 48);
|
|
||||||
if (hasSDCard) {
|
|
||||||
uint64_t cardsize = ((uint64_t) sdcard->csd.capacity) * sdcard->csd.sector_size / (1024 * 1024);
|
|
||||||
getdisplay().printf("%llu MB", cardsize);
|
|
||||||
} else {
|
|
||||||
getdisplay().print("off");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Uptime
|
|
||||||
int64_t uptime = esp_timer_get_time() / 1000000;
|
|
||||||
String uptime_unit;
|
|
||||||
if (uptime < 120) {
|
|
||||||
uptime_unit = " seconds";
|
|
||||||
} else {
|
|
||||||
if (uptime < 2 * 3600) {
|
|
||||||
uptime /= 60;
|
|
||||||
uptime_unit = " minutes";
|
|
||||||
} else if (uptime < 2 * 3600 * 24) {
|
|
||||||
uptime /= 3600;
|
|
||||||
uptime_unit = " hours";
|
|
||||||
} else {
|
|
||||||
uptime /= 86400;
|
|
||||||
uptime_unit = " days";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getdisplay().setCursor(8, y0 + 80);
|
|
||||||
getdisplay().print("Uptime:");
|
|
||||||
getdisplay().setCursor(90, y0 + 80);
|
|
||||||
getdisplay().print(uptime);
|
|
||||||
getdisplay().print(uptime_unit);
|
|
||||||
|
|
||||||
// CPU speed config / active
|
|
||||||
getdisplay().setCursor(202, y0);
|
|
||||||
getdisplay().print("CPU speed:");
|
|
||||||
getdisplay().setCursor(300, y0);
|
|
||||||
getdisplay().print(cpuspeed);
|
|
||||||
getdisplay().print(" / ");
|
|
||||||
int cpu_freq = esp_clk_cpu_freq() / 1000000;
|
|
||||||
getdisplay().print(String(cpu_freq));
|
|
||||||
|
|
||||||
// total RAM free
|
|
||||||
int Heap_free = esp_get_free_heap_size();
|
|
||||||
getdisplay().setCursor(202, y0 + 16);
|
|
||||||
getdisplay().print("Total free:");
|
|
||||||
getdisplay().setCursor(300, y0 + 16);
|
|
||||||
getdisplay().print(String(Heap_free));
|
|
||||||
|
|
||||||
// RAM free for task
|
|
||||||
int RAM_free = uxTaskGetStackHighWaterMark(NULL);
|
|
||||||
getdisplay().setCursor(202, y0 + 32);
|
|
||||||
getdisplay().print("Task free:");
|
|
||||||
getdisplay().setCursor(300, y0 + 32);
|
|
||||||
getdisplay().print(String(RAM_free));
|
|
||||||
|
|
||||||
} else if (mode == 'S') {
|
|
||||||
// Settings
|
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
|
||||||
getdisplay().setCursor(x0, 48);
|
|
||||||
getdisplay().print("System settings");
|
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
|
||||||
x0 = 8;
|
|
||||||
y0 = 72;
|
|
||||||
|
|
||||||
// left column
|
|
||||||
getdisplay().setCursor(x0, y0);
|
|
||||||
getdisplay().print("Simulation:");
|
|
||||||
getdisplay().setCursor(120, y0);
|
|
||||||
getdisplay().print(simulation ? "on" : "off");
|
|
||||||
|
|
||||||
getdisplay().setCursor(x0, y0 + 16);
|
|
||||||
getdisplay().print("Environment:");
|
|
||||||
getdisplay().setCursor(120, y0 + 16);
|
|
||||||
getdisplay().print(env_module);
|
|
||||||
|
|
||||||
getdisplay().setCursor(x0, y0 + 32);
|
|
||||||
getdisplay().print("Buzzer:");
|
|
||||||
getdisplay().setCursor(120, y0 + 32);
|
|
||||||
getdisplay().print(buzzer_mode);
|
|
||||||
|
|
||||||
getdisplay().setCursor(x0, y0 + 64);
|
|
||||||
getdisplay().print("GPS:");
|
|
||||||
getdisplay().setCursor(120, y0 + 64);
|
|
||||||
getdisplay().print(gps_module);
|
|
||||||
|
|
||||||
getdisplay().setCursor(x0, y0 + 80);
|
|
||||||
getdisplay().print("RTC:");
|
|
||||||
getdisplay().setCursor(120, y0 + 80);
|
|
||||||
getdisplay().print(rtc_module);
|
|
||||||
|
|
||||||
getdisplay().setCursor(x0, y0 + 96);
|
|
||||||
getdisplay().print("Wifi:");
|
|
||||||
getdisplay().setCursor(120, y0 + 96);
|
|
||||||
getdisplay().print(commonData->status.wifiApOn ? "on" : "off");
|
|
||||||
|
|
||||||
// Home location
|
|
||||||
getdisplay().setCursor(x0, y0 + 128);
|
|
||||||
getdisplay().print("Home Lat.:");
|
|
||||||
getdisplay().setCursor(120, y0 + 128);
|
|
||||||
getdisplay().print(formatLatitude(homelat));
|
|
||||||
getdisplay().setCursor(x0, y0 + 144);
|
|
||||||
getdisplay().print("Home Lon.:");
|
|
||||||
getdisplay().setCursor(120, y0 + 144);
|
|
||||||
getdisplay().print(formatLongitude(homelon));
|
|
||||||
|
|
||||||
// right column
|
|
||||||
getdisplay().setCursor(202, y0);
|
|
||||||
getdisplay().print("Batt. sensor:");
|
|
||||||
getdisplay().setCursor(320, y0);
|
|
||||||
getdisplay().print(batt_sensor);
|
|
||||||
|
|
||||||
// Solar sensor
|
|
||||||
getdisplay().setCursor(202, y0 + 16);
|
|
||||||
getdisplay().print("Solar sensor:");
|
|
||||||
getdisplay().setCursor(320, y0 + 16);
|
|
||||||
getdisplay().print(solar_sensor);
|
|
||||||
|
|
||||||
// Generator sensor
|
|
||||||
getdisplay().setCursor(202, y0 + 32);
|
|
||||||
getdisplay().print("Gen. sensor:");
|
|
||||||
getdisplay().setCursor(320, y0 + 32);
|
|
||||||
getdisplay().print(gen_sensor);
|
|
||||||
|
|
||||||
// Gyro sensor
|
|
||||||
|
|
||||||
} else if (mode == 'C') {
|
|
||||||
// Card info
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
|
||||||
getdisplay().setCursor(8, 48);
|
|
||||||
getdisplay().print("SD Card info");
|
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
|
||||||
|
|
||||||
x0 = 20;
|
|
||||||
y0 = 72;
|
|
||||||
getdisplay().setCursor(x0, y0);
|
|
||||||
#ifdef BOARD_OBP60S3
|
|
||||||
// This mode should not be callable by devices without card hardware
|
|
||||||
// In case of accidential reaching this, display a friendly message
|
|
||||||
getdisplay().print("This mode is not indended to be reached!\n");
|
|
||||||
getdisplay().print("There's nothing to see here. Move on.");
|
|
||||||
#endif
|
|
||||||
#ifdef BOARD_OBP40S3
|
|
||||||
getdisplay().print("Work in progress...");
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
this code should go somewhere else. only for testing purposes here
|
|
||||||
identify card as OBP-Card:
|
|
||||||
magic.dat
|
|
||||||
version.dat
|
|
||||||
readme.txt
|
|
||||||
IMAGES/
|
|
||||||
CHARTS/
|
|
||||||
LOGS/
|
|
||||||
DATA/
|
|
||||||
hint: file access with fopen, fgets, fread, fclose
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Simple test for magic file in root
|
|
||||||
getdisplay().setCursor(x0, y0 + 32);
|
|
||||||
String file_magic = MOUNT_POINT "/magic.dat";
|
|
||||||
logger->logDebug(GwLog::LOG, "Test magicfile: %s", file_magic.c_str());
|
|
||||||
struct stat st;
|
|
||||||
if (stat(file_magic.c_str(), &st) == 0) {
|
|
||||||
getdisplay().printf("File %s exists", file_magic.c_str());
|
|
||||||
} else {
|
|
||||||
getdisplay().printf("File %s not found", file_magic.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Root directory check
|
|
||||||
DIR* dir = opendir(MOUNT_POINT);
|
|
||||||
int dy = 0;
|
|
||||||
if (dir != NULL) {
|
|
||||||
logger->logDebug(GwLog::LOG, "Root directory: %s", MOUNT_POINT);
|
|
||||||
struct dirent* entry;
|
|
||||||
while (((entry = readdir(dir)) != NULL) and (dy < 140)) {
|
|
||||||
getdisplay().setCursor(x0, y0 + 64 + dy);
|
|
||||||
getdisplay().print(entry->d_name);
|
|
||||||
// type 1 is file, type 2 is dir
|
|
||||||
if (entry->d_type == 2) {
|
|
||||||
getdisplay().print("/");
|
|
||||||
}
|
|
||||||
dy += 20;
|
|
||||||
logger->logDebug(GwLog::DEBUG, " %s type %d", entry->d_name, entry->d_type);
|
|
||||||
}
|
|
||||||
closedir(dir);
|
|
||||||
} else {
|
|
||||||
logger->logDebug(GwLog::LOG, "Failed to open root directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// NMEA2000 device list
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
|
||||||
getdisplay().setCursor(8, 48);
|
|
||||||
getdisplay().print("NMEA2000 device list");
|
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
|
||||||
getdisplay().setCursor(20, 80);
|
|
||||||
getdisplay().print("RxD: ");
|
|
||||||
getdisplay().print(String(commonData->status.n2kRx));
|
|
||||||
getdisplay().setCursor(20, 100);
|
|
||||||
getdisplay().print("TxD: ");
|
|
||||||
getdisplay().print(String(commonData->status.n2kTx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update display
|
// Update display
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
def cleanup_patches(source, target, env):
|
||||||
|
for p in patchfiles:
|
||||||
|
patch = os.path.join(patchdir, p)
|
||||||
|
print(f"removing {patch}")
|
||||||
|
res = subprocess.run(["git", "apply", "-R", patch], capture_output=True, text=True)
|
||||||
|
if res.returncode != 0:
|
||||||
|
print(res.stderr)
|
||||||
|
|
||||||
patching = False
|
patching = False
|
||||||
|
|
||||||
epdtype = "unknown"
|
epdtype = "unknown"
|
||||||
@@ -46,11 +54,13 @@ if patching:
|
|||||||
print("patchdir not found, no patches applied")
|
print("patchdir not found, no patches applied")
|
||||||
else:
|
else:
|
||||||
patchfiles = [f for f in os.listdir(patchdir)]
|
patchfiles = [f for f in os.listdir(patchdir)]
|
||||||
for p in patchfiles:
|
if len(patchfiles) > 0:
|
||||||
patch = os.path.join(patchdir, p)
|
for p in patchfiles:
|
||||||
print(f"applying {patch}")
|
patch = os.path.join(patchdir, p)
|
||||||
res = subprocess.run(["git", "apply", patch], capture_output=True, text=True)
|
print(f"applying {patch}")
|
||||||
if res.returncode != 0:
|
res = subprocess.run(["git", "apply", patch], capture_output=True, text=True)
|
||||||
print(res.stderr)
|
if res.returncode != 0:
|
||||||
|
print(res.stderr)
|
||||||
|
env.AddPostAction("$PROGPATH", cleanup_patches)
|
||||||
else:
|
else:
|
||||||
print("no patches found")
|
print("no patches found")
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ void OBP60Task(GwApi *api){
|
|||||||
#endif
|
#endif
|
||||||
LOG_DEBUG(GwLog::LOG,"...done");
|
LOG_DEBUG(GwLog::LOG,"...done");
|
||||||
|
|
||||||
int lastPage=-1; // initialize with an impiossible value, so we can detect wether we are during startup and no page has been displayed yet
|
int lastPage=-1; // initialize with an impossible value, so we can detect wether we are during startup and no page has been displayed yet
|
||||||
|
|
||||||
BoatValueList boatValues; //all the boat values for the api query
|
BoatValueList boatValues; //all the boat values for the api query
|
||||||
HstryBuffers hstryBufferList(1920, &boatValues, logger); // Create empty list of boat data history buffers (1.920 values = seconds = 32 min.)
|
HstryBuffers hstryBufferList(1920, &boatValues, logger); // Create empty list of boat data history buffers (1.920 values = seconds = 32 min.)
|
||||||
@@ -729,7 +729,7 @@ void OBP60Task(GwApi *api){
|
|||||||
else{
|
else{
|
||||||
getdisplay().fillScreen(commonData.fgcolor); // Clear display
|
getdisplay().fillScreen(commonData.fgcolor); // Clear display
|
||||||
#ifdef DISPLAY_GDEY042T81
|
#ifdef DISPLAY_GDEY042T81
|
||||||
getdisplay().hibernate(); // Set display in hybenate mode
|
getdisplay().hibernate(); // Set display in hibenate mode
|
||||||
getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
||||||
#else
|
#else
|
||||||
getdisplay().init(115200); // Init for normal displays
|
getdisplay().init(115200); // Init for normal displays
|
||||||
@@ -757,7 +757,7 @@ void OBP60Task(GwApi *api){
|
|||||||
else{
|
else{
|
||||||
getdisplay().fillScreen(commonData.fgcolor); // Clear display
|
getdisplay().fillScreen(commonData.fgcolor); // Clear display
|
||||||
#ifdef DISPLAY_GDEY042T81
|
#ifdef DISPLAY_GDEY042T81
|
||||||
getdisplay().hibernate(); // Set display in hybenate mode
|
getdisplay().hibernate(); // Set display in hibernate mode
|
||||||
getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
||||||
#else
|
#else
|
||||||
getdisplay().init(115200); // Init for normal displays
|
getdisplay().init(115200); // Init for normal displays
|
||||||
@@ -782,7 +782,7 @@ void OBP60Task(GwApi *api){
|
|||||||
else{
|
else{
|
||||||
getdisplay().fillScreen(commonData.fgcolor); // Clear display
|
getdisplay().fillScreen(commonData.fgcolor); // Clear display
|
||||||
#ifdef DISPLAY_GDEY042T81
|
#ifdef DISPLAY_GDEY042T81
|
||||||
getdisplay().hibernate(); // Set display in hybenate mode
|
getdisplay().hibernate(); // Set display in hibernate mode
|
||||||
getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse
|
||||||
#else
|
#else
|
||||||
getdisplay().init(115200); // Init for normal displays
|
getdisplay().init(115200); // Init for normal displays
|
||||||
|
|||||||
103
lib/obp60task/patches/01-nmea2000.patch
Normal file
103
lib/obp60task/patches/01-nmea2000.patch
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
diff --git a/lib/api/GwApi.h b/lib/api/GwApi.h
|
||||||
|
index 88f9690..9663a65 100644
|
||||||
|
--- a/lib/api/GwApi.h
|
||||||
|
+++ b/lib/api/GwApi.h
|
||||||
|
@@ -2,6 +2,8 @@
|
||||||
|
#define _GWAPI_H
|
||||||
|
#include "GwMessage.h"
|
||||||
|
#include "N2kMsg.h"
|
||||||
|
+#include "Nmea2kTwai.h"
|
||||||
|
+#include "N2kDeviceList.h"
|
||||||
|
#include "NMEA0183Msg.h"
|
||||||
|
#include "GWConfig.h"
|
||||||
|
#include "GwBoatData.h"
|
||||||
|
@@ -222,6 +224,8 @@ class GwApi{
|
||||||
|
* accessing boat data must only be executed from within the main thread
|
||||||
|
* you need to use the request pattern as shown in GwExampleTask.cpp
|
||||||
|
*/
|
||||||
|
+ virtual Nmea2kTwai *getNMEA2000()=0;
|
||||||
|
+ virtual tN2kDeviceList *getN2kDeviceList()=0;
|
||||||
|
virtual GwBoatData *getBoatData()=0;
|
||||||
|
virtual ~GwApi(){}
|
||||||
|
};
|
||||||
|
diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h
|
||||||
|
index 604c356..2fe4496 100644
|
||||||
|
--- a/lib/obp60task/OBP60Extensions.h
|
||||||
|
+++ b/lib/obp60task/OBP60Extensions.h
|
||||||
|
@@ -15,6 +15,9 @@
|
||||||
|
#define MOUNT_POINT "/sdcard"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+// Patches to apply to gateway code
|
||||||
|
+#define PATCH_N2K
|
||||||
|
+
|
||||||
|
// FRAM address reservations 32kB: 0x0000 - 0x7FFF
|
||||||
|
// 0x0000 - 0x03ff: single variables
|
||||||
|
#define FRAM_PAGE_NO 0x0002
|
||||||
|
diff --git a/lib/usercode/GwUserCode.cpp b/lib/usercode/GwUserCode.cpp
|
||||||
|
index 1b007f8..90087d4 100644
|
||||||
|
--- a/lib/usercode/GwUserCode.cpp
|
||||||
|
+++ b/lib/usercode/GwUserCode.cpp
|
||||||
|
@@ -216,6 +216,14 @@ public:
|
||||||
|
{
|
||||||
|
return api->getLogger();
|
||||||
|
}
|
||||||
|
+ virtual Nmea2kTwai *getNMEA2000()
|
||||||
|
+ {
|
||||||
|
+ return api->getNMEA2000();
|
||||||
|
+ }
|
||||||
|
+ virtual tN2kDeviceList *getN2kDeviceList()
|
||||||
|
+ {
|
||||||
|
+ return api->getN2kDeviceList();
|
||||||
|
+ }
|
||||||
|
virtual GwBoatData *getBoatData()
|
||||||
|
{
|
||||||
|
return api->getBoatData();
|
||||||
|
@@ -428,4 +436,4 @@ void GwUserCode::handleWebRequest(const String &url,AsyncWebServerRequest *req){
|
||||||
|
}
|
||||||
|
LOG_DEBUG(GwLog::DEBUG,"no task found for web request %s[%s]",url.c_str(),tname.c_str());
|
||||||
|
req->send(404, "text/plain", "not found");
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
+}
|
||||||
|
diff --git a/src/main.cpp b/src/main.cpp
|
||||||
|
index 44c715f..fdb0366 100644
|
||||||
|
--- a/src/main.cpp
|
||||||
|
+++ b/src/main.cpp
|
||||||
|
@@ -100,6 +100,7 @@ GwLog logger(LOGLEVEL,NULL);
|
||||||
|
GwConfigHandler config(&logger);
|
||||||
|
|
||||||
|
#include "Nmea2kTwai.h"
|
||||||
|
+#include <N2kDeviceList.h>
|
||||||
|
static const unsigned long CAN_RECOVERY_PERIOD=3000; //ms
|
||||||
|
static const unsigned long NMEA2000_HEARTBEAT_INTERVAL=5000;
|
||||||
|
class Nmea2kTwaiLog : public Nmea2kTwai{
|
||||||
|
@@ -126,6 +127,7 @@ class Nmea2kTwaiLog : public Nmea2kTwai{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Nmea2kTwai &NMEA2000=*(new Nmea2kTwaiLog((gpio_num_t)ESP32_CAN_TX_PIN,(gpio_num_t)ESP32_CAN_RX_PIN,CAN_RECOVERY_PERIOD,&logger));
|
||||||
|
+tN2kDeviceList *pN2kDeviceList;
|
||||||
|
|
||||||
|
#ifdef GWBUTTON_PIN
|
||||||
|
bool fixedApPass=false;
|
||||||
|
@@ -333,6 +335,12 @@ public:
|
||||||
|
status.n2kTx=countNMEA2KOut.getGlobal();
|
||||||
|
channels.fillStatus(status);
|
||||||
|
}
|
||||||
|
+ virtual Nmea2kTwai *getNMEA2000(){
|
||||||
|
+ return &NMEA2000;
|
||||||
|
+ }
|
||||||
|
+ virtual tN2kDeviceList *getN2kDeviceList(){
|
||||||
|
+ return pN2kDeviceList;
|
||||||
|
+ }
|
||||||
|
virtual GwBoatData *getBoatData(){
|
||||||
|
return &boatData;
|
||||||
|
}
|
||||||
|
@@ -935,6 +943,7 @@ void setup() {
|
||||||
|
NMEA2000.SetMsgHandler([](const tN2kMsg &n2kMsg){
|
||||||
|
handleN2kMessage(n2kMsg,N2K_CHANNEL_ID);
|
||||||
|
});
|
||||||
|
+ pN2kDeviceList = new tN2kDeviceList(&NMEA2000);
|
||||||
|
NMEA2000.Open();
|
||||||
|
logger.logDebug(GwLog::LOG,"starting addon tasks");
|
||||||
|
logger.flush();
|
||||||
Reference in New Issue
Block a user