diff options
author | Ryan <fauxpark@gmail.com> | 2021-06-17 17:14:23 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 17:14:23 +1000 |
commit | 2f08a343948c6db3c67505f8fca5fdbfed41831b (patch) | |
tree | 5d62c1a5229107ce9a20a230375f508905564629 | |
parent | a9c6adb083556ae485dbf1e9f86ad615e32a8b7a (diff) | |
download | qmk_firmware-2f08a343948c6db3c67505f8fca5fdbfed41831b.tar.gz qmk_firmware-2f08a343948c6db3c67505f8fca5fdbfed41831b.zip |
OLED driver tweaks (#13215)
-rw-r--r-- | docs/feature_oled_driver.md | 30 | ||||
-rw-r--r-- | drivers/oled/oled_driver.c | 4 | ||||
-rw-r--r-- | drivers/oled/oled_driver.h | 12 |
3 files changed, 22 insertions, 24 deletions
diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md index d2dc6103a..f3b659b1b 100644 --- a/docs/feature_oled_driver.md +++ b/docs/feature_oled_driver.md | |||
@@ -263,22 +263,11 @@ void oled_write(const char *data, bool invert); | |||
263 | void oled_write_ln(const char *data, bool invert); | 263 | void oled_write_ln(const char *data, bool invert); |
264 | 264 | ||
265 | // Pans the buffer to the right (or left by passing true) by moving contents of the buffer | 265 | // Pans the buffer to the right (or left by passing true) by moving contents of the buffer |
266 | // Useful for moving the screen in preparation for new drawing | 266 | // Useful for moving the screen in preparation for new drawing |
267 | // oled_scroll_left or oled_scroll_right should be preferred for all cases of moving a static | 267 | // oled_scroll_left or oled_scroll_right should be preferred for all cases of moving a static |
268 | // image such as a logo or to avoid burn-in as it's much, much less cpu intensive | 268 | // image such as a logo or to avoid burn-in as it's much, much less cpu intensive |
269 | void oled_pan(bool left); | 269 | void oled_pan(bool left); |
270 | 270 | ||
271 | // Writes a PROGMEM string to the buffer at current cursor position | ||
272 | // Advances the cursor while writing, inverts the pixels if true | ||
273 | // Remapped to call 'void oled_write(const char *data, bool invert);' on ARM | ||
274 | void oled_write_P(const char *data, bool invert); | ||
275 | |||
276 | // Writes a PROGMEM string to the buffer at current cursor position | ||
277 | // Advances the cursor while writing, inverts the pixels if true | ||
278 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page | ||
279 | // Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM | ||
280 | void oled_write_ln_P(const char *data, bool invert); | ||
281 | |||
282 | // Returns a pointer to the requested start index in the buffer plus remaining | 271 | // Returns a pointer to the requested start index in the buffer plus remaining |
283 | // buffer length as struct | 272 | // buffer length as struct |
284 | oled_buffer_reader_t oled_read_raw(uint16_t start_index); | 273 | oled_buffer_reader_t oled_read_raw(uint16_t start_index); |
@@ -289,13 +278,24 @@ void oled_write_raw(const char *data, uint16_t size); | |||
289 | // Writes a single byte into the buffer at the specified index | 278 | // Writes a single byte into the buffer at the specified index |
290 | void oled_write_raw_byte(const char data, uint16_t index); | 279 | void oled_write_raw_byte(const char data, uint16_t index); |
291 | 280 | ||
292 | // Writes a PROGMEM string to the buffer at current cursor position | ||
293 | void oled_write_raw_P(const char *data, uint16_t size); | ||
294 | |||
295 | // Sets a specific pixel on or off | 281 | // Sets a specific pixel on or off |
296 | // Coordinates start at top-left and go right and down for positive x and y | 282 | // Coordinates start at top-left and go right and down for positive x and y |
297 | void oled_write_pixel(uint8_t x, uint8_t y, bool on); | 283 | void oled_write_pixel(uint8_t x, uint8_t y, bool on); |
298 | 284 | ||
285 | // Writes a PROGMEM string to the buffer at current cursor position | ||
286 | // Advances the cursor while writing, inverts the pixels if true | ||
287 | // Remapped to call 'void oled_write(const char *data, bool invert);' on ARM | ||
288 | void oled_write_P(const char *data, bool invert); | ||
289 | |||
290 | // Writes a PROGMEM string to the buffer at current cursor position | ||
291 | // Advances the cursor while writing, inverts the pixels if true | ||
292 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page | ||
293 | // Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM | ||
294 | void oled_write_ln_P(const char *data, bool invert); | ||
295 | |||
296 | // Writes a PROGMEM string to the buffer at current cursor position | ||
297 | void oled_write_raw_P(const char *data, uint16_t size); | ||
298 | |||
299 | // Can be used to manually turn on the screen if it is off | 299 | // Can be used to manually turn on the screen if it is off |
300 | // Returns true if the screen was on or turns on | 300 | // Returns true if the screen was on or turns on |
301 | bool oled_on(void); | 301 | bool oled_on(void); |
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 53bdc196d..8e5ed5f07 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c | |||
@@ -115,7 +115,7 @@ bool oled_initialized = false; | |||
115 | bool oled_active = false; | 115 | bool oled_active = false; |
116 | bool oled_scrolling = false; | 116 | bool oled_scrolling = false; |
117 | uint8_t oled_brightness = OLED_BRIGHTNESS; | 117 | uint8_t oled_brightness = OLED_BRIGHTNESS; |
118 | uint8_t oled_rotation = 0; | 118 | oled_rotation_t oled_rotation = 0; |
119 | uint8_t oled_rotation_width = 0; | 119 | uint8_t oled_rotation_width = 0; |
120 | uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values | 120 | uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values |
121 | uint8_t oled_scroll_start = 0; | 121 | uint8_t oled_scroll_start = 0; |
@@ -158,7 +158,7 @@ static void InvertCharacter(uint8_t *cursor) { | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | bool oled_init(uint8_t rotation) { | 161 | bool oled_init(oled_rotation_t rotation) { |
162 | #if defined(USE_I2C) && defined(SPLIT_KEYBOARD) | 162 | #if defined(USE_I2C) && defined(SPLIT_KEYBOARD) |
163 | if (!is_keyboard_master()) { | 163 | if (!is_keyboard_master()) { |
164 | return true; | 164 | return true; |
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index cbf5380ee..a6b85f37e 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h | |||
@@ -226,13 +226,17 @@ void oled_write(const char *data, bool invert); | |||
226 | void oled_write_ln(const char *data, bool invert); | 226 | void oled_write_ln(const char *data, bool invert); |
227 | 227 | ||
228 | // Pans the buffer to the right (or left by passing true) by moving contents of the buffer | 228 | // Pans the buffer to the right (or left by passing true) by moving contents of the buffer |
229 | // Useful for moving the screen in preparation for new drawing | ||
229 | void oled_pan(bool left); | 230 | void oled_pan(bool left); |
230 | 231 | ||
231 | // Returns a pointer to the requested start index in the buffer plus remaining | 232 | // Returns a pointer to the requested start index in the buffer plus remaining |
232 | // buffer length as struct | 233 | // buffer length as struct |
233 | oled_buffer_reader_t oled_read_raw(uint16_t start_index); | 234 | oled_buffer_reader_t oled_read_raw(uint16_t start_index); |
234 | 235 | ||
236 | // Writes a string to the buffer at current cursor position | ||
235 | void oled_write_raw(const char *data, uint16_t size); | 237 | void oled_write_raw(const char *data, uint16_t size); |
238 | |||
239 | // Writes a single byte into the buffer at the specified index | ||
236 | void oled_write_raw_byte(const char data, uint16_t index); | 240 | void oled_write_raw_byte(const char data, uint16_t index); |
237 | 241 | ||
238 | // Sets a specific pixel on or off | 242 | // Sets a specific pixel on or off |
@@ -251,17 +255,11 @@ void oled_write_P(const char *data, bool invert); | |||
251 | // Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM | 255 | // Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM |
252 | void oled_write_ln_P(const char *data, bool invert); | 256 | void oled_write_ln_P(const char *data, bool invert); |
253 | 257 | ||
258 | // Writes a PROGMEM string to the buffer at current cursor position | ||
254 | void oled_write_raw_P(const char *data, uint16_t size); | 259 | void oled_write_raw_P(const char *data, uint16_t size); |
255 | #else | 260 | #else |
256 | // Writes a string to the buffer at current cursor position | ||
257 | // Advances the cursor while writing, inverts the pixels if true | ||
258 | # define oled_write_P(data, invert) oled_write(data, invert) | 261 | # define oled_write_P(data, invert) oled_write(data, invert) |
259 | |||
260 | // Writes a string to the buffer at current cursor position | ||
261 | // Advances the cursor while writing, inverts the pixels if true | ||
262 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page | ||
263 | # define oled_write_ln_P(data, invert) oled_write(data, invert) | 262 | # define oled_write_ln_P(data, invert) oled_write(data, invert) |
264 | |||
265 | # define oled_write_raw_P(data, size) oled_write_raw(data, size) | 263 | # define oled_write_raw_P(data, size) oled_write_raw(data, size) |
266 | #endif // defined(__AVR__) | 264 | #endif // defined(__AVR__) |
267 | 265 | ||