Circuit python and oled

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Wesselah
 
Posts: 5
Joined: Wed Dec 13, 2017 3:44 pm

Circuit python and oled

Post by Wesselah »

I tried the oled example from circuit python and oled worked.
https://learn.adafruit.com/micropython- ... y?view=all
But oled.text does not work and found that it is not implemented in the library.
So i used the micropython way . https://learn.adafruit.com/micropython- ... awing-text
But i got stuck at bf.init are there any examples or code to help me use text onan oled ssd1306?
Would be very appriciated

User avatar
danhalbert
 
Posts: 4655
Joined: Tue Aug 08, 2017 12:37 pm

Re: Circuit python and oled

Post by danhalbert »

Which board are you using, and what version of CircuitPython? oled.text() appears to be implemented in the latest version of the library that I see, but it depends on framebuf.

The Learn Guides are undergoing a lot of revisions to keep up with the latest versions of CircuitPython, and this one has not been revised recently.

User avatar
Wesselah
 
Posts: 5
Joined: Wed Dec 13, 2017 3:44 pm

Re: Circuit python and oled

Post by Wesselah »

I am using the latest circuit python downloaded from adafruit reposotry on a trinket m0.
I am using framebuf as shown on the example page writing text as mentioned in my post.
I just don’t get past bf.init() so i wondering if anybody did oled text with circuitpython or that i am pionering her?
Im am trying every thing in REPL to find the errors step by step.
I do not get an error on bf = bitmapfont.BitmapFont(128, 64, oled.pixel). I have a ssd1306 connected and oled.fill(1) works so that why i used the oled.pixel function as displained in the example for an other display. But with bf.init() i do get an error forwhat i think is a error in the font5x8.bin because of the fontname it is rb in the library but i think it is wb if i look at the raw font5x8 compile code.
So any clue in any direction would help.
I know i could solve this with arduino coding but i would like to do it in circuit python as it is the default for the board which is pretty new :-)

User avatar
danhalbert
 
Posts: 4655
Joined: Tue Aug 08, 2017 12:37 pm

Re: Circuit python and oled

Post by danhalbert »

Yes, sorry, .text is not implemented in that Python implementation of framebuf. Framebuf is not included in the Trinket M0 or Gemma M0 CircuitPython builds due to lack of space. However, if you upgrade to an Express board (Feather M0 Express, Metro M0 Express, or Circuit Playground Express), native framebuf (with text support) is included.

User avatar
Wesselah
 
Posts: 5
Joined: Wed Dec 13, 2017 3:44 pm

Re: Circuit python and oled

Post by Wesselah »

What your saying is true but in the documentation on the example page there is a reference to the drawing text page ( first post) and there the framebuf library is mentioned. I was abble to include all the librarys in the trinket mo and was following the example drawing text further. There it stops at the command bf.init()
So all the librarys needed are on the trinket m0 so that should not be a problem.
If the library framebuf can not work on circuit python and thats the reason bf.init() does not work then there is a mistake on the page and needs correction.
But honestle i think the problem lays elswhere in the font5x8.bin file what do you think?

User avatar
Wesselah
 
Posts: 5
Joined: Wed Dec 13, 2017 3:44 pm

Re: Circuit python and oled

Post by Wesselah »

I made a mistake on my previous reply i mean this txt.
Note that not all boards support built-in text rendering. In particular the non-express boards like Gemma and Trinket M0 don't have the memory to build in text drawing. You can however on those boards load a separate Python text drawing library to draw text. See the Drawing Text guide! Which i am using so reading that text is sugests that the drawing text which i am using should work and that is where i am stuck on an oled display.
Sorry to be confusing

User avatar
danhalbert
 
Posts: 4655
Joined: Tue Aug 08, 2017 12:37 pm

Re: Circuit python and oled

Post by danhalbert »

Sorry, I didn't realize which example you were using. The "rb" in the init() code means "read binary". The "wb" in font_to_binary.py means "write binary", because that program is creating the 5x8font.bin file. In the first case the file is opened for reading, in the second for writing.

Do you have the file 5x8font.bin stored on your CIRCUITPY drive, and if so, where (in what directory)? What error specifically does bf.init() raise?

User avatar
Wesselah
 
Posts: 5
Joined: Wed Dec 13, 2017 3:44 pm

Re: Circuit python and oled

Post by Wesselah »

The font is placed in the lib directory and the fault is not be able to read the font
I will post a screen shot of the fault when i arrive home

User avatar
danhalbert
 
Posts: 4655
Joined: Tue Aug 08, 2017 12:37 pm

Re: Circuit python and oled

Post by danhalbert »

Thanks. If the failure is a failure to open the file, try putting the font file in the top-level directory.

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”