init and gateway runs

This commit is contained in:
norbert-walter 2022-02-03 17:07:19 +01:00
parent 92c96b256a
commit 3260ea0a22
3 changed files with 777 additions and 105 deletions

View File

@ -0,0 +1,106 @@
#ifndef _OBP60EXTENSIONPORT_H
#define _OBP60EXTENSIONPORT_H
#include <Arduino.h>
#include "OBP60Hardware.h"
MCP23017 mcp = MCP23017(MCP23017_I2C_ADDR);
// SPI pin definitions for E-Ink display
GxIO_Class io(SPI, OBP_SPI_CS, OBP_SPI_DC, OBP_SPI_RST); // SPI, CS, DC, RST
GxEPD_Class display(io, OBP_SPI_RST, OBP_SPI_BUSY); // io, RST, BUSY
// Global vars
int outA = 0; // Outport Byte A
int outB = 0; // Outport Byte B
bool blinkingLED = false; // Enable / disable blinking flash LED
int uvDuration = 0; // Under voltage duration in n x 100ms
uint buzPower = 50; // Buzzer loudness in [%]
void setPortPin(uint pin, bool value){
if(pin <=7){
outA &= ~(1 << pin); // Clear bit
outA |= (value << pin); // Set bit
mcp.writeRegister(MCP23017Register::GPIO_A, outA);
}
else{
pin = pin - 8;
outB &= ~(1 << pin); // Clear bit
outB |= (value << pin); // Set bit
mcp.writeRegister(MCP23017Register::GPIO_B, outB);
}
}
void togglePortPin(uint pin){
if(pin <=7){
outA ^= (1 << pin); // Set bit
mcp.writeRegister(MCP23017Register::GPIO_A, outA);
}
else{
pin = pin - 8;
outB ^= (1 << pin); // Set bit
mcp.writeRegister(MCP23017Register::GPIO_B, outB);
}
}
void blinkingFlashLED(){
noInterrupts();
if(blinkingLED == true){
togglePortPin(OBP_FLASH_LED);
}
else{
setPortPin(OBP_FLASH_LED, false);
}
interrupts();
}
void buzzer(uint frequency, uint power, uint duration){
if(frequency > 8000){ // Max 8000Hz
frequency = 8000;
}
if(power > 100){ // Max 100%
power = 100;
}
if(duration > 1000){ // Max 1000ms
duration = 1000;
}
pinMode(OBP_BUZZER, OUTPUT);
ledcSetup(0, frequency, 8); // Ch 0, ferquency in Hz, 8 Bit resolution of PWM
ledcAttachPin(OBP_BUZZER, 0);
ledcWrite(0, int(power * 1.28)); // 50% duty cycle are 100%
delay(duration);
ledcWrite(0, 0); // 0% duty cycle are 0%
}
void underVoltageDetection(){
noInterrupts();
float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20
if(actVoltage < MIN_VOLTAGE){
uvDuration ++;
}
else{
uvDuration = 0;
}
if(uvDuration > POWER_FAIL_TIME){
setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off
setPortPin(OBP_FLASH_LED, false); // Flash LED Off
buzzer(TONE4, buzPower, 20); // Buzzer tone 4kHz 20% 20ms
setPortPin(OBP_POWER_50, false); // Power rail 5.0V Off
setPortPin(OBP_POWER_33, false); // Power rail 3.3V Off
// Shutdown EInk display
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); // Partial update
// display._sleep(); // Display shut dow
// Stop system
while(true){
esp_deep_sleep_start(); // Deep Sleep without weakup. Weakup only after power cycle (restart).
}
}
interrupts();
}
#endif

View File

@ -1,4 +1,462 @@
[
{
"name": "obp60Config",
"label": "Logging",
"type": "boolean",
"default": "false",
"description": "Switch on logging of position acquired/failed",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "timeZone",
"label": "Time Zone",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": -12,
"max": 12,
"description": "Time zone [UTC -12...+12]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "draft",
"label": "Boat Draft [m]",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": 0,
"max": 10,
"description": "The draft of the boat [0...10m]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "fuelTank",
"label": "Fuel Tank [l]",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": 0,
"max": 5000,
"description": "Fuel tank capacity [0...5000l]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "fuelConsumption",
"label": "Fuel Consuption [l/h]",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": 0,
"max": 1000,
"description": "Medium fuel consumption [0...1000l/h]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "waterTank",
"label": "Water Tank [l]",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": 0,
"max": 5000,
"description": "Water tank capacity [0...5000l]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "wasteTank",
"label": "Waste Tank [l]",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": 0,
"max": 5000,
"description": "Water tank capacity [0...5000l]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "batteryVoltage",
"label": "Battery Voltage [V]",
"type": "number",
"default": "12",
"check": "checkMinMax",
"min": 0,
"max": 1000,
"description": "Fuel tank capacity [0...1000V]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "batteryType",
"label": "Battery Type",
"type": "list",
"default": "Pb",
"description": "Type of battery",
"list": [
"Pb",
"Gel",
"AGM",
"LiFePo4"
],
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "batteryCapacity",
"label": "Battery Capacity [Ah]",
"type": "number",
"default": "0",
"check": "checkMinMax",
"min": 0,
"max": 10000,
"description": "Fuel tank capacity [0...10000Ah]",
"category": "OBP60 Settings",
"capabilities": {
"obp60":"true"
}
},
{
"name": "lengthFormat",
"label": "Length Format",
"type": "list",
"default": "m",
"description": "Length format [m|ft]",
"list": [
"m",
"ft"
],
"category": "OBP60 Units",
"capabilities": {
"obp60":"true"
}
},
{
"name": "distanceFormat",
"label": "Distance Format",
"type": "list",
"default": "m",
"description": "Distance format [m|km|nm]",
"list": [
"m",
"km",
"nm"
],
"category": "OBP60 Units",
"capabilities": {
"obp60":"true"
}
},
{
"name": "speedFormat",
"label": "Speed Format",
"type": "list",
"default": "m/s",
"description": "Distance format [m/s|km/h|kn]",
"list": [
"m/s",
"km/h",
"kn"
],
"category": "OBP60 Units",
"capabilities": {
"obp60":"true"
}
},
{
"name": "windspeedFormat",
"label": "Wind Speed Format",
"type": "list",
"default": "m/s",
"description": "Distance format [m/s|km/h|kn|bft]",
"list": [
"m/s",
"km/h",
"kn",
"bft"
],
"category": "OBP60 Units",
"capabilities": {
"obp60":"true"
}
},
{
"name": "tempFormat",
"label": "Temperature Format",
"type": "list",
"default": "C",
"description": "Length format [K|°C|°F]",
"list": [
"K",
"C",
"F"
],
"category": "OBP60 Units",
"capabilities": {
"obp60":"true"
}
},
{
"name": "dateFormat",
"label": "Date Format",
"type": "list",
"default": "GB",
"description": "Date format [DE|GB|US] DE: 31.12.2022, GB: 31/12/2022, US: 12/31/2022",
"list": [
"DE",
"GB",
"US"
],
"category": "OBP60 Units",
"capabilities": {
"obp60":"true"
}
},
{
"name": "useGPS",
"label": "GPS NEO-6M",
"type": "boolean",
"default": "false",
"description": "Using internal GPS modul NEO-6M",
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "useBME280",
"label": "BME280",
"type": "boolean",
"default": "false",
"description": "Using internal BME280 modul",
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "use1Wire",
"label": "1Wire",
"type": "boolean",
"default": "false",
"description": "Using external 1Wirew devices (DS18B20)",
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "powerMode",
"label": "Power Mode",
"type": "list",
"default": "Max Power",
"description": "Settings for power mode",
"list": [
"Max Power",
"Only 3.3V",
"Only 5.0V",
"Min Power"
],
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "underVoltage",
"label": "Undervoltage",
"type": "boolean",
"default": "false",
"description": "If undervoltage detection [on|off] lower than 9V then switch off the device",
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "useSimuData",
"label": "Simulation Data",
"type": "boolean",
"default": "false",
"description": "Can use for simulation data by missing bus data.",
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "display",
"label": "Display Mode",
"type": "list",
"default": "Logo + QR Code",
"description": "Settings for display mode",
"list": [
"White Screen",
"Logo",
"Logo + QR Code",
"Off"
],
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{
"name": "statusLine",
"label": "Status Line",
"type": "boolean",
"default": "true",
"description": "Show status line [on|off]",
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{
"name": "refresh",
"label": "Refresh",
"type": "boolean",
"default": "false",
"description": "Refresh E-Ink display after each new page request [on|off]. A refresh reduce background shaddows from older pages.",
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{
"name": "holdvalues",
"label": "Hold Values",
"type": "boolean",
"default": "false",
"description": "Hold old measuring values by missing data stream [on|off]",
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{
"name": "backlight",
"label": "Backlight Mode",
"type": "list",
"default": "Off",
"description": "Settings for display mode",
"list": [
"Off",
"Control by Sun",
"Control by Bus",
"Control by Time",
"Control by Key",
"On"
],
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{
"name": "flashLED",
"label": "Flash LED Mode",
"type": "list",
"default": "Off",
"description": "Settings for flash LED",
"list": [
"Off",
"Bus Data",
"GPS Fix",
"Limits Overrun"
],
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{
"name": "buzzerError",
"label": "Buzzer Error",
"type": "boolean",
"default": "false",
"description": "Sound on error",
"category": "OBP60 Buzzer",
"capabilities": {
"obp60":"true"
}
},
{
"name": "buzzerGps",
"label": "Buzzer GPS Fix",
"type": "boolean",
"default": "false",
"description": "Sound on missing or lost GPS fix",
"category": "OBP60 Buzzer",
"capabilities": {
"obp60":"true"
}
},
{
"name": "buzzerLim",
"label": "Buzzer by Limits",
"type": "boolean",
"default": "false",
"description": "Sound on limit overrun",
"category": "OBP60 Buzzer",
"capabilities": {
"obp60":"true"
}
},
{
"name": "buzzerMode",
"label": "Buzzer Mode",
"type": "list",
"default": "Off",
"description": "Settings for Buzzer Mode",
"list": [
"Off",
"Short Single Beep",
"Longer Single Beep",
"Beep until Confirmation"
],
"category": "OBP60 Buzzer",
"capabilities": {
"obp60":"true"
}
},
{
"name": "buzzerPower",
"label": "Buzzer Power [%]",
"type": "number",
"default": "50",
"check": "checkMinMax",
"min": 0,
"max": 100,
"description": "Buzzer Loudness [0...100%]",
"category": "OBP60 Buzzer",
"capabilities": {
"obp60":"true"
}
},
{
"name": "visiblePages",
"label": "number of pages",
@ -7,260 +465,249 @@
"min": 1,
"max": 4,
"default":"1",
"category":"pagecommon",
"category":"OBP60 Pages",
"capabilities": {
"pagetask":"true"
"obp60":"true"
}
},
{
"name": "page1type",
"label": "type",
"label": "Type",
"type": "list",
"default": "oneValue",
"description": "type of page for page 1",
"description": "Type of page for page 1",
"list":["oneValue","twoValues","threeValues","forValues","apparentWind"],
"category": "page1",
"category": "OBP60 Page 1",
"capabilities": {
"pagetask":"true"
"obp60":"true"
}
},
{
"name": "page1value1",
"label": "field1",
"label": "Field 1 ",
"type": "boatData",
"default": "",
"description": "the display for field one",
"category": "page1",
"description": "The display for field one",
"category": "OBP60 Page 1",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page1type":"oneValue"},{"page1type":"twoValues"},{"page1type":"threeValues"},{"page1type":"forValues"}]
},
{
"name": "page1value2",
"label": "field2",
"label": "Field 2",
"type": "boatData",
"default": "",
"description": "the display for field two",
"category": "page1",
"description": "The display for field two",
"category": "OBP60 Page 1",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page1type":"twoValues"},{"page1type":"threeValues"},{"page1type":"forValues"}]
}
,
},
{
"name": "page1value3",
"label": "field3",
"label": "Field 3",
"type": "boatData",
"default": "",
"description": "the display for field 3",
"category": "page1",
"description": "The display for field 3",
"category": "OBP60 Page 1",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page1type":"threeValues"},{"page1type":"forValues"}]
}
,
},
{
"name": "page1value4",
"label": "field4",
"label": "Field 4",
"type": "boatData",
"default": "",
"description": "the display for field 4",
"category": "page1",
"description": "The display for field 4",
"category": "OBP60 Page 1",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page1type":"forValues"}]
},
{
"name": "page2type",
"label": "type",
"label": "Type",
"type": "list",
"default": "oneValue",
"description": "type of page for page 1",
"description": "Type of page for page 2",
"list":["oneValue","twoValues","threeValues","forValues","apparentWind"],
"category": "page2",
"category": "OBP60 Page 2",
"capabilities": {
"pagetask":"true"
"obp60":"true"
}
},
{
"name": "page2value1",
"label": "field1",
"label": "Field 1",
"type": "boatData",
"default": "",
"description": "the display for field one",
"category": "page2",
"description": "The display for field one",
"category": "OBP60 Page 2",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page2type":"oneValue"},{"page2type":"twoValues"},{"page2type":"threeValues"},{"page2type":"forValues"}]
},
{
"name": "page2value2",
"label": "field2",
"label": "Field 2",
"type": "boatData",
"default": "",
"description": "the display for field two",
"category": "page2",
"description": "The display for field two",
"category": "OBP60 Page 2",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page2type":"twoValues"},{"page2type":"threeValues"},{"page2type":"forValues"}]
}
,
},
{
"name": "page2value3",
"label": "field3",
"label": "Field 3",
"type": "boatData",
"default": "",
"description": "the display for field 3",
"category": "page2",
"description": "The display for field 3",
"category": "OBP60 Page 2",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page2type":"threeValues"},{"page2type":"forValues"}]
}
,
},
{
"name": "page2value4",
"label": "field4",
"label": "Field 4",
"type": "boatData",
"default": "",
"description": "the display for field 4",
"category": "page2",
"description": "The display for field 4",
"category": "OBP60 Page 2",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page2type":"forValues"}]
}
,
},
{
"name": "page3type",
"label": "type",
"label": "Type",
"type": "list",
"default": "oneValue",
"description": "type of page for page 1",
"description": "Type of page for page 3",
"list":["oneValue","twoValues","threeValues","forValues","apparentWind"],
"category": "page3",
"category": "OBP60 Page 3",
"capabilities": {
"pagetask":"true"
"obp60":"true"
}
},
{
"name": "page3value1",
"label": "field1",
"label": "Field 1",
"type": "boatData",
"default": "",
"description": "the display for field one",
"category": "page3",
"description": "The display for field one",
"category": "OBP60 Page 3",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page3type":"oneValue"},{"page3type":"twoValues"},{"page3type":"threeValues"},{"page3type":"forValues"}]
},
{
"name": "page3value2",
"label": "field2",
"label": "Field 2",
"type": "boatData",
"default": "",
"description": "the display for field two",
"category": "page3",
"description": "The display for field two",
"category": "OBP60 Page 3",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page3type":"twoValues"},{"page3type":"threeValues"},{"page3type":"forValues"}]
}
,
},
{
"name": "page3value3",
"label": "field3",
"label": "Field 3",
"type": "boatData",
"default": "",
"description": "the display for field 3",
"category": "page3",
"description": "The display for field 3",
"category": "OBP60 Page 3",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page3type":"threeValues"},{"page3type":"forValues"}]
}
,
},
{
"name": "page3value4",
"label": "field4",
"label": "Field 4",
"type": "boatData",
"default": "",
"description": "the display for field 4",
"category": "page3",
"description": "The display for field 4",
"category": "OBP60 Page 3",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page3type":"forValues"}]
}
,
},
{
"name": "page4type",
"label": "type",
"label": "Type",
"type": "list",
"default": "oneValue",
"description": "type of page for page 1",
"description": "Type of page for page 4",
"list":["oneValue","twoValues","threeValues","forValues","apparentWind"],
"category": "page4",
"category": "OBP60 Page 4",
"capabilities": {
"pagetask":"true"
"obp60":"true"
}
},
{
"name": "page4value1",
"label": "field1",
"label": "Field 1",
"type": "boatData",
"default": "",
"description": "the display for field one",
"category": "page4",
"description": "The display for field one",
"category": "OBP60 Page 4",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page4type":"oneValue"},{"page4type":"twoValues"},{"page4type":"threeValues"},{"page4type":"forValues"}]
},
{
"name": "page4value2",
"label": "field2",
"label": "Field 2",
"type": "boatData",
"default": "",
"description": "the display for field two",
"category": "page4",
"description": "The display for field two",
"category": "OBP60 Page 4",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page4type":"twoValues"},{"page4type":"threeValues"},{"page4type":"forValues"}]
}
,
},
{
"name": "page4value3",
"label": "field3",
"label": "Field 3",
"type": "boatData",
"default": "",
"description": "the display for field 3",
"category": "page4",
"description": "The display for field 3",
"category": "OBP60 Page 4",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page4type":"threeValues"},{"page4type":"forValues"}]
}
,
},
{
"name": "page4value4",
"label": "field4",
"label": "Field 4",
"type": "boatData",
"default": "",
"description": "the display for field 4",
"category": "page4",
"description": "The display for field 4",
"category": "OBP60 Page 4",
"capabilities": {
"pagetask":"true"
"obp60":"true"
},
"condition":[{"page4type":"forValues"}]
}
]

View File

@ -12,6 +12,7 @@
#include <GxGDEW042T2/GxGDEW042T2.h> // 4.2" Waveshare S/W 300 x 400 pixel
#include <GxIO/GxIO_SPI/GxIO_SPI.h> // GxEPD lip for SPI display communikation
#include <GxIO/GxIO.h> // GxEPD lip for SPI
#include "OBP60ExtensionPort.h" // Functions lib for extension board
// True type character sets
#include "Ubuntu_Bold8pt7b.h"
@ -26,9 +27,127 @@
#include "MFD_OBP60_400x300_sw.h" // MFD with logo
#include "Logo_OBP_400x300_sw.h" // OBP Logo
tNMEA0183Msg NMEA0183Msg;
tNMEA0183 NMEA0183;
// Timer Interrupts for hardware functions
Ticker Timer1; // Under voltage detection
Ticker Timer2; // Binking flash LED
// Global vars
bool initComplete = false; // Initialization complete
int taskRunCounter = 0; // Task couter for loop section
bool gps_ready = false; // GPS initialized and ready to use
// Hardware initialisation before start all services
//##################################################
void OBP60Init(GwApi *api){
api->getLogger()->logDebug(GwLog::LOG,"obp60init running");
// Define timer interrupts
bool uvoltage = api->getConfig()->getConfigItem(api->getConfig()->underVoltage,true)->asBoolean();
if(uvoltage == true){
Timer1.attach_ms(1, underVoltageDetection); // Maximum speed with 1ms
}
Timer2.attach_ms(500, blinkingFlashLED);
// Extension port MCP23017
// Check I2C devices MCP23017
Wire.begin(OBP_I2C_SDA, OBP_I2C_SCL);
Wire.beginTransmission(MCP23017_I2C_ADDR);
if (Wire.endTransmission() != 0) {
api->getLogger()->logDebug(GwLog::ERROR,"MCP23017 not found, check wiring");
initComplete = false;
}
else{
// Start communication
mcp.init();
mcp.portMode(MCP23017Port::A, 0b00110000); //Port A, 0 = out, 1 = in
mcp.portMode(MCP23017Port::B, 0b11110000); //Port B, 0 = out, 1 = in
// Extension Port A set defaults
setPortPin(OBP_DIGITAL_OUT1, false); // PA0
setPortPin(OBP_DIGITAL_OUT2, false); // PA1
setPortPin(OBP_FLASH_LED, false); // PA2
setPortPin(OBP_BACKLIGHT_LED, false); // PA3
setPortPin(OBP_POWER_50, true); // PA6
setPortPin(OBP_POWER_33, true); // PA7
// Extension Port B set defaults
setPortPin(PB0, false); // PB0
setPortPin(PB1, false); // PB1
setPortPin(PB2, false); // PB2
setPortPin(PB3, false); // PB3
// Settings for 1Wire
bool enable1Wire = api->getConfig()->getConfigItem(api->getConfig()->use1Wire,true)->asBoolean();
if(enable1Wire == true){
api->getLogger()->logDebug(GwLog::DEBUG,"1Wire Mode is On");
}
else{
api->getLogger()->logDebug(GwLog::DEBUG,"1Wire Mode is Off");
}
// Settings for NMEA0183
String nmea0183Mode = api->getConfig()->getConfigItem(api->getConfig()->serialDirection,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"NMEA0183 Mode is: %s", nmea0183Mode);
pinMode(OBP_DIRECTION_PIN, OUTPUT);
if(String(nmea0183Mode) == "receive" || String(nmea0183Mode) == "off"){
digitalWrite(OBP_DIRECTION_PIN, false);
}
if(String(nmea0183Mode) == "send"){
digitalWrite(OBP_DIRECTION_PIN, true);
}
// Settings for backlight
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"Backlight Mode is: %s", backlightMode);
if(String(backlightMode) == "On"){
setPortPin(OBP_BACKLIGHT_LED, true);
}
if(String(backlightMode) == "Off"){
setPortPin(OBP_BACKLIGHT_LED, false);
}
if(String(backlightMode) == "Control by Key"){
setPortPin(OBP_BACKLIGHT_LED, false);
}
// Settings flash LED mode
String ledMode = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"Backlight Mode is: %s", ledMode);
if(String(ledMode) == "Off"){
blinkingLED = false;
}
if(String(ledMode) == "Limits Overrun"){
blinkingLED = true;
}
// Start serial stream and take over GPS data stream form internal GPS
bool gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
if(gpsOn == true){
Serial2.begin(9600, SERIAL_8N1, OBP_GPS_TX, -1); // GPS RX unused in hardware (-1)
if (!Serial2) {
api->getLogger()->logDebug(GwLog::ERROR,"GPS modul NEO-6M not found, check wiring");
gps_ready = false;
}
else{
api->getLogger()->logDebug(GwLog::DEBUG,"GPS modul NEO-M6 found");
NMEA0183.SetMessageStream(&Serial2);
NMEA0183.Open();
gps_ready = true;
}
}
// Marker for init complete
// Used in OBP60Task()
initComplete = true;
// Buzzer tone for initialization finish
buzPower = uint(api->getConfig()->getConfigItem(api->getConfig()->buzzerPower,true)->asInt());
buzzer(TONE4, buzPower, 500);
}
void OBP60Init(GwApi *param){
param->getLogger()->logDebug(GwLog::LOG,"obp60init running");
}
typedef struct {