mirror of
https://github.com/stevenhowes/MX5-Arduino.git
synced 2026-05-27 00:03:37 +01:00
Clean up of debug prints, and safer CAS handling
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "schedule.h"
|
#include "schedule.h"
|
||||||
#include "tables.h"
|
#include "tables.h"
|
||||||
|
void(* resetFunc) (void) = 0; //declare reset function @ address 0
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Sensors
|
// Sensors
|
||||||
@@ -45,4 +46,3 @@ void loop() {
|
|||||||
// Run scheduler
|
// Run scheduler
|
||||||
schedule_process();
|
schedule_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ void battery_init()
|
|||||||
{
|
{
|
||||||
Serial.println("ERR: Battery high");
|
Serial.println("ERR: Battery high");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.println("INF: Battery ok");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_battery_run()
|
void task_battery_run()
|
||||||
@@ -27,5 +23,3 @@ void task_battery_run()
|
|||||||
// Nudge it along so we have an index starting at 0 for tables etc
|
// Nudge it along so we have an index starting at 0 for tables etc
|
||||||
battery_voltage_index = constrain(battery_voltage_value,7,16) - 7;
|
battery_voltage_index = constrain(battery_voltage_value,7,16) - 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,13 @@ void cas_process()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Clear it if we're in sync, but don't clear log flag
|
// Clear it if we're in sync, but don't clear log flag
|
||||||
cas_sync_fail = 0;
|
if(cas_sync_initial == 1)
|
||||||
|
{
|
||||||
|
cas_sync_initial = 0;
|
||||||
|
cas_sync_fail = 0;
|
||||||
|
cas_sync_fail_log = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this number because we KNOW it's right
|
// Use this number because we KNOW it's right
|
||||||
@@ -137,7 +143,3 @@ void cas_process()
|
|||||||
}
|
}
|
||||||
cas_sgc_lastvalue = sgc;
|
cas_sgc_lastvalue = sgc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ unsigned long cas_sgc_lastrise = 0; // micros() of the las
|
|||||||
unsigned long cas_sgc_lastfall = 0; // "" of the last fall
|
unsigned long cas_sgc_lastfall = 0; // "" of the last fall
|
||||||
byte cas_sgc_lastvalue = 0; // The state of SGC on the previous cycle
|
byte cas_sgc_lastvalue = 0; // The state of SGC on the previous cycle
|
||||||
|
|
||||||
|
byte cas_sync_initial = 1;
|
||||||
byte cas_sync_fail = 0; // We lost track of a cylinder
|
byte cas_sync_fail = 0; // We lost track of a cylinder
|
||||||
byte cas_sync_fail_log = 0; // We need to output this in debug
|
byte cas_sync_fail_log = 0; // We need to output this in debug
|
||||||
|
|
||||||
@@ -57,4 +58,3 @@ byte throttle_current_value = 0; // Percentage
|
|||||||
byte throttle_previous_1_value = 0; // Percentage
|
byte throttle_previous_1_value = 0; // Percentage
|
||||||
byte throttle_previous_2_value = 0; // Percentage
|
byte throttle_previous_2_value = 0; // Percentage
|
||||||
byte throttle_delta = 0; // Difference between current and delta
|
byte throttle_delta = 0; // Difference between current and delta
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ void task_debug_run()
|
|||||||
// Log if we're out of sync timing-wise
|
// Log if we're out of sync timing-wise
|
||||||
if(cas_sync_fail_log > 0)
|
if(cas_sync_fail_log > 0)
|
||||||
{
|
{
|
||||||
Serial.println("ERR: CAS sync fail");
|
if(cas_sync_initial == 0)
|
||||||
|
{
|
||||||
|
Serial.println("ERR: CAS sync fail");
|
||||||
|
}
|
||||||
cas_sync_fail_log = 0;
|
cas_sync_fail_log = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +141,14 @@ void task_debug_run()
|
|||||||
}else if(readbyte == 'R') // Enable RPM output
|
}else if(readbyte == 'R') // Enable RPM output
|
||||||
{
|
{
|
||||||
debug_rpm = 1;
|
debug_rpm = 1;
|
||||||
|
}else if(readbyte == 'S') // Arduino reset
|
||||||
|
{
|
||||||
|
resetFunc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow it to re-sync (i.e. reset CAS failure as it was intentional)
|
||||||
|
cas_sync_initial = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outputs the fuel table as JSON
|
// Outputs the fuel table as JSON
|
||||||
@@ -200,4 +209,3 @@ void task_debug_safekill()
|
|||||||
cas_sync_fail=1;
|
cas_sync_fail=1;
|
||||||
cas_sync_fail_log=0;
|
cas_sync_fail_log=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ void map_init()
|
|||||||
Serial.println("ERR: MAP low");
|
Serial.println("ERR: MAP low");
|
||||||
else if(map_current_value > 108)
|
else if(map_current_value > 108)
|
||||||
Serial.println("ERR: MAP high ");
|
Serial.println("ERR: MAP high ");
|
||||||
else
|
|
||||||
Serial.println("INF: MAP ok");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_map_run()
|
void task_map_run()
|
||||||
@@ -17,5 +15,3 @@ void task_map_run()
|
|||||||
map_current_index = map(map_current_value, map_range_min, map_range_max, 0, 15);
|
map_current_index = map(map_current_value, map_range_min, map_range_max, 0, 15);
|
||||||
map_current_index = constrain(map_current_index,0,15);
|
map_current_index = constrain(map_current_index,0,15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user