You learn new things each day you work on a project, right? For larger projects I like to work with vscode and platformio. This makes life easier because you can work on code for both processors in one editor, and I really like the additional functions like splitscreen, a function-index and being able to see all references to a function or variable. So when I finished working on the code for the I2C monitor in a development or test-workspace, I copied the code to the main project and checked if it played nicely with everything else, something strange happened …
The code compiles with the usual nags, which are nothing serious and mostly library related, but when I uploaded the code the oled screen stayed dead. How can this be? First you check all your cabling. I didn’t use the oled working on the I2C-monitoringcode in the test-workspace. The cabeling seemed fine, so I checked with an other oled screen but this one also played dead … oops. Next I remarked some of the changes I made in the housekeeping and the main loop but that didn’t make any difference at all. Then I focused on the setup loop and added a delay after the initialization, this way the screen should show the Adafruit logo; it didn’t. I tried a quick I2C scanner and it showed a response at the correct address so the screen must be ok right? Next I uploaded the Adafruit example into the test-workspace and uploaded it to the Teensy and … success, it worked! Good news and bad news, the good news: the hardware is working, the bad news: the fault is entirely my own.
I did find out that the oled.begin function in my project did not succeed. This is probably a library thing right? I didn’t change anything about the oled code in the setup since the last time it worked so maybe changes or different versions or dependency related issues due to updates? I copied the versions from the test-workspace with the working Adafruit example to the main project, but that didn’t help. I simply could not figure out why the example code worked and in my program it didn’t. Of to the forums to find some answers and I can tell you, that is not very easy: searching for answers why the example works and your own code does not. Somehow an issue a lot of beginners face, but I did find one mention about not enough memory for the library to create an offscreen display on an Uno. Could this be the issue? Ah, my main program still had an array size of 8192 items for the capturebuffer. This was ok with dma but the new code needed more buffers: 1 word and 2 byte arrays instead of 1 word and 1 byte. The teensy is 32 bits so in hardware it probably used 3 word arrays. After I reverted back to array sizes of 4096 items, the screen came back to life.
I should look into some memory optimization for the buffers if it does not take to much interrupt time, another item for the to-do list.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.