Adafruit-RGB_matrix_Panel(32*16)
Dependencies: Adafruit-GFX
Revision 5:1f8409ee8850, committed 2014-05-25
- Comitter:
- lelect
- Date:
- Sun May 25 11:30:30 2014 +0000
- Parent:
- 4:0ff6053c4bb2
- Child:
- 6:b594794a132e
- Child:
- 7:3ac98c836aa1
- Commit message:
- this does not work...@updateDisplay
Changed in this revision
RGBmatrixPanel.cpp | Show annotated file Show diff for this revision Revisions of this file |
RGBmatrixPanel.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/RGBmatrixPanel.cpp Sun May 25 09:32:41 2014 +0000 +++ b/RGBmatrixPanel.cpp Sun May 25 11:30:30 2014 +0000 @@ -1,5 +1,5 @@ #define DEBUG -//#undef DEBUG +#undef DEBUG #include "RGBmatrixPanel.h" #include "gamma.h" @@ -36,12 +36,12 @@ // Constructor for 16x32 panel: RGBmatrixPanel::RGBmatrixPanel(PinName r1,PinName r2,PinName g1,PinName g2,PinName b1,PinName b2,PinName a,PinName b, PinName c, PinName sclk, PinName latch, PinName oe, bool dbuf) :Adafruit_GFX(32, 16), + _dataBus(r1,g1,b1,r2,g2,b2), + _rowBus(a,b,c), + _d(NC), _sclk(sclk), _latch(latch), - _oe(oe), - _d(NC), - _dataBus(r1,g1,b1,r2,g2,b2), - _rowBus(c,b,a) + _oe(oe) { init(8, dbuf); } @@ -49,12 +49,12 @@ // Constructor for 32x32 panel: RGBmatrixPanel::RGBmatrixPanel(PinName r1,PinName r2,PinName g1,PinName g2,PinName b1,PinName b2,PinName a,PinName b,PinName c,PinName d,PinName sclk,PinName latch,PinName oe,bool dbuf) :Adafruit_GFX(32, 32), + _dataBus(r1,g1,b1,r2,g2,b2), + _rowBus(a,b,c), + _d(d),// Init 32x32-specific elements: _sclk(sclk), _latch(latch), - _oe(oe), - _d(d),// Init 32x32-specific elements: - _dataBus(r1,g1,b1,r2,g2,b2), - _rowBus(c,b,a) + _oe(oe) { init(16,dbuf); } @@ -68,9 +68,9 @@ // Set up Timer for interrupt: #ifndef DEBUG - _refresh.attach(this,(&RGBmatrixPanel::updateDisplay),0.0001); //updateDisplay() called every 1ms + _refresh.attach_us(this,(&RGBmatrixPanel::updateDisplay),100); //updateDisplay() called every 1ms #else - _refresh.attach(this,(&RGBmatrixPanel::updateDisplay),1.2); //updateDisplay() called every 2s + _refresh.attach(this,(&RGBmatrixPanel::updateDisplay),0.5); //updateDisplay() called every 2s #endif } @@ -232,7 +232,7 @@ // Data is stored in the high 6 bits so it can be quickly // copied to the DATAPORT register w/6 output lines. for(; bit < limit; bit <<= 1) { - ptr[0] &= ~(_BV(4)|_BV(3)|_BV(2)); // Mask(0b11100011) out R,G,B in one op + *ptr &= ~(_BV(4)|_BV(3)|_BV(2)) ; // Mask(0b11100011) out R,G,B in one op if(r & bit) *ptr |= _BV(2); // Plane N R: bit 2 if(g & bit) *ptr |= _BV(3); // Plane N G: bit 3 if(b & bit) *ptr |= _BV(4); // Plane N B: bit 4 @@ -320,6 +320,7 @@ void RGBmatrixPanel::updateDisplay(void) { + uint8_t *ptr; log_debug("\r\ncall updateDisplay\r\n"); _oe=1; _latch=1; @@ -337,17 +338,21 @@ } } else if(plane == 1) { log_debug("\tupdate row%s","\r\n"); - _rowBus=row; + _rowBus.write(row); } + _dataBus=0; _oe=0; _latch=0; + ptr = (uint8_t *)buffptr; + log_debug("\t(row@plane)=(%d,%d)\r\n",row,plane); int color; if(plane > 0) { + //ptr[i]>>2 for(int i=0; i<32; i++) { - color=0x3F&(buffptr[i]); - //buffptr[i]>>2 - _dataBus=color>>2; + color=*(ptr+i); + color=(color>>2)&0x3F; + _dataBus.write(color); _sclk=1; _sclk=0; #ifdef DEBUG @@ -361,9 +366,10 @@ } buffptr += _rawWidth; } else { + //((ptr[i]<<4)|((ptr[i+32]<<2)&0x0C)|((ptr[i+64])&0x03)); for(int i=0; i<32; i++) { - color=0x3F&((buffptr[i]<<4)|((buffptr[i+32]<<2)&0x0C)|((buffptr[i+64])&0x03)); - _dataBus=color; + color=0x3F&((ptr[i]<<4)|((ptr[i+32]<<2)&0x0C)|((ptr[i+64])&0x03)); + _dataBus.write(color); _sclk=1; _sclk=0; #ifdef DEBUG @@ -376,5 +382,6 @@ #endif } } + }
--- a/RGBmatrixPanel.h Sun May 25 09:32:41 2014 +0000 +++ b/RGBmatrixPanel.h Sun May 25 11:30:30 2014 +0000 @@ -47,10 +47,11 @@ // Init/alloc code common to both constructors: void init(uint8_t rows, bool dbuf); - DigitalOut _sclk, _latch, _oe, _d; - BusOut _dataBus,_rowBus; + BusOut _dataBus; + BusOut _rowBus; + DigitalOut _d,_sclk, _latch, _oe; Ticker _refresh; // Counters/pointers for interrupt handler: - uint8_t row, plane; - uint8_t *buffptr; + volatile uint8_t row, plane; + volatile uint8_t *buffptr; }; \ No newline at end of file