summaryrefslogtreecommitdiff
path: root/drivers/lcd
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-12 10:29:31 -0800
committerGitHub <noreply@github.com>2022-02-12 18:29:31 +0000
commit63646e8906e062d1c1de3925cba70c4e3426a855 (patch)
tree4e91648b77b838e1125cf86331d7e84bde6d07a9 /drivers/lcd
parentafcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff)
Format code according to conventions (#16322)
Diffstat (limited to 'drivers/lcd')
-rw-r--r--drivers/lcd/st7565.c25
-rw-r--r--drivers/lcd/st7565.h8
2 files changed, 21 insertions, 12 deletions
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c
index 49b13c00f1..47ee02804b 100644
--- a/drivers/lcd/st7565.c
+++ b/drivers/lcd/st7565.c
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
39// Addressing Setting Commands 39// Addressing Setting Commands
40#define PAM_SETCOLUMN_LSB 0x00 40#define PAM_SETCOLUMN_LSB 0x00
41#define PAM_SETCOLUMN_MSB 0x10 41#define PAM_SETCOLUMN_MSB 0x10
42#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 42#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
43 43
44// Hardware Configuration Commands 44// Hardware Configuration Commands
45#define DISPLAY_START_LINE 0x40 45#define DISPLAY_START_LINE 0x40
@@ -138,7 +138,9 @@ bool st7565_init(display_rotation_t rotation) {
138 return true; 138 return true;
139} 139}
140 140
141__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { return rotation; } 141__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) {
142 return rotation;
143}
142 144
143void st7565_clear(void) { 145void st7565_clear(void) {
144 memset(st7565_buffer, 0, sizeof(st7565_buffer)); 146 memset(st7565_buffer, 0, sizeof(st7565_buffer));
@@ -212,7 +214,8 @@ void st7565_advance_page(bool clearPageRemainder) {
212 remaining = remaining / ST7565_FONT_WIDTH; 214 remaining = remaining / ST7565_FONT_WIDTH;
213 215
214 // Write empty character until next line 216 // Write empty character until next line
215 while (remaining--) st7565_write_char(' ', false); 217 while (remaining--)
218 st7565_write_char(' ', false);
216 } else { 219 } else {
217 // Next page index out of bounds? 220 // Next page index out of bounds?
218 if (index + remaining >= ST7565_MATRIX_SIZE) { 221 if (index + remaining >= ST7565_MATRIX_SIZE) {
@@ -263,7 +266,7 @@ void st7565_write_char(const char data, bool invert) {
263 _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); 266 _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");
264 267
265 // set the reder buffer data 268 // set the reder buffer data
266 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index 269 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
267 if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) { 270 if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) {
268 memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH); 271 memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH);
269 } else { 272 } else {
@@ -389,7 +392,7 @@ void st7565_write_raw_P(const char *data, uint16_t size) {
389 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE)); 392 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE));
390 } 393 }
391} 394}
392#endif // defined(__AVR__) 395#endif // defined(__AVR__)
393 396
394bool st7565_on(void) { 397bool st7565_on(void) {
395 if (!st7565_initialized) { 398 if (!st7565_initialized) {
@@ -429,7 +432,9 @@ bool st7565_off(void) {
429 432
430__attribute__((weak)) void st7565_off_user(void) {} 433__attribute__((weak)) void st7565_off_user(void) {}
431 434
432bool st7565_is_on(void) { return st7565_active; } 435bool st7565_is_on(void) {
436 return st7565_active;
437}
433 438
434bool st7565_invert(bool invert) { 439bool st7565_invert(bool invert) {
435 if (!st7565_initialized) { 440 if (!st7565_initialized) {
@@ -445,9 +450,13 @@ bool st7565_invert(bool invert) {
445 return st7565_inverted; 450 return st7565_inverted;
446} 451}
447 452
448uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; } 453uint8_t st7565_max_chars(void) {
454 return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH;
455}
449 456
450uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; } 457uint8_t st7565_max_lines(void) {
458 return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT;
459}
451 460
452void st7565_task(void) { 461void st7565_task(void) {
453 if (!st7565_initialized) { 462 if (!st7565_initialized) {
diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h
index d453dbe6da..0e42c8765b 100644
--- a/drivers/lcd/st7565.h
+++ b/drivers/lcd/st7565.h
@@ -29,16 +29,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29# define ST7565_DISPLAY_HEIGHT 32 29# define ST7565_DISPLAY_HEIGHT 32
30#endif 30#endif
31#ifndef ST7565_MATRIX_SIZE 31#ifndef ST7565_MATRIX_SIZE
32# define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed) 32# define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed)
33#endif 33#endif
34#ifndef ST7565_BLOCK_TYPE 34#ifndef ST7565_BLOCK_TYPE
35# define ST7565_BLOCK_TYPE uint16_t 35# define ST7565_BLOCK_TYPE uint16_t
36#endif 36#endif
37#ifndef ST7565_BLOCK_COUNT 37#ifndef ST7565_BLOCK_COUNT
38# define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed) 38# define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed)
39#endif 39#endif
40#ifndef ST7565_BLOCK_SIZE 40#ifndef ST7565_BLOCK_SIZE
41# define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed) 41# define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed)
42#endif 42#endif
43 43
44// the column address corresponding to the first column in the display hardware 44// the column address corresponding to the first column in the display hardware
@@ -174,7 +174,7 @@ void st7565_write_raw_P(const char *data, uint16_t size);
174# define st7565_write_P(data, invert) st7565_write(data, invert) 174# define st7565_write_P(data, invert) st7565_write(data, invert)
175# define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert) 175# define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert)
176# define st7565_write_raw_P(data, size) st7565_write_raw(data, size) 176# define st7565_write_raw_P(data, size) st7565_write_raw(data, size)
177#endif // defined(__AVR__) 177#endif // defined(__AVR__)
178 178
179// Can be used to manually turn on the screen if it is off 179// Can be used to manually turn on the screen if it is off
180// Returns true if the screen was on or turns on 180// Returns true if the screen was on or turns on