u8g library Omega symbol

I have read and tried every thread I could find about how to display the ohm symbol (omega) in my arduino sketch, using the u8g fonts, but can't figure it out.

I have found many many symbols in the font examples section, but no omega. Is it there ?

Is it there ?

You have the library you are asking questions about. We don't. Or, even a link to it.

this I don't know how to respond to. You never heard of the u8glib.h ?

I have looked at the symbols I could find till my eyes fell out and didn't see it. I was hoping that somebody would say "it is right there at line such and such", or "you're looking in the wrong place, that is only the partial library".

Hi

Unicode is not supported for u8g, so you should better switch to u8g2. U8g2 includes the both the greek omega symbol (unicode 0x03a9) and the ohm sign (unicode 0x02126).

The ohm sign is part of the u8g2_7x13_t_symbols font:

Greek symbols are part of the unicode font:

When using the new U8g2 function "drawUTF8" of if you enable unicode support for the Arduino print function, then you can just paste your ohm sign into the string inside Arduino IDE.

So it can look like this:

u8g2.drawUTF8("ΩΩ");   // ohm sign (first) and greek omega sign (second)

Oliver

Thanks Oliver -

The U8G2 lib was the conclusion I was coming to also, and not liking it.

I had just got the U8G lib to run the sketch when I found it did not have an Omega.
After thrashing around trying to find the symbol in some forgotten part of the library, I started transitioning my sketch from u8g to u8g2, and it does nothing but crash.

But I have been at this for many hours and I am beat down and tired. Maybe it will come together after some rest.

olikraus:
Hi

Unicode is not supported for u8g, so you should better switch to u8g2. U8g2 includes the both the greek omega symbol (unicode 0x03a9) and the ohm sign (unicode 0x02126).

The ohm sign is part of the u8g2_7x13_t_symbols font:

Greek symbols are part of the unicode font:

When using the new U8g2 function "drawUTF8" of if you enable unicode support for the Arduino print function, then you can just paste your ohm sign into the string inside Arduino IDE.

So it can look like this:

u8g2.drawUTF8("ΩΩ");   // ohm sign (first) and greek omega sign (second)

Oliver

I got it to print the ohm symbol, from your response. But I certainly do not understand where the address came from. I guess it is hex. I compared the position of the ohm symbol with the address (0x02126), but couldn't figure it out. I have looked around for an explanation of how to decypher a font table, but no luck (meaning I didn't understand the explanation).

The reason I'm trying to figure it out is that, the ohm sign I got to print is too small. I found a larger one in u8g2_font_8x13_t_symbols. But I can't figure out how to specify the address for the symbol.
Also, should I be using u8g2.drawGlyph() ?

But I certainly do not understand where the address came from. I guess it is hex.

I already did some compression with the u8glib fonts. With U8g2 fonts are even more compressed. The benefit is, that you can have thousands or more glyphs with on an Arduino UNO. The occupied size in bytes is always listed in the overview pics.

There is no full description on this, but some documentation can be found in the source code:

I found a larger one in u8g2_font_8x13_t_symbols

There is also an omega symbol in the 10x20 font:

Also note the size here: u8g2_font_10x20_t_greek will occupy 3857 bytes, while the uncompressed data will be around 10K byte.

Which size do you need for the omega glyph?
There is a omega symbol also in the free-universal font also (fntgrpfreeuniversal · olikraus/u8g2 Wiki · GitHub).
Not all gylphs of all fonts are part of the u8g2 release, but it could be easily generated from any ttf font.

I have attached front u8g2_font_omega_tn.c (see overview pic omega.jpg).
Just copy the c code to your .ino file and apply the font name u8g2_font_omega_tn to setFont command.

This omega symbol is around 30 pixel high.

Also, should I be using u8g2.drawGlyph() ?

Of course you can also use u8g2.drawGlyph().

Oliver

Edit: I have created an issue for u8g2 for this topic: add symbols to free universal font · Issue #473 · olikraus/u8g2 · GitHub

u8g2_font_omega_tn.c (4.7 KB)

#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <U8g2lib.h>


// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The following list is incomplete. The complete list of supported 
// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device
// U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);

const int sensorPin = A0;  // Analog input pin that senses Vout
int sensorValue = 0;       // sensorPin default value
float Vin = 5;             // Input voltage
float Vout = 0;            // Vout default value
float Rref = 3000;          // Reference resistor's value in ohms
float R = 0;               // Tested resistors default value
float R1=0;

/*
  Fontname: -FreeType-FreeUniversal-Medium-R-Normal--64-640-72-72-P-300-ISO10646-1
  Copyright: (FreeUniversal) Copyright (c) Stephen Wilson 2009    a modification of:    Original Font (SIL Sophia)  Copyright (c) SIL International, 1994-2008.    
  Glyphs: 21/243
  BBX Build Mode: 0
*/
const uint8_t u8g2_font_omega_tn[1537] U8G2_FONT_SECTION("u8g2_font_omega_tn") = 
  "\25\0\5\4\6\6\5\6\10\63=\0\363.\363\60\370\0\0\0\0\4\31 \6\0\0\301I*@\32"
  "\206m\325#\220`\305\224d\214I\206\230UHie\220G\4\201D\220\210\222@\6-A\304\3?"
  "\240\202\11*\231\24\22\212D\220WDq\204\220VHY\206\230d\214I\305\24&\220\70\0+a\346"
  "\331A\340H>\30\344\203A>\30\344\203A>\30\344\203A>\30\344\203A>\30\344\203A>\30\344"
  "\203A>\30\344\203A>\30\344\203A>\30$>\360\377\200\210\344\203A>\30\344\203A>\30\344\203"
  "A>\30\344\203A>\30\344\203A>\30\344\203A>\30\344\203A>\30\344\203A>\30$\2,\30"
  "\13\64\61Ir\215C.b\310!\246\230R\212U\212)\245\230b\0-\10O\61\333J\360\17.\11"
  "\7b\301H\360\3\13/=\323<\273\314G\271\312\221G\134q\344\21W\34y\304U\216<\342\212#"
  "\217\270\342\310#\256r\344\21W\34y\304U\216\270\312\221G\134q\344\21W\71\342*G\36q\305\221"
  "G\134\345\0\60S\35<\277\321\205ds\17\210\365\0I\17\230\223J\62'\235r\326!\246\31b\232"
  "\31\346\31a\236\21\346\31Q\240\11&\362\377\277hB\201'\230w\202yF\230g\204yf\230v\206"
  "i\206\230f\212Y\306\234t\16*(=P\324\3\203=\20\134\233H\1\61\35\220\213A\322t\20:"
  "\311\250\262F\23\17<\220B\33\253\244s\222Q\366\377\377\377\17\62;\334KAR\225\240k\17\210\364"
  "@A\17\30\223\14\42H\31r\230\31\207\31q\234\11\307\231p\234\11\346\31k\253\306\232z\350\241\210"
  "^\24M|\24M\374\67\323\304\350\3\377\7\12\63T\35<\277Q\205\244s\17\210\365\0I\17\230\223"
  "J*(\235r\326\31\247\231q\234\21\307\31a\236\11\347\231k\331c\215=\365\232\351\65\270\244\232,"
  ":\252,\272\327\65\367\134\353\262\310b\203\355\271g\304iG \205H\62\311<\200\316\3&=\60\330"
  "\213J\1\64N\240+\301\321y\60\272\231Uu\243l\232`f\21F\32a\242\31&\26b\240!\346"
  "\231b\236)\306\31c\232\71\246\231c\230Af\231d\226IFY\311,\223\314\62\310\60sL\63\307"
  "\64c\214\63\246<c\36\370@Q\243\355?\3\0\65S\335;\277\321\360\200\42\17(\362\200\42\17"
  "(\362\200\42\346\332\5)\63\30\62\342\31\23\36\20\345\1EXAD\245\63\20\63\3\261#\216\63"
  "\302<#\14\64\327~\267=\23\316\63\341<\23P\63\343\260\63\220:%\31t\36\60\351\1\262\36\20"
  "\316I\264\0\66c\36<?R\206h{\17\10\366\0I\17\230\224\12:\10\241\202\324)\207\231b\332"
  "\31\307\231a\236\31\346\236k\260=\203\224!\355\230\361\214\21\17\210b\302\3\204\254\223FZg\240v"
  "\2z&\240g\302\211\375E\23L\64\301D\23\316\63\303<\63N;\344\254S\322A\347\1\224\36("
  "\353\1\361\334D\12\0\67\66\235K\301R\360\377\200\272\226=\326\330c\315\65\366Xc\217\65\327\330c"
  "\215\275\254\261\307\32{Yc\257z\354\261\306^\365\330c\215\275\352\261W=\366\324c\317\3\70l\36"
  "<?\322\205\246s\17\214\365@A\17$\223\25\244\20\71\354\214\343\216\60\357\10\3\215\60\320\10\3\215"
  "\60\320\10\3\315\60\316\20\343L\61\314\230\243\316A\6\245\7H{ \274\366\36\20\354\201\222\220A\347"
  ",S\214\63\304\70\63\14\64\302@\23\214,\301H~\321\301\23\14\64\342\270\63\16;D\235T\36H"
  "\347\201\223\36(\355I\264\0\71e\36<?R\245\342\3\241=@\322\3\347<\220\14:\251\234\205\210"
  "iH\230w\204yG\30h\202\211\375\213\16\236`\36\12\346\241pZ\22g)\221\16\33\17\224`\310"
  "\3C\230\362@\30\346\64bR\62\6\33\134r\301\66a\236\31\346\31R\334!\246\231b\330)G\235"
  "\203LB\17\230\364@Y\17\14\347&b\0\0\0\3\224u\247\33\303T\32>\70\342\203\62>(\343"
  "\3R>\30\345\3q>\10\347\203p>\0\311\247\276\370\10g\17q\366\30'\223q\362 \350\222r"
  "\356\60\250\222s\352@\247\16\204\346Pg\16\205\342`'\16v\340h\350\15w\34q\250\15x\30\201"
  "\207\15y\326\220G\215\211\322\240\7\215z\320\260\307\214{\314\270\210\20|\310\310g\20}\304\3\17\34"
  "\361\300`\1\3\251\211\357+\301Y\271>\10\17\214\215\16\262\247\231y\340%\217;\364\260c\317\62"
  "\370\244\203\17:\372\234\243\217A\32\225\303O\71\374\20\304\321@\34\15\304\321@\34\15\304\321@\34\15"
  "\304\321@\34\15\304\21\71\34\221\303OA\32\25\244\221\71\372\34\224\17:\370\250s\15;\365\264\63\317"
  ";\321L\343N=\352\260\320J*l\274\221\206#n\244\321L\33i\260\7\20z\340\201\204\36x "
  "\241\7\36H\350\201\7\324y\340\1u\36(\3\274f\243K\247T`\240\71\6\232c\240\71\6\232c"
  "\240\71\6\232c\240\71\6\232c\240\71\6\232c\240\71\6\232c\240\71\6\232c\240\71\6\232c\240\71"
  "\6\232c\240\71\6\232c\240\71\6\232c\240\71\6\232c\336\71\346\235s\32:\210\241\223\322\62\253\230"
  "\360\300\3C<\360\200\30\17<\363\200\20H\241`\272\375\257\3\3\300k\242\30\277\322\363\0+\17\70"
  "\362\300\33\17<\20\304\3\17\10\361\300\3\42\14C\16Q\342PI\234rH\12\250\34\42\11\42\222 "
  "\42\11\42\222 \42\311)\222\234\22\313)\261\234\22\313)\221\240\22\11*\221\240\22\11*\260\240\202\302"
  ")\250\240`\14\62F\24\223\214\21\344\250#\310@\212\21\244\30AK\225\303\224\61\355\244\1K\1\0"
  "";


void setup(void) {
  u8g2.begin();
}

void loop(void) {
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB14_tr);
  u8g2.drawStr(0,20,"Hellot ");
  u8g2.setCursor(70, 20);
  u8g2.print(R,0);

  //u8g2.setFont(u8g2_font_unifont_t_greek);
  u8g2.setFont(u8g2_font_omega_tn);
  //u8g2.setFont(u8g2_font_omega_tn[1537]);
  

  //u8g2.drawGlyph(100,20,0x03a9);
  //u8g2.drawStr(100,20,0x03a9);
  //u8g2.setFont(u8g2_font_unifont_t_symbols);
   // u8g2.drawGlyph(5, 45, 0x03a9);  /* dec 9731/hex 2603 Snowman */
  
  u8g2.sendBuffer();

  
}
sketch\u8g2_font_omega_tn.c:7:7: error: unknown type name 'uint8_t'

 const uint8_t u8g2_font_omega_tn[1537] U8G2_FONT_SECTION("u8g2_font_omega_tn") = 

       ^

sketch\u8g2_font_omega_tn.c:7:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'U8G2_FONT_SECTION'

 const uint8_t u8g2_font_omega_tn[1537] U8G2_FONT_SECTION("u8g2_font_omega_tn") = 

                                        ^

exit status 1
Error compiling for board Arduino Nano.

I made some attempts at following your suggestions, but the truth is, I didn't get what you were saying.
As I vaguely understand it you suggested 3 ways to obtain the Omega symbol, and mentioned the memory requirements of 2 of them.

From the code, you can see that I know how to print the omega symbol by setting the font and drawStr() if the hex address is handed to me.

I think you were saying that there are 2 more fonts to choose from (along with their associated memory sizes), and a specific Omega font.

But as you can also see from my sketch I am still flailing around. I can set the fonts for the first two, but don't know the hex addresses. As for the specific Omega font, as you can see I get error messages.

I did go to the link, and I am no wiser.

I think the 20 pixel would be about the right size.

Would you have a look at my sketch and tell me where I went wrong (and possibly tell me the hex address for the 20 pix Omega) ?

and possibly tell me the hex address for the 20 pix Omega

Yust to be clear: This is embedded uC programming. You can not expect the same flexibility compared to your desktop PC. A desktop PC has gigabytes of memory, but your Arduino uC might have only 32K of ROM. Whatever you want, has to be put into your uC system manually.

You ask me to tell you the address of the 20 pix omega. The truth is: It is not there. U8g2 users will beat me if i would put all symbols in all sizes into u8g2 library. It is also not possible to calculate the bitmap at a given size on the fly. A library like truetype library (which performs such on the fly calculation) also eats up a LOT of memory and will take a long time for rendering a single glyph on a 16MHz controller. So please remember: What you need has to be precalculated and included manually.

So: Each font contains some glyphs at a specific size. So the font above includes the omega only once at a size of 30 pixel.

But as you can also see from my sketch I am still flailing around.

The code seems to fail with uint8_t. I do not know why, but "#include <stdint.h>" seems to be missing. Maybe you can add this include. It should compile with this additional line. You could also replace "unit8_t" with "unsigned char".

u8g2.drawStr(100,20,0x03a9);

This will not work (your uC will probably crash) because drawStr expects a string not a value!

u8g2.drawGlyph(100,20,0x03a9);

Yes, this will draw the glyph with unicode 0x03a9. Yet please remember, that there are two different omega symbols in the unicode space: 0x03a9 and 0x2126. A u8g2 font may include none, one or both of them. You should always crosscheck the overview picture whether and which code is included. Depending on this your need either use this:

u8g2.drawGlyph(100,20,0x03a9);

or this

u8g2.drawGlyph(100,20,0x02126);

I have attached another omega font (use "u8g2.drawGlyph(100,20,0x03a9);"). The size should be 22, smaller sizes do not look that good (due to rounding erros of the ttf font conversion tool which i have used here).

One more (completly different) idea: You could also use a bitmap instead of a font: Render your omega symbol on with a graphics tool like "the gimp". Save the image as xbm bitmap and use the u8g2.drawXBM() procedure.
There is a nice tutorial for this: https://sandhansblog.wordpress.com/2017/04/16/interfacing-displaying-a-custom-graphic-on-an-0-96-i2c-oled/.

Oliver

(personal note: font was generated with:
./otf2bdf/otf2bdf -a -r 72 -p 32 -o tmp.bdf ../ttf/FreeUniversal-Regular.ttf
./bdfconv -v -f 1 -m '32,35-57,$$300-$$3ff,$$2030-$$3000' tmp.bdf -o u8g2_font_omega_tn.c -n u8g2_font_omega_tn -d ../bdf/helvB18.bdf )

u8g2_font_omega_tn.c (5.16 KB)

1 Like

ok, regarding the limited memory issue in embedded uC.... i can not resist to quote from one of my favorit Harrison Ford movies:

Quinn: They come here looking for the magic, hoping to find romance, when they can't find it anywhere else.

Robin: Maybe they will.

Quinn: It's an island, babe. If you didn't bring it here, you won't find it here.

From: http://www.imdb.com/title/tt0120828/quotes

Oliver -

In trying to understand your last response it dawned on me that you must be the author of the u8g2 library.

And quoting someone, always go the the top man. which I did without realizing.

So if my questions seemed like complaining about a shortcoming, it certainly was not.

Now that I know I'm talking to the big boss I will think longer and harder before pestering you more.

Thanks.

Don't worry, let me know your doubts, i will try to answer.

Please excause my quotes, I just felt that your expections a little bit high to a system which has very limited resources like an Arduino Uno or other Arduno boards.

Oliver

OK. Your last response did the trick. Now I have a usable Omega symbol being displayed in the line of text.

It looks as tho you modified a font to help me out. That is much appreciated. Seeing an Omega symbol on the display looks much better than the word "ohms", and takes less room on the line.

The sketch is pretty well done and working and it came in at about 13.1k. From what I have read, the ATtiny167 has 14.5k available after bootloader, so hopefully it will run and be stable.

Thanks for your help. It may not seem like it, but I know more than I did about the whole process.

Now I can enjoy my coffee.