I wanted to add the degree cymbal to display.text("{:0.0f}c".format(temperature), 0, 40, scale=4) print(chr(176)) will display Ā°
I could not figure out how to use / add that in my line of code.
So I did a copy past of that character from the Thonny output, to my code, and lol it worked. display.text("{:0.0f}Ā°c".format(temperature), 0, 40, scale=4)
If there is a keyboard combo for this i have no idea what it is. And Iād still like to know how it should have been done. =) Code wise.
odds are, the font doesnāt support itā¦ in which case youād need a different/custom font. AFAICT most fonts in mPython are doing well to support basic ASCII. No clue here how to edit fonts.
I know Swedish uses an overring for some characters, and Irish uses an over dot, so fonts aimed at those might work. Alternatively some English fonts place the asterisk character high and itās usually included.
Thatās stuff Iām not up to speed on, as they say.
If I put print(chr(176)) in my code, Thonny outputs the Ā° in the shell window.
And clip and pasting the Ā° into my code gets it displayed correctly on my SPI LCD.
Trying to add the (chr(176)) to my code failed, which made me try the clip and past of the Ā° from the shell window to my code. I actually chucked to myself when it worked. =)
I have it doing what I wanted. I just used what I call trickery to get there. ;)
Iāve included an extra font, in three sizes, in this project. Easy to add to any project. The extended character set includes the degree symbol, Greek letters and much more.
It does not need the Pimoroni extras and includes simple graphics commands.
I stumbled across this same issue, and found that the deg symbol is in the Pimoroni uf2 now.
I just used character map to insert āĀ°ā you could copy paste that one to your code, without the quotes, as Iām sure youāre aware.
It will display as seen in the very rough and ready photo below. Hope that helps.
This is a port of the above code that runs on my Tufty. I will be adding an RV3028 to it at some point to display Date and time. When I unplug the USB port it displays the Battery voltage and % remaining across the top.
Same thing happens on my Tufty clone above. The date display is replaced with Battery % remaining.
::wipes egg off face:: I read that wildly wrongā¦ no more āIāll just check the forums real quick before I do Xā for me.
I think the proper handling is either the way you ended up doing it*, or the more explicit display.text("{:0.0f}{}c".format(temperature,chr(176)), 0, 40, scale=4)
or even display.text("{:0.0f}{:c}c".format(temperature,176), 0, 40, scale=4)
*chr( # ) should map to unicode for any supported character, so instead of print copy paste you can directly insert the character. the method to do so is specific to the OS (and sometime certain programs support other methods). Wikipedia lists the most common methods
it doesnāt help that there are three competing format options in python (four if you count print( x, y ))ā¦ and to be honest I can never remember which is preferred in mPython, other than $# being depreciated for everything.
for a language thatās supposed to be simple, human readable, and aspires to āclean codeā it sure does have a lot of inconsistent and puzzling gotchas (the preference for spaces, āfromā imported classes succesfully referencing external functions, and lack of proper do/while are all things that currently make me twitch)
I have blocks of code I borrowed from example code I got here and there. I know what they do, but have no idea how they do it? ;) If there in the right place at the right time, in my code, they work. Which works for me. =)
If I was younger Iād likely spend more time trying to dissect it. I do do that sometimes if I really want to tweak it a lot.
On a sort of side note. I am partially color blind, I have a Red Green Color Deficiency. I can see red and green. But telling green from yellow is a challenge for me on things like RGB LED matrixes. I can not see turquois, it either looks green or blue to me.
What it means for me is trusting that my code is actually displaying green when I think it should, or displaying yellow when I think it should.
Or tweaking the RGB values so āIā can see a distinct difference. The side effect of that, is when Iām showing off what I built, and explaining how it works. I get ābut thatās not greenā etc comments. ;)
You know, you just gave me an ideaā¦ Iāve seen so many of those color charts for what people with different vision are supposed to see, and it just struck me that the space between specific colors must be compressed (less separate tints) in something like red/green deficiencyā¦ I bet it would be possible to write some code that could mimic that and shift colors away from the weaker range into the stronger one, or vice versa. Iāll have to give it some thought but I bet it could not only simulate it, but also invert it making colors seem more vibrant. gonna have to let this idea stew for a bit, thanks
Reflected versus illuminated probably factors into it. Mixing pigments is a totally different ballgame versus mixing light. ;) Mixing Red and Green paint isnāt going to get you yellow, lol.
Mixing wavelengths of light also gets you colors that arenāt in the rainbow.
Purple isnāt a real color. ;) The color purple is unlike all others, in a physical sense (zmescience.com)