mirror of
https://github.com/Hopiu/rpi-rgb-led-matrix.git
synced 2026-03-16 22:10:27 +00:00
o Make work with 16 row displays
This commit is contained in:
parent
43b299a8d5
commit
cedc03d79f
2 changed files with 10 additions and 8 deletions
|
|
@ -62,7 +62,7 @@ RGBMatrix::RGBMatrix(GPIO *io) : io_(io) {
|
|||
b.bits.output_enable = b.bits.clock = b.bits.strobe = 1;
|
||||
b.bits.r1 = b.bits.g1 = b.bits.b1 = 1;
|
||||
b.bits.r2 = b.bits.g2 = b.bits.b2 = 1;
|
||||
b.bits.row = 0xf;
|
||||
b.bits.row = kRowMask;
|
||||
// Initialize outputs, make sure that all of these are supported bits.
|
||||
const uint32_t result = io_->InitOutputs(b.raw);
|
||||
assert(result == b.raw);
|
||||
|
|
@ -75,8 +75,8 @@ void RGBMatrix::ClearScreen() {
|
|||
}
|
||||
|
||||
void RGBMatrix::FillScreen(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int x = 0; x < kColumns; ++x) {
|
||||
for (int y = 0; y < 32; ++y) {
|
||||
for (int x = 0; x < width(); ++x) {
|
||||
for (int y = 0; y < height(); ++y) {
|
||||
SetPixel(x, y, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ void RGBMatrix::SetPixel(uint8_t x, uint8_t y,
|
|||
|
||||
for (int b = 0; b < kPWMBits; ++b) {
|
||||
uint8_t mask = 1 << b;
|
||||
IoBits *bits = &bitplane_[b].row[y & 0xf].column[x];
|
||||
IoBits *bits = &bitplane_[b].row[y & kRowMask].column[x];
|
||||
if (y < kDoubleRows) { // Upper sub-panel.
|
||||
bits->bits.r1 = (red & mask) == mask;
|
||||
bits->bits.g1 = (green & mask) == mask;
|
||||
|
|
@ -129,7 +129,7 @@ void RGBMatrix::UpdateScreen() {
|
|||
serial_mask.bits.clock = 1;
|
||||
|
||||
IoBits row_mask;
|
||||
row_mask.bits.row = 0xf;
|
||||
row_mask.bits.row = kRowMask;
|
||||
|
||||
IoBits clock, output_enable, strobe;
|
||||
clock.bits.clock = 1;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ public:
|
|||
void ClearScreen();
|
||||
void FillScreen(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
int width() const { return kColumns; }
|
||||
int height() const { return kDisplayRows; }
|
||||
inline int width() const { return kColumns; }
|
||||
inline int height() const { return kDisplayRows; }
|
||||
void SetPixel(uint8_t x, uint8_t y,
|
||||
uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
|
|
@ -49,10 +49,12 @@ private:
|
|||
//
|
||||
// Sometimes, 16x32 boards actually might not have 2x8, but 1x16, which
|
||||
// means 1:16 multiplexing for that as well. In that case, remove the '/ 2'.
|
||||
// Rarely needed.
|
||||
kDoubleRows = kDisplayRows / 2, // Calculated constant.
|
||||
|
||||
// Calculated constant that you probably don't want to change.
|
||||
// Calculated constants that you probably don't want to change.
|
||||
kColumns = kChainedBoards * 32,
|
||||
kRowMask = kDoubleRows - 1
|
||||
};
|
||||
|
||||
union IoBits {
|
||||
|
|
|
|||
Loading…
Reference in a new issue