Comments (4)
You need to check, whether the required character is available in the selected font. In your example the selected font doesn't contain the desired character: https://github.com/olikraus/u8g2/wiki/fntgrpopengameart#chroma48medium8
I suggest to use this font instead: https://github.com/olikraus/u8g2/wiki/fntgrpcodeman38#pressstart2p
from u8g2.
OK, in the code snippet above, I changed the font, as folllows:
//u8x8_i2c.setFont(u8x8_font_chroma48medium8_r);
u8x8_i2c.setFont(u8x8_font_pressstart2p_f);
Looking at the character map, I can verify that the characters printed are according to the character codes:
example: when printing 'char(224)', it prints 'à', which is correct.
But when printing "à", it prints "Ä " (wrong character, followed by a space), which is not correct.
Check: printing asc('à) returns 195. The character map of the font indeed indicates Ä for character code 195.
So, Arduino does not translate a character to the character code expected by the OLED.
Example: it sends character code 195, and not 224, when printing 'à'.
Does that mean I'm again using a wrong font ? I would again appreciate your help.
Best regards
Herwig
from u8g2.
The short suggestion is: Read out the hex code from the table. For Ä this would be 0xc4. Hex codes can be embedded into strings, by using \x escape sequence: "\xc4pfel" would print the German word "Äpfel" (apples).
Long answer: If you enter "Ä" (or any other char) into your keyboard, then:
- your text editor translates the key into an encoded which is used / configured in your text editor. This might be UTF-8 in case of Arduino IDE. The UTF8 encoding for Ä is "0xC3 0xA4", which as nothing todo with 0xC4
- Once your c-code contains the byte sequence "0xC3 0xA4" (remember you will always see Ä because your editor is configured for UTF-8), then the C-Compiler has to understand what exactly is "0xC3 0xA4". Usually it doesn't do much, but some remarks are here: https://gcc.gnu.org/onlinedocs/gcc-4.0.4/cpp/Character-sets.html
- Finally the software (in this case U8g2 / U8x8) has to decode the encoded character and fetch the correct glyph from the font. In this case, u8x8 and u8g2 have to assume, what input encoded you might have, because there is no way to tell u8g2 / u8x8 how your editor is configured.
Now, this is what u8g2 and u8x8 will do: Both will assume ISO/IEC 8859 encoding.
U8g2 (as a special feature) also supports UTF8 if enabled (https://github.com/olikraus/u8g2/wiki/u8g2reference#enableutf8print) or if you use the drawUTF8 function.
U8x8 has a similar function, but my suggestion is not to trust that u8x8 function.
Coming back to your problem: Your IDE will probably use UTF8 encoding, however U8x8 assumes ISO/IEC 8859 encoding... so no wonder the wrong chars will appear. So better use the \xYY number code from the u8x8 font table.
from u8g2.
OK, thanks for the quick reply.
from u8g2.
Related Issues (20)
- NodeMCU ESP8266 display not working HOT 3
- Pin mux conflict with RP2040 (Pico) earlephilhower Arduino core HOT 2
- KS0108: Increase reset duration to 5mS HOT 1
- t6963 f Data Hold Time HOT 6
- How to switch to the next page in u8g2 HOT 1
- SPI is Broken on ESP32 S2 mini. (Possibly S2 as well) HOT 1
- Can I use u8g2 with SSD1357 mono mode? HOT 3
- SH1107 128x128 OLED text jumbled around HOT 6
- STM32F4 t6963 interfacing usage HOT 19
- Support for Monochrome Low-Power ST7302 Display HOT 1
- Using ERC240160 in ESP32S3 SPI HW mode does not work HOT 1
- Artefacts using U8G2_SSD1309_128X64_NONAME0_F_4W_SW_SPI OLED Display
- internal compiler error: in type_hash_canon, at tree.c:7158 HOT 1
- U8g2 font size and type HOT 3
- New Version UW ttyp0
- Doubt in constructor for KS0108 Controller based 128X64 GLCD HOT 1
- The width of the text obtained using u8g2_GetStrWidth is very strange HOT 8
- UW TTYP0 Font Update
- UC1611s The first line displays a vertical coordinate of 8, which on an LCD display is equivalent to a downward translation of the screen coordinate by 8 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from u8g2.