auto-sync

This commit is contained in:
rusEfi 2015-01-08 10:05:05 -06:00
parent 493f09337a
commit 7d35f9bee5
4 changed files with 82 additions and 42 deletions

View File

@ -312,6 +312,8 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
engineConfiguration->diffLoadEnrichmentCoef = 1; engineConfiguration->diffLoadEnrichmentCoef = 1;
engineConfiguration->hasMapSensor = true; engineConfiguration->hasMapSensor = true;
engineConfiguration->hasMafSensor = true;
engineConfiguration->hasTpsSensor = true;
engineConfiguration->hasAfrSensor = true; engineConfiguration->hasAfrSensor = true;
engineConfiguration->hasCltSensor = true; engineConfiguration->hasCltSensor = true;
engineConfiguration->hasBaroSensor = false; engineConfiguration->hasBaroSensor = false;

View File

@ -533,6 +533,8 @@ typedef struct {
bool_t hasVehicleSpeedSensor : 1; // bit 9 bool_t hasVehicleSpeedSensor : 1; // bit 9
bool_t isJoystickEnabled : 1; // bit 10 bool_t isJoystickEnabled : 1; // bit 10
bool_t isGpsEnabled : 1; // bit 11 bool_t isGpsEnabled : 1; // bit 11
bool_t hasMafSensor : 1; // bit 12
bool_t hasTpsSensor : 1; // bit 13
int unused6284; int unused6284;

View File

@ -11,10 +11,25 @@ typedef enum {
LL_STRING, LL_STRING,
LL_VERSION, LL_VERSION,
LL_CONFIG, LL_CONFIG,
LL_ALGORITHM,
LL_RPM, LL_RPM,
LL_TRIGGER_ERRORS,
LL_TRIGGER_DUTY,
LL_CLT_TEMPERATURE, LL_CLT_TEMPERATURE,
LL_IAT_TEMPERATURE, LL_IAT_TEMPERATURE,
LL_ALGORITHM, LL_TPS,
LL_VBATT,
LL_MAF,
LL_MAP,
LL_EGO,
LL_BARO,
LL_BASE_FUEL,
LL_TOTAL_FUEL,
LL_CLT_FUEL_CORR,
LL_IAT_FUEL_CORR,
} lcd_line_e; } lcd_line_e;
class MenuItem { class MenuItem {

View File

@ -19,6 +19,7 @@
#include "joystick.h" #include "joystick.h"
#include "utlist.h" #include "utlist.h"
#include "lcd_menu_tree.h" #include "lcd_menu_tree.h"
#include "memstreams.h"
EXTERN_ENGINE EXTERN_ENGINE
; ;
@ -29,12 +30,18 @@ static MenuTree tree(&ROOT);
static MenuItem miRpm(tree.root, LL_RPM); static MenuItem miRpm(tree.root, LL_RPM);
static MenuItem miSensors(tree.root, "sensors"); static MenuItem miSensors(tree.root, "sensors");
static MenuItem miTrigger(tree.root, "trigger");
static MenuItem miBench(tree.root, "bench test"); static MenuItem miBench(tree.root, "bench test");
static MenuItem miAbout(tree.root, "about"); static MenuItem miAbout(tree.root, "about");
static MenuItem miTriggerErrors(&miRpm, LL_TRIGGER_ERRORS);
static MenuItem miTriggerDuty(&miRpm, LL_TRIGGER_DUTY);
static MenuItem miClt(&miSensors, LL_CLT_TEMPERATURE); static MenuItem miClt(&miSensors, LL_CLT_TEMPERATURE);
static MenuItem miIat(&miSensors, LL_IAT_TEMPERATURE); static MenuItem miIat(&miSensors, LL_IAT_TEMPERATURE);
static MenuItem miTps(&miSensors, LL_TPS);
static MenuItem miVBatt(&miSensors, LL_VBATT);
static MenuItem miMap(&miSensors, LL_MAP);
static MenuItem miBaro(&miSensors, LL_BARO);
static MenuItem miTestFan(&miBench, "test fan"); static MenuItem miTestFan(&miBench, "test fan");
static MenuItem miTestFuelPump(&miBench, "test pump"); static MenuItem miTestFuelPump(&miBench, "test pump");
@ -49,10 +56,13 @@ static MenuItem miTestInj4(&miBench, "test injector4");
static MenuItem miVersion(&miAbout, LL_VERSION); static MenuItem miVersion(&miAbout, LL_VERSION);
static MenuItem miConfig(&miAbout, LL_CONFIG); static MenuItem miConfig(&miAbout, LL_CONFIG);
//static MenuItem miAlgo(&miAbout, LL_ALGORITHM); static MenuItem miAlgo(&miAbout, LL_ALGORITHM);
#define DISP_LINES (engineConfiguration->HD44780height - 1) #define DISP_LINES (engineConfiguration->HD44780height - 1)
static char lcdLineBuffer[30];
static MemoryStream lcdLineStream;
void onJoystick(joystick_button_e button) { void onJoystick(joystick_button_e button) {
/** /**
* this method is invoked on EXTI IRQ thread * this method is invoked on EXTI IRQ thread
@ -76,9 +86,12 @@ char * appendStr(char *ptr, const char *suffix) {
void initLcdController(void) { void initLcdController(void) {
tree.init(&miRpm, 3); tree.init(&miRpm, 3);
msObjectInit(&lcdLineStream, (uint8_t *) lcdLineBuffer,
sizeof(lcdLineBuffer), 0);
} }
static char * prepareVBattMapLine(engine_configuration_s *engineConfiguration, char *buffer) { static char * prepareVBattMapLine(engine_configuration_s *engineConfiguration,
char *buffer) {
char *ptr = buffer; char *ptr = buffer;
*ptr++ = 'V'; *ptr++ = 'V';
ptr = ftoa(ptr, getVBatt(engineConfiguration), 10.0f); ptr = ftoa(ptr, getVBatt(engineConfiguration), 10.0f);
@ -97,7 +110,6 @@ static char * prepareCltIatTpsLine(Engine *engine, char *buffer) {
return ptr; return ptr;
} }
static const char* algorithmStr[] = { "MAF", "TPS", "MAP", "SD" };
static const char* ignitionModeStr[] = { "1C", "IND", "WS" }; static const char* ignitionModeStr[] = { "1C", "IND", "WS" };
static const char* injectionModeStr[] = { "Sim", "Seq", "Bch" }; static const char* injectionModeStr[] = { "Sim", "Seq", "Bch" };
static const char* idleModeStr[] = { "I:A", "I:M" }; static const char* idleModeStr[] = { "I:A", "I:M" };
@ -129,7 +141,8 @@ char * appendPinStatus(char *buffer, io_pin_e pin) {
} }
} }
static char * prepareInfoLine(engine_configuration_s *engineConfiguration, char *buffer) { static char * prepareInfoLine(engine_configuration_s *engineConfiguration,
char *buffer) {
char *ptr = buffer; char *ptr = buffer;
ptr = appendStr(ptr, " "); ptr = appendStr(ptr, " ");
@ -157,33 +170,63 @@ static char * prepareStatusLine(char *buffer) {
static char buffer[MAX_LCD_WIDTH + 4]; static char buffer[MAX_LCD_WIDTH + 4];
static char dateBuffer[30]; static char dateBuffer[30];
static void lcdPrintf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
lcdLineStream.eos = 0; // reset
chvprintf((BaseSequentialStream *) &lcdLineStream, fmt, ap);
lcdLineStream.buffer[lcdLineStream.eos] = 0; // terminator
va_end(ap);
lcd_HD44780_print_string(lcdLineBuffer);
}
static void showLine(lcd_line_e line) { static void showLine(lcd_line_e line) {
switch (line) { switch (line) {
case LL_VERSION: case LL_VERSION:
lcd_HD44780_print_string("version "); lcdPrintf("version %s", VCS_VERSION);
lcd_HD44780_print_string(VCS_VERSION);
return; return;
case LL_CONFIG: case LL_CONFIG:
lcd_HD44780_print_string("config "); lcdPrintf("config %s",
lcd_HD44780_print_string(getConfigurationName(engine->engineConfiguration->engineType)); getConfigurationName(engine->engineConfiguration->engineType));
return; return;
case LL_RPM: case LL_RPM:
lcd_HD44780_print_string("RPM "); lcdPrintf("RPM %d", getRpmE(engine));
itoa10(buffer, getRpmE(engine));
lcd_HD44780_print_string(buffer);
return; return;
case LL_CLT_TEMPERATURE: case LL_CLT_TEMPERATURE:
lcd_HD44780_print_string("Coolant "); lcdPrintf("Coolant %f", getCoolantTemperature(engine));
ftoa(buffer, getCoolantTemperature(engine), 10.0f);
lcd_HD44780_print_string(buffer);
return; return;
case LL_IAT_TEMPERATURE: case LL_IAT_TEMPERATURE:
lcd_HD44780_print_string("Intake Air "); lcdPrintf("Intake Air %f", getIntakeAirTemperature(engine));
ftoa(buffer, getIntakeAirTemperature(engine), 10.0f);
lcd_HD44780_print_string(buffer);
return; return;
case LL_ALGORITHM: case LL_ALGORITHM:
lcd_HD44780_print_string(getEngine_load_mode_e(engineConfiguration->algorithm)); lcdPrintf(getEngine_load_mode_e(engineConfiguration->algorithm));
return;
case LL_TPS:
lcdPrintf("Throttle %f%%", getTPS());
return;
case LL_VBATT:
lcdPrintf("Battery %fv", getVBatt(engineConfiguration));
return;
case LL_BARO:
if (engineConfiguration->hasBaroSensor) {
lcdPrintf("Baro: none");
} else {
lcdPrintf("Baro: %f", getBaroPressure());
}
return;
case LL_MAP:
if (engineConfiguration->hasMapSensor) {
lcdPrintf("MAP: none");
} else {
lcdPrintf("MAP %s", getMap());
}
return;
case LL_TRIGGER_ERRORS:
lcdPrintf("Errors");
return;
case LL_TRIGGER_DUTY:
lcdPrintf("Duty");
return; return;
} }
} }
@ -219,28 +262,6 @@ void updateHD44780lcd(Engine *engine) {
} }
} }
// for (int i = infoIndex; i < infoIndex + DISP_LINES; i++) {
// lcd_HD44780_set_position(i - infoIndex, 0);
//
// lcd_HD44780_print_char(cursorY == i ? '*' : ' ');
//
// showLine((lcd_line_e) i);
//
// int column = getCurrentHD44780column();
//
// for (int r = column; r < 20; r++) {
// lcd_HD44780_print_char(' ');
// }
// }
// lcd_HD44780_set_position(0, 0);
// bool_t isEven = getTimeNowSeconds() % 2 == 0;
//
// if (isEven) {
//
// } else {
//
// }
// //
// lcd_HD44780_set_position(0, 9); // lcd_HD44780_set_position(0, 9);
// /** // /**