Skip to content
Snippets Groups Projects
Commit 74b130df authored by nrs1g15's avatar nrs1g15
Browse files

lap timer

parent 02453a24
No related branches found
No related tags found
No related merge requests found
//
// Created by Sil on 01/08/2019.
//
#include "lapTimer.h"
#include "wireless.h"
void lapTimerISR()
{
static uint8_t lapTimerPayload[6];
static uint32_t lastTriggeredMs = 0;
uint32_t currentMs = millis();
if ((currentMs - lastTriggeredMs) >= LAP_TIMER_DEBOUNCE_MS) {
lapTimerPayload[0] = 0xFF;
memcpy(&(lapTimerPayload[1]), currentMs, 4);
lapTimerPayload[5] = 0xFF;
wirelessWrite(lapTimerPayload, 6);
lastTriggeredMs = millis();
}
}
void lapTimerBegin()
{
attachInterrupt(digitalPinToInterrupt(LAP_TIMER_INT_PIN), lapTimerISR, FALLING);
}
//
// Created by Sil on 01/08/2019.
//
#ifndef LAPTIMER_H
#define LAPTIMER_H
#include "Arduino.h"
#define LAP_TIMER_INT_PIN 21
#define LAP_TIMER_DEBOUNCE_MS 1000
void lapTimerBegin();
#endif //LAPTIMER_H
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include "ecuCan.h" #include "ecuCan.h"
#include "can.h" #include "can.h"
#include "dashController.h" #include "dashController.h"
// #include "wireless.h" #include "wireless.h"
#include "lapTimer.h"
void setup() void setup()
{ {
...@@ -15,10 +16,9 @@ void setup() ...@@ -15,10 +16,9 @@ void setup()
// Serial.println("BEGIN"); // Serial.println("BEGIN");
dashBegin(); dashBegin();
sdBegin(); sdBegin();
canBegin(); canBegin();
lapTimerBegin();
} }
void loop() void loop()
...@@ -28,6 +28,7 @@ void loop() ...@@ -28,6 +28,7 @@ void loop()
/* /*
* ALL PROCESSES *MUST* BE NON BLOCKING * ALL PROCESSES *MUST* BE NON BLOCKING
*/ */
canProcessRx(); canProcessRx();
dashControllerProcess(); dashControllerProcess();
sdProcess(); sdProcess();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment