Go Down

Topic: How to install libraries? (Read 1 time) previous topic - next topic

Chicken325

I have gotten a Nokia screen from Adafruit.  I have everything set up, except I can't get it to use the libraries.  In my Arduino/libraries folder, I have glcdfont.c, PCD8544.cpp, and PCD8544.h.  This is my sketch: (the example Adafruit code)
Code: [Select]
#include "PCD8544.h"

// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 4, 3);

// a bitmap of a 16x16 fruit icon
static unsigned char __attribute__ ((progmem)) logo16_glcd_bmp[]={
0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0xf8, 0xbe, 0x9f, 0xff, 0xf8, 0xc0, 0xc0, 0xc0, 0x80, 0x00,
0x20, 0x3c, 0x3f, 0x3f, 0x1f, 0x19, 0x1f, 0x7b, 0xfb, 0xfe, 0xfe, 0x07, 0x07, 0x07, 0x03, 0x00, };
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16

void setup(void) {
 
  Serial.begin(9600);
 
  Serial.println("hello!");

  nokia.init();

  // turn all the pixels on (a handy test)
  nokia.command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYALLON);
  delay(500);
  // back to normal
  nokia.command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);

  // show splashscreen
  nokia.display();
  delay(2000);
  nokia.clear();

  // draw a single pixel
  nokia.setPixel(10, 10, BLACK);
  nokia.display();        // show the changes to the buffer
  delay(2000);
  nokia.clear();

   // draw many lines
  testdrawline();
  nokia.display();       // show the lines
// nokia.clear();
 
  // draw rectangles
  testdrawrect();
  nokia.display();
  delay(2000);
  nokia.clear();
 
  // draw multiple rectangles
  testfillrect();
  nokia.display();
  delay(2000);
  nokia.clear();
 
  // draw mulitple circles
  testdrawcircle();
  nokia.display();
  delay(2000);
  nokia.clear();
 
  // draw the first ~120 characters in the font
  testdrawchar();
  nokia.display();
  delay(2000);
  nokia.clear();

  // draw a string at location (0,0)
  nokia.drawstring(0, 0, "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor");
  nokia.display();
  delay(2000);
  nokia.clear();

  // draw a bitmap icon and 'animate' movement
  testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
}

void loop(void) {}

#define NUMFLAKES 8
#define XPOS 0
#define YPOS 1
#define DELTAY 2

void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
  uint8_t icons[NUMFLAKES][3];
  srandom(666);     // whatever seed

  // initialize
  for (uint8_t f=0; f< NUMFLAKES; f++) {
    icons[f][XPOS] = random() % LCDWIDTH;
    icons[f][YPOS] = 0;
    icons[f][DELTAY] = random() % 5 + 1;
  }

  while (1) {
    // draw each icon
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      nokia.drawbitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
    }
    nokia.display();
    delay(200);
   
    // then erase it + move it
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      nokia.drawbitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, 0);
      // move it
      icons[f][YPOS] += icons[f][DELTAY];
      // if its gone, reinit
      if (icons[f][YPOS] > LCDHEIGHT) {
icons[f][XPOS] = random() % LCDWIDTH;
icons[f][YPOS] = 0;
icons[f][DELTAY] = random() % 5 + 1;
      }
    }
  }
}

void testdrawchar(void) {
  for (uint8_t i=0; i < 64; i++) {
    nokia.drawchar((i % 14) * 6, i/14, i);
  }   
  nokia.display();
  delay(2000);
  for (uint8_t i=0; i < 64; i++) {
    nokia.drawchar((i % 14) * 6, i/14, i + 64);
  }   
}

void testdrawcircle(void) {
  for (uint8_t i=0; i<48; i+=2) {
    nokia.drawcircle(41, 23, i, BLACK);
  }
}


void testdrawrect(void) {
  for (uint8_t i=0; i<48; i+=2) {
    nokia.drawrect(i, i, 96-i, 48-i, BLACK);
  }
}

void testfillrect(void) {
  for (uint8_t i=0; i<48; i++) {
      // alternate colors for moire effect
    nokia.fillrect(i, i, 84-i, 48-i, i%2);
  }
}

void testdrawline() {
  for (uint8_t i=0; i<84; i+=4) {
    nokia.drawline(0, 0, i, 47, BLACK);
  }
  for (uint8_t i=0; i<48; i+=4) {
    nokia.drawline(0, 0, 83, i, BLACK);
  }

  nokia.display();
  delay(1000);
  for (uint8_t i=0; i<84; i+=4) {
    nokia.drawline(i, 47, 0, 0, WHITE);
  }
  for (uint8_t i=0; i<48; i+=4) {
    nokia.drawline(83, i, 0, 0, WHITE);
  }
}

It gives me a bunch of errors :(
Code: [Select]
screen.cpp: In function 'void setup()':
screen:22: error: 'nokia' was not declared in this scope
screen:25: error: 'PCD8544_DISPLAYCONTROL' was not declared in this scope
screen:25: error: 'PCD8544_DISPLAYALLON' was not declared in this scope
screen:28: error: 'PCD8544_DISPLAYNORMAL' was not declared in this scope
screen:36: error: 'BLACK' was not declared in this scope
screen.cpp: In function 'void testdrawbitmap(const uint8_t*, uint8_t, uint8_t)':
screen:93: error: 'LCDWIDTH' was not declared in this scope
screen:101: error: 'nokia' was not declared in this scope
screen:101: error: 'BLACK' was not declared in this scope
screen:103: error: 'nokia' was not declared in this scope
screen:112: error: 'LCDHEIGHT' was not declared in this scope
screen:113: error: 'LCDWIDTH' was not declared in this scope
screen.cpp: In function 'void testdrawchar()':
screen:123: error: 'nokia' was not declared in this scope
screen:125: error: 'nokia' was not declared in this scope
screen.cpp: In function 'void testdrawcircle()':
screen:134: error: 'nokia' was not declared in this scope
screen:134: error: 'BLACK' was not declared in this scope
screen.cpp: In function 'void testdrawrect()':
screen:141: error: 'nokia' was not declared in this scope
screen:141: error: 'BLACK' was not declared in this scope
screen.cpp: In function 'void testfillrect()':
screen:148: error: 'nokia' was not declared in this scope
screen.cpp: In function 'void testdrawline()':
screen:154: error: 'nokia' was not declared in this scope
screen:154: error: 'BLACK' was not declared in this scope
screen:157: error: 'nokia' was not declared in this scope
screen:157: error: 'BLACK' was not declared in this scope
screen:160: error: 'nokia' was not declared in this scope
screen:163: error: 'WHITE' was not declared in this scope
screen:166: error: 'WHITE' was not declared in this scope

Do you guys know what's wrong?  Thanks so much, I can't wait to use this screen! :)

Chicken325

Figured it out myself.  You have to make a folder to put the libraries in, in the /libraries folder.  I put the lcd folder in /libraries and then I put all the files of the library in the lcd folder.  Then I restarted Arduino and in the Sketch > Import library... menu you can import lcd.  You'll then have to delete the old import statement.  Then it worked!

liuzengqiang

You should create a folder under sketchbooks/libraries instead of libraries. The arduino/libraries folder is for system libraries not contributed libraries.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Chicken325

The Arduino application already knows the library is contributed.  It says so.  If I move libraries inside a new folder named sketchbooks, it can't see the library anymore.

retrolefty


The Arduino application already knows the library is contributed.  It says so.  If I move libraries inside a new folder named sketchbooks, it can't see the library anymore.


contributed libraries should be placed like such:

Quote
C:\Documents and Settings\Primary Windows User\My Documents\Arduino\libraries

10 Folders:

Button
DS1307
Flash
MsTimer2
Playtune
Streaming
String
Tone
WString
__MACOSX


0 Files:

Go Up