auto-sync

This commit is contained in:
rusEfi 2015-01-08 22:04:09 -06:00
parent e3e817b8ee
commit cdb5f18ed7
10 changed files with 62 additions and 38 deletions

View File

@ -31,7 +31,11 @@
#include "chprintf.h"
#define MAX_FILLER 11
#define FLOAT_PRECISION 100000
/**
* That's out default %f precision here. Two digits should be fine?
* That's important on the lcd screen
*/
#define FLOAT_PRECISION 100
static char *long_to_string_with_divisor(char *p,
long num,
unsigned radix,

View File

@ -42,23 +42,30 @@ void MenuTree::nextItem(void) {
topVisible = topVisible->next;
}
MenuItem::MenuItem(MenuItem * parent, const char *text, VoidCallback callback) {
lcdLine = LL_STRING;
this->text = text;
init(parent, callback);
}
MenuItem::MenuItem(MenuItem * parent, const char *text) {
lcdLine = LL_STRING;
this->text = text;
init(parent);
init(parent, NULL);
}
MenuItem::MenuItem(MenuItem * parent, lcd_line_e lcdLine) {
this->lcdLine = lcdLine;
this->text = NULL;
init(parent);
init(parent, NULL);
}
void MenuItem::init(MenuItem * parent) {
void MenuItem::init(MenuItem * parent, VoidCallback callback) {
this->parent = parent;
firstChild = NULL;
lastChild = NULL;
next = NULL;
this->callback = callback;
// root element has NULL parent
if (parent != NULL) {

View File

@ -32,8 +32,11 @@ typedef enum {
LL_IAT_FUEL_CORR,
} lcd_line_e;
typedef void (*VoidCallback)(void);
class MenuItem {
public:
MenuItem(MenuItem * parent, const char *text, VoidCallback callback);
MenuItem(MenuItem * parent, const char *text);
MenuItem(MenuItem * parent, lcd_line_e lcdLine);
const char *text;
@ -45,8 +48,9 @@ public:
MenuItem *firstChild;
MenuItem *lastChild;
MenuItem *next;
VoidCallback callback;
private:
void init(MenuItem * parent);
void init(MenuItem * parent, VoidCallback callback);
};
class MenuTree {

View File

@ -20,6 +20,7 @@
#include "utlist.h"
#include "lcd_menu_tree.h"
#include "memstreams.h"
#include "settings.h"
EXTERN_ENGINE
;
@ -43,6 +44,7 @@ static MenuItem miVBatt(&miSensors, LL_VBATT);
static MenuItem miMap(&miSensors, LL_MAP);
static MenuItem miBaro(&miSensors, LL_BARO);
static MenuItem miStopEngine(&miBench, "stop engine", stopEngine);
static MenuItem miTestFan(&miBench, "test fan");
static MenuItem miTestFuelPump(&miBench, "test pump");
static MenuItem miTestSpark1(&miBench, "test spark1");
@ -85,13 +87,11 @@ char * appendStr(char *ptr, const char *suffix) {
}
void initLcdController(void) {
tree.init(&miRpm, 3);
msObjectInit(&lcdLineStream, (uint8_t *) lcdLineBuffer,
sizeof(lcdLineBuffer), 0);
tree.init(&miRpm, engineConfiguration->HD44780height - 1);
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;
*ptr++ = 'V';
ptr = ftoa(ptr, getVBatt(engineConfiguration), 10.0f);
@ -141,8 +141,7 @@ 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;
ptr = appendStr(ptr, " ");
@ -187,8 +186,7 @@ static void showLine(lcd_line_e line) {
lcdPrintf("version %s", VCS_VERSION);
return;
case LL_CONFIG:
lcdPrintf("config %s",
getConfigurationName(engine->engineConfiguration->engineType));
lcdPrintf("config %s", getConfigurationName(engine->engineConfiguration->engineType));
return;
case LL_RPM:
lcdPrintf("RPM %d", getRpmE(engine));
@ -231,6 +229,13 @@ static void showLine(lcd_line_e line) {
}
}
static void fillWithSpaces(void) {
int column = getCurrentHD44780column();
for (int r = column; r < 20; r++) {
lcd_HD44780_print_char(' ');
}
}
void updateHD44780lcd(Engine *engine) {
MenuItem *p = tree.topVisible;
int count = 0;
@ -238,7 +243,11 @@ void updateHD44780lcd(Engine *engine) {
lcd_HD44780_set_position(count, 0);
char firstChar;
if (p == tree.current) {
firstChar = p->firstChild == NULL ? '*' : '>';
if (p->callback != NULL) {
firstChar = '!';
} else {
firstChar = p->firstChild == NULL ? '*' : '>';
}
} else {
firstChar = ' ';
}
@ -248,20 +257,21 @@ void updateHD44780lcd(Engine *engine) {
} else {
showLine(p->lcdLine);
}
int column = getCurrentHD44780column();
for (int r = column; r < 20; r++) {
lcd_HD44780_print_char(' ');
}
fillWithSpaces();
p = p->next;
}
for (; count < tree.linesCount; count++) {
lcd_HD44780_set_position(count, 0);
for (int r = 0; r < 20; r++) {
lcd_HD44780_print_char(' ');
}
fillWithSpaces();
}
memcpy(buffer, getWarninig(), engineConfiguration->HD44780width);
buffer[engineConfiguration->HD44780width] = 0;
lcd_HD44780_set_position(engineConfiguration->HD44780height - 1, 0);
lcd_HD44780_print_string(buffer);
fillWithSpaces();
//
// lcd_HD44780_set_position(0, 9);
// /**

View File

@ -749,7 +749,7 @@ static void disableIgnition(void) {
scheduleMsg(&logger, "ignition disabled");
}
static void stopEngine(Engine *engine) {
void stopEngine(void) {
engine->stopEngineRequestTimeNt = getTimeNowNt();
}
@ -818,7 +818,7 @@ void initSettings(engine_configuration_s *engineConfiguration) {
addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit);
addConsoleActionI("set_firing_order", setFiringOrder);
addConsoleActionI("set_algorithm", setAlgorithm);
addConsoleActionP("stopengine", (VoidPtr)stopEngine, engine);
addConsoleAction("stopengine", (Void)stopEngine);
// todo: refactor this - looks like all boolean flags should be controlled with less code duplication
addConsoleAction("enable_injection", enableInjection);

View File

@ -14,16 +14,7 @@
void initSettings(engine_configuration_s *engineConfiguration);
void printSpiState(Logging *logger, board_configuration_s *boardConfiguration);
void printConfiguration(engine_configuration_s *engineConfiguration);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void stopEngine(void);
void setEngineType(int value);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* INJECTOR_CONTROL_H_ */

View File

@ -444,12 +444,16 @@ uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s con
//static Logging logger;
#endif
void initTriggerDecoder(void) {
void initTriggerDecoderLogger(void) {
#if (EFI_PROD_CODE || EFI_SIMULATOR)
outputPinRegisterExt2("trg_err", &triggerDecoderErrorPin, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode);
initLogging(&logger, "trigger decoder");
#endif
}
void initTriggerDecoder(void) {
#if (EFI_PROD_CODE || EFI_SIMULATOR)
outputPinRegisterExt2("trg_err", &triggerDecoderErrorPin, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode);
#endif
}
#endif

View File

@ -91,6 +91,7 @@ class Engine;
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, Engine *engine);
void initTriggerDecoder(void);
void initTriggerDecoderLogger(void);
bool_t isTriggerDecoderError(void);

View File

@ -207,7 +207,7 @@ void initHardware(Logging *l, Engine *engine) {
* which would be used while finding trigger synch index
* while config read
*/
initTriggerDecoder();
initTriggerDecoderLogger();
/**
* We need the LED_ERROR pin even before we read configuration
@ -247,6 +247,8 @@ void initHardware(Logging *l, Engine *engine) {
return;
}
initTriggerDecoder();
mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin,
PAL_MODE_INPUT_PULLUP);
bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE();

View File

@ -31,6 +31,7 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
efitick_t now = getTimeNowNt();
if (now - lastEventTime < NT_EVENT_GAP)
return; // two consecutive events are probably just jitter
lastEventTime = now;
joyTotal++;
joystick_button_e button;
// todo: I guess it's time to reduce code duplication and start working with an array