3535#define OP_SHUTDOWN 12
3636#define OP_DISPLAYTEST 15
3737
38- Max72xxPanel::Max72xxPanel (byte csPin, byte hDisplays, byte vDisplays) : Adafruit_GFX(hDisplays << 3 , vDisplays << 3 ) {
38+ Max72xxPanel::Max72xxPanel (uint8_t csPin, uint8_t hDisplays, uint8_t vDisplays) : Adafruit_GFX(hDisplays << 3 , vDisplays << 3 ) {
3939
4040 Max72xxPanel::SPI_CS = csPin;
4141
42- byte displays = hDisplays * vDisplays;
42+ uint8_t displays = hDisplays * vDisplays;
4343 Max72xxPanel::hDisplays = hDisplays;
4444 Max72xxPanel::bitmapSize = displays << 3 ;
4545
46- Max72xxPanel::bitmap = (byte *)malloc (bitmapSize);
47- Max72xxPanel::matrixRotation = (byte *)malloc (displays);
48- Max72xxPanel::matrixPosition = (byte *)malloc (displays);
46+ Max72xxPanel::bitmap = (uint8_t *)malloc (bitmapSize);
47+ Max72xxPanel::matrixRotation = (uint8_t *)malloc (displays);
48+ Max72xxPanel::matrixPosition = (uint8_t *)malloc (displays);
4949
50- for ( byte display = 0 ; display < displays; display++ ) {
50+ for ( uint8_t display = 0 ; display < displays; display++ ) {
5151 matrixPosition[display] = display;
5252 matrixRotation[display] = 0 ;
5353 }
@@ -76,23 +76,23 @@ Max72xxPanel::Max72xxPanel(byte csPin, byte hDisplays, byte vDisplays) : Adafrui
7676 setIntensity (7 );
7777}
7878
79- void Max72xxPanel::setPosition (byte display, byte x, byte y) {
79+ void Max72xxPanel::setPosition (uint8_t display, uint8_t x, uint8_t y) {
8080 matrixPosition[x + hDisplays * y] = display;
8181}
8282
83- void Max72xxPanel::setRotation (byte display, byte rotation) {
83+ void Max72xxPanel::setRotation (uint8_t display, uint8_t rotation) {
8484 matrixRotation[display] = rotation;
8585}
8686
8787void Max72xxPanel::setRotation (uint8_t rotation) {
8888 Adafruit_GFX::setRotation (rotation);
8989}
9090
91- void Max72xxPanel::shutdown (boolean b) {
91+ void Max72xxPanel::shutdown (bool b) {
9292 spiTransfer (OP_SHUTDOWN, b ? 0 : 1 );
9393}
9494
95- void Max72xxPanel::setIntensity (byte intensity) {
95+ void Max72xxPanel::setIntensity (uint8_t intensity) {
9696 spiTransfer (OP_INTENSITY, intensity);
9797}
9898
@@ -132,11 +132,11 @@ void Max72xxPanel::drawPixel(int16_t xx, int16_t yy, uint16_t color) {
132132 // Translate the x, y coordinate according to the layout of the
133133 // displays. They can be ordered and rotated (0, 90, 180, 270).
134134
135- byte display = matrixPosition[(x >> 3 ) + hDisplays * (y >> 3 )];
135+ uint8_t display = matrixPosition[(x >> 3 ) + hDisplays * (y >> 3 )];
136136 x &= 0b111 ;
137137 y &= 0b111 ;
138138
139- byte r = matrixRotation[display];
139+ uint8_t r = matrixRotation[display];
140140 if ( r >= 2 ) { // 180 or 270 degrees
141141 x = 7 - x;
142142 }
@@ -147,14 +147,14 @@ void Max72xxPanel::drawPixel(int16_t xx, int16_t yy, uint16_t color) {
147147 tmp = x; x = y; y = tmp;
148148 }
149149
150- byte d = display / hDisplays;
150+ uint8_t d = display / hDisplays;
151151 x += (display - d * hDisplays) << 3 ; // x += (display % hDisplays) * 8
152152 y += d << 3 ; // y += (display / hDisplays) * 8
153153
154154 // Update the color bit in our bitmap buffer.
155155
156- byte *ptr = bitmap + x + WIDTH * (y >> 3 );
157- byte val = 1 << (y & 0b111 );
156+ uint8_t *ptr = bitmap + x + WIDTH * (y >> 3 );
157+ uint8_t val = 1 << (y & 0b111 );
158158
159159 if ( color ) {
160160 *ptr |= val;
@@ -167,12 +167,12 @@ void Max72xxPanel::drawPixel(int16_t xx, int16_t yy, uint16_t color) {
167167void Max72xxPanel::write () {
168168 // Send the bitmap buffer to the displays.
169169
170- for ( byte row = OP_DIGIT7; row >= OP_DIGIT0; row-- ) {
170+ for ( uint8_t row = OP_DIGIT7; row >= OP_DIGIT0; row-- ) {
171171 spiTransfer (row);
172172 }
173173}
174174
175- void Max72xxPanel::spiTransfer (byte opcode, byte data) {
175+ void Max72xxPanel::spiTransfer (uint8_t opcode, uint8_t data) {
176176 // If opcode > OP_DIGIT7, send the opcode and data to all displays.
177177 // If opcode <= OP_DIGIT7, display the column with data in our buffer for all displays.
178178 // We do not support (nor need) to use the OP_NOOP opcode.
@@ -182,8 +182,8 @@ void Max72xxPanel::spiTransfer(byte opcode, byte data) {
182182
183183 // Now shift out the data, two bytes per display. The first byte is the opcode,
184184 // the second byte the data.
185- byte end = opcode - OP_DIGIT0;
186- byte start = bitmapSize + end;
185+ uint8_t end = opcode - OP_DIGIT0;
186+ uint8_t start = bitmapSize + end;
187187 do {
188188 start -= 8 ;
189189 SPI.transfer (opcode);
0 commit comments