-
Notifications
You must be signed in to change notification settings - Fork 112
/
backlightcontrols.ino
36 lines (28 loc) · 1.02 KB
/
backlightcontrols.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**************************************************************
Example of display backlight control depending on playback.
This file must be in the root directory of the sketch.
**************************************************************/
#include <Ticker.h>
const uint8_t backlightPin = 13;
const uint8_t backlightInitValue = HIGH;
const uint16_t turnBlOffInterval = 120; /* 2 min */
Ticker backlightTicker;
void backlightOff(){
backlightTicker.detach();
digitalWrite(backlightPin, !backlightInitValue);
}
void yoradio_on_setup() {
pinMode(backlightPin, OUTPUT);
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.attach(turnBlOffInterval, backlightOff);
}
void player_on_track_change(){
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.detach();
backlightTicker.attach(turnBlOffInterval, backlightOff);
}
void player_on_stop_play(){
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.detach();
backlightTicker.attach(turnBlOffInterval, backlightOff);
}