implemented Wash-Mode

This commit is contained in:
Marcel Peterkau 2025-06-15 13:23:28 +02:00
parent c7af5619eb
commit b7ccffc157
8 changed files with 81 additions and 10 deletions

View File

@ -349,6 +349,33 @@
</div>
</div>
</div>
<div class="form-group row">
<label for="washdistance" class="control-label col-4">Waschmodus Distanz</label>
<div class="col-8">
<div class="input-group">
<input id="washdistance" type="text"
class="set-wsevent data-washdistance form-control" required="required">
<div class="input-group-append">
<span class="input-group-text">m</span>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="washinterval" class="control-label col-4">Waschmodus Interval</label>
<div class="col-8">
<div class="input-group">
<input id="washinterval" type="text"
class="set-wsevent data-washinterval form-control" required="required">
<div class="input-group-append">
<span class="input-group-text">m</span>
</div>
</div>
</div>
</div>
</p>
<!-- Div Group Lube Settings-->
<!-- Div Group Oiltank Settings -->

View File

@ -73,6 +73,7 @@ typedef enum eSystem_Status
sysStat_Startup,
sysStat_Normal,
sysStat_Rain,
sysStat_Wash,
sysStat_Purge,
sysStat_Error,
sysStat_Shutdown

View File

@ -21,7 +21,7 @@
#include "dtc.h"
#include "common.h"
#define EEPROM_STRUCTURE_REVISION 3 // Increment this version when changing EEPROM structures
#define EEPROM_STRUCTURE_REVISION 4 // Increment this version when changing EEPROM structures
#if PCB_REV == 1 || PCB_REV == 2 || PCB_REV == 3
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC64
@ -69,6 +69,8 @@ typedef struct
uint32_t RimDiameter_Inch;
uint32_t DistancePerRevolution_mm;
uint16_t BleedingPulses;
uint16_t WashMode_Distance;
uint16_t WashMode_Interval;
SpeedSource_t SpeedSource;
GPSBaudRate_t GPSBaudRate;
CANSource_t CANSource;
@ -85,7 +87,7 @@ typedef struct
// Default configuration settings
const LubeConfig_t LubeConfig_defaults = {
0, 8000, 4000, 320, DEFAULT_PUMP_DOSE, 30, 1, 150, 70, 18, 2000, 25, SOURCE_IMPULSE,
0, 8000, 4000, 320, DEFAULT_PUMP_DOSE, 30, 1, 150, 70, 18, 2000, 25, 500, 10, SOURCE_IMPULSE,
BAUD_115200,
KTM_890_ADV_R_2021,
false,

View File

@ -3,10 +3,10 @@
*
* @brief Header file for converting structs to JSON objects.
*
* @note This file is auto-generated by a script on 2024-01-30 20:29:34.
* @note This file is auto-generated by a script on 2025-06-15 11:37:51.
*
* @author Marcel Peterkau
* @date 30.01.2024
* @date 15.06.2025
*/
#ifndef _STRUCT2JSON_H_
@ -23,4 +23,4 @@ void generateJsonObject_PersistenceData(JsonObject data);
#endif /* _STRUCT2JSON_H_ */
// CODEGENERATOR_CHECKSUM: 59f35aadffd0bbef253210ea2fbaaf9a515553a2e3cc9bf4cfa2819b63c969ce
// CODEGENERATOR_CHECKSUM: 4702cb49ea55617cbb34715164810bb58d3c3f46fb1653b6f47bd4fd9cb0031e

View File

@ -33,8 +33,8 @@ void ButtonAction_ToggleWiFi()
void ButtonAction_WashMode()
{
Debug_pushMessage("Wash mode not yet implemented\n");
// TODO: Implementieren, sobald Verhalten klar ist
globals.systemStatus = sysStat_Wash;
Debug_pushMessage("Setting WashMode\n");
}
// Liste der Aktionen, sortiert nach Mindest-Haltezeit (ms)

View File

@ -29,6 +29,7 @@ uint32_t lubePulseTimestamp = 0;
void RunLubeApp(uint32_t add_milimeters)
{
static tSystem_Status lastSystemStatus = sysStat_Startup;
static uint16_t washModeDistance = 0;
// Calculate and update tank percentage
globals.TankPercentage = PersistenceData.tankRemain_microL / (LubeConfig.tankCapacity_ml * 10);
@ -102,6 +103,32 @@ void RunLubeApp(uint32_t add_milimeters)
}
break;
case sysStat_Wash:
if (lastSystemStatus != globals.systemStatus)
{
washModeDistance = LubeConfig.WashMode_Distance;
strcpy_P(globals.systemStatustxt, PSTR("Wash"));
LEDControl_SetBasic(LED_WASH_COLOR, LED_PATTERN_BREATH);
lastSystemStatus = globals.systemStatus;
}
// Trigger lube pulse if traveled distance exceeds the configured Interval in Wash mode
if (PersistenceData.TravelDistance_highRes_mm / 1000 > LubeConfig.WashMode_Interval)
{
LubePulse();
PersistenceData.TravelDistance_highRes_mm = 0;
if (washModeDistance >= LubeConfig.WashMode_Distance)
{
washModeDistance = washModeDistance - LubeConfig.WashMode_Interval;
}
else
{
globals.systemStatus = globals.resumeStatus;
}
}
break;
case sysStat_Purge:
if (lastSystemStatus != globals.systemStatus)
{

View File

@ -3,10 +3,10 @@
*
* @brief Implementation file for converting structs to JSON objects.
*
* @note This file is auto-generated by a script on 2024-01-30 20:29:34.
* @note This file is auto-generated by a script on 2025-06-15 11:37:51.
*
* @author Marcel Peterkau
* @date 30.01.2024
* @date 15.06.2025
*/
@ -26,6 +26,8 @@ void generateJsonObject_LubeConfig(JsonObject data)
data["RimDiameter_Inch"] = LubeConfig.RimDiameter_Inch;
data["DistancePerRevolution_mm"] = LubeConfig.DistancePerRevolution_mm;
data["BleedingPulses"] = LubeConfig.BleedingPulses;
data["WashMode_Distance"] = LubeConfig.WashMode_Distance;
data["WashMode_Interval"] = LubeConfig.WashMode_Interval;
data["SpeedSource"] = LubeConfig.SpeedSource;
data["GPSBaudRate"] = LubeConfig.GPSBaudRate;
data["CANSource"] = LubeConfig.CANSource;
@ -52,4 +54,4 @@ void generateJsonObject_PersistenceData(JsonObject data)
// CODEGENERATOR_CHECKSUM: 59f35aadffd0bbef253210ea2fbaaf9a515553a2e3cc9bf4cfa2819b63c969ce
// CODEGENERATOR_CHECKSUM: 4702cb49ea55617cbb34715164810bb58d3c3f46fb1653b6f47bd4fd9cb0031e

View File

@ -580,6 +580,14 @@ void Websocket_HandleSettings(uint8_t *data)
{
strncpy(LubeConfig.wifi_client_password, value, sizeof(LubeConfig.wifi_client_password));
}
else if (strcmp(identifier, "washinterval") == 0)
{
LubeConfig.WashMode_Interval = atoi(value);
}
else if (strcmp(identifier, "washdistance") == 0)
{
LubeConfig.WashMode_Distance = atoi(value);
}
else
{
Debug_pushMessage("Got unknown Settings-id and value '%s' from ws-client\n", identifier);
@ -700,6 +708,8 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
const char mapping[] = "MAPPING_STATIC:"
"lubedistancenormal;"
"lubedistancerain;"
"washdistance;"
"washinterval;"
"tankcap;"
"pumppulse;"
"tankwarn;"
@ -730,6 +740,8 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
temp.concat(String(LubeConfig.DistancePerLube_Default) + ";");
temp.concat(String(LubeConfig.DistancePerLube_Rain) + ";");
temp.concat(String(LubeConfig.WashMode_Distance) + ";");
temp.concat(String(LubeConfig.WashMode_Interval) + ";");
temp.concat(String(LubeConfig.tankCapacity_ml) + ";");
temp.concat(String(LubeConfig.amountPerDose_microL) + ";");
temp.concat(String(LubeConfig.TankRemindAtPercentage) + ";");