Edit: First (Simple) Library Not Working

[edit]Ever tinker I try brings up new or the same errors! See code below…[/edit]
I have just created my first (working) library. It give simple use of a Seventeen segment LED display using almost all digital (and analogue) I/O.

I compiled the library fine after a long time of tinkering, but when I can o compile an example I got this error:

In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:4,

c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/…/…/avr/include/stdlib.h:111: error: expected unqualified-id before ‘int’

c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/…/…/avr/include/stdlib.h:111: error: expected `)’ before ‘int’

c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/…/…/avr/include/stdlib.h:111: error: expected `)’ before ‘int’

In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:6,

What does this mean?

Thanks, /me

make sure you put #include "WProgram.h" in the header file as well as the cpp OR at the beginning of each sketch that includes the new lib. The tutorial is incorrect as far as I can tell. That fixed my problem (which i believe was the same one)

OK thanks, that was missing; but now I get this error:

In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:4,

from hardware\libraries\Sts/Sts.h:5,

c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/…/…/avr/include/stdlib.h:111: error: expected unqualified-id before ‘int’

c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/…/…/avr/include/stdlib.h:111: error: expected `)’ before ‘int’

c:/program files/arduino/arduino-0015/hardware/tools/avr/lib/gcc/…/…/avr/include/stdlib.h:111: error: expected `)’ before ‘int’

In file included from C:\Program Files\Arduino\arduino-0015\hardware\cores\arduino/WProgram.h:6,

from hardware\libraries\Sts/Sts.h:5,

#include "WProgram.h"
#include "Sts.h"

byte charactersCap[26][16] = {
  {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1},  // A
  {1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,1},  // B
  {1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1},  // C
  {1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1},  // D
  {1,0,0,1,0,0,0,1,1,1,0,0,0,1,0,1},  // E
  {1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1},  // F
  {1,0,0,1,0,0,0,1,1,1,1,0,1,0,0,1},  // G
  {0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0},  // H
  {1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1},  // I
  {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1},  // J
  {0,0,0,1,1,0,0,1,0,0,0,1,0,0,1,0},  // K
  {0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0},  // L
  {1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1},  // M
  {0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0},  // N
  {1,0,0,1,0,0,0,1,1,1,1,0,0,1,0,1},  // O
  {1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1},  // P
  {1,0,0,1,0,0,0,1,1,1,1,1,0,1,0,1},  // Q
  {1,0,0,1,1,0,0,1,0,0,0,1,1,1,0,1},  // R
  {1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,1},  // S
  {1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1},  // T
  {0,0,0,1,0,0,0,1,1,1,1,0,0,1,0,0},  // U
  {0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0},  // V
  {0,0,0,1,0,1,0,1,1,1,1,0,0,1,0,0},  // W
  {0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0},  // X
  {0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0},  // Y
  {1,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1}};  // Z

void Sts::displayCap(int _charNum)
{
  for(int i=0; i<15; i++) {
    digitalWrite((i+2), charactersCap[_charNum][i]);
  }
}

void Sts::displaySml(int _charNum)
{
  for(int i=0; i<15; i++) {
    digitalWrite((i+2), charactersCap[_charNum][i]);
  }
}

void Sts::displayNum(int _charNum)
{
  for(int i=0; i<15; i++) {
    digitalWrite((i+2), charactersCap[_charNum][i]);
  }
}
#ifndef Sts_h
#define Sts_h

#include "WConstants.h"
#include "WProgram.h"

class Sts
{
  public:
    void displayCap(int _charNum);
    void displaySml(int _charNum);
    void displayNum(int _charNum);
  private:
    int _charNum;
    byte charactersCap[26][16];
};

#endif

Here’s the .cpp and .h files of my library.

[edit]I have only included one font table as they take a long time to make and take up a lot of space.[/edit]

Cheers, /me

Now that I have what I think is the right code for the library:

#include "WProgram.h"
#include "Sts.h"

byte charactersCap[26][16] = {
  {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1},  // A
  {1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,1},  // B
  {1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1},  // C
  {1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1},  // D
  {1,0,0,1,0,0,0,1,1,1,0,0,0,1,0,1},  // E
  {1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1},  // F
  {1,0,0,1,0,0,0,1,1,1,1,0,1,0,0,1},  // G
  {0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0},  // H
  {1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1},  // I
  {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1},  // J
  {0,0,0,1,1,0,0,1,0,0,0,1,0,0,1,0},  // K
  {0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0},  // L
  {1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1},  // M
  {0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0},  // N
  {1,0,0,1,0,0,0,1,1,1,1,0,0,1,0,1},  // O
  {1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,1},  // P
  {1,0,0,1,0,0,0,1,1,1,1,1,0,1,0,1},  // Q
  {1,0,0,1,1,0,0,1,0,0,0,1,1,1,0,1},  // R
  {1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,1},  // S
  {1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1},  // T
  {0,0,0,1,0,0,0,1,1,1,1,0,0,1,0,0},  // U
  {0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0},  // V
  {0,0,0,1,0,1,0,1,1,1,1,0,0,1,0,0},  // W
  {0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0},  // X
  {0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0},  // Y
  {1,0,0,0,0,0,1,0,1,1,0,0,0,0,1,1}};  // Z

Sts::Sts(){
  for(int i=2; i<17; i++){
    pinMode(i, OUTPUT);
  }
}

void Sts::displayCap(int _charNum)
{
  for(int i=0; i<15; i++) {
    digitalWrite((i+2), charactersCap[_charNum][i]);
  }
}
#ifndef Sts_h
#define Sts_h

#include "WProgram.h"

class Sts
{
  public:
    Sts();
    int _charNum;
    void displayCap(int _charNum);
    byte charactersCap[26][16];
  private:
};

#endif

And the basic example:

#include <Sts.h>

void setup(){
}

void loop() {
for(int i=0; i<26; i++) {
Sts.displayCap(i);
delay(500);
}
}

But I still get this error: In function ‘void loop()’:
error: expected unqualified-id before ‘.’ token

So I think I’m implementing something wrong…

Don’t you have to construct an object?

Does this work:

#include <Sts.h>

Sts testSts();
void setup(){
}

void loop() {
 for(int i=0; i<26; i++) {
   testSts.displayCap(i);
   delay(500);
 }
}

Yes I have been trying with that type of code too...but always get this result:

In function 'void loop()': error: request for member 'displayCap' in 'testSts', which is of non-class type 'Sts ()()

try

Sts testSts;

instead of

Sts testSts();

Yes that compiles! Thank you; know onto completing it in the same fashion. So hopefully nothing else can go wrong [touch wood].

Cheers for the help, /me

Haha no worries!

I was just working on making modifications to the RotaryEncoder library yesterday and ran into a few frustrating issues similar to yours.