attiny85 + SSD1306 = gauge - Page 1
Forum section: electronics / general

author: YKuwahara
author_rank: Newbie
timestamp: May 04, 2019, 10:33:33 am
content: 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.htmlAnd 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 1Error compiling for board Digispark (Default - 16.5mhz).---------------------------- EORE ---------------------------------I'd appreciate your help.Thank You.

author: sokoloff
author_rank: Super Contributor
timestamp: May 04, 2019, 01:21:20 pm
content: 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:Arduino: 1.8.9 (Mac OS X), Board: "Digispark (Default - 16.5mhz)"Build options changed, rebuilding allIn 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 typeu8g_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 typeu8g_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 typeu8g_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 typeu8g_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 typeu8g_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 typeu8g_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 1Error compiling for board Digispark (Default - 16.5mhz).This report would have more information with"Show verbose output during compilation"option enabled in File -> Preferences.

author: Psi
author_rank: Super Contributor
timestamp: May 04, 2019, 01:28:59 pm
content: 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?

author: YKuwahara
author_rank: Newbie
timestamp: May 04, 2019, 07:04:12 pm
content: 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.

author: YKuwahara
author_rank: Newbie
timestamp: May 04, 2019, 07:09:29 pm
content: Quote from: Psi on May 04, 2019, 01:28:59 pmYes, 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.

author: cv007
author_rank: Frequent Contributor
timestamp: May 04, 2019, 10:25:27 pm
content: 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.

author: YKuwahara
author_rank: Newbie
timestamp: May 05, 2019, 12:24:34 am
content: 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.

author: cv007
author_rank: Frequent Contributor
timestamp: May 05, 2019, 01:42:42 am
content: QuoteYou already have that, but you also wantQuoteIf 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.

author: YKuwahara
author_rank: Newbie
timestamp: May 05, 2019, 06:34:42 pm
content: Quote from: cv007 on May 05, 2019, 01:42:42 amI 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.