aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Baart <thomas@splitkb.com>2019-11-03 23:34:47 +0100
committerDrashna Jaelre <drashna@live.com>2019-11-03 14:34:47 -0800
commitbe6562a22335b85e9904c0f7cc748943c9e809a7 (patch)
treefc1036ab54253a0c2c66c8ca12a2f6490f0d5b8a
parent732d1dd4f6f9ec060b4b8332309c82ebb6c3ca25 (diff)
downloadqmk_firmware-be6562a22335b85e9904c0f7cc748943c9e809a7.tar.gz
qmk_firmware-be6562a22335b85e9904c0f7cc748943c9e809a7.zip
Adds raw write functions to the OLED driver (#7237)
* Added oled_write_raw and oled_write_raw_P functions to the OLED driver * Added oled_write_raw method calls to feature_oled_driver.md
-rw-r--r--docs/feature_oled_driver.md6
-rw-r--r--drivers/oled/oled_driver.c21
-rw-r--r--drivers/oled/oled_driver.h6
3 files changed, 31 insertions, 2 deletions
diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md
index 623f1816a..b124ba5a8 100644
--- a/docs/feature_oled_driver.md
+++ b/docs/feature_oled_driver.md
@@ -229,6 +229,12 @@ void oled_write_P(const char *data, bool invert);
229// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM 229// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM
230void oled_write_ln_P(const char *data, bool invert); 230void oled_write_ln_P(const char *data, bool invert);
231 231
232// Writes a string to the buffer at current cursor position
233void oled_write_raw(const char *data, uint16_t size);
234
235// Writes a PROGMEM string to the buffer at current cursor position
236void oled_write_raw_P(const char *data, uint16_t size);
237
232// Can be used to manually turn on the screen if it is off 238// Can be used to manually turn on the screen if it is off
233// Returns true if the screen was on or turns on 239// Returns true if the screen was on or turns on
234bool oled_on(void); 240bool oled_on(void);
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 72960cca4..f20f4629a 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -431,6 +431,15 @@ void oled_write_ln(const char *data, bool invert) {
431 oled_advance_page(true); 431 oled_advance_page(true);
432} 432}
433 433
434void oled_write_raw(const char *data, uint16_t size) {
435 if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
436 for (uint16_t i = 0; i < size; i++) {
437 if (oled_buffer[i] == data[i]) continue;
438 oled_buffer[i] = data[i];
439 oled_dirty |= (1 << (i / OLED_BLOCK_SIZE));
440 }
441}
442
434#if defined(__AVR__) 443#if defined(__AVR__)
435void oled_write_P(const char *data, bool invert) { 444void oled_write_P(const char *data, bool invert) {
436 uint8_t c = pgm_read_byte(data); 445 uint8_t c = pgm_read_byte(data);
@@ -444,6 +453,16 @@ void oled_write_ln_P(const char *data, bool invert) {
444 oled_write_P(data, invert); 453 oled_write_P(data, invert);
445 oled_advance_page(true); 454 oled_advance_page(true);
446} 455}
456
457void oled_write_raw_P(const char *data, uint16_t size) {
458 if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
459 for (uint16_t i = 0; i < size; i++) {
460 uint8_t c = pgm_read_byte(++data);
461 if (oled_buffer[i] == c) continue;
462 oled_buffer[i] = c;
463 oled_dirty |= (1 << (i / OLED_BLOCK_SIZE));
464 }
465}
447#endif // defined(__AVR__) 466#endif // defined(__AVR__)
448 467
449bool oled_on(void) { 468bool oled_on(void) {
@@ -566,4 +585,4 @@ void oled_task(void) {
566#endif 585#endif
567} 586}
568 587
569__attribute__((weak)) void oled_task_user(void) {} 588__attribute__((weak)) void oled_task_user(void) {} \ No newline at end of file
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index ac8a1c765..bba6a7a12 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -200,6 +200,8 @@ void oled_write(const char *data, bool invert);
200// Advances the cursor to the next page, wiring ' ' to the remainder of the current page 200// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
201void oled_write_ln(const char *data, bool invert); 201void oled_write_ln(const char *data, bool invert);
202 202
203void oled_write_raw(const char *data, uint16_t size);
204
203#if defined(__AVR__) 205#if defined(__AVR__)
204// Writes a PROGMEM string to the buffer at current cursor position 206// Writes a PROGMEM string to the buffer at current cursor position
205// Advances the cursor while writing, inverts the pixels if true 207// Advances the cursor while writing, inverts the pixels if true
@@ -211,6 +213,8 @@ void oled_write_P(const char *data, bool invert);
211// Advances the cursor to the next page, wiring ' ' to the remainder of the current page 213// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
212// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM 214// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM
213void oled_write_ln_P(const char *data, bool invert); 215void oled_write_ln_P(const char *data, bool invert);
216
217void oled_write_raw_P(const char *data, uint16_t size);
214#else 218#else
215// Writes a string to the buffer at current cursor position 219// Writes a string to the buffer at current cursor position
216// Advances the cursor while writing, inverts the pixels if true 220// Advances the cursor while writing, inverts the pixels if true
@@ -254,4 +258,4 @@ bool oled_scroll_off(void);
254uint8_t oled_max_chars(void); 258uint8_t oled_max_chars(void);
255 259
256// Returns the maximum number of lines that will fit on the oled 260// Returns the maximum number of lines that will fit on the oled
257uint8_t oled_max_lines(void); 261uint8_t oled_max_lines(void); \ No newline at end of file