-
Notifications
You must be signed in to change notification settings - Fork 0
/
myLED.h
62 lines (48 loc) · 1.4 KB
/
myLED.h
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
/*
This file contains a class definition for a simple LED which can turned on, off and
flicker/blink. The calculation of the internal stati and writing to the pin is split up into
different methods so you can controll how often you need update the output.
Author: Daniel Ramonat
Date: 07.10.2020
*/
#ifndef MYLED_H
#define MYLED_H
#include "types.h"
#include "Arduino.h"
enum LEDSTAT
{
OFF,
ON,
BLINK
};
enum BLINKTYPE
{
OFF_ON_OFF,
ON_OFF_ON,
};
class MyLED
{
public:
/* constructor
* \param[in] pin the arduino pin number where the LED is at */
MyLED(USHORT pin);
/* thurns the LED on */
void turnOn(void);
/* thurns the LED off */
void turnOff(void);
/* what the name says */
void toggle(void);
/* lets the LED blink either on->off->on or off->on->off
* \param[in] duration duration of blink */
void blink(ULONG duration);
/* writing internal status to actuall pin OUTPUT. This is rather slow */
void writeOut(void);
private:
const USHORT pinNumber; // Pin number where the LED is conneted
LEDSTAT status; // status see LEDSTAT
LEDSTAT statusK1; // status of the last cycle
ULONG tStartBlink; // time when the blinking startet (actual output)
ULONG blinkDur; // blinking duration
BLINKTYPE blinkType; // whether blink startet when LED was on or off, see BLINKTYPE
};
#endif