Add enable_fast_mode to LedBlaster.

This commit is contained in:
Maxwell Pray
2023-02-21 03:57:48 -08:00
parent 756cb8936c
commit 63ed9c4ac9
2 changed files with 23 additions and 5 deletions
+22 -5
View File
@@ -1,25 +1,42 @@
#define LED_PIN 13
#define LED_ON_MS 15
#define LED_OFF_MS 450
#define LED_ON_MS_NORMAL 15
#define LED_OFF_MS_NORMAL 450
#define LED_ON_MS_FAST 6
#define LED_OFF_MS_FAST 408
#include <Arduino.h>
namespace LedBlaster {
uint16_t led_on_ms;
uint16_t led_off_ms;
void enable_fast_mode(bool fast_mode_enabled) {
if (fast_mode_enabled) {
led_on_ms = LED_ON_MS_FAST;
led_off_ms = LED_OFF_MS_FAST;
} else {
led_on_ms = LED_ON_MS_NORMAL;
led_off_ms = LED_OFF_MS_NORMAL;
}
}
void setup() {
pinMode(LED_PIN, OUTPUT);
enable_fast_mode(false);
}
void emit_0() {
digitalWrite(LED_PIN, HIGH);
delayMicroseconds(LED_ON_MS);
delayMicroseconds(led_on_ms);
digitalWrite(LED_PIN, LOW);
delayMicroseconds(LED_OFF_MS);
delayMicroseconds(led_off_ms);
}
void emit_1() {
delayMicroseconds(LED_ON_MS + LED_OFF_MS);
delayMicroseconds(led_on_ms + led_off_ms);
}
void emit_byte(uint8_t serial_byte) {
+1
View File
@@ -5,6 +5,7 @@
namespace LedBlaster {
void setup();
void enable_fast_mode(bool fast_mode_enabled);
void emit_0();
void emit_1();
void emit_byte(uint8_t serial_byte);