Fix ssd1306 start line - #586
Conversation
|
The code changes look plausible, but you posted over 11 screens of bot drivel to support a three-line change! Please post a description and reproduction instructions that will not waste a reviewer's time. |
|
Sorry, never done a pull request, so i asked wrongly an ai if it was good to put all that stuff, hope that now its better |
|
Thank you, that is better, but the link to the ZIP is also gone. Can you restore it, and include the AVR binary, as I do not use PlatformIO? The change does improve the code, but in a way that does not seem useful. The incorrect parsing of that command is gone but the command still does nothing, so the only way it can really fix anything is if the command is used only to restate the default. Otherwise it just changes one bug to another. Also, the data sheet does not mention resetting the VRAM. It might be better to fill with a pattern on reset so that display of uninitialised memory is clearly visible. |
|
ok, i've added back the link to te zip file, i've also included the firmware.elf and firmware.hex files inside of it, if you intended that for "AVR binary"(btw the main.cpp file included is compatible with arduino ide, or any other ide like arduino, not only with platformIO).
Yes, I understand that this change does not implement the effect of the
Just for specification, i've tested the vram fix only after solving the first problem, and initially i didn't know that the issue of the vertical shift, only on half of the display, was caused by the VRAM. After some different try and error, the complete VRAM array initializzation removed that remaining artifact so i opted for using this solution. In the end:
|
|
That seems odd to me, but it is an improvement, so I can merge it. Can you squash it to one change, with at most a two-line description? Alternatively, I can do a squash merge, but that will put my name on your submission. |
6984b06 to
a2635cf
Compare
|
ok, I've squashed the changes to one, I hope that's correct, I've never made one before |
|
It looks fine. Thanks, G. |
Fix SSD1306 start-line command decoding and full VRAM reset
While using simavr to simulate an ATmega32U4 project with an SSD1306 display driven by the U8g2 library over hardware SPI, I encountered two issues in the virtual SSD1306 part:
Set Display Start Linecommands in the0x40..0x7Frange were treated as multi-byte commands.This two issue together caused the display to show its content incorrectly causing to shift horizzontally the content, and disallign half of it vertically:
Reproduction
A minimal reproduction can be created by setting up a PlatformIO or Arduino project using the U8g2 library with an SSD1306 128×64 display:
If you want to test faster, here the code(
reproduction_files.zip
) that i used as example for investigating and resolving this issues, the zip contain:
src/main.cpp: the source code made using Arduino IDE or PlatformIOsimulator/atmega32u4_test.c: source code used by simavr for emulating the atmega32u4platformio.ini: configuration file if you want to use PlatformioIOcompiled_firmware/: folder that contain the the compiled firmware for the ATmega33U4 from the src/source main.cppFix
Issue 1: incorrect
Set Display Start LinedecodingAccording to the SSD1306 datasheet the Set Display Start Line command is encoded as a single byte. Fixed with:
Issue 2: incomplete VRAM clearing on reset
The framebuffer is 1024 bytes for a 128×64 display, but the previous reset logic only cleared half of it.
Fix:
Clear the complete framebuffer using its actual size: