@@ -24,7 +24,7 @@ keyMap myBtn_map[]={
2424 {K_ESC,options->getCmdChar(escCmd)},
2525 {K_ENTER,options->getCmdChar(enterCmd)}
2626 };
27- PCF8574KeyIn<6> myButton(myBtn_map);
27+ PCF8574KeyIn<6> myButton(myBtn_map,Wire );
2828
2929***/
3030
@@ -48,21 +48,19 @@ PCF8574KeyIn<6> myButton(myBtn_map);
4848 #endif
4949 // emulate a stream keyboard, this is not using interrupts as a good driver should do
5050 // AND is not using a buffer either!
51- template <int N, int _dev=0x20 , int _sda=SDA, int _scl=SCL > // default pcf8574 address=0x20
51+ template <int N,int _dev=0x20 > // default pcf8574 address=0x20
5252 class PCF8574KeyIn :public menuIn {
5353 private:
54- bool modeEdit;
54+ bool modeEdit;
5555 public:
5656 keyMap* keys;
57+ TwoWire& dev;
5758 int lastkey;
5859 unsigned long pressMills=0 ;
59- PCF8574KeyIn<N, _dev, _sda, _scl> (keyMap k[]):keys(k),lastkey(-1 ) {}
60+ PCF8574KeyIn (keyMap k[],TwoWire& dev=Wire ):keys(k),dev(dev ),lastkey(-1 ) {}
6061 void setFieldMode (bool mode) override {
6162 modeEdit = mode;
6263 }
63- void begin () {
64- Wire.begin (_sda, _scl);
65- }
6664 int available (void ) {
6765 int ch=peek ();
6866 if (lastkey==-1 ) {
@@ -83,8 +81,8 @@ PCF8574KeyIn<6> myButton(myBtn_map);
8381 }
8482 int peek (void ) {
8583 // Serial<<"peek"<<endl;
86- Wire .requestFrom (_dev, 1 );
87- uint8_t val = Wire .read ();
84+ dev .requestFrom (_dev, 1 );
85+ uint8_t val = dev .read ();
8886 for (int n=0 ;n<N;n++) {
8987 int8_t pin = keys[n].pin ;
9088 int8_t code = keys[n].code ;
0 commit comments