-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Update OLED driver to support some new displays #10379
Conversation
There are some 64×32 and 64×48 OLED displays with SSD1306-like controllers that need the OLED_COLUMN_OFFSET feature (64 visible columns are in the middle of the 128 columns supported by the controller). Adding OLED_COLUMN_OFFSET to the column address makes these displays usable with some restrictions (e.g., scrolling does not work properly, because the uninitialized portions of display memory are scrolled into view, and proper rotation needs further fixes).
Attempting to configure the OLED driver for a 64×48 display uncovered some errors in the address calculations. Other displays apparently always used blocks that occupied the whole physical height with 90°/270° rotation, but the 64×48 display requires using smaller blocks (specifically, 24 blocks of 16 bytes, so that both height and width could be divided into whole blocks), therefore the top and bottom page numbers in the address need to be calculated properly. There was also a minor error in the end page number calculation in calc_bounds(), but it did not seem to affect anything (maybe that value is not actually used by the controller unless blocks actually span multiple pages).
Because the SH1106 controller does not support the horizontal addressing mode, it is not possible to transfer the whole block at once when using 90°/270° rotation. Implement this using separate transfers with address setup for every page-wide strip instead; this is slower than doing a single transfer, but still better than no rotation support at all.
After some more testing it seems that the configuration for the 64×128 SH1107 display that I found is in fact wrong — I noticed that the right column was showing some garbage with low brightness; seems that the proper configuration involves changing the |
Just FYI (also tagging @fauxpark), a quick test with a Kinda difficult to get an image, but Setting Also, awesome work on this PR. Was expecting to have to get these OLEDS working myself. |
@zvecr Yes, the code for the 64×128 display (which actually uses the SH1107 chip, not SH1106) was wrong. Look at master...sigprof:oled-driver-new-hardware-support-v2 for now (I'm still rearranging those commits though). The configuration for that 64×128 screen with the new code would be: #define OLED_DISPLAY_CUSTOM
#define OLED_DISPLAY_WIDTH 64
#define OLED_DISPLAY_HEIGHT 128
#define OLED_COM_PIN_OFFSET 32
#define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)
#define OLED_BLOCK_TYPE uint16_t
#define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
#define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
#define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8)
#define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)
#define OLED_COM_PINS COM_PINS_ALT
#define OLED_IC OLED_IC_SH1107 |
The VCOMH deselect value might need to be chip-specific, then, or at least configurable. |
Sorry about that, GitHub decided to delete the |
I've been using your implementation from the v2 branch since a couple of days without any problems, thank you! The SH1107 Displays (link no longer works but I think it is this one) have very noticeable high pitched coil whine when lighting up large parts of the screen, setting |
Thank you for your contribution! |
Hi, is there any update on this? |
I'm trying the SSD1107 OLED from this link https://es.aliexpress.com/item/4000547865501.html?spm=a2g0o.9042311.0.0.a99263c0nuLi91 on a Lily58L, and seems to work fine but only with OLED_ROTATION_270 (at least works). Can I help with any way to try to add better support? |
#15238 |
Has some merge conflicts. (Also, the sh1107 has a 128x128 display too) |
Hi, is there any progress on this? Would love to see this merged :) FWIW the v2 branch seems to work fine on top of latest develop (after resolving some conflicts). Tested on these GME64128-02 modules. |
Not intentionally, at least. Also, can also confirm that the v2 branch works well with the 128x128 SH1107 screens. would like to get this or similar merged, partially because it's a pain to maintain a separate file |
Closing this since #20331 covers this, and some of the added suggestions |
Description
Update the OLED driver to make it work with more display variants:
Changes which needed to be made in the driver code:
#define OLED_COLUMN_OFFSET 32
, however, the existing driver code supportedOLED_COLUMN_OFFSET
only forOLED_IC_SH1106
; the code forOLED_IC_SSD1306
needed to be updated to use the offset too.calc_bounds_90()
were wrong, but they gave correct values for previously supported displays. The errors were uncovered when trying to configure the driver for the 64×48 display size — in this case the display width is no longer an integer multiple of the display height, and therefore blocks no longer occupy the whole height when using 90°/270° rotation, and the top and bottom page numbers in addressing commands must be calculated properly.OLED_IC_SH1106
— it gives a 20% to 50% performance penalty when testing on the 128×32 SSD1306 display (which actually supports both command sets), but this is still better than no rotation support at all.Fixes from #10377 are also needed to make these displays work properly.
TODO before removing the draft status
OLED_COLUMN_OFFSET
support forOLED_IC_SSD1306
OLED_IC_SH1106
Configuration for the 64×32 SSD1306 display
Configuration for the 64×48 SSD1306 display
Configuration for the 64×128 SH1107 display
Types of Changes
Checklist