Hellen says cyclic buffer

This commit is contained in:
rusefi 2020-09-07 11:31:29 -04:00
parent 375e3b6bcc
commit d06690b3b6
3 changed files with 116 additions and 37 deletions

View File

@ -33,7 +33,7 @@ enable2ndByteCanID = false
[MegaTune]
; https://rusefi.com/forum/viewtopic.php?p=36201#p36201
signature = @@TS_SIGNATURE@@
signature = @@TS_SIGNATURE@@
[TunerStudio]
queryCommand = "S"
@ -285,7 +285,7 @@ enable2ndByteCanID = false
calibrationValue = scalar, F32, 128, "", 1, 0
calibrationMode = scalar, U08, 132, "", 1, 0
; 1 bytes padding1
fuelingLoad = scalar, U16, 134, "%", 0.01, 0
ignitionLoad = scalar, U16, 136, "%", 0.01, 0
@ -440,7 +440,7 @@ enable2ndByteCanID = false
requiresPowerCycle = etb_use_two_wires
requiresPowerCycle = etbFreq
requiresPowerCycle = idle_solenoidFrequency
requiresPowerCycle = boostPwmFrequency
requiresPowerCycle = alternatorPwmFrequency
@ -448,7 +448,7 @@ enable2ndByteCanID = false
requiresPowerCycle = auxPidFrequency2
requiresPowerCycle = auxPidFrequency3
requiresPowerCycle = auxPidFrequency4
requiresPowerCycle = fsioOutputPins1
requiresPowerCycle = fsioOutputPins2
requiresPowerCycle = fsioOutputPins3
@ -465,7 +465,7 @@ enable2ndByteCanID = false
requiresPowerCycle = fsioOutputPins14
requiresPowerCycle = fsioOutputPins15
requiresPowerCycle = fsioOutputPins16
requiresPowerCycle = fsioFrequency1
requiresPowerCycle = fsioFrequency2
requiresPowerCycle = fsioFrequency3
@ -482,12 +482,12 @@ enable2ndByteCanID = false
requiresPowerCycle = fsioFrequency14
requiresPowerCycle = fsioFrequency15
requiresPowerCycle = fsioFrequency16
requiresPowerCycle = fsioAdc1
requiresPowerCycle = fsioAdc2
requiresPowerCycle = fsioAdc3
requiresPowerCycle = fsioAdc4
readOnly = warning_message
@ -738,7 +738,7 @@ enable2ndByteCanID = false
yBins = boostTpsBins, TPSValue
zBins = boostTableClosedLoop
table = fsioTable1Tbl, fsioTable1Map, "FSIO Table #1", 1
xBins = fsioTable1RpmBins, RPMValue
@ -1050,14 +1050,14 @@ gaugeCategory = Knock
indicator = { sd_status & 8}, "SD Log", "SD Log", white, black, green, black
indicator = { sd_status & 16}, "SD Err", "SD Err", white, black, red, black
; this is required so that the "config error" feature works in TS
; this is required so that the "config error" feature works in TS
; don't change this line - TS is looking for an indicator with particular text/styling
; you don't even have to show it by default
indicator = { ind_hasFatalError }, "Config Error", "Config Error", white, black, red, black
; minor info
indicator = { ind_fan}, "fan off", "fan on", white, black, green, black
indicator = { isCylinderCleanupActivated}, "no cyl cleanup", "cyl cleanup", white, black, yellow, black
indicator = { isCylinderCleanupActivated}, "no cyl cleanup", "cyl cleanup", white, black, yellow, black
indicator = { needBurn }, "config ok", "unsaved changes", white, black, yellow, black
indicator = { hasSdCard}, "no SD", "with SD", white, black, green, black
indicator = { ind_fuel_pump}, "pump off", "pump on", white, black, green, black
@ -1082,7 +1082,7 @@ gaugeCategory = Knock
[KeyActions]
showPanel = spi, spiFunction
showPanel = con, connection
showPanel = con, connection
[Datalog]
; Channel Label Type Format
@ -1207,7 +1207,7 @@ gaugeCategory = Knock
entry = knock6, "Knock 6", int, "%d"
entry = knock7, "Knock 7", int, "%d"
entry = knock8, "Knock 8", int, "%d"
; tpsADC = U16, "ADC",
; alignmet = U16, "al",
; atmPres = F32, "pres",
@ -1315,7 +1315,7 @@ menuDialog = main
subMenu = cltIdleCurve, "CLT multiplier"
subMenu = iacCoastingCurve, "Coasting IAC Position for Auto-Idle", 0, {useIacTableForCoasting == 1}
menu = "&Advanced"
menu = "&Advanced"
subMenu = boostDialog, "Boost Control"
subMenu = boostPidDialog, "Closed Loop Boost", { boostType == 1 }
@ -1399,7 +1399,7 @@ menuDialog = main
subMenu = sdCard, "SD Card Logger" @@if_ts_show_sd_card
subMenu = connection, "Connection"
subMenu = tle8888, "TLE8888"
subMenu = allPins1, "Full pinout 1/3" @@if_ts_show_full_pinout
subMenu = allPins2, "Full pinout 2/3" @@if_ts_show_full_pinout
subMenu = allPins3_1_and_2 "Full pinout 3/3" @@if_ts_show_full_pinout
@ -1419,7 +1419,7 @@ menuDialog = main
subMenu = etbDialog, "Electronic throttle body (beta version)" @@if_ts_show_etb
subMenu = etbTpsBiasCurve, "Electronic throttle body bias curve" @@if_ts_show_etb
subMenu = pedalToTpsTbl, "Electronic Pedal Map" @@if_ts_show_etb
subMenu = std_separator
subMenu = std_separator
# subMenu = smLaunchControl, "Launch Control"
# subMenu = std_separator
# subMenu = smRollingLaunch, "Rolling Launch"
@ -1462,7 +1462,7 @@ cmd_test_spk13 = "@@TS_IO_TEST_COMMAND_char@@\x00\x12\x00\x0d"
cmd_test_spk14 = "@@TS_IO_TEST_COMMAND_char@@\x00\x12\x00\x0e"
cmd_test_spk15 = "@@TS_IO_TEST_COMMAND_char@@\x00\x12\x00\x0f"
cmd_test_spk16 = "@@TS_IO_TEST_COMMAND_char@@\x00\x12\x00\x10"
cmd_test_inj1 = "@@TS_IO_TEST_COMMAND_char@@@@CMD_TS_INJECTOR_CATEGORY@@\x00\x01"
cmd_test_inj2 = "@@TS_IO_TEST_COMMAND_char@@@@CMD_TS_INJECTOR_CATEGORY@@\x00\x02"
@ -1588,7 +1588,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Ignition Pin 1", ignitionPins1, {isIgnitionEnabled == 1}
; see rusefi_config.txt comment next to 'ignitionPin2logic' which says
; this section is auto-generated by FiringOrderTSLogic.java
@@FIRINGORDER@@
@@FIRINGORDER@@
field = "This is useful to have tachometer working"
field = " while converting from distributor"
field = "Dizzy out Pin", dizzySparkOutputPin, {isIgnitionEnabled == 1}
@ -1660,7 +1660,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Invert Cam/VVT", invertCamVVTSignal
panel = triggerInputComparator @@if_ts_show_trigger_comparator
dialog = triggerConfiguration
panel = triggerConfiguration_settings, North, { consumeObdSensors == 0 }
panel = triggerInputs, South, { consumeObdSensors == 0 }
@ -1834,7 +1834,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
panel = pedalSensorLeft, West
panel = pedalGauges, East
dialog = mc33Dialog, "GDI Dreams"
dialog = mc33Dialog, "GDI Dreams"
field = "MC33816 cs", mc33816_cs
field = "MC33816 rstb", mc33816_rstb
field = "MC33816 flag0", mc33816_flag0
@ -1853,7 +1853,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Hold current target", mc33_i_hold
field = "mc33_t_hold_off ?????", mc33_t_hold_off
field = "Maximum injection duration", mc33_t_hold_tot
; Sensor Inputs
dialog = otherSensorInputs, "Other Sensor Inputs"
@ -2044,6 +2044,10 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "LIS302DLCsPin", LIS302DLCsPin
field = "MIL / Check Engine", malfunctionIndicatorPin
field = "Saab CDM knock", cdmInputPin
field = "DRV8860 CS", drv8860_cs
field = "DRV8860 CS Mode", drv8860_csPinMode
field = "DRV8860 MISO pin", drv8860_miso
field = "DRV8860 SPI", drv8860spiDevice
field = "comm status light", communicationLedPin
field = "running status light", runningLedPin
@ -2142,7 +2146,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
dialog = iatSensor, "IAT Sensor", border
panel = iat_thermistor, West
panel = iatGauges, East
; Sensors->Oil pressure sensor
dialog = oilp_settings, "Oil Pressure Sensor"
field = "Oil Pressure ADC input", oilPressure_hwChannel
@ -2549,7 +2553,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
panel = batteryDialog
panel = alternator
panel = startStopDialog
dialog = speedSensorAnalog
field = "Input pin", vehicleSpeedSensorInputPin
field = "revolution to speed mult", vehicleSpeedCoef
@ -2565,7 +2569,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
dialog = speedSensor, "Speed sensor", xAxis
panel = speedSensorLeft
gauge = VSSGauge
; Engine->Other inputs
dialog = analogInputSettings, "Analog Input Settings"
field = "!ECU reboot needed to apply these settings"
@ -2841,10 +2845,10 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "use FSIO #5 for critical engine stop", useFSIO5ForCriticalIssueEngineStop
field = "#5", fsioFormulas5
field = "use FSIO #6 for rev limiter", useFSIO6ForRevLimiter
field = "#6", fsioFormulas6
field = "#7", fsioFormulas7
field = "use FSIO #8 for servo #1", useFSIO8ForServo1
@ -2889,8 +2893,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Control Mode", boostType, { isBoostControlEnabled }
field = "Output", boostControlPin, { isBoostControlEnabled }
field = "Output Mode", boostControlPinMode, { isBoostControlEnabled }
field = "Frequency", boostPwmFrequency, { isBoostControlEnabled }
field = "Frequency", boostPwmFrequency, { isBoostControlEnabled }
dialog = boostDialog, "", border
panel = boost_left, West
panel = boostTableTbl, Center
@ -2898,20 +2902,20 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
;Boost Closed Loop
dialog = boostPidleft, ""
field = "P Gain", boostPid_pFactor, { isBoostControlEnabled && boostType == 1 }
field = "I Gain", boostPid_iFactor, { isBoostControlEnabled && boostType == 1 }
field = "D Gain", boostPid_dFactor, { isBoostControlEnabled && boostType == 1 }
field = "Control Period", boostPid_periodMs, { isBoostControlEnabled && boostType == 1 }
field = "Min Duty", boostPid_minValue, { isBoostControlEnabled && boostType == 1 }
field = "Max Duty", boostPid_maxValue, { isBoostControlEnabled && boostType == 1 }
field = "P Gain", boostPid_pFactor, { isBoostControlEnabled && boostType == 1 }
field = "I Gain", boostPid_iFactor, { isBoostControlEnabled && boostType == 1 }
field = "D Gain", boostPid_dFactor, { isBoostControlEnabled && boostType == 1 }
field = "Control Period", boostPid_periodMs, { isBoostControlEnabled && boostType == 1 }
field = "Min Duty", boostPid_minValue, { isBoostControlEnabled && boostType == 1 }
field = "Max Duty", boostPid_maxValue, { isBoostControlEnabled && boostType == 1 }
dialog = boostTableDialog, "", card
panel = boostTable2Tbl
dialog = boostPidDialog, "", border
panel = boostPidleft, West
panel = boostTableDialog, Center
panel = boostTableDialog, Center
help = veTableDialogHelp, "Volumetric Efficiency"
text = "Volumetric Efficiency is used to calculate fuel in Speed Density mode"
webHelp = "https://rusefi.com/s/fuel"
@ -3096,7 +3100,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Ignition Cut", launchSparkCutEnable, {launchControlEnabled == 1}
field = "Fuel Cut", launchFuelCutEnable, {launchControlEnabled == 1}
field = "Hard Cut RPM Range", hardCutRpmRange, {launchControlEnabled == 1}

View File

@ -41,7 +41,7 @@ class cyclic_buffer
volatile T elements[maxSize];
volatile int currentIndex;
private:
protected:
void baseC(int size);
/**
* number of elements added into this buffer, would be eventually bigger then size

View File

@ -0,0 +1,75 @@
/**
* @file fifo_buffer.h
* @brief A FIFO buffer (base on cyclic_buffer)
*
* https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)
*
* @date Aug 6, 2020
* @author andreika <prometheus.pcb@gmail.com>
* @author Andrey Belomutskiy
*
*/
#ifndef FIFO_BUFFER_H
#define FIFO_BUFFER_H
#include "cyclic_buffer.h"
// todo: this is not a thread-safe version!
template<typename T, size_t maxSize = CB_MAX_SIZE>
class fifo_buffer : public cyclic_buffer<T, maxSize> {
public:
fifo_buffer() : currentIndexRead(0) {
}
void put(T item);
T get();
void clear() /*override*/;
void put(const T *items, int numItems);
bool isEmpty() const {
return getCount() == 0;
}
bool isFull() const {
return getCount() >= getSize();
}
public:
volatile int currentIndexRead; // FIFO "tail"
};
template<typename T, size_t maxSize>
void fifo_buffer<T, maxSize>::put(T item) {
// check if full
if (!isFull()) {
cyclic_buffer::add(item);
}
}
template<typename T, size_t maxSize>
void fifo_buffer<T, maxSize>::put(const T *items, int numItems) {
for (int i = 0; i < numItems; i++) {
put(items[i]);
}
}
template<typename T, size_t maxSize>
T fifo_buffer<T, maxSize>::get() {
auto ret = elements[currentIndexRead];
if (!isEmpty()) {
currentIndexRead = (currentIndexRead + 1) % size;
count--;
}
return ret;
}
template<typename T, size_t maxSize>
void fifo_buffer<T, maxSize>::clear() {
cyclic_buffer::clear();
currentIndexRead = 0;
}
#endif /* FIFO_BUFFER_H */