zeiv / SSD1306-ruby

Ruby library for the SSD1306 OLED display.
MIT License
10 stars 10 forks source link

error on raspbery pi #8

Open texrg opened 7 years ago

texrg commented 7 years ago

Hello, I use 128x32 on Raspberry Pi , i get this error:

var/lib/gems/2.1.0/gems/SSD1306-0.6.1/lib/SSD1306/display.rb:144:in pack': no implicit conversion of nil into Integer (TypeError) from /var/lib/gems/2.1.0/gems/SSD1306-0.6.1/lib/SSD1306/display.rb:144:indisplay!'

I install without any error

gem install SSD1306

Fetching: SSD1306-0.6.1.gem (100%) Successfully installed SSD1306-0.6.1 Parsing documentation for SSD1306-0.6.1 Installing ri documentation for SSD1306-0.6.1 Done installing documentation for SSD1306 after 17 seconds 1 gem installed

zeiv commented 7 years ago

Hey texrg, do you think you could post your code? Are you creating a new display object with a height of 30?

At a quick glance it seems that this error is being caused because the library expects display heights to be in multiples of 8. I have the 128x64. My thought was the only other option was 128x32, right?

In any case, try setting your height to 32. If your display is actually 30 pixels tall, you might end up having your text cut off a tiny bit, but using 32 as the height should fix the error.

Alternatively you could set the height to 24, but then you would have 6 unusable rows.

texrg commented 7 years ago

128x32 my small mistake

zeiv commented 7 years ago

Did that fix the problem for you?

texrg commented 7 years ago

no

zeiv commented 7 years ago

Shoot. Can you tell me anything more about the error, or provide a code snippet?

eflukx commented 6 years ago

Encountered the same issue. When the height is set to 32 (maybe anything not 64 ?) this happens when initializing the display object. I encountered it when playing around, didn't bother to fix it as I have a 128x64 display.

paichi81 commented 6 years ago

I use 128x32 OLED. font_size 2 is OK.

disp.font_size=2 
disp.println "HOGE" # OK
disp.font_size = 1 # BAD