Degrees C Symbol
-
Hi all,
I can't seem to find the answer to this anywhere. I'm using the Arduino API and trying to display the degrees C symbol eg 5.2ºC in
M5.Lcd.printf("%0.1f%cC", temp, (char)000)
but can't for the life of me find what number I need for(char)000
Can anyone help?
-
@richardmckenna The character " ° " is not in the range of ASCII code. So it cannot be displayed, maybe you can try to use " 'C " symbol instead, it will look more same
-
@m5stack hmmm ok that's a shame.
I don't suppose you can suggest any other way of displaying it? Would have thought it was a common thing to do given temperature applications are a popular thing for this kind of hardware.
Is there any documentation on what characters are available? Or is it just the standard ASCII set but not the extended set?
-
@richardmckenna You can refer to this Unicode example, but in fact it still does not support displaying " ° ", but will be able to display more characters. Please pay attention to the content of the notes when using.
Github link: https://github.com/m5stack/M5Stack/tree/master/examples/Advanced/Display_Unicode
-
@m5stack Thank you I will take a look.
-
I manually create the degree symbol by drawing a white circle and then a smaller black circle on top. But it takes some trial and error depending on your text size.
-
@world101 thanks. I think I will do this.
-
This post is deleted! -
This post is deleted! -
//Fake degrees C Symbol
String strTemp; strTemp = String(temp1 + strtof(&adj1[0], NULL)); strTemp += " C"; M5.Lcd.drawCentreString(strTemp,320/2,50,1); //M5.Lcd.print(String(temp1 + strtof(&adj1[0], NULL))+"℃"); //broken --; int nTempLen=strTemp.length(); M5.Lcd.setTextSize(1); M5.Lcd.setCursor(2, 50); M5.Lcd.print("Sensor"); M5.Lcd.print(" 1"); if(nTempLen==6) { M5.Lcd.setCursor(195, 45); } else if(nTempLen==7) { M5.Lcd.setCursor(205, 45); } else if(nTempLen==8) { M5.Lcd.setCursor(216, 45); } else { M5.Lcd.setCursor(200, 45); } M5.Lcd.setTextSize(2); M5.Lcd.print("o"); //lowcase o
-
Just an update. I noticed that uiFlow now supports Unicode characters. I'm not sure in which release it was introduced, but I'm now able to add the degree symbol to a label using characters from this site.
Two drawbacks...
- Size is fixed at unicode 24 (similar in size to DejaVu 24).
- Unicode 24 is missing from the label set font block