summaryrefslogtreecommitdiff
path: root/drivers/oled/oled_driver.c
diff options
context:
space:
mode:
authorThomas Baart <thomas@splitkb.com>2019-11-03 23:34:47 +0100
committerFlorian Didron <fdidron@users.noreply.github.com>2020-01-09 08:57:11 +0900
commit8a4525a6789952d2dfc1816646cde2b578ef042c (patch)
tree51b26b14a0853cc878d46a95c9534a74b25f8369 /drivers/oled/oled_driver.c
parent1836a6f5d22faca8a8db828d64d47bbfb7d8e45e (diff)
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
Diffstat (limited to 'drivers/oled/oled_driver.c')
-rw-r--r--drivers/oled/oled_driver.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 72960cca4c..f20f4629aa 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) {
oled_advance_page(true);
}
+void oled_write_raw(const char *data, uint16_t size) {
+ if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
+ for (uint16_t i = 0; i < size; i++) {
+ if (oled_buffer[i] == data[i]) continue;
+ oled_buffer[i] = data[i];
+ oled_dirty |= (1 << (i / OLED_BLOCK_SIZE));
+ }
+}
+
#if defined(__AVR__)
void oled_write_P(const char *data, bool invert) {
uint8_t c = pgm_read_byte(data);
@@ -444,6 +453,16 @@ void oled_write_ln_P(const char *data, bool invert) {
oled_write_P(data, invert);
oled_advance_page(true);
}
+
+void oled_write_raw_P(const char *data, uint16_t size) {
+ if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
+ for (uint16_t i = 0; i < size; i++) {
+ uint8_t c = pgm_read_byte(++data);
+ if (oled_buffer[i] == c) continue;
+ oled_buffer[i] = c;
+ oled_dirty |= (1 << (i / OLED_BLOCK_SIZE));
+ }
+}
#endif // defined(__AVR__)
bool oled_on(void) {
@@ -566,4 +585,4 @@ void oled_task(void) {
#endif
}
-__attribute__((weak)) void oled_task_user(void) {}
+__attribute__((weak)) void oled_task_user(void) {} \ No newline at end of file