Newer
Older
const uint8_t init[4] = {0x21, 0xa0, 0xe1, 0x81};
const uint8_t zeile[8] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x10, 0x12, 0x14};
const uint8_t fill[17] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
const uint8_t empty[17] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// erste byte: bei welche zeile es anfängt
// 0x00 => data address pointer command begins with 0000, second half modifies command to tell which line it is
/*
lines go from 0 - 15 => nimm alle gerade (0, 2, 4, 6, 8, 10, 12, 14), (1, 3, 5, 7, 9, 11, 13, 15)
so every other byte is egal
0xff == every led in row lights up (all 8 bits are lit up)
*/
const uint8_t matrix[9][17] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // empty
{0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // achtel
{0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // viertel
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // dreiachtel
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // hälfte
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // fünfachtel
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, // dreiviertel
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00}, // siebenachtel
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00}, // ganzes
};
// Pin 0 and 1 are given I2C functionality (they're the ones connected to the led matrix)
gpio_set_function(0, GPIO_FUNC_I2C);
gpio_set_function(1, GPIO_FUNC_I2C);
// refer to page 439 in RP2040, redundant with write_blocking - pins are used as output (write enable) (sort of)
// gpio_pull_up(1);
// gpio_pull_up(0);
// 0x70 i2c address for 28 pin (refer to matrix.pdf page 21)
// can't be directly written cuz we need pointers
// system setup (clock enable), ROW/INT set, dimming, display setup
// const uint8_t init[4] = {0x21, 0xa0, 0xe1, 0x81};
i2c_write_blocking(i2c_default, 0x70, &init[0], 1, false);
i2c_write_blocking(i2c_default, 0x70, &init[1], 1, false);
i2c_write_blocking(i2c_default, 0x70, &init[2], 1, false);
i2c_write_blocking(i2c_default, 0x70, &init[3], 1, false);
i2c_write_blocking(i2c_default, 0x70, zeile, 4, false);
i2c_write_blocking(i2c_default, 0x70, empty, 17, false);
for (int i = 0; i <= 8; i++)
i2c_write_blocking(i2c_default, 0x70, matrix[i], 17, false);
for (int j = 0; j < 10000000; j++)
{
volatile int i = 0;
}