How to display the degree icon

128x128 pixel 1.5" full colour OLED display with MicroSD card slot. [Product page]
Post Reply
robinsdl
Posts: 4
Joined: Thu Dec 13, 2018 2:36 am

How to display the degree icon

Post by robinsdl » Thu Dec 13, 2018 2:42 am

Hi,
I have used other oled displays from other manufactures (Adafruit) and have been able to display the degree symbol using (char)247, however this does not work on the OLED128.
Can you please tell me how to use the degree symbol when using the Droid_Sans_12 font.

Also is there a way to increase the overall brightness of the display. I am already using the brightGrayscaleTable, but it does seem to make much of a difference.

Thanks

Brissieboy
Posts: 165
Joined: Fri Sep 20, 2013 7:25 am

Re: How to display the degree icon

Post by Brissieboy » Thu Dec 13, 2018 7:04 am

Not sure if this helps, but the degree symbol is part of the extended character set (127-255) so may not be available in the font you are using.
And I think the degree symbol is 176 decimal, not 247.
No idea on the brightness issue as I have not yet had a need to play with the OLED display.

robinsdl
Posts: 4
Joined: Thu Dec 13, 2018 2:36 am

Re: How to display the degree icon

Post by robinsdl » Thu Dec 13, 2018 11:12 pm

I have already tried 176 as well as 247. I have entered it in the code like this:

Code: Select all

coolmax.println((char)176);
Maybe there is an issue with how it is entered in the code?
I know that I can do it using a bitmap however this is a lot harder to implement when there are multiple temperature values that are constantly being updated.

Brissieboy
Posts: 165
Joined: Fri Sep 20, 2013 7:25 am

Re: How to display the degree icon

Post by Brissieboy » Sat Dec 15, 2018 12:04 am

The Droid_Sans_12 font that you are using only defines characters within the range 32-127 (decimal). I'm not aware of any that do define the full extended character set - they might be out there but they would take up a lot of memory space.
Might be best to find another solution. Rather than going to graphics, you could just redefine a character in the font that you know you will never use (such as 96 the grave accent which is seldom required), or modify a font to include the character/s you want. And document your code and modified font accordingly of course.

robinsdl
Posts: 4
Joined: Thu Dec 13, 2018 2:36 am

Re: How to display the degree icon

Post by robinsdl » Sun Dec 16, 2018 8:06 pm

Brissieboy,
I think that your suggestion of changing one of the existing characters in the font will work.
I will post the solution so that others can use it once I have it working correctly.

Brissieboy
Posts: 165
Joined: Fri Sep 20, 2013 7:25 am

Re: How to display the degree icon

Post by Brissieboy » Sun Dec 16, 2018 11:06 pm

There is quite a bit of information on how these fonts work on this forum. You might find this thread a helpful starting point.

robinsdl
Posts: 4
Joined: Thu Dec 13, 2018 2:36 am

Re: How to display the degree icon

Post by robinsdl » Wed Dec 19, 2018 1:07 am

I have successfully modified the font code so that I now have a degree symbol.
Here is a quick "how to" for anyone else looking for a solution:

Open the "Droid_Sans_12.h" file (or another font of your choice) in your favourite editor.
This font file can be found in your "/Arduino/libraries/FTOLED/Fonts" folder.

Locate the font character you wish to edit, I am using 34:
(make sure that you choose a character that you will not use in your project)

Copy the line of code that contains the character that you are going to modify and paste it below the line you copied and place 2 forward slashes in front of it as shown below:
(this changes it to a "documentation" line, that way you have a backup of the original character code)

Code: Select all

//0x07, 0x00, 0x07, 0x00, 0x00, 0x00, // 34
Edit the character code to read:

Code: Select all

0x02, 0x05, 0x02, 0x00, 0x00, 0x00, // 34
Save the "Droid_Sans_12.h" file:

You can now import the code into your arduino project by using:

Code: Select all

print((char)34)
This will display the degree symbol on your oled display.

Brissieboy
Posts: 165
Joined: Fri Sep 20, 2013 7:25 am

Re: How to display the degree icon

Post by Brissieboy » Wed Dec 19, 2018 10:47 am

It is best to rename your modified font to avoid any confusion as well as adding plenty of comments in the file to show what you have done and why - remember that you can never have too many comments.
To rename the font you need to do 3 things:
(demo here will use "MY_Droid_Sans_12" for the new name as an example)

1. In the font file modify the line

Code: Select all

static const uint8_t Droid_Sans_12[] PROGMEM = {
to

Code: Select all

static const uint8_t MY_Droid_Sans_12[] PROGMEM = {
2. Save the file as "MY_Droid_Sans_12.h"
3. In your sketch use the font name "MY_Droid_Sans_12" when ever you refer to this font.

Post Reply