diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md index dea9cb807495..2d0bda138013 100644 --- a/docs/feature_oled_driver.md +++ b/docs/feature_oled_driver.md @@ -10,6 +10,7 @@ Tested combinations: |SSD1306 |128x32|AVR |Primary support | |SSD1306 |128x64|AVR |Verified working | |SSD1306 |128x32|Arm | | +|SSD1306 |64x48 |Arm | | |SH1106 |128x64|AVR |No rotation or scrolling| Hardware configurations using Arm-based microcontrollers or different sizes of OLED modules may be compatible, but are untested. @@ -173,17 +174,18 @@ These configuration options should be placed in `config.h`. Example: |`OLED_SCROLL_TIMEOUT` |`0` |Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | |`OLED_SCROLL_TIMEOUT_RIGHT`|*Not defined* |Scroll timeout direction is right when defined, left when undefined. | |`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. | -|`OLED_COLUMN_OFFSET` |`0` |(SH1106 only.) Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC.| +|`OLED_COLUMN_OFFSET` |`0` |Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC. | |`OLED_BRIGHTNESS` |`255` |The default brightness level of the OLED, from 0 to 255. | |`OLED_UPDATE_INTERVAL` |`0` |Set the time interval for updating the OLED display in ms. This will improve the matrix scan rate. | ## 128x64 & Custom sized OLED Displays - The default display size for this feature is 128x32 and all necessary defines are precalculated with that in mind. We have added a define, `OLED_DISPLAY_128X64`, to switch all the values to be used in a 128x64 display, as well as added a custom define, `OLED_DISPLAY_CUSTOM`, that allows you to provide the necessary values to the driver. + The default display size for this feature is 128x32 and all necessary defines are precalculated with that in mind. We have added defines, `OLED_DISPLAY_128X64` or `OLED_DISPLAY_64X48`, to switch all the values to be used in a 128x64 or 64x48 display, as well as added a custom define, `OLED_DISPLAY_CUSTOM`, that allows you to provide the necessary values to the driver. |Define |Default |Description | |---------------------|---------------|----------------------------------------------------------------------------------------------------------------------------------------| |`OLED_DISPLAY_128X64`|*Not defined* |Changes the display defines for use with 128x64 displays. | +|`OLED_DISPLAY_64X48` |*Not defined* |Changes the display defines for use with 64x48 displays.
`OLED_COLUMN_OFFSET` might be needed. |`OLED_DISPLAY_CUSTOM`|*Not defined* |Changes the display defines for use with custom displays.
Requires user to implement the below defines. | |`OLED_DISPLAY_WIDTH` |`128` |The width of the OLED display. | |`OLED_DISPLAY_HEIGHT`|`32` |The height of the OLED display. | diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 291049e36bd7..b80629c81ae5 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h @@ -68,6 +68,37 @@ along with this program. If not, see . // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } +#elif defined(OLED_DISPLAY_64X48) +# ifndef OLED_DISPLAY_WIDTH +# define OLED_DISPLAY_WIDTH 64 +# endif +# ifndef OLED_DISPLAY_HEIGHT +# define OLED_DISPLAY_HEIGHT 48 +# endif +# ifndef OLED_MATRIX_SIZE +# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 384 (compile time mathed) +# endif +# ifndef OLED_BLOCK_TYPE +# define OLED_BLOCK_TYPE uint16_t +# endif +# ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) +# endif +# ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) +# endif +# ifndef OLED_COM_PINS +# define OLED_COM_PINS COM_PINS_ALT +# endif +# ifndef OLED_SOURCE_MAP +# define OLED_SOURCE_MAP \ + { 0, 8, 16, 24 } +# endif +# ifndef OLED_TARGET_MAP +# define OLED_TARGET_MAP \ + { 24, 16, 8, 0 } +# endif + #else // defined(OLED_DISPLAY_128X64) // Default 128x32 # ifndef OLED_DISPLAY_WIDTH diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c index 342920572e3a..05249bb98470 100644 --- a/drivers/oled/ssd1306_sh1106.c +++ b/drivers/oled/ssd1306_sh1106.c @@ -248,7 +248,7 @@ void oled_clear(void) { static void calc_bounds(uint8_t update_start, uint8_t *cmd_array) { // Calculate commands to set memory addressing bounds. uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH; - uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH; + uint8_t start_column = (OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH) + OLED_COLUMN_OFFSET; #if (OLED_IC == OLED_IC_SH1106) // Commands for Page Addressing Mode. Sets starting page and column; has no end bound. // Column value must be split into high and low nybble and sent as two commands.