Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64x48 oled support #19955

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/feature_oled_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.<br />Useful for 128x64 displays centered on a 132x64 SH1106 IC.|
|`OLED_COLUMN_OFFSET` |`0` |Shift output to the right this many pixels.<br />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.<br>`OLED_COLUMN_OFFSET` might be needed.
|`OLED_DISPLAY_CUSTOM`|*Not defined* |Changes the display defines for use with custom displays.<br>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. |
Expand Down
31 changes: 31 additions & 0 deletions drivers/oled/oled_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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
Expand Down
2 changes: 1 addition & 1 deletion drivers/oled/ssd1306_sh1106.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down