auto-sync
This commit is contained in:
parent
e3e817b8ee
commit
cdb5f18ed7
|
@ -31,7 +31,11 @@
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
|
|
||||||
#define MAX_FILLER 11
|
#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,
|
static char *long_to_string_with_divisor(char *p,
|
||||||
long num,
|
long num,
|
||||||
unsigned radix,
|
unsigned radix,
|
||||||
|
|
|
@ -42,23 +42,30 @@ void MenuTree::nextItem(void) {
|
||||||
topVisible = topVisible->next;
|
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) {
|
MenuItem::MenuItem(MenuItem * parent, const char *text) {
|
||||||
lcdLine = LL_STRING;
|
lcdLine = LL_STRING;
|
||||||
this->text = text;
|
this->text = text;
|
||||||
init(parent);
|
init(parent, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem::MenuItem(MenuItem * parent, lcd_line_e lcdLine) {
|
MenuItem::MenuItem(MenuItem * parent, lcd_line_e lcdLine) {
|
||||||
this->lcdLine = lcdLine;
|
this->lcdLine = lcdLine;
|
||||||
this->text = NULL;
|
this->text = NULL;
|
||||||
init(parent);
|
init(parent, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItem::init(MenuItem * parent) {
|
void MenuItem::init(MenuItem * parent, VoidCallback callback) {
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
firstChild = NULL;
|
firstChild = NULL;
|
||||||
lastChild = NULL;
|
lastChild = NULL;
|
||||||
next = NULL;
|
next = NULL;
|
||||||
|
this->callback = callback;
|
||||||
|
|
||||||
// root element has NULL parent
|
// root element has NULL parent
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
|
|
|
@ -32,8 +32,11 @@ typedef enum {
|
||||||
LL_IAT_FUEL_CORR,
|
LL_IAT_FUEL_CORR,
|
||||||
} lcd_line_e;
|
} lcd_line_e;
|
||||||
|
|
||||||
|
typedef void (*VoidCallback)(void);
|
||||||
|
|
||||||
class MenuItem {
|
class MenuItem {
|
||||||
public:
|
public:
|
||||||
|
MenuItem(MenuItem * parent, const char *text, VoidCallback callback);
|
||||||
MenuItem(MenuItem * parent, const char *text);
|
MenuItem(MenuItem * parent, const char *text);
|
||||||
MenuItem(MenuItem * parent, lcd_line_e lcdLine);
|
MenuItem(MenuItem * parent, lcd_line_e lcdLine);
|
||||||
const char *text;
|
const char *text;
|
||||||
|
@ -45,8 +48,9 @@ public:
|
||||||
MenuItem *firstChild;
|
MenuItem *firstChild;
|
||||||
MenuItem *lastChild;
|
MenuItem *lastChild;
|
||||||
MenuItem *next;
|
MenuItem *next;
|
||||||
|
VoidCallback callback;
|
||||||
private:
|
private:
|
||||||
void init(MenuItem * parent);
|
void init(MenuItem * parent, VoidCallback callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MenuTree {
|
class MenuTree {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "utlist.h"
|
#include "utlist.h"
|
||||||
#include "lcd_menu_tree.h"
|
#include "lcd_menu_tree.h"
|
||||||
#include "memstreams.h"
|
#include "memstreams.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
EXTERN_ENGINE
|
EXTERN_ENGINE
|
||||||
;
|
;
|
||||||
|
@ -43,6 +44,7 @@ static MenuItem miVBatt(&miSensors, LL_VBATT);
|
||||||
static MenuItem miMap(&miSensors, LL_MAP);
|
static MenuItem miMap(&miSensors, LL_MAP);
|
||||||
static MenuItem miBaro(&miSensors, LL_BARO);
|
static MenuItem miBaro(&miSensors, LL_BARO);
|
||||||
|
|
||||||
|
static MenuItem miStopEngine(&miBench, "stop engine", stopEngine);
|
||||||
static MenuItem miTestFan(&miBench, "test fan");
|
static MenuItem miTestFan(&miBench, "test fan");
|
||||||
static MenuItem miTestFuelPump(&miBench, "test pump");
|
static MenuItem miTestFuelPump(&miBench, "test pump");
|
||||||
static MenuItem miTestSpark1(&miBench, "test spark1");
|
static MenuItem miTestSpark1(&miBench, "test spark1");
|
||||||
|
@ -85,13 +87,11 @@ char * appendStr(char *ptr, const char *suffix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initLcdController(void) {
|
void initLcdController(void) {
|
||||||
tree.init(&miRpm, 3);
|
tree.init(&miRpm, engineConfiguration->HD44780height - 1);
|
||||||
msObjectInit(&lcdLineStream, (uint8_t *) lcdLineBuffer,
|
msObjectInit(&lcdLineStream, (uint8_t *) lcdLineBuffer, sizeof(lcdLineBuffer), 0);
|
||||||
sizeof(lcdLineBuffer), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * prepareVBattMapLine(engine_configuration_s *engineConfiguration,
|
static char * prepareVBattMapLine(engine_configuration_s *engineConfiguration, char *buffer) {
|
||||||
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);
|
||||||
|
@ -141,8 +141,7 @@ char * appendPinStatus(char *buffer, io_pin_e pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * prepareInfoLine(engine_configuration_s *engineConfiguration,
|
static char * prepareInfoLine(engine_configuration_s *engineConfiguration, char *buffer) {
|
||||||
char *buffer) {
|
|
||||||
char *ptr = buffer;
|
char *ptr = buffer;
|
||||||
|
|
||||||
ptr = appendStr(ptr, " ");
|
ptr = appendStr(ptr, " ");
|
||||||
|
@ -187,8 +186,7 @@ static void showLine(lcd_line_e line) {
|
||||||
lcdPrintf("version %s", VCS_VERSION);
|
lcdPrintf("version %s", VCS_VERSION);
|
||||||
return;
|
return;
|
||||||
case LL_CONFIG:
|
case LL_CONFIG:
|
||||||
lcdPrintf("config %s",
|
lcdPrintf("config %s", getConfigurationName(engine->engineConfiguration->engineType));
|
||||||
getConfigurationName(engine->engineConfiguration->engineType));
|
|
||||||
return;
|
return;
|
||||||
case LL_RPM:
|
case LL_RPM:
|
||||||
lcdPrintf("RPM %d", getRpmE(engine));
|
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) {
|
void updateHD44780lcd(Engine *engine) {
|
||||||
MenuItem *p = tree.topVisible;
|
MenuItem *p = tree.topVisible;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -238,7 +243,11 @@ void updateHD44780lcd(Engine *engine) {
|
||||||
lcd_HD44780_set_position(count, 0);
|
lcd_HD44780_set_position(count, 0);
|
||||||
char firstChar;
|
char firstChar;
|
||||||
if (p == tree.current) {
|
if (p == tree.current) {
|
||||||
firstChar = p->firstChild == NULL ? '*' : '>';
|
if (p->callback != NULL) {
|
||||||
|
firstChar = '!';
|
||||||
|
} else {
|
||||||
|
firstChar = p->firstChild == NULL ? '*' : '>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
firstChar = ' ';
|
firstChar = ' ';
|
||||||
}
|
}
|
||||||
|
@ -248,20 +257,21 @@ void updateHD44780lcd(Engine *engine) {
|
||||||
} else {
|
} else {
|
||||||
showLine(p->lcdLine);
|
showLine(p->lcdLine);
|
||||||
}
|
}
|
||||||
int column = getCurrentHD44780column();
|
fillWithSpaces();
|
||||||
for (int r = column; r < 20; r++) {
|
|
||||||
lcd_HD44780_print_char(' ');
|
|
||||||
}
|
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; count < tree.linesCount; count++) {
|
for (; count < tree.linesCount; count++) {
|
||||||
lcd_HD44780_set_position(count, 0);
|
lcd_HD44780_set_position(count, 0);
|
||||||
for (int r = 0; r < 20; r++) {
|
fillWithSpaces();
|
||||||
lcd_HD44780_print_char(' ');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
// lcd_HD44780_set_position(0, 9);
|
||||||
// /**
|
// /**
|
||||||
|
|
|
@ -749,7 +749,7 @@ static void disableIgnition(void) {
|
||||||
scheduleMsg(&logger, "ignition disabled");
|
scheduleMsg(&logger, "ignition disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stopEngine(Engine *engine) {
|
void stopEngine(void) {
|
||||||
engine->stopEngineRequestTimeNt = getTimeNowNt();
|
engine->stopEngineRequestTimeNt = getTimeNowNt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ void initSettings(engine_configuration_s *engineConfiguration) {
|
||||||
addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit);
|
addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit);
|
||||||
addConsoleActionI("set_firing_order", setFiringOrder);
|
addConsoleActionI("set_firing_order", setFiringOrder);
|
||||||
addConsoleActionI("set_algorithm", setAlgorithm);
|
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
|
// todo: refactor this - looks like all boolean flags should be controlled with less code duplication
|
||||||
addConsoleAction("enable_injection", enableInjection);
|
addConsoleAction("enable_injection", enableInjection);
|
||||||
|
|
|
@ -14,16 +14,7 @@
|
||||||
void initSettings(engine_configuration_s *engineConfiguration);
|
void initSettings(engine_configuration_s *engineConfiguration);
|
||||||
void printSpiState(Logging *logger, board_configuration_s *boardConfiguration);
|
void printSpiState(Logging *logger, board_configuration_s *boardConfiguration);
|
||||||
void printConfiguration(engine_configuration_s *engineConfiguration);
|
void printConfiguration(engine_configuration_s *engineConfiguration);
|
||||||
|
void stopEngine(void);
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
void setEngineType(int value);
|
void setEngineType(int value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* INJECTOR_CONTROL_H_ */
|
#endif /* INJECTOR_CONTROL_H_ */
|
||||||
|
|
|
@ -444,12 +444,16 @@ uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s con
|
||||||
//static Logging logger;
|
//static Logging logger;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initTriggerDecoder(void) {
|
void initTriggerDecoderLogger(void) {
|
||||||
#if (EFI_PROD_CODE || EFI_SIMULATOR)
|
#if (EFI_PROD_CODE || EFI_SIMULATOR)
|
||||||
outputPinRegisterExt2("trg_err", &triggerDecoderErrorPin, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode);
|
|
||||||
|
|
||||||
initLogging(&logger, "trigger decoder");
|
initLogging(&logger, "trigger decoder");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initTriggerDecoder(void) {
|
||||||
|
#if (EFI_PROD_CODE || EFI_SIMULATOR)
|
||||||
|
outputPinRegisterExt2("trg_err", &triggerDecoderErrorPin, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,6 +91,7 @@ class Engine;
|
||||||
|
|
||||||
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, Engine *engine);
|
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, Engine *engine);
|
||||||
void initTriggerDecoder(void);
|
void initTriggerDecoder(void);
|
||||||
|
void initTriggerDecoderLogger(void);
|
||||||
|
|
||||||
bool_t isTriggerDecoderError(void);
|
bool_t isTriggerDecoderError(void);
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ void initHardware(Logging *l, Engine *engine) {
|
||||||
* which would be used while finding trigger synch index
|
* which would be used while finding trigger synch index
|
||||||
* while config read
|
* while config read
|
||||||
*/
|
*/
|
||||||
initTriggerDecoder();
|
initTriggerDecoderLogger();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need the LED_ERROR pin even before we read configuration
|
* We need the LED_ERROR pin even before we read configuration
|
||||||
|
@ -247,6 +247,8 @@ void initHardware(Logging *l, Engine *engine) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initTriggerDecoder();
|
||||||
|
|
||||||
mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin,
|
mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin,
|
||||||
PAL_MODE_INPUT_PULLUP);
|
PAL_MODE_INPUT_PULLUP);
|
||||||
bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE();
|
bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE();
|
||||||
|
|
|
@ -31,6 +31,7 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
||||||
efitick_t now = getTimeNowNt();
|
efitick_t now = getTimeNowNt();
|
||||||
if (now - lastEventTime < NT_EVENT_GAP)
|
if (now - lastEventTime < NT_EVENT_GAP)
|
||||||
return; // two consecutive events are probably just jitter
|
return; // two consecutive events are probably just jitter
|
||||||
|
lastEventTime = now;
|
||||||
joyTotal++;
|
joyTotal++;
|
||||||
joystick_button_e button;
|
joystick_button_e button;
|
||||||
// todo: I guess it's time to reduce code duplication and start working with an array
|
// todo: I guess it's time to reduce code duplication and start working with an array
|
||||||
|
|
Loading…
Reference in New Issue