OLED Display flicker or blanking?
moseisley
Posts: 10
Hello all, new to the Propeller and programming as well. I have put together a small SPIN program to read some potentiometers, I want to send the raw pot reading to a small OLED display with the SSD1306 chip. I am using this OBJ: SSD1306_Driver_Plus v 1.3. In my SPIN code the "pot" reading is in a loop. When I send it to the display (I am sending 1 line of text and the value reading) it blinks or blanks, but I can see the value change as I turn the pot. I have tried changing the timing of the loop but it doesn't seem like it changes. Is there a way to stop the blinking/blanking or am I doing something wrong in the code??
Comments
Can you post your code, or at least tell us more about you're using the OLED display?
Thanks for responding! On further playing with I notice when I initiate the OLED code everything slows down even output to the PST, it updates when the OLED blinks as does motor movement, when the OLED code is commented out it seems to run and update smoothly. Using the .96 128x64 ssd1306 OLED display in I2C mode. I have paired down the code and posted it below, also attached a video file of the oled behavior.
You really should post an archive so that all of the files are in one place -- don't make people search for libraries they may not have.
As per JonnyMac's suggestion I have added a zip with all relevant files to previous comment!
Init() is a big routine doing a rather lot of setting up. You probably don't want to be calling that upon every print. What happens when that's commented out?
Also, and I haven't tested any of this myself, you've got a bad indentation on the main loop. The waitcnt() is short. That might exclude it from the loop. Here, I've added one space to fix the indentation:
evanh, thanks for the reply, I have tried the comment out of init, and I indented the waitcnt() no difference.
Maybe give it longer. Use /4 instead of /40:
waitcnt(clkfreq / 4 + cnt)
Hmm, looking at the object file it seems that that CLS character triggers a rather large screen erase sequence. It'll be spending a lot of time doing that. Here's a much shorter routine that hopefully will allow you to overwrite the text on screen instead of repeatedly erasing.
You'll need to add this to the
SSD1306_Driver_Plus.spin
source file and then make use of it with aOLED.Home
in place ofOLED.Tx(CLS)
In addition to what @evanh suggested, you can also write blank spaces to a line (or part of a line) to clear the content, rather than clearing the entire display. Often times you'll find that blanking a line is less flickery than clearing he whole display and re-writing all the content.
Thank you for the replies again!
evanh I did try the waitcnt() adjustment earlier but no change, but you suggestion and code snippet did do the trick!! Thank you, I have attached a video of the result. I do however have a couple questions, how would I move it to another line on the display, I don't see any location commands in that driver, also how would I clear the line as I am getting leftover characters from the reading, like when I turn the pot to 0 I see some value still there? VonSzarvas I did try that but evanh has come up with a very simple solution thank you!
I know I'm a little late, but the OLED driver I use on Arduino has a HOME command, in addition to CLS. For testing, I would have used something like this:
The Home command doesn't erase anything, but the " " null spaces at the end erase extra characters on the line.
This worked for the clearing thanks, I tried this but didn't put it in the right place! Thank you!
I tried to upload a video file but it wont let me !!??
It may exceed the upload file size. I usually post videos on my YouTube channel and embed or link them.
yep size limit, here is what I get now, just need to figure positioning out now!
Yeah, looking at the object, it doesn't seem to support character positioning. You'd have to build the screen using HOME and CR.
Looks that way, darn!!
It will be possible with better knowledge of the hardware. My posted routine isn't exactly doing a home either. I just copied the first part of the clear screen routine - which I presume is setting the hardware into a character line mode. Which just happens to also reset the cursor's position.
There looks to be a few supported modes by the hardware, including bitmap graphics.
I don't have the time to port it from C, but the Arduino SSD1306 library I use has CLS, HOME, cursor position, different fonts existing on the same screen, circles, lines, etc.
Seems like in C it wouldn't be too hard to port, but again, no time here. I'm trying to move within 2 months.
Thank you, I have at least something that works, I would have no idea how to port or implement the function as I am still trying to learn this stuff, and ALL of this really helps!! I appreciate the time from this group!! I will keep plugging along and read as much as I can to try and figure it out.
Good luck! Just for reference, this is the SSD1306 display I am using and below is a photo from a project showing the graphics and text on the display.
https://savagecircuits.com/arduino-blaster/
Very soon I will have a video of it in action, since the display is quite animated. Below is the code that draws the display in the photo.
Savage looks very slick!! Also very nice website!! I think I figured out the 1306 driver I am using, you have to use "page" to get line by line, then I used spaces to position on the line see attached pic. Also here is the code snippet for the pic:
Very cool! It was the nomenclature that got me. When I used to write software back in the DOS days, pages were like separate cached screens. I did not equate "pages" in that driver to "lines". I'm glad you figured it out. If text is all you need, that should get you where you need to go.