Fix for PageWindRose and calibration for einternal voltage sensor
This commit is contained in:
		
							parent
							
								
									4de0606521
								
							
						
					
					
						commit
						e0505997c7
					
				| 
						 | 
					@ -248,6 +248,9 @@ void sensorTask(void *param){
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int rotoffset = api->getConfig()->getConfigItem(api->getConfig()->rotOffset,true)->asInt();
 | 
					    int rotoffset = api->getConfig()->getConfigItem(api->getConfig()->rotOffset,true)->asInt();
 | 
				
			||||||
 | 
					    double voffset = (api->getConfig()->getConfigItem(api->getConfig()->vOffset,true)->asString()).toFloat();
 | 
				
			||||||
 | 
					    double vslope = (api->getConfig()->getConfigItem(api->getConfig()->vSlope,true)->asString()).toFloat();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    long starttime0 = millis();     // GPS update all 1s
 | 
					    long starttime0 = millis();     // GPS update all 1s
 | 
				
			||||||
    long starttime5 = millis();     // Voltage update all 1s
 | 
					    long starttime5 = millis();     // Voltage update all 1s
 | 
				
			||||||
    long starttime6 = millis();     // Environment sensor update all 1s
 | 
					    long starttime6 = millis();     // Environment sensor update all 1s
 | 
				
			||||||
| 
						 | 
					@ -283,6 +286,7 @@ void sensorTask(void *param){
 | 
				
			||||||
        if(millis() > starttime5 + 1000 && String(powsensor1) == "off"){
 | 
					        if(millis() > starttime5 + 1000 && String(powsensor1) == "off"){
 | 
				
			||||||
            starttime5 = millis();
 | 
					            starttime5 = millis();
 | 
				
			||||||
            sensors.batteryVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20;   // Vin = 1/20
 | 
					            sensors.batteryVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20;   // Vin = 1/20
 | 
				
			||||||
 | 
					            sensors.batteryVoltage = sensors.batteryVoltage * vslope + voffset; // Calibration
 | 
				
			||||||
            // Save new data in average array
 | 
					            // Save new data in average array
 | 
				
			||||||
            batV.reading(int(sensors.batteryVoltage * 100));
 | 
					            batV.reading(int(sensors.batteryVoltage * 100));
 | 
				
			||||||
            // Calculate the average values for different time lines from integer values
 | 
					            // Calculate the average values for different time lines from integer values
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -128,7 +128,6 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Show values AWA
 | 
					        // Show values AWA
 | 
				
			||||||
        display.setTextColor(textcolor);
 | 
					        display.setTextColor(textcolor);
 | 
				
			||||||
        if(holdvalues == false){
 | 
					 | 
				
			||||||
        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
				
			||||||
        display.setCursor(10, 65);
 | 
					        display.setCursor(10, 65);
 | 
				
			||||||
        display.print(svalue1);                     // Value
 | 
					        display.print(svalue1);                     // Value
 | 
				
			||||||
| 
						 | 
					@ -138,18 +137,10 @@ public:
 | 
				
			||||||
        display.setFont(&Ubuntu_Bold8pt7b);
 | 
					        display.setFont(&Ubuntu_Bold8pt7b);
 | 
				
			||||||
        display.setCursor(10, 115);
 | 
					        display.setCursor(10, 115);
 | 
				
			||||||
        display.print(" ");
 | 
					        display.print(" ");
 | 
				
			||||||
 | 
					        if(holdvalues == false){
 | 
				
			||||||
            display.print(unit1);                   // Unit
 | 
					            display.print(unit1);                   // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else{
 | 
					        else{
 | 
				
			||||||
            display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(10, 65);
 | 
					 | 
				
			||||||
            display.print(svalue1old);                     // Value
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold12pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(10, 95);
 | 
					 | 
				
			||||||
            display.print(name1);                       // Name
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold8pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(10, 115);
 | 
					 | 
				
			||||||
            display.print(" ");
 | 
					 | 
				
			||||||
            display.print(unit1old);                // Unit
 | 
					            display.print(unit1old);                // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -158,7 +149,6 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Show values AWS
 | 
					        // Show values AWS
 | 
				
			||||||
        display.setTextColor(textcolor);
 | 
					        display.setTextColor(textcolor);
 | 
				
			||||||
        if(holdvalues == false){
 | 
					 | 
				
			||||||
        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
				
			||||||
        display.setCursor(10, 270);
 | 
					        display.setCursor(10, 270);
 | 
				
			||||||
        display.print(svalue2);                     // Value
 | 
					        display.print(svalue2);                     // Value
 | 
				
			||||||
| 
						 | 
					@ -168,45 +158,33 @@ public:
 | 
				
			||||||
        display.setFont(&Ubuntu_Bold8pt7b);
 | 
					        display.setFont(&Ubuntu_Bold8pt7b);
 | 
				
			||||||
        display.setCursor(10, 190);
 | 
					        display.setCursor(10, 190);
 | 
				
			||||||
        display.print(" ");
 | 
					        display.print(" ");
 | 
				
			||||||
 | 
					        if(holdvalues == false){
 | 
				
			||||||
            display.print(unit2);                   // Unit
 | 
					            display.print(unit2);                   // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else{
 | 
					        else{
 | 
				
			||||||
            display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(10, 270);
 | 
					 | 
				
			||||||
            display.print(svalue2old);                  // Value
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold12pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(10, 220);
 | 
					 | 
				
			||||||
            display.print(name2);                       // Name
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold8pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(10, 190);
 | 
					 | 
				
			||||||
            display.print(" ");
 | 
					 | 
				
			||||||
            display.print(unit2old);                // Unit
 | 
					            display.print(unit2old);                // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Show values TWD
 | 
					        // Show values TWD
 | 
				
			||||||
        display.setTextColor(textcolor);
 | 
					        display.setTextColor(textcolor);
 | 
				
			||||||
        if(holdvalues == false){
 | 
					 | 
				
			||||||
        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
				
			||||||
        display.setCursor(295, 65);
 | 
					        display.setCursor(295, 65);
 | 
				
			||||||
            display.print(svalue3);                     // Value
 | 
					        if(valid3 == true){
 | 
				
			||||||
 | 
					            display.print(abs(value3 * 360 / PI), 0);   // Value
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else{
 | 
				
			||||||
 | 
					            display.print("---");                   // Value
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        display.setFont(&Ubuntu_Bold12pt7b);
 | 
					        display.setFont(&Ubuntu_Bold12pt7b);
 | 
				
			||||||
        display.setCursor(335, 95);
 | 
					        display.setCursor(335, 95);
 | 
				
			||||||
        display.print(name3);                       // Name
 | 
					        display.print(name3);                       // Name
 | 
				
			||||||
        display.setFont(&Ubuntu_Bold8pt7b);
 | 
					        display.setFont(&Ubuntu_Bold8pt7b);
 | 
				
			||||||
        display.setCursor(335, 115);
 | 
					        display.setCursor(335, 115);
 | 
				
			||||||
        display.print(" ");
 | 
					        display.print(" ");
 | 
				
			||||||
 | 
					        if(holdvalues == false){
 | 
				
			||||||
            display.print(unit3);                   // Unit
 | 
					            display.print(unit3);                   // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else{
 | 
					        else{
 | 
				
			||||||
            display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(295, 65);
 | 
					 | 
				
			||||||
            display.print(svalue3old);                  // Value
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold12pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(335, 95);
 | 
					 | 
				
			||||||
            display.print(name3);                       // Name
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold8pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(335, 115);
 | 
					 | 
				
			||||||
            display.print(" ");
 | 
					 | 
				
			||||||
            display.print(unit3old);                // Unit
 | 
					            display.print(unit3old);                // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -215,7 +193,6 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Show values TWS
 | 
					        // Show values TWS
 | 
				
			||||||
        display.setTextColor(textcolor);
 | 
					        display.setTextColor(textcolor);
 | 
				
			||||||
        if(holdvalues == false){
 | 
					 | 
				
			||||||
        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					        display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
				
			||||||
        display.setCursor(295, 270);
 | 
					        display.setCursor(295, 270);
 | 
				
			||||||
        display.print(svalue4);                     // Value
 | 
					        display.print(svalue4);                     // Value
 | 
				
			||||||
| 
						 | 
					@ -225,18 +202,10 @@ public:
 | 
				
			||||||
        display.setFont(&Ubuntu_Bold8pt7b);
 | 
					        display.setFont(&Ubuntu_Bold8pt7b);
 | 
				
			||||||
        display.setCursor(335, 190);
 | 
					        display.setCursor(335, 190);
 | 
				
			||||||
        display.print(" ");
 | 
					        display.print(" ");
 | 
				
			||||||
 | 
					        if(holdvalues == false){
 | 
				
			||||||
            display.print(unit4);                   // Unit
 | 
					            display.print(unit4);                   // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else{  
 | 
					        else{  
 | 
				
			||||||
            display.setFont(&DSEG7Classic_BoldItalic20pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(295, 270);
 | 
					 | 
				
			||||||
            display.print(svalue4old);                  // Value
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold12pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(335, 220);
 | 
					 | 
				
			||||||
            display.print(name4);                       // Name
 | 
					 | 
				
			||||||
            display.setFont(&Ubuntu_Bold8pt7b);
 | 
					 | 
				
			||||||
            display.setCursor(335, 190);
 | 
					 | 
				
			||||||
            display.print(" ");
 | 
					 | 
				
			||||||
            display.print(unit4old);                // Unit
 | 
					            display.print(unit4old);                // Unit
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,8 +20,8 @@
 | 
				
			||||||
        "default": "0.00",
 | 
					        "default": "0.00",
 | 
				
			||||||
        "check": "checkMinMax",
 | 
					        "check": "checkMinMax",
 | 
				
			||||||
        "min": 0.00,
 | 
					        "min": 0.00,
 | 
				
			||||||
        "max": 10.00,
 | 
					        "max": 50.00,
 | 
				
			||||||
        "description": "The draft of the boat [0...10m]",
 | 
					        "description": "The draft of the boat [0...50m]",
 | 
				
			||||||
        "category": "OBP60 Settings",
 | 
					        "category": "OBP60 Settings",
 | 
				
			||||||
        "capabilities": {
 | 
					        "capabilities": {
 | 
				
			||||||
            "obp60":"true"
 | 
					            "obp60":"true"
 | 
				
			||||||
| 
						 | 
					@ -274,7 +274,7 @@
 | 
				
			||||||
        "label": "Env. Sensor",
 | 
					        "label": "Env. Sensor",
 | 
				
			||||||
        "type": "list",
 | 
					        "type": "list",
 | 
				
			||||||
        "default": "off",
 | 
					        "default": "off",
 | 
				
			||||||
        "description": "Use internal or external environment sensor via I2C bus[off|BME280|BMP280|SHT21]",
 | 
					        "description": "Use internal or external environment sensor via I2C bus [off|BME280|BMP280|SHT21]",
 | 
				
			||||||
        "list": [
 | 
					        "list": [
 | 
				
			||||||
            "off",
 | 
					            "off",
 | 
				
			||||||
            "BME280",
 | 
					            "BME280",
 | 
				
			||||||
| 
						 | 
					@ -382,7 +382,7 @@
 | 
				
			||||||
        "label": "Gen. Shunt",
 | 
					        "label": "Gen. Shunt",
 | 
				
			||||||
        "type": "list",
 | 
					        "type": "list",
 | 
				
			||||||
        "default": "10",
 | 
					        "default": "10",
 | 
				
			||||||
        "description": "Shunt current value [10A|50A|100A|200A|300A|400A|500A]",
 | 
					        "description": "Shunt current value [10A|50A|100A|200A|300A|400A|500A] @ 75mV",
 | 
				
			||||||
        "list": [
 | 
					        "list": [
 | 
				
			||||||
            "10",
 | 
					            "10",
 | 
				
			||||||
            "50",
 | 
					            "50",
 | 
				
			||||||
| 
						 | 
					@ -524,7 +524,7 @@
 | 
				
			||||||
        "name": "underVoltage",
 | 
					        "name": "underVoltage",
 | 
				
			||||||
        "label": "Undervoltage",
 | 
					        "label": "Undervoltage",
 | 
				
			||||||
        "type": "boolean",
 | 
					        "type": "boolean",
 | 
				
			||||||
        "default": "true",
 | 
					        "default": "false",
 | 
				
			||||||
        "description": "Switch off device if voltage drops below 9V [on|off]",
 | 
					        "description": "Switch off device if voltage drops below 9V [on|off]",
 | 
				
			||||||
        "category": "OBP60 Hardware",
 | 
					        "category": "OBP60 Hardware",
 | 
				
			||||||
        "capabilities": {
 | 
					        "capabilities": {
 | 
				
			||||||
| 
						 | 
					@ -542,6 +542,28 @@
 | 
				
			||||||
            "obp60":"true"
 | 
					            "obp60":"true"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        "name": "vOffset",
 | 
				
			||||||
 | 
					        "label": "VSensor Offset",
 | 
				
			||||||
 | 
					        "type": "number",
 | 
				
			||||||
 | 
					        "default": "0.00",
 | 
				
			||||||
 | 
					        "description": "Offset for internal voltage sensor (ESP32)",
 | 
				
			||||||
 | 
					        "category": "OBP60 Calibrations",
 | 
				
			||||||
 | 
					        "capabilities": {
 | 
				
			||||||
 | 
					            "obp60":"true"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        "name": "vSlope",
 | 
				
			||||||
 | 
					        "label": "VSensor Slope",
 | 
				
			||||||
 | 
					        "type": "number",
 | 
				
			||||||
 | 
					        "default": "1.00",
 | 
				
			||||||
 | 
					        "description": "Slope for internal voltage sensor (ESP32)",
 | 
				
			||||||
 | 
					        "category": "OBP60 Calibrations",
 | 
				
			||||||
 | 
					        "capabilities": {
 | 
				
			||||||
 | 
					            "obp60":"true"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        "name": "display",
 | 
					        "name": "display",
 | 
				
			||||||
        "label": "Display Mode",
 | 
					        "label": "Display Mode",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue