Author Topic: attiny85 + SSD1306 = gauge  (Read 3616 times)

0 Members and 1 Guest are viewing this topic.

Offline YKuwaharaTopic starter

  • Newbie
  • Posts: 5
  • Country: us
attiny85 + SSD1306 = gauge
« on: May 04, 2019, 10:33:33 am »
Hi all!,

I´m new at arduino programming. I found this link from ¨Maker Tutor¨at  ¨http://www.arduinotutorialonline.com/2017/12/arduino-and-oled-display-gauge-with.HTML¨

and created a new sketch at arduino IDE with arduino uno and an I2C SSD1306 display.

I just copied and pasted the code and compiled and uploaded to the arduino uno and everything worked just fine.

Then, I ordered a ¨Digispark Kickstarter ATTINY85 General Micro USB Development Board ASS¨ from eBay to make it more compact.

but......

After have added the drivers, board compatibility, compiled and uploaded the ¨blinking led and hello world¨ with success to the ATTINY85¨

I tried to upload the same code to the ATTINY85 and got a lot of errors back.


I´ve tried migrating from u8g to u8g2 and removed some code and removed the fonts, but still have getting a lot of errors.

I had tried with the arduino uno again and everything Works just fine.

Could some one with the knowledge help me to make it work with the ATTINY85 and the SSD1306?



here is the original code:

http://www.arduinotutorialonline.com/2017/12/arduino-and-oled-display-gauge-with.html



And this are the returned errors after modifications:


--------------------- BORE --------------------------


In file included from C:\Users\Multimedia\Documents\Arduino\libraries\U8g2\src/U8g2lib.h:50:0,

                 from C:\Users\Multimedia\Documents\Arduino\sketches\gauge\gauge.ino:1:

C:\Users\Multimedia\Documents\Arduino\libraries\U8g2\src/U8x8lib.h:282:12: error: conflicting return type specified for 'virtual size_t U8X8::write(const uint8_t*, size_t)'

     size_t write(const uint8_t *buffer, size_t size) {

            ^

In file included from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Stream.h:24:0,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/TinyDebugSerial.h:31,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:18,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,

                 from sketch\gauge.ino.cpp:1:

C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Print.h:75:18: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

     virtual void write(const uint8_t *buffer, size_t size);

                  ^

In file included from C:\Users\Multimedia\Documents\Arduino\libraries\U8g2\src/U8g2lib.h:50:0,

                 from C:\Users\Multimedia\Documents\Arduino\sketches\gauge\gauge.ino:1:

C:\Users\Multimedia\Documents\Arduino\libraries\U8g2\src/U8x8lib.h:351:12: error: conflicting return type specified for 'virtual size_t U8X8LOG::write(const uint8_t*, size_t)'

     size_t write(const uint8_t *buffer, size_t size) {

            ^

In file included from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Stream.h:24:0,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/TinyDebugSerial.h:31,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:18,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,

                 from sketch\gauge.ino.cpp:1:

C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Print.h:75:18: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

     virtual void write(const uint8_t *buffer, size_t size);

                  ^

In file included from C:\Users\Multimedia\Documents\Arduino\sketches\gauge\gauge.ino:1:0:

C:\Users\Multimedia\Documents\Arduino\libraries\U8g2\src/U8g2lib.h:277:12: error: conflicting return type specified for 'virtual size_t U8G2::write(const uint8_t*, size_t)'

     size_t write(const uint8_t *buffer, size_t size) {

            ^

In file included from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Stream.h:24:0,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/TinyDebugSerial.h:31,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:18,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,

                 from sketch\gauge.ino.cpp:1:

C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Print.h:75:18: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

     virtual void write(const uint8_t *buffer, size_t size);

                  ^

In file included from C:\Users\Multimedia\Documents\Arduino\sketches\gauge\gauge.ino:1:0:

C:\Users\Multimedia\Documents\Arduino\libraries\U8g2\src/U8g2lib.h:357:12: error: conflicting return type specified for 'virtual size_t U8G2LOG::write(const uint8_t*, size_t)'

     size_t write(const uint8_t *buffer, size_t size) {

            ^

In file included from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Stream.h:24:0,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/TinyDebugSerial.h:31,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:18,

                 from C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,

                 from sketch\gauge.ino.cpp:1:

C:\Users\Multimedia\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Print.h:75:18: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

     virtual void write(const uint8_t *buffer, size_t size);

                  ^

exit status 1
Error compiling for board Digispark (Default - 16.5mhz).



---------------------------- EORE ---------------------------------


I'd appreciate your help.

Thank You.
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: attiny85 + SSD1306 = gauge
« Reply #1 on: May 04, 2019, 01:21:20 pm »
You got us help you. To do that, we need more information.

Where did you download the board definition files?
Where did you get the u8glib library? From git or from a zip file? What version or tag of that library are you using?

I spent 15 minutes trying to replicate your issue and got a different set of errors (probably because I'm not downloading the same versions of the library and board support files because you haven't told us where/what version you're using).

This is a pretty helpful bunch in general, but we're not mindreaders. You gotta give us more details.

Here's the errors I got, similar with both 1.18.0 and 1.19.1 of the u8glib library zip file.

Code: [Select]
Arduino: 1.8.9 (Mac OS X), Board: "Digispark (Default - 16.5mhz)"

Build options changed, rebuilding all
In file included from /Users/jsokoloff/Documents/Arduino/sketch_may04a_eevblog/sketch_may04a_eevblog.ino:10:0:
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:201:58: error: '__FlashStringHelper' does not name a type
     u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStrP(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                          ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:201:79: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
     u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStrP(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                                               ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:202:60: error: '__FlashStringHelper' does not name a type
     u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr90P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                            ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:202:81: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
     u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr90P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                                                 ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:203:61: error: '__FlashStringHelper' does not name a type
     u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr180P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                             ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:203:82: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
     u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr180P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                                                  ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:204:61: error: '__FlashStringHelper' does not name a type
     u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr270P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                             ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:204:82: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
     u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr270P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
                                                                                  ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:206:39: error: '__FlashStringHelper' does not name a type
     u8g_uint_t getStrPixelWidth(const __FlashStringHelper *s) { return u8g_GetStrPixelWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
                                       ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:206:60: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
     u8g_uint_t getStrPixelWidth(const __FlashStringHelper *s) { return u8g_GetStrPixelWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
                                                            ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:207:34: error: '__FlashStringHelper' does not name a type
     u8g_uint_t getStrWidth(const __FlashStringHelper *s) { return u8g_GetStrWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
                                  ^
/Users/jsokoloff/Documents/Arduino/libraries/U8glib-1.18.0/src/U8glib.h:207:55: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
     u8g_uint_t getStrWidth(const __FlashStringHelper *s) { return u8g_GetStrWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
                                                       ^
exit status 1
Error compiling for board Digispark (Default - 16.5mhz).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 
The following users thanked this post: YKuwahara

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10227
  • Country: nz
Re: attiny85 + SSD1306 = gauge
« Reply #2 on: May 04, 2019, 01:28:59 pm »
There was some compatibility issues between ATTiny micrcontrollers and U8glib due to the ATTiny not having the same hardware SPI as the ATMega does.
So it maybe related to that.
Are you using the latest version of arduino and u8glib library?


« Last Edit: May 04, 2019, 01:45:08 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: YKuwahara

Offline YKuwaharaTopic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: attiny85 + SSD1306 = gauge
« Reply #3 on: May 04, 2019, 07:04:12 pm »
Hi!, Thank´s for your help.

I´m using Windows 10 x64, Arduino IDE 1.8.9, Board files from ¨https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json¨(added at Arduino settings, then installed from ¨Arduino Board Manager¨ and selected ¨Digistump AVR boards 1.6.7¨.

The library is ¨U8glib by Oliver 1.19.1¨ from Arduino IDE library manager.

The changes I´ve tried with U8g2lib is with ¨U8g2 by Oliver v.2.25.10¨ from Library Manager.

Let me know what if you need any other information.

Thank´s again.





« Last Edit: May 04, 2019, 07:11:56 pm by YKuwahara »
 

Offline YKuwaharaTopic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: attiny85 + SSD1306 = gauge
« Reply #4 on: May 04, 2019, 07:09:29 pm »
There was some compatibility issues between ATTiny micrcontrollers and U8glib due to the ATTiny not having the same hardware SPI as the ATMega does.
So it maybe related to that.
Are you using the latest version of arduino and u8glib library?

Yes, I´ve downloaded the latest IDE version.

I found some info about the SPI errors and downloaded some library from git ¨u8glib_arduino_v1.14pre1 - (no spi)¨ and got the same results... Lot of errors.
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 854
Re: attiny85 + SSD1306 = gauge
« Reply #5 on: May 04, 2019, 10:25:27 pm »
Lets back up a little.

You have code which seems to need about 16kb. You now want to use an attiny85 which has 8kb, of which some 2kb is used by a usb bootloader it seems. Its going to be hard to get 16kb of code to fit in 6kb, so it probably doesn't do any good to hunt down errors.

The errors look like a virtual write function has a conflict in the return type- size_t and void, I would guess the attiny code is old where it uses 'void' as the return type for the virtual write function (Print class), and main arduino code switched to size_t at some point. So you have a library using the newer style, and older attiny code which no longer matches.
 

Offline YKuwaharaTopic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: attiny85 + SSD1306 = gauge
« Reply #6 on: May 05, 2019, 12:24:34 am »
do you know about any gauge code that fits attiny?

I don´t care about that code.

The only thing that I want, is to add a gauge alike to my Project using a potentiometer.

 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 854
Re: attiny85 + SSD1306 = gauge
« Reply #7 on: May 05, 2019, 01:42:42 am »
Quote
The only thing that I want, is to add a gauge alike to my Project using a potentiometer.
You already have that, but you also want
Quote
... to make it more compact.

If you are an 'assembler' of pieces of code and hardware others have made to get the result you want, just find yourself the smallest arduino board that has enough space to hold that code. You can turn on verbose compiler output where you can then see code size information.

Or with a little more work, just go buy an atmega328 (the bare chip) and put your existing code in it. That would end up quite small in size. That will require temporarily using your existing uno to program the chip, and also figure out about fuses/clock sources/etc.
 
The following users thanked this post: YKuwahara

Offline YKuwaharaTopic starter

  • Newbie
  • Posts: 5
  • Country: us
Re: attiny85 + SSD1306 = gauge
« Reply #8 on: May 05, 2019, 06:34:42 pm »
Quote
The only thing that I want, is to add a gauge alike to my Project using a potentiometer.
You already have that, but you also want
Quote
... to make it more compact.

If you are an 'assembler' of pieces of code and hardware others have made to get the result you want, just find yourself the smallest arduino board that has enough space to hold that code. You can turn on verbose compiler output where you can then see code size information.

Or with a little more work, just go buy an atmega328 (the bare chip) and put your existing code in it. That would end up quite small in size. That will require temporarily using your existing uno to program the chip, and also figure out about fuses/clock sources/etc.


I know, i also tried modifying the .h and .cpp library files, removing all the letters that I don´t need, code for other screens, etc. but still too big for the attiny. I wanted to use the attiny because I have 3 and I also know that I can use the bare atmega328.

As I will not be able to use the attiny. I´ve decided to buy the nano and a rotary encoder module to add more options, some starting logo, menú, etc. to my Project.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf