-
Notifications
You must be signed in to change notification settings - Fork 0
/
led2.ino
103 lines (87 loc) · 1.56 KB
/
led2.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***********************/
/* MAE LED */
/***********************/
/* Swano Lab - 2017 */
/***********************/
#include "leds.h"
int LED2_iEtatEnCours;
int LED2_iCompteurLed;
int LED2_iPeriodTarget;
bool LED2_bPinState;
void LED2_Setup(void)
{
digitalWrite(LED2_PIN, LOW);
pinMode(LED2_PIN, OUTPUT);
LED2_iEtatEnCours = ETAT_LED_OFF;
LED2_bPinState = LOW;
LED2_iCompteurLed = 0;
LED2_iPeriodTarget = 0;
}
void LED2_Etat_ON(void)
{
digitalWrite(LED2_PIN, HIGH);
LED2_bPinState = HIGH;
}
void LED2_Etat_OFF(void)
{
digitalWrite(LED2_PIN, LOW);
LED2_bPinState = LOW;
}
void LED2_Etat_Blink(void)
{
LED2_iCompteurLed--;
if ( LED2_iCompteurLed == 0)
{
LED2_Toggle();
LED2_iCompteurLed = LED2_iPeriodTarget;
}
}
void LED2_Toggle(void)
{
if ( LED2_bPinState == LOW)
{
digitalWrite(LED2_PIN, HIGH);
LED2_bPinState = HIGH;
}
else
{
if ( LED2_bPinState == HIGH)
{
digitalWrite(LED2_PIN, LOW);
LED2_bPinState = LOW;
}
}
}
void LED2_SetLed_ON(void)
{
LED2_iEtatEnCours = ETAT_LED_ON;
}
void LED2_SetLed_OFF(void)
{
LED2_iEtatEnCours = ETAT_LED_OFF;
}
void LED2_SetLed_BLINK(int iPeriod)
{
if ( LED2_iEtatEnCours != ETAT_LED_BLINK)
{
LED2_iCompteurLed = iPeriod;
LED2_iPeriodTarget = iPeriod;
LED2_Toggle();
LED2_iEtatEnCours = ETAT_LED_BLINK;
}
}
void LED2_MAE(void)
{
if (LED2_iEtatEnCours == ETAT_LED_OFF)
{
LED2_Etat_OFF();
}
if (LED2_iEtatEnCours == ETAT_LED_ON)
{
LED2_Etat_ON();
}
if (LED2_iEtatEnCours == ETAT_LED_BLINK)
{
LED2_Etat_Blink();
}
}