1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-28 21:23:07 +01:00

Backup actual firmware

This commit is contained in:
norbert-walter
2025-12-13 21:08:39 +01:00
parent 69367b91d7
commit b54acbae42
3 changed files with 33 additions and 5 deletions

View File

@@ -27,9 +27,7 @@
#include "fonts/IBM8x8px.h"
// E-Ink Display
#define GxEPD_WIDTH 400 // Display width
#define GxEPD_HEIGHT 300 // Display height
// Definition for e-paper width an height refer OBP60Hardware.h
#ifdef DISPLAY_GDEW042T2
// Set display type and SPI pins for display
GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(OBP_SPI_CS, OBP_SPI_DC, OBP_SPI_RST, OBP_SPI_BUSY)); // GDEW042T2 400x300, UC8176 (IL0398)

View File

@@ -42,6 +42,8 @@
#define OBP_SPI_DIN 48
#define SHOW_TIME 6000 // Show time in [ms] for logo and WiFi QR code
#define FULL_REFRESH_TIME 600 // Refresh cycle time in [s][600...3600] for full display update (very important healcy function)
#define GxEPD_WIDTH 400 // Display width
#define GxEPD_HEIGHT 300 // Display height
// GPS (NEO-6M, NEO-M8N, ATGM336H)
#define OBP_GPS_RX 2
@@ -119,6 +121,8 @@
#define OBP_SPI_DIN 11
#define SHOW_TIME 6000 // Show time in [ms] for logo and WiFi QR code
#define FULL_REFRESH_TIME 600 // Refresh cycle time in [s][600...3600] for full display update (very important healcy function)
#define GxEPD_WIDTH 400 // Display width
#define GxEPD_HEIGHT 300 // Display height
// SPI SD-Card
#define SD_SPI_CS GPIO_NUM_10
#define SD_SPI_MOSI GPIO_NUM_40

View File

@@ -19,6 +19,9 @@ bool firstRun = true; // Detect the first page run
int zoom = 15; // Default zoom level
bool showValues = false; // Show values HDT, SOG, DBT in navigation map
// Init image backup for navigation map
uint8_t* imageBackupData = (uint8_t*) heap_caps_malloc((GxEPD_WIDTH * GxEPD_HEIGHT), MALLOC_CAP_SPIRAM); // Allocate PSRAM for image backup buffer for navigation map(400 x 300 pix)
public:
PageNavigation(CommonData &common){
commonData = &common;
@@ -119,6 +122,11 @@ public:
static double magneticHeading = 0;
static double speedOverGround = 0;
static double depthBelowTransducer = 0;
int imgWidth = 0;
int imgHeight = 0;
int imgBackupWidth = 400;
int imgBackupHeight = 250;
bool hasImageBackup = false;
// Get boat values #1 Latitude
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
@@ -360,8 +368,8 @@ public:
auto& json = net.json(); // Extract JSON content
int numPix = json["number_pixels"] | 0; // Read number of pixels
int imgWidth = json["width"] | 0; // Read width of image
int imgHeight = json["height"] | 0; // Read height og image
imgWidth = json["width"] | 0; // Read width of image
imgHeight = json["height"] | 0; // Read height og image
const char* b64src = json["picture_base64"].as<const char*>(); // Read picture as Base64 content
size_t b64len = strlen(b64src); // Calculate length of Base64 content
@@ -387,13 +395,31 @@ public:
size_t decodedSize = 0;
decoder.decodeBase64(b64, imageData, imgSize, decodedSize);
// Copy actual navigation man to ackup map
memcpy(imageBackupData, imageData, imgSize);
// Show image (navigation map)
getdisplay().drawBitmap(0, 25, imageData, imgWidth, imgHeight, commonData->fgcolor);
hasImageBackup = true;
// Clean PSRAM
free(b64);
free(imageData);
}
// If no network connection then use backup navigation map
else{
// Show backup image (backup navigation map)
if (hasImageBackup) {
getdisplay().drawBitmap(0, 25, imageBackupData, imgBackupWidth, imgBackupHeight, commonData->fgcolor);
}
// Show info: Connection lost
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().fillRect(200, 250 , 200, 25, commonData->fgcolor); // Black rect
getdisplay().fillRect(202, 252 , 196, 21, commonData->bgcolor); // White rect
getdisplay().setCursor(205, 270);
getdisplay().print("Connection lost");
}
// ############### Draw Values ################