mirror of
https://github.com/okalachev/flix.git
synced 2025-07-27 17:49:33 +00:00
28 lines
542 B
C++
28 lines
542 B
C++
// Copyright (c) 2023 Oleg Kalachev <okalachev@gmail.com>
|
|
// Repository: https://github.com/okalachev/flix
|
|
|
|
// Board's LED control
|
|
|
|
#define BLINK_PERIOD 500000
|
|
|
|
#ifndef LED_BUILTIN
|
|
#define LED_BUILTIN 2 // for ESP32 Dev Module
|
|
#endif
|
|
|
|
void setupLED() {
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
}
|
|
|
|
void setLED(bool on) {
|
|
static bool state = false;
|
|
if (on == state) {
|
|
return; // don't call digitalWrite if the state is the same
|
|
}
|
|
digitalWrite(LED_BUILTIN, on ? HIGH : LOW);
|
|
state = on;
|
|
}
|
|
|
|
void blinkLED() {
|
|
setLED(micros() / BLINK_PERIOD % 2);
|
|
}
|