User description
Fixes issue #10765 where last line of OLED shown garbage.
PR Type
Bug fix
Description
This description is generated by an AI tool. It may have inaccuracies
-
Fixed OLED display garbage on last line
-
Improved page-by-page clearing method for all 8 pages
-
Added proper address reset after clearing operation
Diagram Walkthrough
flowchart LR
A["Old Method"] --> B["Single loop 1024 iterations"]
C["New Method"] --> D["8 pages loop"]
D --> E["128 columns per page"]
E --> F["Proper address reset"]
B --> G["Garbage on last line"]
F --> H["Clean display"]
File Walkthrough
| Relevant files |
|---|
| Bug fix |
display_ug2864hsweg01.cFix OLED clear function page addressing
src/main/drivers/display_ug2864hsweg01.c
- Replaced single 1024-iteration loop with proper 8-page clearing
- Added page-by-page addressing for complete display coverage
- Added address reset commands after clearing operation
- Improved code comments for clarity
|
+18/-9 |
|
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
| ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
⚡ Recommended focus areas for review
Addressing Mode
The code sets horizontal addressing mode but then uses page addressing commands. This mixed addressing approach may not work correctly on all OLED controllers and could cause display issues.
i2c_OLED_send_cmd(0x20); // Set Memory Addressing Mode
i2c_OLED_send_cmd(0x00); // Set Memory Addressing Mode to Horizontal addressing mode
// Clear all 8 pages (0-7)
for (uint8_t page = 0; page < 8; page++) {
i2c_OLED_send_cmd(0xb0 + page); // set page address
Missing Command
The original code included display start line register command (0x40) which was removed. This command may be necessary for proper display initialization and its removal could affect display behavior.
void i2c_OLED_clear_display(void)
{
i2c_OLED_send_cmd(0xa6); // Set Normal Display
i2c_OLED_send_cmd(0xae); // Display OFF
i2c_OLED_send_cmd(0x20); // Set Memory Addressing Mode
i2c_OLED_send_cmd(0x00); // Set Memory Addressing Mode to Horizontal addressing mode
// Clear all 8 pages (0-7)
for (uint8_t page = 0; page < 8; page++) {
i2c_OLED_send_cmd(0xb0 + page); // set page address
i2c_OLED_send_cmd(0x00); // set low col address to 0
i2c_OLED_send_cmd(0x10); // set high col address to 0
for (uint8_t col = 0; col < 128; col++) {
i2c_OLED_send_byte(0x00); // clear
}
}
i2c_OLED_send_cmd(0xb0); // Reset to page 0
i2c_OLED_send_cmd(0x00); // Reset low col address to 0
i2c_OLED_send_cmd(0x10); // Reset high col address to 0
i2c_OLED_send_cmd(0x81); // Setup CONTRAST CONTROL
i2c_OLED_send_cmd(200); // Contrast value
i2c_OLED_send_cmd(0xaf); // Display ON
}
|
PR Code Suggestions ✨
No code suggestions found for the PR.
There is also PR #10760 which in my opinion is not fixing root cause and possibly overwrites something wrong.
Fixed @qodo-merge-pro valid concerns.
Which displays did you test this with, please?
The SSH1106 needs more data sent to it than the SSD1306. The SSD1306 just gets bytes for the pixels. The SSH1106 has memory for four extra columnsthat are not displayed.
For the SSH1106, we would send two blank columns, then the data you want displayed, then two more blank columns.
Any changes should be tested with both, please.