Skip to content

Commit

Permalink
making led flash every 5 sends
Browse files Browse the repository at this point in the history
  • Loading branch information
romanini committed May 30, 2024
1 parent d3ca236 commit 49642a4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Arduino/processor/led.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#define FLASH_INTERVAL 25
#define FLASH_COUNT 5
#define FLASH_PIN 2

uint32_t flash_millis = millis();
bool led_on = false;
int flash_count = 0;

void setup_led() {
pinMode(FLASH_PIN, OUTPUT);
}

void flash_led() {
flash_count += 1;
if (flash_count == FLASH_COUNT) {
flash_count = 0;
flash_millis = millis();
led_on = true;
digitalWrite(FLASH_PIN, HIGH);
}
}

void check_led() {
if (led_on && (millis() - flash_millis > FLASH_INTERVAL)) {
led_on = false;
digitalWrite(FLASH_PIN, LOW);
}
}

4 changes: 3 additions & 1 deletion Arduino/processor/processor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <WiFiNINA.h>
#include "AutoPilot.h"

#define DEBUG_ENABLED true
#define DEBUG_ENABLED false
#ifdef DEBUG_ENABLED
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINT2(x,y) Serial.print(x,y)
Expand Down Expand Up @@ -33,6 +33,7 @@ void setup() {
setup_motor();
setup_compass();
setup_gps();
setup_led();
publish_RESET();
Serial.println("Setup complete");
}
Expand All @@ -43,6 +44,7 @@ void loop() {
check_compass();
check_gps();
check_motor();
check_led();
publish_APDAT();
// calculage_average_loop_time(millis() - start_time);
// if (millis() - last_display_loop_average > DISAPLY_AVERAGE_RATE) {
Expand Down
1 change: 1 addition & 0 deletions Arduino/processor/publish.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void publish_APDAT() {
udpClient.beginPacket(broadcastIp, broadcastPort);
udpClient.write(serialzied_data);
udpClient.endPacket();
flash_led();
}
}

Expand Down

0 comments on commit 49642a4

Please sign in to comment.