Hello,
I am programming a motorcycle data logger and I would like add a screen to my project.
I have 2 ones:
-Adafruit SSD1306
-Adafruit 2.8 TFT LCD
I would prefer use the 2.8 TFT because first it is largest and so more confortable and second I will be able to display more information.
But I have found more tutorials about the SSD1306 (maybe also easier to start) so I have begun with this one.
To summarize the global algorithm idea of my main sketch, there is a main loop every 10 millis which acquires wheel speed, IMU data, .... and save everything on the SD. I would like display some of this data on the screen every 0.5 s.
To begin I have tried to display the results of the wheel speed sensor computations:
To do it I have used the ADAFRUIT_SSD1306 library. I have timing problem because refresh the screen with the new results takes more than 10 ms so the CPU is not able to acquire the sensor for a while. 
One person on the forum advices me to use the u8g2 library to solve my timing problem.
I guess that I can split data displaying as follows:
period n : refresh speed
period n+1: refresh RPM
...
period n+3: Count
Do you think I can really reach less than 10 ms with the u8g2 library?
Do you have any suggestion?
I guess that the 2.8 TFT is slower, is there a way to also reach the 10 ms?
I am open about the proposed solution, if it is better to use a dedicated board it could be possible.
Thank you,
Pm
Hi
Full color TFTs will be much slower. Just think about the data amount: For a full color 16Bit TFT the lib has to transfer 16 bit per pixel. For the SSD1306 there is only one bit to send. So it will be 16x faster.
10ms refresh for the complete screen will not be possible. This would be 100 Hz (frames per second) which is almost impossible frough SPI. 20ms/50Hz might be reachable with a Due or Zero Board.
One way could be to use the U8x8 sublibrary of U8g2 (U8x8 is included with U8g2). This will allow you to transfer the changed values only. Pseudo code will look like this:
- Print all constant strings on the display
- Loop:
- Get Speed (and/or other values)
- Set cursor to destination pos
- Print Speed (and/or other values)
With this concept you can easily reach 10ms refresh.
However U8x8 fonts are not so nice and there is no graphics available, but there is 2x2 upscale option.
Oliver
Hi,
10ms refresh for the complete screen will not be possible. This would be 100 Hz (frames per second) which is almost impossible frough SPI. 20ms/50Hz might be reachable with a Due or Zero Board.
I just need to refresh the value of the speed, the rpm,...
As I said the screen loop is much slower than acquisition loop that is why I can refresh value one by one after the fastest loop timestamp.
Full color TFTs will be much slower. Just think about the data amount: For a full color 16Bit TFT the lib has to transfer 16 bit per pixel.
Do you have an idea about how I can include the TFT into my project to display GPS location, speed, .... without interfering with acquisition loop at 100 Hz? Use a dedicated board?
- Print all constant strings on the display
- Loop:
- Get Speed (and/or other values)
- Set cursor to destination pos
- Print Speed (and/or other values)
I have seen that u8g2 is your own library and you follow many projects using this one. Maybe you have ever realized a similar sketch with someone else? I mean that I am looking for the global syntax to declare a fix legend(1) ("speed:",...) and to clear/refresh(4,5) the correspondant value.
Have a good day,
Pm
Do you have an idea about how I can include the TFT into my project to display GPS location, speed, .... without interfering with acquisition loop at 100 Hz? Use a dedicated board?
I suggest to use timer interrupts here. Unfortunately there is no buildin command for this, but several libs are available. Look at MsTimer2 or TimerOne libs.
I mean that I am looking for the global syntax to declare a fix legend(1) ("speed:",...) and to clear/refresh(4,5) the correspondant value.
I do not think that there is a global syntax, but u8g2 has a user manual which describes all the commands and their syntax.
Oliver
Thank you Olivier for your help.
I didn't notice something. The screen will be located around 1 meter from the Arduino board. Using SPI communication, will I have important delay due to long wires?
Thank you,
Pm
Hi
There will be no delay because of the long wires, but you may observer bit errors due to the lower signal quality. It may even not work at some distance.
Oliver