aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_oled_driver.md4
-rw-r--r--drivers/oled/oled_driver.c13
-rw-r--r--drivers/oled/oled_driver.h4
3 files changed, 21 insertions, 0 deletions
diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md
index 772ce57bd..5f3095198 100644
--- a/docs/feature_oled_driver.md
+++ b/docs/feature_oled_driver.md
@@ -247,6 +247,10 @@ void oled_write_raw_byte(const char data, uint16_t index);
247// Writes a PROGMEM string to the buffer at current cursor position 247// Writes a PROGMEM string to the buffer at current cursor position
248void oled_write_raw_P(const char *data, uint16_t size); 248void oled_write_raw_P(const char *data, uint16_t size);
249 249
250// Sets a specific pixel on or off
251// Coordinates start at top-left and go right and down for positive x and y
252void oled_write_pixel(uint8_t x, uint8_t y, bool on);
253
250// Can be used to manually turn on the screen if it is off 254// Can be used to manually turn on the screen if it is off
251// Returns true if the screen was on or turns on 255// Returns true if the screen was on or turns on
252bool oled_on(void); 256bool oled_on(void);
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index eedaedcd3..977b70178 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -462,6 +462,19 @@ void oled_write_raw(const char *data, uint16_t size) {
462 } 462 }
463} 463}
464 464
465void oled_write_pixel(uint8_t x, uint8_t y, bool on) {
466 if (x >= OLED_DISPLAY_WIDTH || y >= OLED_DISPLAY_HEIGHT) {
467 return;
468 }
469 uint16_t index = x + (y / 8) * OLED_DISPLAY_WIDTH;
470 if (on) {
471 oled_buffer[index] |= (1 << (y % 8));
472 } else {
473 oled_buffer[index] &= ~(1 << (y % 8));
474 }
475 oled_dirty |= (1 << (index / OLED_BLOCK_SIZE));
476}
477
465#if defined(__AVR__) 478#if defined(__AVR__)
466void oled_write_P(const char *data, bool invert) { 479void oled_write_P(const char *data, bool invert) {
467 uint8_t c = pgm_read_byte(data); 480 uint8_t c = pgm_read_byte(data);
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 3e5a5bcab..af6e5a2b6 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -206,6 +206,10 @@ void oled_pan(bool left);
206void oled_write_raw(const char *data, uint16_t size); 206void oled_write_raw(const char *data, uint16_t size);
207void oled_write_raw_byte(const char data, uint16_t index); 207void oled_write_raw_byte(const char data, uint16_t index);
208 208
209// Sets a specific pixel on or off
210// Coordinates start at top-left and go right and down for positive x and y
211void oled_write_pixel(uint8_t x, uint8_t y, bool on);
212
209#if defined(__AVR__) 213#if defined(__AVR__)
210// Writes a PROGMEM string to the buffer at current cursor position 214// Writes a PROGMEM string to the buffer at current cursor position
211// Advances the cursor while writing, inverts the pixels if true 215// Advances the cursor while writing, inverts the pixels if true