Skip to content

Commit 4e07676

Browse files
MarkusMarkus
Markus
authored and
Markus
committed
transSloppy
1 parent b447115 commit 4e07676

File tree

2 files changed

+37
-39
lines changed

2 files changed

+37
-39
lines changed

main/config.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ struct ConfigParam config = {
2222
.triggerWheelTeeth = 6, // number of teeth in trigger wheel for RPM calculation
2323
.tpsAgre = 2, // 1-10 how aggressive slope tps has
2424
.diffRatio = 3.27,
25-
.maxSlip = 0.5 // Maximum allowed slip before error
25+
.maxSlip = 0.5, // Maximum allowed slip before error
26+
.transSloppy = 1.2 // multiplier for pressures coping with old transmissions
2627
};
2728

2829
// End of environment conf

main/serial_config.cpp

+35-38
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ void initConfig()
135135
setConfig(64, 5);
136136
setConfig(65, 6);
137137
setConfig(66, 2);
138-
EEPROM.write(4090, 69);
138+
setConfig(67, 1.00);
139+
EEPROM.put(4090, 69);
139140
Serial.println("Virgin init");
140141
}
141142
else
142143
{
143144
int features[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
144-
int config[] = {50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 62, 63, 64, 65, 66};
145+
int config[] = {50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 62, 63, 64, 65, 66, 67};
145146
int configF[] = {58, 61};
146147

147148
for (int i = 0; i < sizeof features / sizeof features[0]; i++)
@@ -159,7 +160,8 @@ void initConfig()
159160
for (int i = 0; i < sizeof configF / sizeof configF[0]; i++)
160161
{
161162
asset = configF[i] * 10;
162-
float configVal = EEPROM.read(asset);
163+
float configVal;
164+
EEPROM.get(asset, configVal);
163165
setConfigFloat(configF[i], configVal);
164166
}
165167
}
@@ -273,21 +275,17 @@ void getFeatures()
273275
void setFeatures(int asset, int value)
274276
{
275277
lastActiveConfig = millis();
276-
if (debugEnabled)
277-
{
278-
Serial.print("Setting feature: ");
279-
Serial.print(asset);
280-
Serial.print(":");
281-
Serial.println(value);
282-
}
283278
if (asset > 0 && asset < 40)
284279
{
285-
int assetLocation = asset * 10;
286-
int assetRead = EEPROM.read(assetLocation);
287-
if (assetRead != value)
280+
if (debugEnabled)
288281
{
289-
EEPROM.write(assetLocation, value);
282+
Serial.print("Setting feature: ");
283+
Serial.print(asset);
284+
Serial.print(":");
285+
Serial.println(value);
290286
}
287+
int assetLocation = asset * 10;
288+
EEPROM.put(assetLocation, value);
291289
}
292290

293291
switch (asset)
@@ -364,21 +362,18 @@ void setFeatures(int asset, int value)
364362
void setConfigFloat(int asset, float value)
365363
{
366364
lastActiveConfig = millis();
367-
if (debugEnabled)
368-
{
369-
Serial.print("Setting configF: ");
370-
Serial.print(asset);
371-
Serial.print(":");
372-
Serial.println(value);
373-
}
365+
374366
if (asset > 49 && asset < 70)
375367
{
376-
int assetLocation = asset * 10;
377-
float assetRead = EEPROM.read(assetLocation);
378-
if (assetRead != value)
368+
if (debugEnabled)
379369
{
380-
EEPROM.write(assetLocation, fvalue);
370+
Serial.print("Setting configF: ");
371+
Serial.print(asset);
372+
Serial.print(":");
373+
Serial.println(value);
381374
}
375+
int assetLocation = asset * 10;
376+
EEPROM.put(assetLocation, value);
382377
}
383378

384379
switch (asset)
@@ -399,21 +394,18 @@ void setConfigFloat(int asset, float value)
399394
void setConfig(int asset, int value)
400395
{
401396
lastActiveConfig = millis();
402-
if (debugEnabled)
403-
{
404-
Serial.print("Setting config: ");
405-
Serial.print(asset);
406-
Serial.print(":");
407-
Serial.println(value);
408-
}
397+
409398
if (asset > 49 && asset < 70)
410399
{
411-
int assetLocation = asset * 10;
412-
int assetRead = EEPROM.read(assetLocation);
413-
if (assetRead != value)
400+
if (debugEnabled)
414401
{
415-
EEPROM.write(assetLocation, value);
402+
Serial.print("Setting config: ");
403+
Serial.print(asset);
404+
Serial.print(":");
405+
Serial.println(value);
416406
}
407+
int assetLocation = asset * 10;
408+
EEPROM.put(assetLocation, value);
417409
}
418410

419411
switch (asset)
@@ -463,7 +455,9 @@ void setConfig(int asset, int value)
463455
case 66:
464456
config.tpsAgre = value;
465457
break;
466-
458+
case 67:
459+
config.transSloppy = value;
460+
break;
467461
default:
468462
break;
469463
}
@@ -526,7 +520,10 @@ void getConfig()
526520
Serial.print(config.triggerWheelTeeth);
527521
Serial.print(";");
528522
Serial.print("66:");
529-
Serial.println(config.tpsAgre);
523+
Serial.print(config.tpsAgre);
524+
Serial.print(";");
525+
Serial.print("67:");
526+
Serial.println(config.transSloppy);
530527
}
531528

532529
void serialConfig()

0 commit comments

Comments
 (0)