OBP40 integration code and improvements
This commit is contained in:
parent
87a7a79358
commit
1545855326
|
@ -326,12 +326,14 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
|
||||||
usbRxOld = commonData.status.usbRx;
|
usbRxOld = commonData.status.usbRx;
|
||||||
usbTxOld = commonData.status.usbTx;
|
usbTxOld = commonData.status.usbTx;
|
||||||
|
|
||||||
|
#ifdef HARDWARE_V21
|
||||||
// Display key lock status
|
// Display key lock status
|
||||||
if (commonData.keylock) {
|
if (commonData.keylock) {
|
||||||
getdisplay().drawXBitmap(170, 1, lock_bits, icon_width, icon_height, commonData.fgcolor);
|
getdisplay().drawXBitmap(170, 1, lock_bits, icon_width, icon_height, commonData.fgcolor);
|
||||||
} else {
|
} else {
|
||||||
getdisplay().drawXBitmap(166, 1, swipe_bits, swipe_width, swipe_height, commonData.fgcolor);
|
getdisplay().drawXBitmap(166, 1, swipe_bits, swipe_width, swipe_height, commonData.fgcolor);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Heartbeat as dot
|
// Heartbeat as dot
|
||||||
getdisplay().setTextColor(commonData.fgcolor);
|
getdisplay().setTextColor(commonData.fgcolor);
|
||||||
|
@ -376,6 +378,7 @@ void displayFooter(CommonData &commonData) {
|
||||||
getdisplay().setFont(&Atari16px);
|
getdisplay().setFont(&Atari16px);
|
||||||
getdisplay().setTextColor(commonData.fgcolor);
|
getdisplay().setTextColor(commonData.fgcolor);
|
||||||
|
|
||||||
|
#ifdef HARDWARE_V21
|
||||||
// Frame around key icon area
|
// Frame around key icon area
|
||||||
if (! commonData.keylock) {
|
if (! commonData.keylock) {
|
||||||
// horizontal elements
|
// horizontal elements
|
||||||
|
@ -422,6 +425,32 @@ void displayFooter(CommonData &commonData) {
|
||||||
getdisplay().setCursor(65, 295);
|
getdisplay().setCursor(65, 295);
|
||||||
getdisplay().print("Press 1 and 6 fast to unlock keys");
|
getdisplay().print("Press 1 and 6 fast to unlock keys");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HARDWARE_LIGHT
|
||||||
|
// grapical page indicator
|
||||||
|
static const uint16_t r = 5;
|
||||||
|
static const uint16_t space = 4;
|
||||||
|
uint16_t w = commonData.data.maxpage * r * 2 + (commonData.data.maxpage - 1) * space;
|
||||||
|
uint16_t x0 = (GxEPD_WIDTH - w) / 2 + r * 2;
|
||||||
|
for (int i = 0; i < commonData.data.maxpage; i++) {
|
||||||
|
if (i == (commonData.data.actpage - 1)) {
|
||||||
|
getdisplay().fillCircle(x0 + i * (r * 2 + space), 290, r, commonData.fgcolor);
|
||||||
|
} else {
|
||||||
|
getdisplay().drawCircle(x0 + i * (r * 2 + space), 290, r, commonData.fgcolor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// key indicators
|
||||||
|
// left side = top key "menu"
|
||||||
|
getdisplay().drawLine(0, 280, 10, 280, commonData.fgcolor);
|
||||||
|
getdisplay().drawLine(55, 280, 65, 280, commonData.fgcolor);
|
||||||
|
getdisplay().drawLine(65, 280, 65, 299, commonData.fgcolor);
|
||||||
|
drawTextCenter(33, 291, commonData.keydata[0].label);
|
||||||
|
// right side = bottom key "exit"
|
||||||
|
getdisplay().drawLine(390, 280, 399, 280, commonData.fgcolor);
|
||||||
|
getdisplay().drawLine(335, 280, 345, 280, commonData.fgcolor);
|
||||||
|
getdisplay().drawLine(335, 280, 335, 399, commonData.fgcolor);
|
||||||
|
drawTextCenter(366, 291, commonData.keydata[1].label);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sunset und sunrise calculation
|
// Sunset und sunrise calculation
|
||||||
|
|
|
@ -250,7 +250,7 @@ void initKeys(CommonData &commonData) {
|
||||||
pinMode(MENUE, INPUT);
|
pinMode(MENUE, INPUT);
|
||||||
pinMode(EXIT, INPUT);
|
pinMode(EXIT, INPUT);
|
||||||
|
|
||||||
// Raed pad values
|
// Read pad values
|
||||||
readSensorpads();
|
readSensorpads();
|
||||||
|
|
||||||
// Detect key
|
// Detect key
|
||||||
|
@ -264,7 +264,7 @@ void initKeys(CommonData &commonData) {
|
||||||
keystatus = keycode;
|
keystatus = keycode;
|
||||||
// Copy keycode
|
// Copy keycode
|
||||||
keycodeold = keycode;
|
keycodeold = keycode;
|
||||||
while(readSensorpads() > 0){} // Wait for pad lesease
|
while(readSensorpads() > 0){} // Wait for pad release
|
||||||
delay(keydelay);
|
delay(keydelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ class Page{
|
||||||
virtual void displayPage(PageData &pageData)=0;
|
virtual void displayPage(PageData &pageData)=0;
|
||||||
virtual void displayNew(PageData &pageData){}
|
virtual void displayNew(PageData &pageData){}
|
||||||
virtual void setupKeys() {
|
virtual void setupKeys() {
|
||||||
|
#ifdef HARDWARE_V21
|
||||||
commonData->keydata[0].label = "";
|
commonData->keydata[0].label = "";
|
||||||
commonData->keydata[1].label = "";
|
commonData->keydata[1].label = "";
|
||||||
commonData->keydata[2].label = "#LEFT";
|
commonData->keydata[2].label = "#LEFT";
|
||||||
|
@ -113,6 +114,12 @@ class Page{
|
||||||
} else {
|
} else {
|
||||||
commonData->keydata[5].label = "";
|
commonData->keydata[5].label = "";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HARDWARE_LIGHT
|
||||||
|
commonData->keydata[0].label = "";
|
||||||
|
commonData->keydata[1].label = "";
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
//return -1 if handled by the page
|
//return -1 if handled by the page
|
||||||
virtual int handleKey(int key){return key;}
|
virtual int handleKey(int key){return key;}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,12 @@
|
||||||
#include "OBP60Extensions.h" // Functions lib for extension board
|
#include "OBP60Extensions.h" // Functions lib for extension board
|
||||||
#include "OBP60Keypad.h" // Functions for keypad
|
#include "OBP60Keypad.h" // Functions for keypad
|
||||||
|
|
||||||
|
#ifdef HARDWARE_LIGHT
|
||||||
|
#include <FS.h> // SD-Card access
|
||||||
|
#include <SD.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// True type character sets includes
|
// True type character sets includes
|
||||||
// See OBP60ExtensionPort.cpp
|
// See OBP60ExtensionPort.cpp
|
||||||
|
|
||||||
|
@ -33,6 +39,9 @@ int taskRunCounter = 0; // Task couter for loop section
|
||||||
//####################################################################################
|
//####################################################################################
|
||||||
void OBP60Init(GwApi *api){
|
void OBP60Init(GwApi *api){
|
||||||
|
|
||||||
|
GwLog *logger = api->getLogger();
|
||||||
|
GwConfigHandler *config = api->getConfig();
|
||||||
|
|
||||||
// Set a new device name and hidden the original name in the main config
|
// Set a new device name and hidden the original name in the main config
|
||||||
String devicename = api->getConfig()->getConfigItem(api->getConfig()->deviceName,true)->asString();
|
String devicename = api->getConfig()->getConfigItem(api->getConfig()->deviceName,true)->asString();
|
||||||
api->getConfig()->setValue(GwConfigDefinitions::systemName, devicename, GwConfigInterface::ConfigType::HIDDEN);
|
api->getConfig()->setValue(GwConfigDefinitions::systemName, devicename, GwConfigInterface::ConfigType::HIDDEN);
|
||||||
|
@ -45,6 +54,33 @@ void OBP60Init(GwApi *api){
|
||||||
// Init hardware
|
// Init hardware
|
||||||
hardwareInit(api);
|
hardwareInit(api);
|
||||||
|
|
||||||
|
#ifdef HARDWARE_LIGHT
|
||||||
|
String sdcard = config->getConfigItem(config->useSDCard, true)->asString();
|
||||||
|
if (sdcard == "on") {
|
||||||
|
setPortPin(OBP_POWER_SD, true); // Power on SD
|
||||||
|
delay(10);
|
||||||
|
SPIClass SD_SPI = SPIClass(HSPI);
|
||||||
|
SD_SPI.begin(SD_SPI_CLK, SD_SPI_MISO, SD_SPI_MOSI);
|
||||||
|
if (SD.begin(SD_SPI_CS, SD_SPI, 80000000)) {
|
||||||
|
String sdtype = "unknown";
|
||||||
|
uint8_t cardType = SD.cardType();
|
||||||
|
switch (cardType) {
|
||||||
|
case CARD_MMC:
|
||||||
|
sdtype = "MMC";
|
||||||
|
break;
|
||||||
|
case CARD_SD:
|
||||||
|
sdtype = "SDSC";
|
||||||
|
break;
|
||||||
|
case CARD_SDHC:
|
||||||
|
sdtype = "SDHC";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||||
|
LOG_DEBUG(GwLog::LOG,"SD card type %s of size %d MB detected", sdtype, cardSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Init power rail 5.0V
|
// Init power rail 5.0V
|
||||||
String powermode = api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
|
String powermode = api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
|
||||||
api->getLogger()->logDebug(GwLog::DEBUG,"Power Mode is: %s", powermode.c_str());
|
api->getLogger()->logDebug(GwLog::DEBUG,"Power Mode is: %s", powermode.c_str());
|
||||||
|
@ -288,15 +324,19 @@ void OBP60Task(GwApi *api){
|
||||||
// return;
|
// return;
|
||||||
GwLog *logger=api->getLogger();
|
GwLog *logger=api->getLogger();
|
||||||
GwConfigHandler *config=api->getConfig();
|
GwConfigHandler *config=api->getConfig();
|
||||||
|
#ifdef HARDWARE_V21
|
||||||
startLedTask(api);
|
startLedTask(api);
|
||||||
|
#endif
|
||||||
PageList allPages;
|
PageList allPages;
|
||||||
registerAllPages(allPages);
|
registerAllPages(allPages);
|
||||||
CommonData commonData;
|
CommonData commonData;
|
||||||
commonData.logger=logger;
|
commonData.logger=logger;
|
||||||
commonData.config=config;
|
commonData.config=config;
|
||||||
|
|
||||||
|
#ifdef HARDWARE_V21
|
||||||
// Keyboard coordinates for page footer
|
// Keyboard coordinates for page footer
|
||||||
initKeys(commonData);
|
initKeys(commonData);
|
||||||
|
#endif
|
||||||
|
|
||||||
tN2kMsg N2kMsg;
|
tN2kMsg N2kMsg;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#define ESP32_CAN_TX_PIN 15
|
#define ESP32_CAN_TX_PIN 15
|
||||||
#define ESP32_CAN_RX_PIN 16
|
#define ESP32_CAN_RX_PIN 16
|
||||||
// Bus load in 50mA steps
|
// Bus load in 50mA steps
|
||||||
#define N2K_LOAD_LEVEL 2 // 5x50mA = 100mA max bus load with back light on
|
#define N2K_LOAD_LEVEL 2 // 2x50mA = 100mA max bus load
|
||||||
// RS485 NMEA0183
|
// RS485 NMEA0183
|
||||||
#define GWSERIAL_TX 9
|
#define GWSERIAL_TX 9
|
||||||
#define GWSERIAL_RX 14
|
#define GWSERIAL_RX 14
|
||||||
|
@ -35,6 +35,11 @@
|
||||||
// OBP60 Task
|
// OBP60 Task
|
||||||
void OBP60Task(GwApi *param);
|
void OBP60Task(GwApi *param);
|
||||||
DECLARE_USERTASK_PARAM(OBP60Task, 35000); // Need 35k RAM as stack size
|
DECLARE_USERTASK_PARAM(OBP60Task, 35000); // Need 35k RAM as stack size
|
||||||
|
#ifdef HARDWARE_V21
|
||||||
DECLARE_CAPABILITY(obp60,true);
|
DECLARE_CAPABILITY(obp60,true);
|
||||||
|
#endif
|
||||||
|
#ifdef HARDWARE_LIGHT
|
||||||
|
DECLARE_CAPABILITY(obp40,true)
|
||||||
|
#endif
|
||||||
DECLARE_STRING_CAPABILITY(HELP_URL, "https://obp60-v2-docu.readthedocs.io/de/latest/"); // Link to help pages
|
DECLARE_STRING_CAPABILITY(HELP_URL, "https://obp60-v2-docu.readthedocs.io/de/latest/"); // Link to help pages
|
||||||
#endif
|
#endif
|
|
@ -59,3 +59,45 @@ upload_port = /dev/ttyACM0 #OBP60 original
|
||||||
upload_protocol = esptool #firmware upload via USB OTG seriell, by first upload need to set the ESP32-S3 in the upload mode with shortcut GND to Pin27
|
upload_protocol = esptool #firmware upload via USB OTG seriell, by first upload need to set the ESP32-S3 in the upload mode with shortcut GND to Pin27
|
||||||
upload_speed = 230400
|
upload_speed = 230400
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:obp40]
|
||||||
|
platform = espressif32@6.8.1
|
||||||
|
board_build.variants_dir = variants
|
||||||
|
board = obp60_s3_light_n8r8 #ESP32-S3 N8R8, 8MB flash, 8MB PSRAM, OBP60 clone
|
||||||
|
board_build.partitions = default_8MB.csv #ESP32-S3 N8, 8MB flash
|
||||||
|
custom_config = config_obp40.json
|
||||||
|
framework = arduino
|
||||||
|
lib_deps =
|
||||||
|
${basedeps.lib_deps}
|
||||||
|
Wire
|
||||||
|
SPI
|
||||||
|
SD
|
||||||
|
esphome/AsyncTCP-esphome@2.0.1
|
||||||
|
robtillaart/PCF8574@0.3.9
|
||||||
|
adafruit/Adafruit Unified Sensor @ 1.1.13
|
||||||
|
blemasle/MCP23017@2.0.0
|
||||||
|
adafruit/Adafruit BusIO@1.5.0
|
||||||
|
adafruit/Adafruit GFX Library@1.11.9
|
||||||
|
#zinggjm/GxEPD2@1.5.8
|
||||||
|
#https://github.com/ZinggJM/GxEPD2
|
||||||
|
https://github.com/thooge/GxEPD2
|
||||||
|
sstaub/Ticker@4.4.0
|
||||||
|
adafruit/Adafruit BMP280 Library@2.6.2
|
||||||
|
adafruit/Adafruit BME280 Library@2.2.2
|
||||||
|
adafruit/Adafruit BMP085 Library@1.2.1
|
||||||
|
enjoyneering/HTU21D@1.2.1
|
||||||
|
robtillaart/INA226@0.2.0
|
||||||
|
paulstoffregen/OneWire@2.3.8
|
||||||
|
milesburton/DallasTemperature@3.11.0
|
||||||
|
signetica/SunRise@2.0.2
|
||||||
|
adafruit/Adafruit FRAM I2C@^2.0.3
|
||||||
|
build_flags=
|
||||||
|
-D DISABLE_DIAGNOSTIC_OUTPUT #Disable diagnostic output for GxEPD2 lib
|
||||||
|
-D BOARD_OBP60S3 #Board OBP60 V2.1 with ESP32S3
|
||||||
|
-D HARDWARE_LIGHT #OBP60 hardware clone (OBP40)
|
||||||
|
-D DISPLAY_GDEY042T81 #new E-Ink display from Waveshare, R10 2.2 ohm
|
||||||
|
${env.build_flags}
|
||||||
|
upload_port = /dev/ttyUSB0 #OBP60 clone
|
||||||
|
upload_protocol = esptool #firmware upload via USB OTG seriell, by first upload need to set the ESP32-S3 in the upload mode with shortcut GND to Pin27
|
||||||
|
upload_speed = 230400
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
Loading…
Reference in New Issue