Errore nella creazione di una libreria

Ciao a tutti! mi sono appena iscritto a questo forum, spero di non sbagliare qualcosa :confused:
ho scopiazzato questo sketch per leggere i valori inviati da un nunchuck wii, con qualche modifica:

#include <Wire.h>

int info [6];
int n = 0;
int j_x, j_y, a_x, a_y, a_z, b_z = 1, b_c = 1;
 
void setup()
{
  Setup ();
}

void Setup ()
{
  Serial.begin (9600);
  Wire.begin ();
  Wire.beginTransmission (0x52);
  Wire.write (0x40);
  Wire.write (0x00);
  Wire.endTransmission ();
}

void Reset()
{
  Wire.beginTransmission (0x52);
  Wire.write (0x00);
  Wire.endTransmission ();
}

void loop()
{

  Reset();
  GetData();
  delay(tempo);
}
 
void GetData()
{
  Wire.requestFrom (0x52, 6);
  while (Wire.available ()) {
    info[n] = Wire.read ();
    n++;
  }
  n = 0;
  Reset();
  j_x = info[0];
  j_y = info[1];
  a_x = info[2]; 
  a_y = info[3]; 
  a_z = info[4]; 
  b_z = 1;
  b_c = 1;
  if ( info[5]       & 1) b_z = 0;
  if ((info[5] >> 1) & 1) b_c = 0;
  if (b_c+b_z == 2) {b_c = 0;}
  else if (b_z == 1){b_c = 1;}
}

int read_x()
{
  GetData();
  return j_x;
}
int read_y()
{
  GetData();
  return j_y;
}
int read_ax()
{
  GetData();
  return a_x;
}
int read_ay()
{
  GetData();
  return a_y;
}
int read_az()
{
  GetData();
  return a_z;
}
int read_z()
{
  GetData();
  return b_z;
}
int read_c()
{
  GetData();
  return b_c;
}

funziona, ma è un po' lunghetto, e volevo creare una libreria chiamata "Nunchuck" per chiamarlo velocemente quando mi serve.
così sono andato sul sito di Arduino.cc alla voce 'libraries', ho scaricato la versione di prova e ho cominciato a scriverci il codice.
questi sono i due file

// include core Wiring API
#include <Arduino.h>
#include <Wire.h>

// include this library's description file
#include "Teest.h"

// include description files for other libraries used (if any)
#include "HardwareSerial.h"


    int info [6];
    int n = 0;
    int tempo = 10;
    int j_x, j_y, a_x, a_y, a_z, b_z = 1, b_c = 1;
// Constructor /////////////////////////////////////////////////////////////////
// Function that handles the creation and setup of instances

Teest::Teest(int givenValue)
{
  Serial.begin (9600);
  Wire.begin ();
  Wire.beginTransmission (0x52);
  Wire.write (0x40);
  Wire.write (0x00);
  Wire.endTransmission ();
}

// Public Methods //////////////////////////////////////////////////////////////
// Functions available in Wiring sketches, this library, and other libraries
int Teest::read_x()
{
  GetData();
  return j_x;
}
int Teest::read_y()
{
  GetData();
  return j_y;
}
int Teest::read_ax()
{
  GetData();
  return a_x;
}
int Teest::read_ay()
{
  GetData();
  return a_y;
}
int Teest::read_az()
{
  GetData();
  return a_z;
}
int Teest::read_z()
{
  GetData();
  return b_z;
}
int Teest::read_c()
{
  GetData();
  return b_c;
}

// Private Methods /////////////////////////////////////////////////////////////
// Functions only available to other functions in this library

void Teest::Reset()
{
  Wire.beginTransmission (0x52);
  Wire.write (0x00);
  Wire.endTransmission ();
}

void Teest::GetData()
{
  Wire.requestFrom (0x52, 6);
  while (Wire.available ())
  {
    info[n] = Wire.read ();
    n++;
  }
  n = 0;
  Reset();
  j_x = info[0];
  j_y = info[1];
  a_x = info[2];
  a_y = info[3];
  a_z = info[4];
  b_z = 1;
  b_c = 1;
  if ( info[5]       & 1) b_z = 0;
  if ((info[5] >> 1) & 1) b_c = 0;
  if (b_c+b_z == 2) {b_c = 0;}
  else if (b_z == 1){b_c = 1;}
}
// ensure this library description is only included once
#ifndef Teest_h
#define Teest_h

// include types & constants of Wiring core API
#include <Arduino.h>

// library interface description
class Teest
{
  // user-accessible "public" interface
  public:
    Teest(int);
    int read_x (void);
    int read_y (void);
    int read_ax(void);
    int read_ay(void);
    int read_az(void);
    int read_c (void);
    int read_z (void);

  // library-accessible "private" interface
  private:
    int info [6];
    int n = 0;
    int tempo = 10;
    int j_x, j_y, a_x, a_y, a_z, b_z = 1, b_c = 1;
    void Reset(void);
    void GetData(void);
};

#endif

se includo in uno sketch vuoto #include <Teest.h> non mi da errori, ma quando si tratta di chiamare una funzione si arrabbia e mi da questo errore:

C:\Users\Ale Ribaudo\Desktop\sketch_apr23a\sketch_apr23a.ino: In function 'void loop()':

sketch_apr23a:11:16: error: expected primary-expression before '.' token

   int p = Teest.read_c();

                ^

exit status 1
expected primary-expression before '.' token

questo è lo sketch:

#include <Teest.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.print("ciaooo \n");
}

void loop() {
  // put your main code here, to run repeatedly:
  int p = Teest.read_c();
}

perchè non va? cosa sto sbagliando? vi ringrazio in anticipo :smiley: ciaoo!

Buona sera,
essendo il tuo primo post nella sezione Italiana del forum, nel rispetto del nostro regolamento, ti chiedo cortesemente di presentarti QUI (spiegando bene quali conoscenze hai di elettronica e di programmazione ... possibilmente evitando di scrivere solo una riga di saluto) e di leggere con MOLTA attenzione il su citato REGOLAMENTO ... Grazie. :slight_smile:

Ciao, l'errore sta nel fatto che non puoi accedere direttamente ai metodi della libreria in quanto tu dentro di essa definisci una classe e quindi devi istanziare un oggetto di tale classe ed utilizzarne i metodi, hai fatto praticamente tutto, ti manca un piccolo passaggio, guarda questo tutorial che è fatto abbastanza bene ed è pure conciso e si adatta perfettamente al tuo caso

Il regolamento lo avevo letto ma la presentazione mi era sfuggita :smiley:
Grazie mille! adesso funziona! o meglio, riesco ad usare la libreria, perchè non fa quello che vorrei, ma questo è un altro discorso :smiley:
ancora Grazie!