auto-sync
This commit is contained in:
parent
1bc72b1fd5
commit
a1afc46a13
|
@ -408,7 +408,7 @@ static void printTPSInfo(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_TypeDef* port = getAdcChannelPort(engineConfiguration->tpsAdcChannel);
|
stm32_gpio_t* port = getAdcChannelPort(engineConfiguration->tpsAdcChannel);
|
||||||
int pin = getAdcChannelPin(engineConfiguration->tpsAdcChannel);
|
int pin = getAdcChannelPin(engineConfiguration->tpsAdcChannel);
|
||||||
|
|
||||||
scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax,
|
scheduleMsg(&logger, "tps min %d/max %d v=%f @%s%d", engineConfiguration->tpsMin, engineConfiguration->tpsMax,
|
||||||
|
|
|
@ -57,6 +57,8 @@ typedef unsigned int time_t;
|
||||||
typedef VirtualTimer virtual_timer_t;
|
typedef VirtualTimer virtual_timer_t;
|
||||||
typedef EventListener event_listener_t;
|
typedef EventListener event_listener_t;
|
||||||
typedef Thread thread_t;
|
typedef Thread thread_t;
|
||||||
|
typedef GPIO_TypeDef stm32_gpio_t;
|
||||||
|
|
||||||
|
|
||||||
#define THD_WORKING_AREA WORKING_AREA
|
#define THD_WORKING_AREA WORKING_AREA
|
||||||
#define THD_FUNCTION(tname, arg) void tname(void *arg)
|
#define THD_FUNCTION(tname, arg) void tname(void *arg)
|
||||||
|
|
|
@ -267,7 +267,7 @@ adc_channel_e getAdcChannel(brain_pin_e pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_TypeDef* getAdcChannelPort(adc_channel_e hwChannel) {
|
stm32_gpio_t* getAdcChannelPort(adc_channel_e hwChannel) {
|
||||||
// todo: replace this with an array :)
|
// todo: replace this with an array :)
|
||||||
switch (hwChannel) {
|
switch (hwChannel) {
|
||||||
case ADC_CHANNEL_IN0:
|
case ADC_CHANNEL_IN0:
|
||||||
|
@ -360,7 +360,7 @@ int getAdcChannelPin(adc_channel_e hwChannel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initAdcHwChannel(adc_channel_e hwChannel) {
|
static void initAdcHwChannel(adc_channel_e hwChannel) {
|
||||||
GPIO_TypeDef* port = getAdcChannelPort(hwChannel);
|
stm32_gpio_t* port = getAdcChannelPort(hwChannel);
|
||||||
int pin = getAdcChannelPin(hwChannel);
|
int pin = getAdcChannelPin(hwChannel);
|
||||||
|
|
||||||
initAdcPin(port, pin, "hw");
|
initAdcPin(port, pin, "hw");
|
||||||
|
@ -427,7 +427,7 @@ static void printFullAdcReport(void) {
|
||||||
appendMsgPrefix(&logger);
|
appendMsgPrefix(&logger);
|
||||||
|
|
||||||
adc_channel_e hwIndex = slowAdc.getAdcHardwareIndexByInternalIndex(index);
|
adc_channel_e hwIndex = slowAdc.getAdcHardwareIndexByInternalIndex(index);
|
||||||
GPIO_TypeDef* port = getAdcChannelPort(hwIndex);
|
stm32_gpio_t* port = getAdcChannelPort(hwIndex);
|
||||||
int pin = getAdcChannelPin(hwIndex);
|
int pin = getAdcChannelPin(hwIndex);
|
||||||
|
|
||||||
int adcValue = slowAdc.getAdcValueByIndex(index);
|
int adcValue = slowAdc.getAdcValueByIndex(index);
|
||||||
|
|
|
@ -283,12 +283,7 @@ static void MMCmount(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined __GNUC__
|
static THD_FUNCTION(MMCmonThread, arg) {
|
||||||
__attribute__((noreturn)) static msg_t MMCmonThread(void)
|
|
||||||
#else
|
|
||||||
static msg_t MMCmonThread(void)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
chRegSetThreadName("MMC_Monitor");
|
chRegSetThreadName("MMC_Monitor");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ static void onGpsMessage(char *buffer) {
|
||||||
// we do not want this on stack, right?
|
// we do not want this on stack, right?
|
||||||
static char gps_str[GPS_MAX_STRING];
|
static char gps_str[GPS_MAX_STRING];
|
||||||
|
|
||||||
static msg_t GpsThreadEntryPoint(void *arg) {
|
static THD_FUNCTION(GpsThreadEntryPoint, arg) {
|
||||||
(void) arg;
|
(void) arg;
|
||||||
chRegSetThreadName("GPS thread");
|
chRegSetThreadName("GPS thread");
|
||||||
|
|
||||||
|
@ -99,9 +99,6 @@ static msg_t GpsThreadEntryPoint(void *arg) {
|
||||||
gps_str[count++] = charbuf;
|
gps_str[count++] = charbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined __GNUC__
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initGps(void) {
|
void initGps(void) {
|
||||||
|
@ -115,7 +112,7 @@ void initGps(void) {
|
||||||
mySetPadMode2("GPS rx", boardConfiguration->gps_rx_pin, PAL_MODE_ALTERNATE(7));
|
mySetPadMode2("GPS rx", boardConfiguration->gps_rx_pin, PAL_MODE_ALTERNATE(7));
|
||||||
|
|
||||||
// todo: add a thread which would save location. If the GPS 5Hz - we should save the location each 200 ms
|
// todo: add a thread which would save location. If the GPS 5Hz - we should save the location each 200 ms
|
||||||
chThdCreateStatic(gpsThreadStack, sizeof(gpsThreadStack), LOWPRIO, GpsThreadEntryPoint, NULL);
|
chThdCreateStatic(gpsThreadStack, sizeof(gpsThreadStack), LOWPRIO, (tfunc_t)GpsThreadEntryPoint, NULL);
|
||||||
|
|
||||||
addConsoleAction("gpsinfo", &printGpsInfo);
|
addConsoleAction("gpsinfo", &printGpsInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ static int initialized = FALSE;
|
||||||
static LoggingWithStorage logger("pin repos");
|
static LoggingWithStorage logger("pin repos");
|
||||||
static int totalPinsUsed = 0;
|
static int totalPinsUsed = 0;
|
||||||
|
|
||||||
static GPIO_TypeDef* ports[7] = {GPIOA,
|
static stm32_gpio_t* ports[7] = {GPIOA,
|
||||||
GPIOB,
|
GPIOB,
|
||||||
GPIOC,
|
GPIOC,
|
||||||
GPIOD,
|
GPIOD,
|
||||||
|
@ -35,7 +35,7 @@ static GPIO_TypeDef* ports[7] = {GPIOA,
|
||||||
/**
|
/**
|
||||||
* @deprecated - use hwPortname() instead
|
* @deprecated - use hwPortname() instead
|
||||||
*/
|
*/
|
||||||
const char *portname(GPIO_TypeDef* GPIOx) {
|
const char *portname(stm32_gpio_t* GPIOx) {
|
||||||
if (GPIOx == GPIOA)
|
if (GPIOx == GPIOA)
|
||||||
return "PA";
|
return "PA";
|
||||||
if (GPIOx == GPIOB)
|
if (GPIOx == GPIOB)
|
||||||
|
@ -55,7 +55,7 @@ const char *portname(GPIO_TypeDef* GPIOx) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getPortIndex(GPIO_TypeDef* port) {
|
static int getPortIndex(stm32_gpio_t* port) {
|
||||||
if (port == GPIOA)
|
if (port == GPIOA)
|
||||||
return 0;
|
return 0;
|
||||||
if (port == GPIOB)
|
if (port == GPIOB)
|
||||||
|
@ -83,7 +83,7 @@ static void reportPins(void) {
|
||||||
const char *name = PIN_USED[i];
|
const char *name = PIN_USED[i];
|
||||||
int portIndex = i / PORT_SIZE;
|
int portIndex = i / PORT_SIZE;
|
||||||
int pin = i % PORT_SIZE;
|
int pin = i % PORT_SIZE;
|
||||||
GPIO_TypeDef* port = ports[portIndex];
|
stm32_gpio_t* port = ports[portIndex];
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
scheduleMsg(&logger, "pin %s%d: %s", portname(port), pin, name);
|
scheduleMsg(&logger, "pin %s%d: %s", portname(port), pin, name);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ const char *hwPortname(brain_pin_e brainPin) {
|
||||||
if (brainPin == GPIO_INVALID) {
|
if (brainPin == GPIO_INVALID) {
|
||||||
return "INVALID";
|
return "INVALID";
|
||||||
}
|
}
|
||||||
GPIO_TypeDef *hwPort = getHwPort(brainPin);
|
stm32_gpio_t *hwPort = getHwPort(brainPin);
|
||||||
if (hwPort == GPIO_NULL) {
|
if (hwPort == GPIO_NULL) {
|
||||||
return "NONE";
|
return "NONE";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include "efiGpio.h"
|
#include "efiGpio.h"
|
||||||
// does not exactly belong here, but that works better for tests
|
// does not exactly belong here, but that works better for tests
|
||||||
void outputPinRegister(const char *msg, OutputPin *output, GPIO_TypeDef *port, uint32_t pin);
|
void outputPinRegister(const char *msg, OutputPin *output, stm32_gpio_t *port, uint32_t pin);
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#define PORT_SIZE 16
|
#define PORT_SIZE 16
|
||||||
|
@ -29,12 +29,12 @@ void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t m
|
||||||
const char *hwPortname(brain_pin_e brainPin);
|
const char *hwPortname(brain_pin_e brainPin);
|
||||||
const char * getPinFunction(brain_input_pin_e brainPin);
|
const char * getPinFunction(brain_input_pin_e brainPin);
|
||||||
void mySetPadMode2(const char *msg, brain_pin_e pin, iomode_t mode);
|
void mySetPadMode2(const char *msg, brain_pin_e pin, iomode_t mode);
|
||||||
const char *portname(GPIO_TypeDef* GPIOx);
|
const char *portname(stm32_gpio_t* GPIOx);
|
||||||
void unmarkPin(brain_pin_e brainPin);
|
void unmarkPin(brain_pin_e brainPin);
|
||||||
|
|
||||||
iomode_t getInputMode(pin_input_mode_e mode);
|
iomode_t getInputMode(pin_input_mode_e mode);
|
||||||
void efiIcuStart(ICUDriver *icup, const ICUConfig *config);
|
void efiIcuStart(ICUDriver *icup, const ICUConfig *config);
|
||||||
ioportmask_t getHwPin(brain_pin_e brainPin);
|
ioportmask_t getHwPin(brain_pin_e brainPin);
|
||||||
GPIO_TypeDef * getHwPort(brain_pin_e brainPin);
|
stm32_gpio_t * getHwPort(brain_pin_e brainPin);
|
||||||
|
|
||||||
#endif /* PIN_REPOSITORY_H_ */
|
#endif /* PIN_REPOSITORY_H_ */
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
category="Fuel"
|
category="Fuel"
|
||||||
storageaddress="1a18" sizex="16"
|
storageaddress="1a18" sizex="16"
|
||||||
storagetype="float" endian="big">
|
storagetype="float" endian="big">
|
||||||
<scaling units="Target Boost (psia) Compensation (%)" expression="x" to_byte="x" format="0.00"
|
<scaling units="Compensation (%)" expression="x" to_byte="x" format="0.00"
|
||||||
fineincrement=".01" coarseincrement="0.1"/>
|
fineincrement=".01" coarseincrement="0.1"/>
|
||||||
<table type="X Axis" storageaddress="19d8" storagetype="float" endian="big">
|
<table type="X Axis" storageaddress="19d8" storagetype="float" endian="big">
|
||||||
<scaling units="uni" expression="x" to_byte="x" format="0.00" fineincrement=".1" coarseincrement="1"/>
|
<scaling units="uni" expression="x" to_byte="x" format="0.00" fineincrement=".1" coarseincrement="1"/>
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
|
|
||||||
<table type="2D" name="Intake air temperature-based extra idle air" storageaddress="1b98"
|
<table type="2D" name="Intake air temperature-based extra idle air" storageaddress="1b98"
|
||||||
sizex="16" storagetype="float" endian="big">
|
sizex="16" storagetype="float" endian="big">
|
||||||
<scaling units="Target Boost (psia) Compensation (%)" expression="x" to_byte="x" format="0.00"
|
<scaling units="Compensation (%)" expression="x" to_byte="x" format="0.00"
|
||||||
fineincrement=".01" coarseincrement="0.1"/>
|
fineincrement=".01" coarseincrement="0.1"/>
|
||||||
<table type="X Axis" storageaddress="1b58" storagetype="float" endian="big">
|
<table type="X Axis" storageaddress="1b58" storagetype="float" endian="big">
|
||||||
<scaling units="uni" expression="x" to_byte="x" format="0.00" fineincrement=".1" coarseincrement="1"/>
|
<scaling units="uni" expression="x" to_byte="x" format="0.00" fineincrement=".1" coarseincrement="1"/>
|
||||||
|
@ -127,5 +127,14 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<table type="2D" name="Engine Noise" storageaddress="7a0"
|
||||||
|
sizex="8" storagetype="float" endian="big">
|
||||||
|
<scaling units="Volts" expression="x" to_byte="x" format="0.00"
|
||||||
|
fineincrement=".01" coarseincrement="0.1"/>
|
||||||
|
<table type="X Axis" storageaddress="7c0" storagetype="float" endian="big">
|
||||||
|
<scaling units="uni" expression="x" to_byte="x" format="0.00" fineincrement=".1" coarseincrement="1"/>
|
||||||
|
</table>
|
||||||
|
</table>
|
||||||
|
|
||||||
</rom>
|
</rom>
|
||||||
</roms>
|
</roms>
|
||||||
|
|
|
@ -102,6 +102,7 @@ public class FuelTunePane {
|
||||||
synchronized (incomingDataPoints) {
|
synchronized (incomingDataPoints) {
|
||||||
for (FuelDataPoint point : incomingDataPoints)
|
for (FuelDataPoint point : incomingDataPoints)
|
||||||
data.add(point.asDataOnline());
|
data.add(point.asDataOnline());
|
||||||
|
incomingDataPoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: move this away from AWT thread
|
// todo: move this away from AWT thread
|
||||||
|
|
|
@ -38,25 +38,7 @@ public class IniFileModel {
|
||||||
State state = State.SKIPPING;
|
State state = State.SKIPPING;
|
||||||
|
|
||||||
while ((line = d.readLine()) != null) {
|
while ((line = d.readLine()) != null) {
|
||||||
LinkedList<String> list = new LinkedList<>(Arrays.asList(line.split("[\t =,]")));
|
handleLine(line);
|
||||||
|
|
||||||
trim(list);
|
|
||||||
|
|
||||||
if (list.isEmpty())
|
|
||||||
continue;
|
|
||||||
String first = list.getFirst();
|
|
||||||
|
|
||||||
if ("dialog".equals(first)) {
|
|
||||||
list.removeFirst();
|
|
||||||
state = State.DIALOG;
|
|
||||||
trim(list);
|
|
||||||
String keyword = list.removeFirst();
|
|
||||||
trim(list);
|
|
||||||
String name = list.isEmpty() ? null : list.removeFirst();
|
|
||||||
|
|
||||||
System.out.println("Dialog " + keyword + ": " + name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,6 +47,49 @@ public class IniFileModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleLine(String line) {
|
||||||
|
try {
|
||||||
|
LinkedList<String> list = new LinkedList<>(Arrays.asList(split(line)));
|
||||||
|
|
||||||
|
trim(list);
|
||||||
|
|
||||||
|
if (list.isEmpty())
|
||||||
|
return;
|
||||||
|
String first = list.getFirst();
|
||||||
|
|
||||||
|
if ("dialog".equals(first)) {
|
||||||
|
handleDialog(list);
|
||||||
|
|
||||||
|
} else if ("field".equals(first)) {
|
||||||
|
handleField(list);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
throw new IllegalStateException("While [" + line + "]", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleField(LinkedList<String> list) {
|
||||||
|
list.removeFirst(); // "field"
|
||||||
|
|
||||||
|
String label = list.isEmpty() ? "" : list.removeFirst();
|
||||||
|
|
||||||
|
String name = list.isEmpty() ? null : list.removeFirst();
|
||||||
|
|
||||||
|
System.out.println("Field label=[" + label + "] : name=[" + name + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDialog(LinkedList<String> list) {
|
||||||
|
State state;
|
||||||
|
list.removeFirst(); // "dialog"
|
||||||
|
state = State.DIALOG;
|
||||||
|
// trim(list);
|
||||||
|
String keyword = list.removeFirst();
|
||||||
|
// trim(list);
|
||||||
|
String name = list.isEmpty() ? null : list.removeFirst();
|
||||||
|
|
||||||
|
System.out.println("Dialog key=" + keyword + ": name=[" + name + "]");
|
||||||
|
}
|
||||||
|
|
||||||
private void trim(LinkedList<String> list) {
|
private void trim(LinkedList<String> list) {
|
||||||
while (!list.isEmpty() && list.getFirst().isEmpty())
|
while (!list.isEmpty() && list.getFirst().isEmpty())
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
|
@ -81,7 +106,7 @@ public class IniFileModel {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
char c = str.charAt(i);
|
char c = str.charAt(i);
|
||||||
if (c == '\"' || c == ' ' && !inQuote) {
|
if (c == '\"' || isWhitespace(c) && !inQuote) {
|
||||||
if (c == '\"')
|
if (c == '\"')
|
||||||
inQuote = !inQuote;
|
inQuote = !inQuote;
|
||||||
if (!inQuote && sb.length() > 0) {
|
if (!inQuote && sb.length() > 0) {
|
||||||
|
@ -97,4 +122,8 @@ public class IniFileModel {
|
||||||
return strings.toArray(new String[strings.size()]);
|
return strings.toArray(new String[strings.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isWhitespace(int c) {
|
||||||
|
return c == ' ' || c == '\t' || c == '=' || c == ',';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.rusefi.ui.config.test;
|
||||||
import com.rusefi.ui.config.IniFileModel;
|
import com.rusefi.ui.config.IniFileModel;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,4 +31,19 @@ public class IniFileModelTest {
|
||||||
assertEquals(s.length, 2);
|
assertEquals(s.length, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testQuotedTokens() {
|
||||||
|
{
|
||||||
|
String[] s = IniFileModel.split("\"hel lo\"");
|
||||||
|
assertEquals(s.length, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRealLine() {
|
||||||
|
String[] s = IniFileModel.split("\tdialog = engineChars,\t\"Base Engine Settings\"");
|
||||||
|
assertEquals(s.length, 3);
|
||||||
|
System.out.println(Arrays.toString(s));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue