i2ckeypad_perso.h 1.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#ifndef i2ckeypad_h_p
#define i2ckeypad_h_p

#include <inttypes.h>

// ne pas tenir compte des commentaires dans le paragraphe de #define suivant
#ifndef PINS_ROWS_COLS
#define PINS_ROWS_COLS
#define COL0  7  // P2 of PCF8574, col0 is usually pin 3 of 4x3 keypads
#define COL1  6  // P0 of PCF8574, col1 is usually pin 1 of 4x3 keypads
#define COL2  5  // P4 of PCF8574, col2 is usually pin 5 of 4x3 keypads
#define COL3  4  // sorry, don't have a 4x4 keypad to try it
#define ROW0  0  // P1 of PCF8574, row0 is usually pin 2 of 4x3 keypads
#define ROW1  1  // P6 of PCF8574, row1 is usually pin 7 of 4x3 keypads
#define ROW2  2  // P5 of PCF8574, row2 is usually pin 6 of 4x3 keypads
#define ROW3  3  // P3 of PCF8574, row3 is usually pin 4 of 4x3 keypads

#endif

class i2ckeypad {
public:
  i2ckeypad(int addr);
  i2ckeypad(int addr, int NbRows, int NbCols);
 // i2ckeypad(int addr, int NbRows, int NbCols, char**);
  char get_key();
  void init();
  
private:
  void pcf8574_write(int, int);
  int pcf8574_byte_read(int);
};

#endif