CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to Draw a Degree Symbol (°) Using circle() in SSD1306

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MCUprogrammer



Joined: 08 Sep 2020
Posts: 233

View user's profile Send private message

How to Draw a Degree Symbol (°) Using circle() in SSD1306
PostPosted: Mon Mar 10, 2025 8:10 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 10, 2025 8:19 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 10, 2025 8:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 10, 2025 9:53 am     Reply with quote

"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

View user's profile Send private message

PostPosted: Mon Mar 10, 2025 11:15 am     Reply with quote

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..... Sad
MCUprogrammer



Joined: 08 Sep 2020
Posts: 233

View user's profile Send private message

PostPosted: Tue Mar 11, 2025 12:38 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 12, 2025 1:58 am     Reply with quote

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. Smile
MCUprogrammer



Joined: 08 Sep 2020
Posts: 233

View user's profile Send private message

PostPosted: Wed Mar 12, 2025 3:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 12, 2025 6:32 am     Reply with quote

I thought you were using my driver (in the code library), not the CCS one?.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 233

View user's profile Send private message

PostPosted: Wed Mar 12, 2025 6:35 am     Reply with quote

I'm using it, but I wanted to test the ccs c library, it didn't work.
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group