changed Capture-Functions to FunctionPointer
This commit is contained in:
parent
059b693889
commit
ac8be93faf
@ -48,6 +48,8 @@ const uint32_t connectTimeoutMs = 5000;
|
|||||||
ESP8266WiFiMulti wifiMulti;
|
ESP8266WiFiMulti wifiMulti;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint32_t (*wheelSpeedcapture)() = nullptr;
|
||||||
|
|
||||||
bool startSetupMode = false;
|
bool startSetupMode = false;
|
||||||
volatile uint32_t wheel_pulse = 0;
|
volatile uint32_t wheel_pulse = 0;
|
||||||
|
|
||||||
@ -138,21 +140,23 @@ void setup()
|
|||||||
{
|
{
|
||||||
case SOURCE_CAN:
|
case SOURCE_CAN:
|
||||||
Init_CAN();
|
Init_CAN();
|
||||||
|
wheelSpeedcapture = &Process_CAN_WheelSpeed;
|
||||||
Serial.print("\nCAN-Init done");
|
Serial.print("\nCAN-Init done");
|
||||||
break;
|
break;
|
||||||
case SOURCE_GPS:
|
case SOURCE_GPS:
|
||||||
Init_GPS();
|
Init_GPS();
|
||||||
|
wheelSpeedcapture = &Process_GPS_WheelSpeed;
|
||||||
Serial.print("\nGPS-Init done");
|
Serial.print("\nGPS-Init done");
|
||||||
break;
|
break;
|
||||||
case SOURCE_IMPULSE:
|
case SOURCE_IMPULSE:
|
||||||
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
|
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING);
|
attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING);
|
||||||
|
wheelSpeedcapture = &Process_Impulse_WheelSpeed;
|
||||||
Serial.print("\nPulse-Input Init done");
|
Serial.print("\nPulse-Input Init done");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("\nSource-Init done");
|
Serial.print("\nSource-Init done");
|
||||||
|
|
||||||
// Configure GPIO pins for button and pump control
|
// Configure GPIO pins for button and pump control
|
||||||
@ -222,30 +226,8 @@ void setup()
|
|||||||
*/
|
*/
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// Variable to store calculated wheel distance
|
|
||||||
uint32_t wheelDistance = 0;
|
|
||||||
|
|
||||||
// Switch based on the configured speed source
|
|
||||||
switch (LubeConfig.SpeedSource)
|
|
||||||
{
|
|
||||||
case SOURCE_IMPULSE:
|
|
||||||
wheelDistance = Process_Impulse_WheelSpeed();
|
|
||||||
break;
|
|
||||||
case SOURCE_CAN:
|
|
||||||
wheelDistance = Process_CAN_WheelSpeed();
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_TIMER
|
|
||||||
case SOURCE_TIME:
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case SOURCE_GPS:
|
|
||||||
wheelDistance = Process_GPS_WheelSpeed();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run lubrication application with the calculated wheel distance
|
// Run lubrication application with the calculated wheel distance
|
||||||
RunLubeApp(wheelDistance);
|
RunLubeApp(wheelSpeedcapture());
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_OLED
|
#ifdef FEATURE_ENABLE_OLED
|
||||||
// Update OLED display if enabled
|
// Update OLED display if enabled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user