fixed correct Calculation of Lube-Distance

This commit is contained in:
Marcel Peterkau 2022-01-10 23:17:07 +01:00
parent febb658bf8
commit a3d5c4ef6f
3 changed files with 22 additions and 13 deletions

View File

@ -21,7 +21,7 @@ void RunLubeApp(volatile uint32_t *wheelPulseCounter)
break;
case sysStat_Normal:
if (TravelDistance_highRes > LubeConfig.DistancePerLube_Default)
if (TravelDistance_highRes / 1000 > LubeConfig.DistancePerLube_Default)
{
LubePulse();
TravelDistance_highRes = 0;
@ -29,7 +29,7 @@ void RunLubeApp(volatile uint32_t *wheelPulseCounter)
break;
case sysStat_Rain:
if (TravelDistance_highRes > LubeConfig.DistancePerLube_Rain)
if (TravelDistance_highRes / 1000 > LubeConfig.DistancePerLube_Rain)
{
LubePulse();
TravelDistance_highRes = 0;

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "globals.h"
#define LUBE_PULSE_LENGHT_MS 500
#define LUBE_PULSE_LENGHT_MS 250
#define LUBE_PULSE_PAUSE_MS 250
void RunLubeApp(volatile uint32_t * wheelPulseCounter);

View File

@ -256,12 +256,10 @@ void LED_Process(tSystem_Status newSysStatus)
case sysStat_Normal:
timestamp = millis() + 1500;
LED_Status = LED_Confirm_Normal;
FastLED.setBrightness(64);
break;
case sysStat_Rain:
timestamp = millis() + 1500;
LED_Status = LED_Confirm_Rain;
FastLED.setBrightness(64);
break;
case sysStat_Purge:
LED_Status = LED_Purge;
@ -278,29 +276,38 @@ void LED_Process(tSystem_Status newSysStatus)
switch (LED_Status)
{
case LED_Startup:
FastLED.setBrightness(255);
timer = timer % 2000;
color = timer > 500 ? 0 : (uint8_t)(timer / 2);
leds[0] = CRGB(color, color, 0);
leds[0] = CRGB(color, color, color);
break;
case LED_Confirm_Normal:
FastLED.setBrightness(255);
leds[0] = timer % 500 > 250 ? CRGB(0, 255, 0) : CRGB(0, 4, 0);
if (timestamp < timer)
{
LED_Status = LED_Normal;
leds[0] = timer % 500 > 250 ? CRGB::Green : CRGB::Black;
FastLED.setBrightness(64);
}
break;
case LED_Normal:
leds[0] = timer % 2000 > 1950 ? CRGB::Green : CRGB::Black;
leds[0] = timer % 2000 > 1950 ? CRGB(0, 255, 0) : CRGB(0, 4, 0);
break;
case LED_Confirm_Rain:
FastLED.setBrightness(255);
leds[0] = timer % 500 > 250 ? CRGB(0, 0, 255) : CRGB(0, 0, 4);
if (timestamp < timer)
{
LED_Status = LED_Rain;
leds[0] = timer % 500 > 250 ? CRGB::Blue : CRGB::Black;
FastLED.setBrightness(64);
}
break;
case LED_Rain:
leds[0] = timer % 2000 > 1950 ? CRGB::Blue : CRGB::Black;
leds[0] = timer % 2000 > 1950 ? CRGB(0, 0, 255) : CRGB(0, 0, 4);
break;
case LED_Purge:
@ -326,8 +333,10 @@ void LED_Process(tSystem_Status newSysStatus)
void DisplayProcess()
{
u8x8.setCursor(0, 3);
u8x8.printf("Dist.: %4d m\n", TravelDistance_highRes / 1000);
u8x8.printf("Purge: %4d\n", globals.purgePulses);
u8x8.printf("Tank: %4d ml\n", LubeConfig.tankRemain_µl / 1000);
uint32_t DistRemain = globals.systemStatus == sysStat_Normal ? LubeConfig.DistancePerLube_Default : LubeConfig.DistancePerLube_Rain;
DistRemain -= TravelDistance_highRes / 1000;
u8x8.printf("next Lube: %4dm\n", DistRemain);
u8x8.printf("Tank: %8dml\n", LubeConfig.tankRemain_µl / 1000);
u8x8.printf("Purges: %8d\n", globals.purgePulses);
u8x8.refreshDisplay();
}