-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplay.h
92 lines (75 loc) · 1.99 KB
/
Display.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
/*
* Display.h
*
* Created on: Jan 31, 2013
* Author: jpm8766
*/
#ifndef DISPLAY_H_
#define DISPLAY_H_
#include "Thread.h"
#include "DataProvider.h"
#include <unistd.h>
#include <stdint.h> /* for uintptr_t */
#include <hw/inout.h> /* for in*() and out*() functions */
// The refresh rate of the screen in Hz
#define NUM_ANODES (4)
//This is the number of updates that should occur before polling the DataProvider again
#define COUNT_INTERVAL (10)
//This is the priorit the display thread should run at
#define DISPLAY_PRIORITY (50)
//This is how long to sleep for between updating each anode
#define SLEEP_PERIOD (3500)
//This is the cathode for the decimal point
#define DP_CATHODE (0b00000001)
// Defines the bits which must be set in order to produce the index's value on a 7 segment display
// NOTE: Bits are set to 1 if they should be on and follow the pattern: 0bABCDEFG(DP)
static const char CATHODE_TABLE[] = {
//zero
(0b11111100),
//one
(0b01100000),
//two
(0b11011010),
//three
(0b11110010),
//four
(0b01100110),
//five
(0b10110110),
//six
(0b10111110),
//seven
(0b11100000),
//eight
(0b11111110),
//nine
(0b11110110),
//blank display
(0b00000000)
};
class Display: public Thread {
public:
Display(DataProvider* d, uintptr_t cat, uintptr_t an);
virtual ~Display();
/**
* Continuously update the 7 segment display from a
* data provider.
*/
void* run();
/**
* Set the data provider; setting this on the fly updates the display
* accordingly.
*
* @param next - the new DataProvider which the display will reflect
*/
void setDataProvider(DataProvider* next);
private:
//The current DataProvider to get DisplayInfo from
DataProvider* data;
//The handle to the port the cathodes are connected to.
uintptr_t cathode;
//The handle to the port the anodes are connected to.
uintptr_t anode;
bool killThread;
};
#endif /* DISPLAY_H_ */