@@ -57,129 +57,129 @@ const static byte charTable[128] = {
57
57
};
58
58
59
59
class LedControl {
60
- private :
61
- /* The array for shifting the data to the devices */
62
- byte spidata[16 ];
63
- /* Send out a single command to the device */
64
- void spiTransfer (int addr, byte opcode, byte data);
65
-
66
- /* We keep track of the led-status for all 8 devices in this array */
67
- byte status[64 ];
68
- /* Data is shifted out of this pin*/
69
- int SPI_MOSI;
70
- /* The clock is signaled on this pin */
71
- int SPI_CLK;
72
- /* This one is driven LOW for chip selectzion */
73
- int SPI_CS;
74
- /* The maximum number of devices we use */
75
- int maxDevices;
76
-
77
- public:
78
- /*
79
- * Create a new controler
80
- * Params :
81
- * dataPin pin on the Arduino where data gets shifted out
82
- * clockPin pin for the clock
83
- * csPin pin for selecting the device
84
- * numDevices maximum number of devices that can be controled
85
- */
86
- LedControl (int dataPin, int clkPin, int csPin, int numDevices=1 );
87
-
88
- /*
89
- * Gets the number of devices attached to this LedControl.
90
- * Returns :
91
- * int the number of devices on this LedControl
92
- */
93
- int getDeviceCount ();
94
-
95
- /*
96
- * Set the shutdown (power saving) mode for the device
97
- * Params :
98
- * addr The address of the display to control
99
- * status If true the device goes into power-down mode. Set to false
100
- * for normal operation.
101
- */
102
- void shutdown (int addr, bool status);
103
-
104
- /*
105
- * Set the number of digits (or rows) to be displayed.
106
- * See datasheet for sideeffects of the scanlimit on the brightness
107
- * of the display.
108
- * Params :
109
- * addr address of the display to control
110
- * limit number of digits to be displayed (1..8)
111
- */
112
- void setScanLimit (int addr, int limit);
113
-
114
- /*
115
- * Set the brightness of the display.
116
- * Params:
117
- * addr the address of the display to control
118
- * intensity the brightness of the display. (0..15)
119
- */
120
- void setIntensity (int addr, int intensity);
121
-
122
- /*
123
- * Switch all Leds on the display off.
124
- * Params:
125
- * addr address of the display to control
126
- */
127
- void clearDisplay (int addr);
128
-
129
- /*
130
- * Set the status of a single Led.
131
- * Params :
132
- * addr address of the display
133
- * row the row of the Led (0..7)
134
- * col the column of the Led (0..7)
135
- * state If true the led is switched on,
136
- * if false it is switched off
137
- */
138
- void setLed (int addr, int row, int col, boolean state);
139
-
140
- /*
141
- * Set all 8 Led's in a row to a new state
142
- * Params:
143
- * addr address of the display
144
- * row row which is to be set (0..7)
145
- * value each bit set to 1 will light up the
146
- * corresponding Led.
147
- */
148
- void setRow (int addr, int row, byte value);
149
-
150
- /*
151
- * Set all 8 Led's in a column to a new state
152
- * Params:
153
- * addr address of the display
154
- * col column which is to be set (0..7)
155
- * value each bit set to 1 will light up the
156
- * corresponding Led.
157
- */
158
- void setColumn (int addr, int col, byte value);
159
-
160
- /*
161
- * Display a hexadecimal digit on a 7-Segment Display
162
- * Params:
163
- * addr address of the display
164
- * digit the position of the digit on the display (0..7)
165
- * value the value to be displayed. (0x00..0x0F)
166
- * dp sets the decimal point.
167
- */
168
- void setDigit (int addr, int digit, byte value, boolean dp);
169
-
170
- /*
171
- * Display a character on a 7-Segment display.
172
- * There are only a few characters that make sense here :
173
- * '0','1','2','3','4','5','6','7','8','9','0',
174
- * 'A','b','c','d','E','F','H','L','P',
175
- * '.','-','_',' '
176
- * Params:
177
- * addr address of the display
178
- * digit the position of the character on the display (0..7)
179
- * value the character to be displayed.
180
- * dp sets the decimal point.
181
- */
182
- void setChar (int addr, int digit, char value, boolean dp);
60
+ private :
61
+ /* The array for shifting the data to the devices */
62
+ byte spidata[16 ];
63
+ /* Send out a single command to the device */
64
+ void spiTransfer (int addr, byte opcode, byte data);
65
+
66
+ /* We keep track of the led-status for all 8 devices in this array */
67
+ byte status[64 ];
68
+ /* Data is shifted out of this pin*/
69
+ int SPI_MOSI;
70
+ /* The clock is signaled on this pin */
71
+ int SPI_CLK;
72
+ /* This one is driven LOW for chip selectzion */
73
+ int SPI_CS;
74
+ /* The maximum number of devices we use */
75
+ int maxDevices;
76
+
77
+ public:
78
+ /*
79
+ * Create a new controler
80
+ * Params :
81
+ * dataPin pin on the Arduino where data gets shifted out
82
+ * clockPin pin for the clock
83
+ * csPin pin for selecting the device
84
+ * numDevices maximum number of devices that can be controled
85
+ */
86
+ LedControl (int dataPin, int clkPin, int csPin, int numDevices=1 );
87
+
88
+ /*
89
+ * Gets the number of devices attached to this LedControl.
90
+ * Returns :
91
+ * int the number of devices on this LedControl
92
+ */
93
+ int getDeviceCount ();
94
+
95
+ /*
96
+ * Set the shutdown (power saving) mode for the device
97
+ * Params :
98
+ * addr The address of the display to control
99
+ * status If true the device goes into power-down mode. Set to false
100
+ * for normal operation.
101
+ */
102
+ void shutdown (int addr, bool status);
103
+
104
+ /*
105
+ * Set the number of digits (or rows) to be displayed.
106
+ * See datasheet for sideeffects of the scanlimit on the brightness
107
+ * of the display.
108
+ * Params :
109
+ * addr address of the display to control
110
+ * limit number of digits to be displayed (1..8)
111
+ */
112
+ void setScanLimit (int addr, int limit);
113
+
114
+ /*
115
+ * Set the brightness of the display.
116
+ * Params:
117
+ * addr the address of the display to control
118
+ * intensity the brightness of the display. (0..15)
119
+ */
120
+ void setIntensity (int addr, int intensity);
121
+
122
+ /*
123
+ * Switch all Leds on the display off.
124
+ * Params:
125
+ * addr address of the display to control
126
+ */
127
+ void clearDisplay (int addr);
128
+
129
+ /*
130
+ * Set the status of a single Led.
131
+ * Params :
132
+ * addr address of the display
133
+ * row the row of the Led (0..7)
134
+ * col the column of the Led (0..7)
135
+ * state If true the led is switched on,
136
+ * if false it is switched off
137
+ */
138
+ void setLed (int addr, int row, int col, boolean state);
139
+
140
+ /*
141
+ * Set all 8 Led's in a row to a new state
142
+ * Params:
143
+ * addr address of the display
144
+ * row row which is to be set (0..7)
145
+ * value each bit set to 1 will light up the
146
+ * corresponding Led.
147
+ */
148
+ void setRow (int addr, int row, byte value);
149
+
150
+ /*
151
+ * Set all 8 Led's in a column to a new state
152
+ * Params:
153
+ * addr address of the display
154
+ * col column which is to be set (0..7)
155
+ * value each bit set to 1 will light up the
156
+ * corresponding Led.
157
+ */
158
+ void setColumn (int addr, int col, byte value);
159
+
160
+ /*
161
+ * Display a hexadecimal digit on a 7-Segment Display
162
+ * Params:
163
+ * addr address of the display
164
+ * digit the position of the digit on the display (0..7)
165
+ * value the value to be displayed. (0x00..0x0F)
166
+ * dp sets the decimal point.
167
+ */
168
+ void setDigit (int addr, int digit, byte value, boolean dp);
169
+
170
+ /*
171
+ * Display a character on a 7-Segment display.
172
+ * There are only a few characters that make sense here :
173
+ * '0','1','2','3','4','5','6','7','8','9','0',
174
+ * 'A','b','c','d','E','F','H','L','P',
175
+ * '.','-','_',' '
176
+ * Params:
177
+ * addr address of the display
178
+ * digit the position of the character on the display (0..7)
179
+ * value the character to be displayed.
180
+ * dp sets the decimal point.
181
+ */
182
+ void setChar (int addr, int digit, char value, boolean dp);
183
183
};
184
184
185
185
#endif // LedControl.h
0 commit comments