Added Button-Function Rain/Normal Switch
This commit is contained in:
parent
acb3c97c02
commit
2217d68026
@ -1,11 +1,40 @@
|
||||
#include "lubeapp.h"
|
||||
|
||||
extern void LED_Process(tSystem_Status newStatus = sysStat_NOP);
|
||||
|
||||
uint32_t lubePulseTimestamp = 0;
|
||||
|
||||
void RunLubeApp(volatile uint32_t *wheelPulseCounter)
|
||||
{
|
||||
static uint32_t buttonTimestamp = 0;
|
||||
static boolean buttonActionDone = false;
|
||||
|
||||
if (digitalRead(GPIO_BUTTON) == LOW)
|
||||
{
|
||||
if (buttonTimestamp == 0)
|
||||
buttonTimestamp = millis() + BUTTON_HOLD_DELAY;
|
||||
|
||||
if (buttonTimestamp < millis() && buttonActionDone == false)
|
||||
{
|
||||
switch (globals.systemStatus)
|
||||
{
|
||||
case sysStat_Normal:
|
||||
globals.systemStatus = sysStat_Rain;
|
||||
globals.resumeStatus = sysStat_Rain;
|
||||
break;
|
||||
|
||||
case sysStat_Rain:
|
||||
globals.systemStatus = sysStat_Normal;
|
||||
globals.resumeStatus = sysStat_Normal;
|
||||
break;
|
||||
}
|
||||
buttonActionDone = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonTimestamp = 0;
|
||||
buttonActionDone = false;
|
||||
}
|
||||
|
||||
// Calculate traveled Distance in mm
|
||||
TravelDistance_highRes += (*wheelPulseCounter * (LubeConfig.DistancePerRevolution_mm / LubeConfig.PulsePerRevolution));
|
||||
*wheelPulseCounter = 0;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#define LUBE_PULSE_LENGHT_MS 100
|
||||
#define LUBE_PULSE_PAUSE_MS 100
|
||||
#define BUTTON_HOLD_DELAY 1000
|
||||
|
||||
void RunLubeApp(volatile uint32_t * wheelPulseCounter);
|
||||
void LubePulse();
|
||||
|
Loading…
x
Reference in New Issue
Block a user