View previous topic :: View next topic |
Author |
Message |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 233
|
How to Draw a Degree Symbol (°) Using circle() in SSD1306 |
Posted: Mon Mar 10, 2025 8:10 am |
|
|
hi @Ttelmah
I am trying to draw a degree symbol (°) next to a temperature value on an SSD1306 OLED display using the `circle()` function. However, every time I attempt this, either the screen gets cleared, or the degree symbol overlaps the text, causing it to shift or disappear. I want to correctly position the ° symbol next to the number without affecting the other content on the screen. I am unsure whether I should be using a windowed drawing approach with `draw_window()` or if there is a better method to achieve this. Could you help me understand what I might be doing wrong and suggest the best way to implement this?
Code: |
void clear_oled_line(int8 clear, int8 x, int8 y)
{
if (clear)
{
OLED_gotoxy(x, y);
printf(OLED_putc, " ");
clear = false;
}
}
clear_oled_line(clear,8, 4);
printf(OLED_putc, "%.1fC ", temp_FPW);
|
for example
Code: |
clear_window();
circle(50, 4, 3, true); // (X=50, Y=4)
draw_window(45, 16); |
_________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Mon Mar 10, 2025 8:19 am |
|
|
I've always used a '*', an 'asterik'(sp ) [ shifted 8 ) AKA times character........ as I'm old and have always used text based LCD modules for a 1/2 century.
There IS a 'special ' character in the LCD font array ,but again... I'm a dinosaur..* works for me.....everytime. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Mon Mar 10, 2025 8:31 am |
|
|
Are you using the smaller font or the larger font?.
In ether case just change a character you are not using the font table to
give the degree character. Perhaps underline, or ^. Or if you are not using
the bargraph characters, one of these.
Or just draw it as a logo. |
|
 |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 233
|
|
Posted: Mon Mar 10, 2025 9:53 am |
|
|
"Thank you for your response! I am using the smaller font, and I noticed that the degree character is not displaying correctly. Your suggestion to replace an unused character sounds great; I will try _ or ^.
However, I was wondering—why don’t we use a small circle (°) instead? Wouldn’t it be a more natural way to represent the degree symbol? Is there a limitation in the font table that prevents it? I’d love to hear your thoughts on this!" _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Mon Mar 10, 2025 11:15 am |
|
|
The key is that the point about the small driver for this is it does not read
bytes back, only writes. This means if you do anything that crosses a byte
that already contains data, this data is lost. So you can generate graphics,
but only if every cell involved contains nothing. A small circle, will cross
many bytes of the display memory, so will probably corrupt many
characters if they are already written.....  |
|
 |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 233
|
|
Posted: Tue Mar 11, 2025 12:38 am |
|
|
I successfully ran the SSD1306 0.96-inch driver on a 1.3-inch SSD1306 display, and it seems to be working fine. Is there anything specific I should be cautious about, or does this not make a difference? The only issue I encountered is that on the 1.3-inch display, when the cursor starts at `x = 0`, half of the first character is cut off. To fix this, I defined a condition where `0` corresponds to the 0.96-inch display and `1` corresponds to the 1.3-inch display, setting the cursor to start at `x = 1` for the larger screen. Does this seem normal to you? _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Wed Mar 12, 2025 1:58 am |
|
|
Look at the define SH1106.
A lot of the displays called SSD1506, actually use this later chip.
This functions the same, but offsets the origin by a couple of pixels.
Just #define this before loading the driver.
I think you will find this fixed your problem.  |
|
 |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 233
|
|
Posted: Wed Mar 12, 2025 3:16 am |
|
|
Well, in the ccs c library, it fills everywhere with white dots, what is the reason for this? _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Wed Mar 12, 2025 6:32 am |
|
|
I thought you were using my driver (in the code library), not the CCS one?. |
|
 |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 233
|
|
Posted: Wed Mar 12, 2025 6:35 am |
|
|
I'm using it, but I wanted to test the ccs c library, it didn't work. _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
 |
|