Go Down

Topic: Nokia 5110 Attiny, 3v (Read 2147 times) previous topic - next topic

Can the Nokia 5110 screen be driven by an attiny84 with the arduino tiny library?

Also, can it be driven by 3v instead of 3.3v? My goal is to get it working off of a 3v cr2032 battery.

If not, or if that is a bad idea, what alternatives do I have that are compact and don't waste battery?

Thanks.

Osgeld

probably if theres enough ram, and whats 0.3 volts between friends?
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Just to update:
It does not appear that the library itself even fits on the 84. I also get this error:
Code: [Select]
In file included from pcdtest.cpp:19:
C:\Users\Nick\Documents\Arduino\libraries\Adafruit_GFX/Adafruit_GFX.h:74: error: conflicting return type specified for 'virtual size_t Adafruit_GFX::write(uint8_t)'
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/Print.h:71: error:   overriding 'virtual void Print::write(uint8_t)'

Tom Carpenter

#3
Aug 04, 2012, 08:29 pm Last Edit: Aug 04, 2012, 08:30 pm by Tom Carpenter Reason: 1
Yeah, thats because someone when they updated the tiny core to Arduino 1.0, missed a bit.

In Print.h in the tiny core, change the following:
Code: [Select]

   virtual size_t write(uint8_t) = 0;
   virtual void write(const char *str);
   virtual void write(const uint8_t *buffer, size_t size);

To be:
Code: [Select]

   virtual size_t write(uint8_t) = 0;
   virtual size_t write(const char *str);
   virtual size_t write(const uint8_t *buffer, size_t size);


And in Print.cpp, change the following:
Code: [Select]
/* default implementation: may be overridden */
void Print::write(const char *str)
{
 while (*str)
   write(*str++);
}

/* default implementation: may be overridden */
void Print::write(const uint8_t *buffer, size_t size)
{
 while (size--)
   write(*buffer++);
}

To:
Code: [Select]
/* default implementation: may be overridden */
size_t Print::write(const char *str)
{
  size_t n = 0;
 while (*str){
   n += write(*str++);
 }
 return n;
}

/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
  size_t n = 0;
  while (size--) {
    n += write(*buffer++);
  }
  return n;
}
~Tom~

hmmm, now I get this:

Code: [Select]
In file included from C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/WProgram.h:17,
                 from C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/Arduino.h:4,
                 from C:\Users\Nick\Documents\Arduino\libraries\Adafruit_GFX/Adafruit_GFX.h:20,
                 from pcdtest.cpp:19:
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/TinyDebugSerial.h:728: error: conflicting return type specified for 'virtual void TinyDebugSerial::write(uint8_t)'
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/Print.h:71: error:   overriding 'virtual size_t Print::write(uint8_t)'
In file included from C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/WProgram.h:18,
                 from C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/Arduino.h:4,
                 from C:\Users\Nick\Documents\Arduino\libraries\Adafruit_GFX/Adafruit_GFX.h:20,
                 from pcdtest.cpp:19:
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/HardwareSerial.h:58: error: conflicting return type specified for 'virtual void HardwareSerial::write(uint8_t)'
C:\Users\Nick\Documents\Arduino\hardware\tiny\cores\tiny/Print.h:71: error:   overriding 'virtual size_t Print::write(uint8_t)'

Tom Carpenter

Eurgh, yeah, woops. I forgot that there are other bits in the core which are based around that version of Print being incorrect.

What you may have to do is to undo the changes to Print.h and Print.cpp, and instead change the Adafruit_GFX.h and Adafruit_GFX.cpp. Could you post the Adafruit library, and I can tell you what needs to be changed.
~Tom~

https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library

The other thing is though that the library seems to big for the 84. It compiles at almost 9kb. So it would need to be pruned in order to work. To display any text or anything it also requires this library:
https://github.com/adafruit/Adafruit-GFX-Library

Tom Carpenter

If you put the Print library back to how it was (I think i put the original in my first post), and change the following

In Adafruit_GFX.cpp
Code: [Select]

#if defined(__AVR_ATtiny84__)
void Adafruit_GFX::write(uint8_t c) { //This line has been added
#elif ARDUINO >= 100
size_t Adafruit_GFX::write(uint8_t c) {
#else
void Adafruit_GFX::write(uint8_t c) {
#endif
 if (c == '\n') {
   cursor_y += textsize*8;
   cursor_x = 0;
 } else if (c == '\r') {
   // skip em
 } else {
   drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
   cursor_x += textsize*6;
   if (wrap && (cursor_x > (_width - textsize*6))) {
     cursor_y += textsize*8;
     cursor_x = 0;
   }
 }
#if defined(__AVR_ATtiny84__)
#elif ARDUINO >= 100
 return 1;
#endif
}


In Adafruit_GFX.h
Code: [Select]

#if defined(__AVR_ATtiny84__)
 virtual void write(uint8_t); //this line is new
#elif ARDUINO >= 100
 virtual size_t write(uint8_t);
#else
 virtual void write(uint8_t);
#endif
~Tom~

I changed back the tiny cores, and added those changes to the GFX files and I still get the same errors but also with this at the end

Code: [Select]
In file included from pcdtest.cpp:19:
C:\Users\Nick\Documents\Arduino\libraries\Adafruit_GFX/Adafruit_GFX.h:27: error: virtual outside class declaration

Tom Carpenter

I must be missing something. I have just tried compiling the example (stripped of all the line, box, circle, triangle stuff) and without modifying anything it compiles fine. Could you post your sketch?
~Tom~

Osgeld

http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

twang

What is this?
http://blog.livedoor.jp/miyanobspage/archives/2426895.html

Go Up