o Allow chaining of boards.

This commit is contained in:
Henner Zeller 2013-02-17 06:20:56 +00:00
parent 35ca26ac81
commit aaf9105f08
3 changed files with 11 additions and 5 deletions

View file

@ -74,7 +74,7 @@ void RGBMatrix::ClearScreen() {
void RGBMatrix::SetPixel(uint8_t x, uint8_t y,
uint8_t red, uint8_t green, uint8_t blue) {
if (x > 31 || y > 31) return;
if (x >= kColumns || y > 31) return;
// TODO: re-map values to be luminance corrected (sometimes called 'gamma').
// Ideally, we had like 10PWM bits for this, but we're too slow for that :/

View file

@ -1,3 +1,4 @@
// -*- c++ -*-
// Controlling a 32x32 RGB matrix via GPIO.
#ifndef RPI_RGBMATRIX_H
@ -18,13 +19,16 @@ class RGBMatrix {
// thread.
void UpdateScreen();
int columns() { return kColumns; }
private:
GPIO *const io_;
enum {
kChainedBoards = 1, // Number of boards that are daisy-chained.
kRows = 16,
kColumns = 32,
kPWMBits = 7 // maximum PWM resolution.
kColumns = kChainedBoards * 32,
kPWMBits = 7 // maximum PWM resolution.
};
union IoBits {

View file

@ -153,16 +153,18 @@ public:
}
void Run() {
const int columns = matrix_->columns();
while (running_) {
if (image_ == NULL) {
usleep(100 * 1000);
continue;
}
usleep(30 * 1000);
for (int x = 0; x < 32; ++x) {
for (int x = 0; x < columns; ++x) {
for (int y = 0; y < 32; ++y) {
const Pixel &p = getPixel((horizontal_position_ + x) % width_, y);
int disp_x = 31 - x; // Display upside down on my desk. Lets flip :)
// Display upside down on my desk. Lets flip :)
int disp_x = columns - x;
int disp_y = 31 - y;
matrix_->SetPixel(disp_x, disp_y, p.red, p.green, p.blue);
}