Reduce stack size for OBP task from 25kB to 10kB, add custom page keel position
This commit is contained in:
parent
d43974ac1a
commit
b229d67ec0
|
@ -143,10 +143,10 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
//########################################################
|
||||
else if (value->getFormat() == "formatFixed0"){
|
||||
if(usesimudata == false) {
|
||||
snprintf(buffer,bsize,"%.0f",value->value);
|
||||
snprintf(buffer,bsize,"%3.0f",value->value);
|
||||
}
|
||||
else{
|
||||
snprintf(buffer,bsize,"%.0f", 8.0 + float(random(0, 10)) / 10.0);
|
||||
snprintf(buffer,bsize,"%3.0f", 8.0 + float(random(0, 10)) / 10.0);
|
||||
}
|
||||
result.unit = "";
|
||||
}
|
||||
|
@ -233,10 +233,10 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
}
|
||||
else{
|
||||
if(speed < 10){
|
||||
snprintf(buffer,bsize,"%2.1f",speed);
|
||||
snprintf(buffer,bsize,"%3.2f",speed);
|
||||
}
|
||||
if(speed >= 10 && speed < 100){
|
||||
snprintf(buffer,bsize,"%2.1f",speed);
|
||||
snprintf(buffer,bsize,"%3.1f",speed);
|
||||
}
|
||||
if(speed >= 100){
|
||||
snprintf(buffer,bsize,"%3.0f",speed);
|
||||
|
@ -261,10 +261,10 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
rotation = 99;
|
||||
}
|
||||
if(rotation > -10 && rotation < 10){
|
||||
snprintf(buffer,bsize,"%1.1f",rotation);
|
||||
snprintf(buffer,bsize,"%3.2f",rotation);
|
||||
}
|
||||
if(rotation <= -10 || rotation >= 10){
|
||||
snprintf(buffer,bsize,"%2.0f",rotation);
|
||||
snprintf(buffer,bsize,"%3.0f",rotation);
|
||||
}
|
||||
}
|
||||
//########################################################
|
||||
|
@ -281,10 +281,10 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
dop = 99.9;
|
||||
}
|
||||
if(dop < 10){
|
||||
snprintf(buffer,bsize,"%2.1f",dop);
|
||||
snprintf(buffer,bsize,"%3.2f",dop);
|
||||
}
|
||||
if(dop >= 10 && dop < 100){
|
||||
snprintf(buffer,bsize,"%2.1f",dop);
|
||||
snprintf(buffer,bsize,"%3.1f",dop);
|
||||
}
|
||||
}
|
||||
//########################################################
|
||||
|
@ -348,7 +348,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
result.unit = "m";
|
||||
}
|
||||
if(depth < 10){
|
||||
snprintf(buffer,bsize,"%2.1f",depth);
|
||||
snprintf(buffer,bsize,"%3.2f",depth);
|
||||
}
|
||||
if(depth >= 10 && depth < 100){
|
||||
snprintf(buffer,bsize,"%3.1f",depth);
|
||||
|
@ -378,7 +378,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
result.unit = "K";
|
||||
}
|
||||
if(temp < 10){
|
||||
snprintf(buffer,bsize,"%2.1f",temp);
|
||||
snprintf(buffer,bsize,"%3.2f",temp);
|
||||
}
|
||||
if(temp >= 10 && temp < 100){
|
||||
snprintf(buffer,bsize,"%3.1f",temp);
|
||||
|
@ -408,7 +408,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
result.unit = "m";
|
||||
}
|
||||
if(distance < 10){
|
||||
snprintf(buffer,bsize,"%2.1f",distance);
|
||||
snprintf(buffer,bsize,"%3.2f",distance);
|
||||
}
|
||||
if(distance >= 10 && distance < 100){
|
||||
snprintf(buffer,bsize,"%3.1f",distance);
|
||||
|
@ -419,7 +419,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
}
|
||||
else{
|
||||
if(value->value < 10){
|
||||
snprintf(buffer,bsize,"%2.1f",value->value);
|
||||
snprintf(buffer,bsize,"%3.2f",value->value);
|
||||
}
|
||||
if(value->value >= 10 && value->value < 100){
|
||||
snprintf(buffer,bsize,"%3.1f",value->value);
|
||||
|
|
|
@ -40,7 +40,13 @@ public:
|
|||
|
||||
// Get boat values for Keel position
|
||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list
|
||||
if(simulation == false){
|
||||
value1 = commonData.data.rotationAngle; // Raw value without unit convertion
|
||||
}
|
||||
else{
|
||||
value1 = (170 + float(random(0, 40)) / 10.0) * 2 * PI / 360; // Simulation data in radiant
|
||||
}
|
||||
|
||||
bool valid1 = commonData.data.validRotAngle; // Valid information
|
||||
String unit1 = "Deg"; // Unit of value
|
||||
if(valid1 == true){
|
||||
|
@ -144,28 +150,21 @@ public:
|
|||
|
||||
}
|
||||
|
||||
// Print label
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.setCursor(100, 70);
|
||||
display.print("Keel Position"); // Label
|
||||
|
||||
// Print Unit of keel position
|
||||
display.setFont(&Ubuntu_Bold12pt7b);
|
||||
display.setCursor(175, 110);
|
||||
display.print(unit1); // Unit
|
||||
/*
|
||||
// Angle limits to +/-45°
|
||||
if(value1 < (-PI / 4)){
|
||||
value1 = -PI / 4;
|
||||
// Angle limits to +/-45° (Attention: 180° offset!)
|
||||
if(value1 < (3 * PI / 4)){
|
||||
value1 = 3 * PI / 4;
|
||||
}
|
||||
if(value1 > (PI / 4)){
|
||||
value1 = PI / 4;
|
||||
if(value1 > (5 * PI / 4)){
|
||||
value1 = 5 * PI / 4;
|
||||
}
|
||||
|
||||
if(holdvalues == true && valid1 == false){
|
||||
value1 = value1old;
|
||||
}
|
||||
|
||||
// Calculate keel position
|
||||
value1 = (value1 * 2) + PI;
|
||||
*/
|
||||
|
||||
// Draw keel position pointer
|
||||
float startwidth = 8; // Start width of pointer
|
||||
|
||||
|
@ -197,10 +196,21 @@ public:
|
|||
}
|
||||
|
||||
// Center circle
|
||||
display.fillCircle(200, 150, startwidth + 22, bgcolor);
|
||||
display.fillCircle(200, 150, startwidth + 20, pixelcolor);
|
||||
display.fillRect(200 - 30, 150 - 30, 2 * 30, 30, bgcolor); // Delete half top circle
|
||||
display.fillCircle(200, 140, startwidth + 22, bgcolor);
|
||||
display.fillCircle(200, 140, startwidth + 20, pixelcolor); // Boat circle
|
||||
display.fillRect(200 - 30, 140 - 30, 2 * 30, 30, bgcolor); // Delete half top of boat circle
|
||||
display.fillRect(150, 150, 100, 4, pixelcolor); // Water line
|
||||
|
||||
// Print label
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.setCursor(100, 70);
|
||||
display.print("Keel Position"); // Label
|
||||
|
||||
// Print Unit of keel position
|
||||
display.setFont(&Ubuntu_Bold12pt7b);
|
||||
display.setCursor(175, 110);
|
||||
display.print(unit1); // Unit
|
||||
|
||||
//*******************************************************************************************
|
||||
// Key Layout
|
||||
|
|
|
@ -564,9 +564,11 @@ void OBP60Task(GwApi *api){
|
|||
long starttime7 = millis(); // Rotation sensor update all 100ms
|
||||
|
||||
while (true){
|
||||
delay(10); // Fixed the problem with NMEA0183 and GPS sentences
|
||||
delay(100); // Fix the problem with NMEA0183 and GPS sentences
|
||||
Timer1.update(); // Update for Timer1
|
||||
Timer2.update(); // Update for Timer2
|
||||
LOG_DEBUG(GwLog::LOG,"Loop");
|
||||
|
||||
if(millis() > starttime0 + 100){
|
||||
starttime0 = millis();
|
||||
|
||||
|
@ -679,7 +681,7 @@ void OBP60Task(GwApi *api){
|
|||
}
|
||||
|
||||
// Send data from environment sensor all 1s
|
||||
if(millis() > starttime6 + 1000){
|
||||
if(millis() > starttime6 + 2000){
|
||||
starttime6 = millis();
|
||||
unsigned char TempSource = 2; // Inside temperature
|
||||
unsigned char PressureSource = 0; // Atmospheric pressure
|
||||
|
@ -754,8 +756,9 @@ void OBP60Task(GwApi *api){
|
|||
}
|
||||
|
||||
// Send rotation angle all 1000ms
|
||||
if(millis() > starttime7 + 1000){
|
||||
if(millis() > starttime7 + 500){
|
||||
starttime7 = millis();
|
||||
LOG_DEBUG(GwLog::LOG,"Rotation sensor");
|
||||
if(String(rotsensor) == "AS5600" && AS5600_ready == true && as5600.detectMagnet() == 1){
|
||||
rotationangle = as5600.getRawAngle() * 0.087; // 0...4095 segments = 0.087 degree
|
||||
// Offset correction
|
||||
|
@ -830,7 +833,6 @@ void OBP60Task(GwApi *api){
|
|||
currentPage->displayPage(commonData,pages[pageNumber].parameters);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
|
|
|
@ -20,7 +20,7 @@ DECLARE_INITFUNCTION(OBP60Init);
|
|||
|
||||
// OBP60 Task
|
||||
void OBP60Task(GwApi *param);
|
||||
DECLARE_USERTASK_PARAM(OBP60Task, 25000) // Need 25k RAM as stack size
|
||||
DECLARE_USERTASK_PARAM(OBP60Task, 10000) // Need 10k RAM as stack size
|
||||
DECLARE_CAPABILITY(obp60,true);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue