summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorbrickbots <rich@brickbots.com>2020-03-06 16:52:39 -0800
committerFlorian Didron <fdidron@users.noreply.github.com>2020-06-12 17:00:27 +0900
commit5b752d390f416ac9556d8022f1fe06f484a638a5 (patch)
tree43dceb99f56e4920585d42ecc585e7e4d27065da /drivers
parent8eec4424d095ca26ff874b4c5fd3ce915118fb57 (diff)
Buffer based OLED panning, write byte to buffer at arbitrary index (#8055)
* Add buffer based single line pan, arbitrary byte write to buffer * Change dirty mask to inverse of OLED_BLOCK_TYPE for future proofing larger buffer sizes * Updating docs to include new functions * Updating to clarify scroll vs pan
Diffstat (limited to 'drivers')
-rw-r--r--drivers/oled/oled_driver.c25
-rw-r--r--drivers/oled/oled_driver.h4
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index d03b2de3a2..079f5688fe 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -428,6 +428,31 @@ void oled_write_ln(const char *data, bool invert) {
oled_advance_page(true);
}
+void oled_pan(bool left) {
+ uint16_t i = 0;
+ for (uint16_t y = 0; y < OLED_DISPLAY_HEIGHT / 8; y++) {
+ if (left) {
+ for (uint16_t x = 0; x < OLED_DISPLAY_WIDTH - 1; x++) {
+ i = y * OLED_DISPLAY_WIDTH + x;
+ oled_buffer[i] = oled_buffer[i + 1];
+ }
+ } else {
+ for (uint16_t x = OLED_DISPLAY_WIDTH - 1; x > 0; x--) {
+ i = y * OLED_DISPLAY_WIDTH + x;
+ oled_buffer[i] = oled_buffer[i - 1];
+ }
+ }
+ }
+ oled_dirty = ~((OLED_BLOCK_TYPE)0);
+}
+
+void oled_write_raw_byte(const char data, uint16_t index) {
+ if (index > OLED_MATRIX_SIZE) index = OLED_MATRIX_SIZE;
+ if (oled_buffer[index] == data) return;
+ oled_buffer[index] = data;
+ oled_dirty |= (1 << (index / OLED_BLOCK_SIZE));
+}
+
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++) {
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 5aea710dd4..63e5efb29d 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -200,7 +200,11 @@ void oled_write(const char *data, bool invert);
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
void oled_write_ln(const char *data, bool invert);
+// Pans the buffer to the right (or left by passing true) by moving contents of the buffer
+void oled_pan(bool left);
+
void oled_write_raw(const char *data, uint16_t size);
+void oled_write_raw_byte(const char data, uint16_t index);
#if defined(__AVR__)
// Writes a PROGMEM string to the buffer at current cursor position