Compare commits
11 Commits
6f4e9b625d
...
edd07d9632
Author | SHA1 | Date |
---|---|---|
|
edd07d9632 | |
|
97b1af71ff | |
![]() |
4110e3f812 | |
![]() |
85dee2a622 | |
![]() |
f2e069b768 | |
![]() |
71946248e2 | |
![]() |
7f954e702d | |
|
7ca0a4d09a | |
|
13abfe4c14 | |
|
8e34fa936d | |
|
4aefc99212 |
|
@ -520,19 +520,23 @@ prebuild(env)
|
|||
board="PLATFORM_BOARD_%s"%env["BOARD"].replace("-","_").upper()
|
||||
print("Board=#%s#"%board)
|
||||
print("BuildFlags=%s"%(" ".join(env["BUILD_FLAGS"])))
|
||||
|
||||
epdtype = "unknown"
|
||||
pcbvers = "unknown"
|
||||
for x in env["BUILD_FLAGS"]:
|
||||
if x.startswith("-D HARDWARE_"):
|
||||
pcbvers = x.split('_')[1]
|
||||
if x.startswith("-D DISPLAY_"):
|
||||
epdtype = x.split('_')[1]
|
||||
|
||||
env.Append(
|
||||
LINKFLAGS=[ "-u", "custom_app_desc" ],
|
||||
CPPDEFINES=[(board,"1"), ("BOARD", env["BOARD"]), ("EPDTYPE", epdtype),
|
||||
("PCBVERS", pcbvers)]
|
||||
CPPDEFINES=[(board,"1")]
|
||||
)
|
||||
#script does not run on clean yet - maybe in the future
|
||||
env.AddPostAction("clean",cleangenerated)
|
||||
|
||||
#look for extra task scripts and include them here
|
||||
for taskdir in userTaskDirs:
|
||||
script = os.path.join(taskdir, "extra_task.py")
|
||||
if os.path.isfile(script):
|
||||
taskname = os.path.basename(os.path.normpath(taskdir))
|
||||
print("#extra task script for '{}'".format(taskname))
|
||||
with open(script) as fh:
|
||||
try:
|
||||
code = compile(fh.read(), taskname, 'exec')
|
||||
except SyntaxError:
|
||||
print("#ERROR: script does not compile")
|
||||
continue
|
||||
exec(code)
|
||||
|
|
|
@ -64,6 +64,12 @@ PCF8574 pcf8574_Out(PCF8574_I2C_ADDR1); // First digital output modul PCF8574 fr
|
|||
Adafruit_FRAM_I2C fram;
|
||||
bool hasFRAM = false;
|
||||
|
||||
// SD Card
|
||||
#ifdef BOARD_OBP40S3
|
||||
sdmmc_card_t *sdcard;
|
||||
bool hasSDCard;
|
||||
#endif
|
||||
|
||||
// Global vars
|
||||
bool blinkingLED = false; // Enable / disable blinking flash LED
|
||||
bool statusLED = false; // Actual status of flash LED on/off
|
||||
|
@ -78,6 +84,9 @@ LedTaskData *ledTaskData=nullptr;
|
|||
|
||||
void hardwareInit(GwApi *api)
|
||||
{
|
||||
GwLog *logger=api->getLogger();
|
||||
GwConfigHandler *config=api->getConfig();
|
||||
|
||||
Wire.begin();
|
||||
// Init PCF8574 digital outputs
|
||||
Wire.setClock(I2C_SPEED); // Set I2C clock on 10 kHz
|
||||
|
@ -87,7 +96,7 @@ void hardwareInit(GwApi *api)
|
|||
fram = Adafruit_FRAM_I2C();
|
||||
if (esp_reset_reason() == ESP_RST_POWERON) {
|
||||
// help initialize FRAM
|
||||
api->getLogger()->logDebug(GwLog::LOG,"Delaying I2C init for 250ms due to cold boot");
|
||||
LOG_DEBUG(GwLog::LOG,"Delaying I2C init for 250ms due to cold boot");
|
||||
delay(250);
|
||||
}
|
||||
// FRAM (e.g. MB85RC256V)
|
||||
|
@ -99,12 +108,53 @@ void hardwareInit(GwApi *api)
|
|||
// Boot counter
|
||||
uint8_t framcounter = fram.read(0x0000);
|
||||
fram.write(0x0000, framcounter+1);
|
||||
api->getLogger()->logDebug(GwLog::LOG,"FRAM detected: 0x%04x/0x%04x (counter=%d)", manufacturerID, productID, framcounter);
|
||||
LOG_DEBUG(GwLog::LOG,"FRAM detected: 0x%04x/0x%04x (counter=%d)", manufacturerID, productID, framcounter);
|
||||
}
|
||||
else {
|
||||
hasFRAM = false;
|
||||
api->getLogger()->logDebug(GwLog::LOG,"NO FRAM detected");
|
||||
LOG_DEBUG(GwLog::LOG,"NO FRAM detected");
|
||||
}
|
||||
// SD Card
|
||||
hasSDCard = false;
|
||||
#ifdef BOARD_OBP40S3
|
||||
if (config->getBool(config->useSDCard)) {
|
||||
esp_err_t ret;
|
||||
sdmmc_host_t host = SDSPI_HOST_DEFAULT();
|
||||
host.slot = SPI3_HOST;
|
||||
spi_bus_config_t bus_cfg = {
|
||||
.mosi_io_num = SD_SPI_MOSI,
|
||||
.miso_io_num = SD_SPI_MISO,
|
||||
.sclk_io_num = SD_SPI_CLK,
|
||||
.quadwp_io_num = -1,
|
||||
.quadhd_io_num = -1,
|
||||
.max_transfer_sz = 4000,
|
||||
};
|
||||
ret = spi_bus_initialize((spi_host_device_t) host.slot, &bus_cfg, SDSPI_DEFAULT_DMA);
|
||||
if (ret != ESP_OK) {
|
||||
LOG_DEBUG(GwLog::ERROR,"Failed to initialize SPI bus for SD card");
|
||||
} else {
|
||||
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
slot_config.gpio_cs = SD_SPI_CS;
|
||||
slot_config.host_id = (spi_host_device_t) host.slot;
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = false,
|
||||
.max_files = 5,
|
||||
.allocation_unit_size = 16 * 1024
|
||||
};
|
||||
ret = esp_vfs_fat_sdspi_mount(MOUNT_POINT, &host, &slot_config, &mount_config, &sdcard);
|
||||
if (ret != ESP_OK) {
|
||||
if (ret == ESP_FAIL) {
|
||||
LOG_DEBUG(GwLog::ERROR,"Failed to mount SD card filesystem");
|
||||
} else {
|
||||
LOG_DEBUG(GwLog::ERROR,"Failed to initialize SD card");
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG(GwLog::ERROR,"SD card filesystem mounted");
|
||||
hasSDCard = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void setPortPin(uint pin, bool value){
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
#include <GxEPD2_BW.h> // E-paper lib V2
|
||||
#include <Adafruit_FRAM_I2C.h> // I2C FRAM
|
||||
|
||||
#ifdef BOARD_OBP40S3
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
#define MOUNT_POINT "/sdcard"
|
||||
#endif
|
||||
|
||||
// FRAM address reservations 32kB: 0x0000 - 0x7FFF
|
||||
// 0x0000 - 0x03ff: single variables
|
||||
#define FRAM_PAGE_NO 0x0002
|
||||
|
@ -24,6 +30,10 @@
|
|||
|
||||
extern Adafruit_FRAM_I2C fram;
|
||||
extern bool hasFRAM;
|
||||
#ifdef BOARD_OBP40S3
|
||||
extern sdmmc_card_t *sdcard;
|
||||
extern bool hasSDCard;
|
||||
#endif
|
||||
|
||||
// Fonts declarations for display (#includes see OBP60Extensions.cpp)
|
||||
extern const GFXfont DSEG7Classic_BoldItalic16pt7b;
|
||||
|
|
|
@ -37,6 +37,18 @@ String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second) {
|
|||
return String(buffer);
|
||||
}
|
||||
|
||||
String formatLatitude(double lat) {
|
||||
float degree = abs(int(lat));
|
||||
float minute = abs((lat - int(lat)) * 60);
|
||||
return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lat > 0) ? "N" : "S");
|
||||
}
|
||||
|
||||
String formatLongitude(double lon) {
|
||||
float degree = abs(int(lon));
|
||||
float minute = abs((lon - int(lon)) * 60);
|
||||
return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lon > 0) ? "E" : "W");
|
||||
}
|
||||
|
||||
FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||
GwLog *logger = commondata.logger;
|
||||
FormatedData result;
|
||||
|
|
|
@ -120,10 +120,10 @@
|
|||
#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)
|
||||
// SPI SD-Card
|
||||
#define SD_SPI_CS 10
|
||||
#define SD_SPI_MOSI 40
|
||||
#define SD_SPI_CLK 39
|
||||
#define SD_SPI_MISO 13
|
||||
#define SD_SPI_CS GPIO_NUM_10
|
||||
#define SD_SPI_MOSI GPIO_NUM_40
|
||||
#define SD_SPI_CLK GPIO_NUM_39
|
||||
#define SD_SPI_MISO GPIO_NUM_13
|
||||
|
||||
// GPS (NEO-6M, NEO-M8N, ATGM336H)
|
||||
#define OBP_GPS_RX 19
|
||||
|
|
|
@ -498,14 +498,18 @@ void sensorTask(void *param){
|
|||
// Send supply voltage value all 1s
|
||||
if(millis() > starttime5 + 1000 && String(powsensor1) == "off"){
|
||||
starttime5 = millis();
|
||||
float rawVoltage = 0;
|
||||
float rawVoltage = 0; // Default value
|
||||
#ifdef BOARD_OBP40S3
|
||||
sensors.batteryVoltage = 0; // If no sensor then zero voltage
|
||||
#endif
|
||||
#if defined(BOARD_OBP40S3) && defined(VOLTAGE_SENSOR)
|
||||
rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.53) * 2; // Vin = 1/2 for OBP40
|
||||
sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration
|
||||
#endif
|
||||
#ifdef BOARD_OBP60S3
|
||||
rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60
|
||||
#endif
|
||||
sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration
|
||||
#endif
|
||||
// Save new data in average array
|
||||
batV.reading(int(sensors.batteryVoltage * 100));
|
||||
// Calculate the average values for different time lines from integer values
|
||||
|
|
|
@ -6,17 +6,13 @@
|
|||
#include <esp32/clk.h>
|
||||
#include "qrcode.h"
|
||||
|
||||
#ifdef BOARD_OBP40S3
|
||||
#include <SD.h>
|
||||
#include <FS.h>
|
||||
#endif
|
||||
|
||||
#define STRINGIZE_IMPL(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE_IMPL(x)
|
||||
#define VERSINFO STRINGIZE(GWDEVVERSION)
|
||||
#define BOARDINFO STRINGIZE(BOARD)
|
||||
#define PCBINFO STRINGIZE(PCBVERS)
|
||||
#define DISPLAYINFO STRINGIZE(EPDTYPE)
|
||||
#define GXEPD2INFO STRINGIZE(GXEPD2VERS)
|
||||
|
||||
/*
|
||||
* Special system page, called directly with fast key sequence 5,4
|
||||
|
@ -43,6 +39,8 @@ String batt_sensor;
|
|||
String solar_sensor;
|
||||
String gen_sensor;
|
||||
String rot_sensor;
|
||||
double homelat;
|
||||
double homelon;
|
||||
|
||||
char mode = 'N'; // (N)ormal, (S)ettings, (D)evice list, (C)ard
|
||||
|
||||
|
@ -69,6 +67,8 @@ public:
|
|||
solar_sensor = common.config->getString(common.config->usePowSensor2);
|
||||
gen_sensor = common.config->getString(common.config->usePowSensor3);
|
||||
rot_sensor = common.config->getString(common.config->useRotSensor);
|
||||
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
||||
homelon = common.config->getString(common.config->homeLON).toDouble();
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
|
@ -203,19 +203,21 @@ public:
|
|||
|
||||
getdisplay().setCursor(8, 95);
|
||||
getdisplay().print("Firmware version: ");
|
||||
getdisplay().setCursor(160, 95);
|
||||
getdisplay().setCursor(150, 95);
|
||||
getdisplay().print(VERSINFO);
|
||||
|
||||
getdisplay().setCursor(8, 113);
|
||||
getdisplay().print("Board version: ");
|
||||
getdisplay().setCursor(160, 113);
|
||||
getdisplay().setCursor(150, 113);
|
||||
getdisplay().print(BOARDINFO);
|
||||
getdisplay().print(String(" HW ") + String(PCBINFO));
|
||||
|
||||
getdisplay().setCursor(8, 131);
|
||||
getdisplay().print("Display version: ");
|
||||
getdisplay().setCursor(160, 131);
|
||||
getdisplay().setCursor(150, 131);
|
||||
getdisplay().print(DISPLAYINFO);
|
||||
getdisplay().print("; GxEPD2 v");
|
||||
getdisplay().print(GXEPD2INFO);
|
||||
|
||||
getdisplay().setCursor(8, 265);
|
||||
#ifdef BOARD_OBP60S3
|
||||
|
@ -250,12 +252,7 @@ public:
|
|||
getdisplay().setCursor(8, y0 + 48);
|
||||
getdisplay().print("SD-Card:");
|
||||
getdisplay().setCursor(90, y0 + 48);
|
||||
if (sdcard) {
|
||||
uint64_t cardsize = SD.cardSize() / (1024 * 1024);
|
||||
getdisplay().print(String(cardsize) + String(" MB"));
|
||||
} else {
|
||||
getdisplay().print("off");
|
||||
}
|
||||
getdisplay().print(hasSDcard ? "ok" : "no");
|
||||
#endif
|
||||
|
||||
// CPU speed config / active
|
||||
|
@ -295,34 +292,44 @@ public:
|
|||
// left column
|
||||
getdisplay().setCursor(x0, y0);
|
||||
getdisplay().print("Simulation:");
|
||||
getdisplay().setCursor(140, y0);
|
||||
getdisplay().setCursor(120, y0);
|
||||
getdisplay().print(simulation ? "on" : "off");
|
||||
|
||||
getdisplay().setCursor(x0, y0 + 16);
|
||||
getdisplay().print("Environment:");
|
||||
getdisplay().setCursor(140, y0 + 16);
|
||||
getdisplay().setCursor(120, y0 + 16);
|
||||
getdisplay().print(env_module);
|
||||
|
||||
getdisplay().setCursor(x0, y0 + 32);
|
||||
getdisplay().print("Buzzer:");
|
||||
getdisplay().setCursor(140, y0 + 32);
|
||||
getdisplay().setCursor(120, y0 + 32);
|
||||
getdisplay().print(buzzer_mode);
|
||||
|
||||
getdisplay().setCursor(x0, y0 + 64);
|
||||
getdisplay().print("GPS:");
|
||||
getdisplay().setCursor(140, y0 + 64);
|
||||
getdisplay().setCursor(120, y0 + 64);
|
||||
getdisplay().print(gps_module);
|
||||
|
||||
getdisplay().setCursor(x0, y0 + 80);
|
||||
getdisplay().print("RTC:");
|
||||
getdisplay().setCursor(140, y0 + 80);
|
||||
getdisplay().setCursor(120, y0 + 80);
|
||||
getdisplay().print(rtc_module);
|
||||
|
||||
getdisplay().setCursor(x0, y0 + 96);
|
||||
getdisplay().print("Wifi:");
|
||||
getdisplay().setCursor(140, y0 + 96);
|
||||
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:");
|
||||
|
@ -356,7 +363,6 @@ public:
|
|||
getdisplay().setCursor(x0, y0);
|
||||
getdisplay().print("Work in progress...");
|
||||
|
||||
|
||||
} else {
|
||||
// NMEA2000 device list
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||
|
|
|
@ -187,7 +187,6 @@ public:
|
|||
}
|
||||
|
||||
// Logging voltage value
|
||||
if (raw == 0) return;
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageVoltage, Type:%s %s:=%f", batType, name1.c_str(), raw);
|
||||
|
||||
// Draw page
|
||||
|
|
|
@ -168,6 +168,8 @@ class PageStruct{
|
|||
// Standard format functions without overhead
|
||||
String formatDate(String fmttype, uint16_t year, uint8_t month, uint8_t day);
|
||||
String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second);
|
||||
String formatLatitude(double lat);
|
||||
String formatLongitude(double lon);
|
||||
|
||||
// Structure for formatted boat values
|
||||
typedef struct{
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Debugging tool
|
||||
##############
|
||||
|
||||
log.txt = text file with error messages from terminal console
|
||||
|
||||
tools/decoder.py -p ESP32S3 -t ~/.platformio/packages/toolchain-xtensa-esp32s3/ -e .pio/build/obp60_s3/firmware.elf log.txt
|
|
@ -0,0 +1,30 @@
|
|||
# PlatformIO extra script for obp60task
|
||||
|
||||
epdtype = "unknown"
|
||||
pcbvers = "unknown"
|
||||
for x in env["BUILD_FLAGS"]:
|
||||
if x.startswith("-D HARDWARE_"):
|
||||
pcbvers = x.split('_')[1]
|
||||
if x.startswith("-D DISPLAY_"):
|
||||
epdtype = x.split('_')[1]
|
||||
|
||||
propfilename = os.path.join(env["PROJECT_LIBDEPS_DIR"], env["PIOENV"], "GxEPD2/library.properties")
|
||||
properties = {}
|
||||
with open(propfilename, 'r') as file:
|
||||
for line in file:
|
||||
match = re.match(r'^([^=]+)=(.*)$', line)
|
||||
if match:
|
||||
key = match.group(1).strip()
|
||||
value = match.group(2).strip()
|
||||
properties[key] = value
|
||||
|
||||
gxepd2vers = "unknown"
|
||||
try:
|
||||
if properties["name"] == "GxEPD2":
|
||||
gxepd2vers = properties["version"]
|
||||
except:
|
||||
pass
|
||||
|
||||
env["CPPDEFINES"].extend([("BOARD", env["BOARD"]), ("EPDTYPE", epdtype), ("PCBVERS", pcbvers), ("GXEPD2VERS", gxepd2vers)])
|
||||
|
||||
print("added hardware info to CPPDEFINES")
|
|
@ -79,8 +79,8 @@ void OBP60Init(GwApi *api){
|
|||
}
|
||||
|
||||
#ifdef BOARD_OBP40S3
|
||||
bool sdcard = config->getBool(config->useSDCard);
|
||||
if (sdcard) {
|
||||
// TODO migrate to new code see OBP60Extensions.cpp
|
||||
if (config->getBool(config->useSDCard)) {
|
||||
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)) {
|
||||
|
@ -99,6 +99,7 @@ void OBP60Init(GwApi *api){
|
|||
}
|
||||
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
LOG_DEBUG(GwLog::LOG,"SD card type %s of size %d MB detected", sdtype, cardSize);
|
||||
SD_SPI.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,6 +383,7 @@ void OBP60Task(GwApi *api){
|
|||
#ifdef HARDWARE_V21
|
||||
startLedTask(api);
|
||||
#endif
|
||||
|
||||
PageList allPages;
|
||||
registerAllPages(allPages);
|
||||
CommonData commonData;
|
||||
|
@ -711,7 +713,7 @@ void OBP60Task(GwApi *api){
|
|||
}
|
||||
|
||||
// #9 or #10 Refresh display after a new page after 4s waiting time and if refresh is disabled
|
||||
if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10)){
|
||||
if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10 || keyboardMessage == 4 || keyboardMessage == 3)){
|
||||
starttime4 = millis();
|
||||
starttime2 = millis(); // Reset the timer for full display update
|
||||
delayedDisplayUpdate = true;
|
||||
|
|
Loading…
Reference in New Issue