Bueno tratando de ver lo que estabas haciendo implementé un LCD i2c con proteus.
Luego se me ocurre buscar algo y como siempre.. apareció un menú i2c para lcd
Aca esta el topic que lo referencia
muy intuitivo, vale la pena mas alla que ya estabas avanzando en tu idea.
Y acá lo que falta: Ya que el ejemplo es para botones simples y el LCD I2C
Pero solo debes reemplazar la rutina que scanea los botons de navegaciones cuidando los valores asignados que estan indicados mas abajo.
Resultado final una librería para i2c usando el rotary enconder.
How to use your input devices instead of standard digital buttons (addUsrNav)
if you want to use your own device to replace the standards buttons managed by MENWIZ and Buttons
libraries (and declared with navButtons functions) you need to write your own function and to declare it
to MENWIZ library using addUsrNav method.
The user defined function will replace the following internal one:
int menwiz::scanNavButtons(){
if(btx->BTU.check()==ON){
return MW_BTU;}
else if (btx->BTD.check()==ON){
return MW_BTD;}
else if (btx->BTL.check()==ON){
return MW_BTL;}
else if (btx->BTR.check()==ON){
return MW_BTR;}
else if (btx->BTE.check()==ON){
return MW_BTE;}
else if (btx->BTC.check()==ON){
return MW_BTC;}
else
return MW_BTNULL;
}
MENWIZ 0.6.0 Quick Tour 10
The user defined function must return one of the following integer values, defined in MENWIZ.h (allways
use the literals instead of the values, as values can be changed in new MENWIZ versions):
// BUTTON CODES
// ----------------------------------------------------------------------
#define MW_BTNULL 30 //NOBUTTON
#define MW_BTU 31 //UP
#define MW_BTD 32 //DOWN
#define MW_BTL 33 //RIGTH
#define MW_BTR 34 //LEFT
#define MW_BTE 35 //ESCAPE
#define MW_BTC 36 //CONFIRM
The returned integer code represent the last pushed button, if any, or MW_BTNULL if no button has been
pushed since last call.
The user defined function, as the internal scanNavButtons, is called once for every time the method
menwiz::draw is called.
The returned code will activate the behavior associated to the pushed button (or no behaviour if no button
has been pushed).
Resuming
in case of any custom device (as analog button or any other) you must:
- write your own function in the sketch (the name is up to the user)
- the function must return one of the 7 values above, depending on the pushed button (or the simulated
ones) - the function must be declared to MENWIZ with the method addUsrNav
How to save your MENWIZ variables to EEPROM (writeEeprom and
readEeprom)
WARNING: the user defined function simulating buttons have to return pushed button codes just once
(that is the function must “clear” the internal status) same as with standard digital buttons! otherwise
the library assumes multiple button pushes, one for each user function call....