HID: fix display width

This commit is contained in:
Lukas F. Hartmann 2022-08-26 17:04:21 +02:00
parent e9396f3cd3
commit 69669556b3
2 changed files with 3 additions and 6 deletions

View File

@ -16,7 +16,6 @@ uint8_t oledbrt = 0;
struct CharacterMatrix display; struct CharacterMatrix display;
// Write command sequence. // Write command sequence.
// Returns true on success.
static inline bool _send_cmd1(uint8_t cmd) { static inline bool _send_cmd1(uint8_t cmd) {
uint8_t buf[] = {0x00, cmd}; uint8_t buf[] = {0x00, cmd};
i2c_write_blocking(i2c0, SSD1306_ADDRESS, buf, 2, false); i2c_write_blocking(i2c0, SSD1306_ADDRESS, buf, 2, false);
@ -24,7 +23,6 @@ static inline bool _send_cmd1(uint8_t cmd) {
} }
// Write 2-byte command sequence. // Write 2-byte command sequence.
// Returns true on success
static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
_send_cmd1(cmd); _send_cmd1(cmd);
_send_cmd1(opr); _send_cmd1(opr);
@ -32,7 +30,6 @@ static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
} }
// Write 3-byte command sequence. // Write 3-byte command sequence.
// Returns true on success
static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
_send_cmd1(cmd); _send_cmd1(cmd);
_send_cmd1(opr1); _send_cmd1(opr1);
@ -266,7 +263,7 @@ void matrix_render(struct CharacterMatrix *matrix) {
send_cmd3(PageAddr, 0, MatrixRows - 1); send_cmd3(PageAddr, 0, MatrixRows - 1);
send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
uint8_t buf[1 + MatrixRows * DisplayWidth]; uint8_t buf[1 + MatrixRows * MatrixCols];
buf[0] = 0x40; buf[0] = 0x40;
int i = 1; int i = 1;
@ -282,7 +279,7 @@ void matrix_render(struct CharacterMatrix *matrix) {
} }
} }
} }
i2c_write_blocking(i2c0, SSD1306_ADDRESS, buf, 1 + MatrixRows * DisplayWidth, false); i2c_write_blocking(i2c0, SSD1306_ADDRESS, buf, 1 + MatrixRows * MatrixCols, false);
matrix->dirty = false; matrix->dirty = false;
done: done:

View File

@ -53,7 +53,7 @@ enum ssd1306_cmds {
#define SSD1306_ADDRESS 0x3C #define SSD1306_ADDRESS 0x3C
#define DisplayHeight 32 #define DisplayHeight 32
#define DisplayWidth 128 #define DisplayWidth 126
#define FontHeight 8 #define FontHeight 8
#define FontWidth 6 #define FontWidth 6