forked from hoffmannjoern/IoT-Shield-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParkingShield.h
139 lines (118 loc) · 4.08 KB
/
ParkingShield.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef PARKINGSHIELD_H
#define PARKINGSHIELD_H
#include <SevenSeg.h>
#include <stdint.h>
#include <DeviceArduino.h>
/**
* @brief The ParkingShield class is designed for the ParkingShield platform, an arduino extension board from J�rn Hoffmann at the University of Leipzig.
* @brief It provides functionality to turn LEDs on/off, measure temperature and brightness, get button states.
* @author Marc Vester (XaserLE)
* @author Jörn Hoffmann (jhoffmann)
* @author Lukas Fischer
*/
class ParkingShield
{
public:
typedef enum {
GREEN_LED,
YELLOW_LED,
RED_LED,
LED_MAX
} led_t;
/**
* @brief Constructor
*/
ParkingShield(void);
/**
* @brief Constructor that allowes specifying the segment display common pin reference
*/
ParkingShield(SevenSeg::connector_t connector);
/**
* @brief Enables or disables an LED.
* @param led The led to set on or off.
* @param enable "True" enables and "false" disables the given led.
*/
static void setLed(led_t led, bool enable);
/**
* @brief Returns the actual measured temperature.
* @return Temperature as centigrade.
*/
unsigned int getTemperature(void) const;
/**
* @brief Returns the actual measured brightness.
* @return Brightness.
*/
unsigned int getBrightness(void) const;
/**
* @brief Returns the average of the last 8 measured brightness values.
* @return Brightness.
*/
unsigned int getAverageBrightness(void);
/**
* @brief Returns whether button S1 is pressed or not.
* @return True if pressed, false otherwise.
*/
bool buttonS1Pressed(void);
/**
* @brief Returns whether button S2 is pressed or not.
* @return True if pressed, false otherwise.
*/
bool buttonS2Pressed(void);
/**
* @brief Use this to make sound with the buzzer.
* @param enable If true, buzzer makes noise. If false, buzzer is off.
*/
void setBuzzer(bool enable) const;
/**
* @brief Let's the buzzer make sound.
* @param frequenzyInHertz The frequenz in hertz.
* @param timeInMilliseconds The duration of the sound in milliseconds.
*/
void beep(int frequencyInHertz, long timeInMilliseconds) const;
/**
* @brief Play's a tone.
* @param tone The tone to play.
* @param duration The duration in microseconds.
*/
void playTone(int tone, int duration) const;
/**
* @brief Play's a note.
* @param note The note to play.
* @param duration The duration in microseconds.
*/
void playNote(char note, int duration) const;
/**
*@brief Play's a popular melody :-D
*/
void playMelody(void) const;
/**
* @brief Play's the storm trooper march :-D
* @brief Much thanks to tagliati (https://gist.github.com/tagliati/1804108).
*/
void playMarch(bool shortVersion = true) const;
/**
*@brief Set repeat interval in milliseconds.
*@brief After buttonPressed() returns true it will block the button for some milliseconds returning false even if the button is still pressed.
*/
void setRepeatInterval(unsigned int interval);
/// The seven segment display, accessable from outside.
SevenSeg sevenSeg;
private:
// Defines
class Button {
public:
Button(Device::pin_t button_pin);
bool sampleButton();
unsigned int repeatInterval;
private:
Device::pin_t pinNumber;
unsigned long repeatTime;
};
// Variables
Button buttonS1;
Button buttonS2;
static const int BRIGHTNESS_ARRAY_SIZE = 8;
int brightnessValuesPointer = 0;
int brightnessValues[BRIGHTNESS_ARRAY_SIZE] = {0};
};
#endif