ESP8266: Fixing extended ASCII issues in SSD1306 OLED library

Do you like this post? Writing posts, developing libraries and programming online font creators is actually hard work. I order most of my electronics from a Chinese website called Banggood. It is save and the items usually arrive in good quality. With every order you do there by following this link you are supporting the blog. Thank you!

I got a few complaints that the esp8266-oledssd1306 library does not handle special characters such as Umlauts properly. It turns out that the Arduino IDE does handle characters in the extended ASCII range (from 128-256) as UTF8 characters which means that Strings containing such characters can take more space than the bare number of symbols in it. For instance the degree character (°) will be represented as two chars with values 0xC2 and 0xB0.

Extended ASCII now working properly

Currently the library only supports extended ASCII range and not UTF8. I don’t know if I will ever support UTF8, so I introduced automatic detection and conversion for characters in the extended ASCII table. This should work transparently for the users of the library. The implementation has currently one ugly aspect: if you call the getStringWidth(..) method followed by drawString(..) the conversion will be made twice.

I released the new version 1.0.2 of the library and it should become available in the Arduino IDE library manager shortly for update.

If you want to read more about UTF8 in the Arduino IDE continue here:
http://playground.arduino.cc/Code/UTF-8

Posted by squix78

14 comments

  1. Hi Daniel

    I am trying your Github code for the new 4-page weather station
    esp8266-weather-station
    It uses the new SSD1306 drivers. I could only find them after I googled. Now that I have them installed I get all kinds of errors: functions that dont exist anymore in SSD1306.cpp but the sketch makes calls to them. They did exist in ssd1306_i2c.cpp but if I use that then I get other errors.

    Could you please release the right Oled lib?

    Cheers
    Dennis

  2. Hi Daniel

    Now I'm really confused… You said the currnet branch is not currently out of sync with the stable version. Do you mean: it IS out of sync?
    I use arduino 1.6.5 so that should not be the issue
    I tried now:
    -your weather station code https://github.com/squix78/esp8266-weather-station
    -installed your OLED lib version 1.0.2 as you suggested
    -installed your JSON parser https://github.com/squix78/json-streaming-parser

    The result is now a long long list of errors.
    The include in the weatherstation sketch does not match: it wants to include ssd1306_i2c.h so I changed this to SSD1306.h

    To fix the problems I tried many things like older and newer OLED lib versions.

    It just seems not to fit with eachother, did you try to compile it yourself in Arduino?

    Here are some of the errors

    Tnx in advance for looking
    Dennis

    Oled_iconbased_4paginas.ino: In function 'void setup()':
    Oled_iconbased_4paginas:88: error: 'class SSD1306' has no member named 'setFrameCallbacks'
    Oled_iconbased_4paginas:90: error: 'class SSD1306' has no member named 'setFrameTransitionTicks'
    Oled_iconbased_4paginas:92: error: 'class SSD1306' has no member named 'setFrameWaitTicks'
    Oled_iconbased_4paginas.ino: In function 'void loop()':
    Oled_iconbased_4paginas:106: error: 'class SSD1306' has no member named 'getFrameState'
    Oled_iconbased_4paginas:106: error: 'class SSD1306' has no member named 'FRAME_STATE_FIX'
    Oled_iconbased_4paginas:118: error: 'class SSD1306' has no member named 'nextFrameTick'
    'class SSD1306' has no member named 'setFrameCallbacks'

  3. 😉 You are right, I meant "IS out of sync"! From what I see it looks as if you are still using the master branch version from github. Have you removed the library manually from your Arduino/libraries folder? I hope that later today or tomorrow I will have time to clean up the mess/confusion. I also vow to use a dev branch on github in the future… Please let me know if you could resolve it…

  4. Hi! I thought it was just a word confusion! Indeed its out of sync. I removed the library manually, just went to my libraries folder and deleted it. Is that not the right way?

    I tried all versions of the OLED lib I could find on your Github, they do all give some kind of error albeit different errors. Maybe you have your version somewhere that will work with the released weather station. I hope so because I thought it would be very cool to have 4 pages AND be able to get my thingspeak data (from another weather station, in my garden) to my OLED station!

    I actually made the OLED project that I found on your page, the one that had the printed circuit board gerber files. Mike was it?
    Its working fine with the firmware I could find on his webpage (which is your firmware, your name is in it).

    Cant wait to take it to the next level

  5. Hi Daniel I got it now… I did not delete the OLED lib that you last released (V1.0.3?) so I did install 1.0.2 but the other lib was still in position so it could never work

    Now it compiles, after a good night's sleep I will try it tomorrow on my hardware!

  6. OK I now tested it all and my weather station seems to work with the OLED lib 1.0.2, I hope you can update the trunk version of the OLED driver on Github that will clear things up.

    I've seen some people on your blog with the same problem, I save you some time and paste your exact reply so they can solve their own problem 🙂

  7. OK I now tested it all and my weather station seems to work with the OLED lib 1.0.2, I hope you can update the trunk version of the OLED driver on Github that will clear things up.

    I've seen some people on your blog with the same problem, I save you some time and paste your exact reply so they can solve their own problem 🙂

Leave a Reply