Pages: [1]   Go Down
Author Topic: Nokia 5110 Attiny, 3v  (Read 1924 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

probably if theres enough ram, and whats 0.3 volts between friends?
Logged


California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to update:
It does not appear that the library itself even fits on the 84. I also get this error:
Code:
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)'
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
   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:
   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:
/* 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:
/* 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;
}
« Last Edit: August 04, 2012, 01:30:58 pm by Tom Carpenter » Logged

~Tom~

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hmmm, now I get this:

Code:
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)'
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

~Tom~

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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
Logged

~Tom~

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
In file included from pcdtest.cpp:19:
C:\Users\Nick\Documents\Arduino\libraries\Adafruit_GFX/Adafruit_GFX.h:27: error: virtual outside class declaration
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

~Tom~

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try it in arduino 0.22
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
I'm a high schooler.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: