#define DEBUG #include //#include #ifdef DEBUG //#include #endif #include #include #include // concatenate multiple input streams (this allows adding a button to the encoder) //#include #include #include #include //keyboard driver and fake stream (for the encoder button) UTFT myGLCD(ITDB32S, 38, 39, 40, 41); //extern uint8_t SmallFont[]; extern uint8_t BigFont[]; //extern uint8_t SevenSegNumFont[]; menuUTFT gfx(myGLCD); //UTouch myTouch( 6, 5, 4, 3, 2); //menuUTouch menuTouch(myTouch, gfx); //define the pins to be used #define encA A9 #define encB A8 //this encoder has a button here #define encBtn A10 quadEncoder quadEncoder(encA, encB); //simple quad encoder driver quadEncoderStream enc(quadEncoder, 10); // simple quad encoder fake Stream //a keyboard with only one key :D, this is the encoder button keyMap encBtn_map[] = {{ -encBtn, menu::enterCode}}; //negative pin numbers means we have a pull-up, this is on when low keyLook<1> encButton(encBtn_map); //multiple inputs allow conjugation of the quadEncoder with a single key keyboard that is the quadEncoder button Stream* in2[] = {&enc, &encButton}; chainStream<2> xx(in2); ///////////////////////////////////////////////////////////////////////// // MENU FUNCTION // this functions will be wired to menu options // meaning they will be called on option click/select // or on field value change/update void nothing() {} void sayIt(prompt& p, menuOut& o, Stream &c) { myGLCD.setBackColor(0, 0, 0); myGLCD.clrScr(); myGLCD.setColor(0, 255, 0); myGLCD.print("Activated option:", 0, 0); myGLCD.print(p.text, 0, 16); o.drawn = 0; delay(1000); myGLCD.clrScr(); } void out(){ Serial.println("HHH"); } int aValue = 50; float fValue = 101.1,dValue=76,tValue=98; ///////////////////////////////////////////////////////////////////////// // MENU DEFINITION // here we define the menu structure and wire actions functions to it MENU(subMenu, "Sub-Menu", OP("Op1", nothing), OP("Op2", nothing), OP("Op3", nothing) ); /*MENU(menuSetup,"Menu config", FIELD(myGLCD.*/ MENU(mainMenu, "Sistema", FIELD(dValue, "TempDEf", " C", 75, 85, 1, 0.1, out), FIELD(tValue, "TempTNK", " C", 75, 99, 1, 0.1, out), OP("Option C", sayIt), OP("Option D", sayIt), OP("Option E", sayIt), OP("Option F", sayIt), FIELD(aValue, "Value", "%", 0, 100, 1, 0), FIELD(fValue, "Value", " Hz", 1, 100000, 100, 0.5), SUBMENU(subMenu) ); void setup() { Serial.begin(9600); myGLCD.InitLCD(); myGLCD.setBrightness(4); myGLCD.clrScr(); // myTouch.InitTouch(); // myTouch.setPrecision(PREC_MEDIUM); myGLCD.setFont(BigFont); myGLCD.setColor(0, 255, 0); myGLCD.setBackColor(0, 0, 0); gfx.init();//setup geometry after myGLCD initialized //restrict menu area, for scroll and boundary tests gfx.maxX = 50; gfx.maxY = 12; mainMenu.setPosition(20, 10); mainMenu.data[1]->enabled = false; gfx.bgColor = VGA_GRAY; pinMode(encBtn, INPUT); digitalWrite(encBtn, 1); quadEncoder.begin(); } void loop() { mainMenu.poll(gfx, xx); }