Dfi now works and all vpdiag compatible, also cleaned up a bit CMDs

This commit is contained in:
2026-03-31 10:15:27 +02:00
parent b43177774e
commit e22b9c681f
5 changed files with 45 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ uint32_t quart_hour_counter = 0;
typedef struct
{
uint8_t isCoded;
float dFi; //-128,127 -> *3/256 = dfi
int8_t dFi; //-128,127 -> *3/256 = dfi
uint8_t inj_mode;
uint32_t quart_hour_counter;
@@ -31,14 +31,16 @@ void MEM_Init(){
MEM_WriteDefault();
}
if(ee.isCoded == 255){
MEM_WriteCustom(0.7, 0);
MEM_WriteCustom(0.0, 0);
}
}
void MEM_RetrieveValues(){
if(!memInit){
MEM_Init();
}
dFi = ee.dFi;
s_dfi_code = ee.dFi;
dFi = (float)s_dfi_code * 3.0 / 256;
inj_mode = ee.inj_mode;
quart_hour_counter = ee.quart_hour_counter;
@@ -49,7 +51,7 @@ void MEM_Cleanup(){ //only after changes to the struct
}
void MEM_WriteAll(){
ee.isCoded = 1;
ee.dFi = dFi;
ee.dFi = s_dfi_code;
ee.inj_mode = inj_mode;
ee.quart_hour_counter = quart_hour_counter;
@@ -58,11 +60,11 @@ void MEM_WriteAll(){
void MEM_WriteDefault(){
ee.isCoded = 1;
ee.dFi = 0.0;
ee.dFi = 0;
ee.inj_mode = 0;
EE_Write();
}
void MEM_WriteCustom(float c_dFi, uint8_t c_inj_mode){
void MEM_WriteCustom(int8_t c_dFi, uint8_t c_inj_mode){
ee.isCoded = 1;
ee.dFi = c_dFi;
ee.inj_mode = c_inj_mode;
@@ -72,3 +74,6 @@ void IncrementQuartHourCounter(){
quart_hour_counter++;
memWrite = 1;
}
int8_t GetDfiValue(){
return ee.dFi;
}