void menu_drawmain(void) { glcd_fillScreen(OFF); glcd_text57(0, 0, mainmenu[0].menutext, 1, ON); glcd_bar(0, 9, 127, 9, 2, ON); //div for(i=1;i<mm;i++) { glcd_text57(0, 14+((i-1)*9), mainmenu[i].menutext, 1, ON); menu_enter(14+((i-1)*9),ON); } glcd_update(); }
void glcd_eq(char *string, unsigned int x0, unsigned int y0, float howmany, unsigned int size, unsigned int fgcolor, unsigned int rectangle_color) { glcd_string(string,x0,y0,size,fgcolor); unsigned int bar_max = 10; // Not for Soldano unsigned int duzina = strlen(string)*size*FONT_SPACE; unsigned int nx0 = x0 + duzina; // Shift for the length of „string" //glcd_clr2(nx0,y0,10,size); glcd_bar(nx0, y0, howmany, bar_max, size, fgcolor, rectangle_color); unsigned int duzina2 = duzina + FONT_SPACE*size*bar_max+4*size; unsigned int nnx0 = x0 + duzina2; glcd_float(howmany,nnx0,y0,size,fgcolor); }
/************************************************************************ * * * Purpose: Draw main menu * * * * Proposito: Dibuja el menu principal * * * * Passed: None * * Argumento: Nada * * Returned: None * * Retorno: Nada * * Note: * * * * * ************************************************************************/ void menu_drawmain(void) { glcd_fillScreen(OFF); glcd_text57(0, 0, MENUTITLE, 1, ON); glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU1, 1, ON); menu_entrar(14,ON); glcd_text57(0, 23, MENU2, 1, ON); glcd_text57(100, 23, UniTemp, 1, ON); menu_entrar(23,ON); glcd_text57(0, 32, MENU3, 1, ON); glcd_text57(100, 32, UniPres, 1, ON); menu_entrar(32,ON); glcd_text57(0, 41, MENU4, 1, ON); glcd_text57(100, 41, UniVel, 1, ON); menu_entrar(41,ON); glcd_update(); }
/************************************************************************ * * * Purpose: Draw and handles the time config menu * * * * Proposito: Dibuja y maneja el menu de configuracion de la hora * * * * Passed: None * * Argumento: Nada * * Returned: None * * Retorno: Nada * * Note: * * * * * ************************************************************************/ void menu_timemenu(void) { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU1, 1, ON); glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_rect(5, 20, 25, 35, NO, ON); //DoW glcd_text57(9, 24, dow, 1, ON); glcd_rect(35, 20, 55, 35, NO, ON); //Dia glcd_text57(39, 24, dia, 1, ON); glcd_rect(65, 20, 85, 35, NO, ON); //Mes glcd_text57(69, 24, mes, 1, ON); glcd_rect(95, 20, 115, 35, NO, ON); //Año glcd_text57(99, 24, ao, 1, ON); glcd_rect(5, 45, 25, 60, NO, ON); //Hora glcd_text57(9, 49, hora, 1, ON); glcd_rect(35, 45, 55, 60, NO, ON); //Minuto glcd_text57(39, 49, min, 1, ON); glcd_rect(65, 45, 85, 60, NO, ON); // AM/PM. glcd_text57(69, 49, aop, 1, ON); glcd_update(); while (1) { readbuttons(); if (right==PRESSED) { control+=1; if (control>=8) { control = 1; } } if (left==PRESSED) { control-=1; if (control<=0) { control = 7; } } if (enter==PRESSED) { control = 10; } switch (control) { case 1: { glcd_rect(65, 45, 85, 60, YES, OFF); glcd_rect(65, 45, 85, 60, NO, ON); // AM/PM. glcd_text57(69, 49, aop, 1, ON); glcd_rect(5, 20, 25, 35, YES, ON); //DoW glcd_text57(9, 24, dow, 1, OFF); glcd_rect(35, 20, 55, 35, YES, OFF); glcd_rect(35, 20, 55, 35, NO, ON); //Dia glcd_text57(39, 24, dia, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { k++; if(k>=7) { k=0; } switch(k) { case 0: { dow[0] = "L"; break; } case 1: { dow[0] = "M"; break; } case 2: { dow[0] = "I"; break; } case 3: { dow[0] = "J"; break; } case 4: { dow[0] = "V"; break; } case 5: { dow[0] = "S"; break; } case 6: { dow[0] = "D"; break; } } glcd_rect(5, 20, 25, 35, YES, ON); //DoW glcd_text57(9, 24, dow, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { k--; if((k<0)||(k>10)) { k=6; } switch(k) { case 0: { dow[0] = "L"; break; } case 1: { dow[0] = "M"; break; } case 2: { dow[0] = "I"; break; } case 3: { dow[0] = "J"; break; } case 4: { dow[0] = "V"; break; } case 5: { dow[0] = "S"; break; } case 6: { dow[0] = "D"; break; } } glcd_rect(5, 20, 25, 35, YES, ON); //DoW glcd_text57(9, 24, dow, 1, OFF); glcd_update(); } break; } case 2: // DIA { glcd_rect(5, 20, 25, 35, YES, OFF); glcd_rect(5, 20, 25, 35, NO, ON); // DoW glcd_text57(9, 24, dow, 1, ON); glcd_rect(35, 20, 55, 35, YES, ON); //Dia glcd_text57(39, 24, dia, 1, OFF); glcd_rect(65, 20, 85, 35, YES, OFF); glcd_rect(65, 20, 85, 35, NO, ON); //Mes glcd_text57(69, 24, mes, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { int8 auxdia; auxdia = atoi(dia); auxdia -=1; if (auxdia==0) { if (atoi(mes)==2) { auxdia = 28; } else { auxdia = 31; } } itoa(auxdia,10,dia); glcd_rect(35, 20, 55, 35, YES, ON); //Dia glcd_text57(39, 24, dia, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { int8 auxdia; auxdia = atoi(dia); auxdia +=1; if (atoi(mes)==2) { if(auxdia==29) { auxdia = 1; } } if (auxdia==32) { auxdia = 1; } itoa(auxdia,10,dia); glcd_rect(35, 20, 55, 35, YES, ON); //Dia glcd_text57(39, 24, dia, 1, OFF); glcd_update(); } break; } case 3: // MES { glcd_rect(35, 20, 55, 35, YES, OFF); glcd_rect(35, 20, 55, 35, NO, ON); //Dia glcd_text57(39, 24, dia, 1, ON); glcd_rect(65, 20, 85, 35, YES, ON); //Mes glcd_text57(69, 24, mes, 1, OFF); glcd_rect(95, 20, 115, 35, YES, OFF); glcd_rect(95, 20, 115, 35, NO, ON); //Año glcd_text57(99, 24, ao, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { int8 auxmes; auxmes = atoi(mes); auxmes -=1; if (auxmes==0) { auxmes = 12; } itoa(auxmes,10,mes); glcd_rect(65, 20, 85, 35, YES, ON); //Mes glcd_text57(69, 24, mes, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { int8 auxmes; auxmes = atoi(mes); auxmes +=1; if (auxmes==13) { auxmes = 1; } itoa(auxmes,10,mes); glcd_rect(65, 20, 85, 35, YES, ON); //Mes glcd_text57(69, 24, mes, 1, OFF); glcd_update(); } break; } case 4: // AÑO { glcd_rect(65, 20, 85, 35, YES, OFF); glcd_rect(65, 20, 85, 35, NO, ON); //Mes glcd_text57(69, 24, mes, 1, ON); glcd_rect(95, 20, 115, 35, YES, ON); //Año glcd_text57(99, 24, ao, 1, OFF); glcd_rect(5, 45, 25, 60, YES, OFF); glcd_rect(5, 45, 25, 60, NO, ON); //Hora glcd_text57(9, 49, hora, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { int8 auxao; auxao = atoi(ao); auxao -=1; if (auxao==0) { auxao = 99; } itoa(auxao,10,ao); glcd_rect(95, 20, 115, 35, YES, ON); //Año glcd_text57(99, 24, ao, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { int8 auxao; auxao = atoi(ao); auxao +=1; if (auxao==99) { auxao = 0; } itoa(auxao,10,ao); glcd_rect(95, 20, 115, 35, YES, ON); //Año glcd_text57(99, 24, ao, 1, OFF); glcd_update(); } break; } case 5: // HORA { glcd_rect(95, 20, 115, 35, YES, OFF); glcd_rect(95, 20, 115, 35, NO, ON); //Año glcd_text57(99, 24, ao, 1, ON); glcd_rect(5, 45, 25, 60, YES, ON); //Hora glcd_text57(9, 49, hora, 1, OFF); glcd_rect(35, 45, 55, 60, YES, OFF); glcd_rect(35, 45, 55, 60, NO, ON); //Minuto glcd_text57(39, 49, min, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { int8 auxhora; auxhora = atoi(hora); auxhora -=1; if ((aop[0]==0x41)||(aop[0]==0x50)) { if (auxhora<=0) { auxhora = 12; } } else { if ((auxhora<0)||(auxhora>50)) { auxhora = 23; } } itoa(auxhora,10,hora); glcd_rect(5, 45, 25, 60, YES, ON); //Hora glcd_text57(9, 49, hora, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { int8 auxhora; auxhora = atoi(hora); auxhora +=1; if ((aop[0]==0x41)||(aop[0]==0x50)) { if (auxhora>12) { auxhora = 1; } } else { if (auxhora>23) { auxhora = 0; } } itoa(auxhora,10,hora); glcd_rect(5, 45, 25, 60, YES, ON); //Hora glcd_text57(9, 49, hora, 1, OFF); glcd_update(); } break; } case 6: // MINUTOS { glcd_rect(5, 45, 25, 60, YES, OFF); glcd_rect(5, 45, 25, 60, NO, ON); //Hora glcd_text57(9, 49, hora, 1, ON); glcd_rect(35, 45, 55, 60, YES, ON); //Minuto glcd_text57(39, 49, min, 1, OFF); glcd_rect(65, 45, 85, 60, YES, OFF); glcd_rect(65, 45, 85, 60, NO, ON); // AM/PM. glcd_text57(69, 49, aop, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { int8 auxmin; auxmin = atoi(min); if (auxmin==0) { auxmin = 60; } auxmin -=1; itoa(auxmin,10,min); glcd_rect(35, 45, 55, 60, YES, ON); //Minuto glcd_text57(39, 49, min, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { int8 auxmin; auxmin = atoi(min); auxmin +=1; if (auxmin>=60) { auxmin = 0; } itoa(auxmin,10,min); glcd_rect(35, 45, 55, 60, YES, ON); //Minuto glcd_text57(39, 49, min, 1, OFF); glcd_update(); } break; } case 7: // AM - PM { glcd_rect(35, 45, 55, 60, YES, OFF); glcd_rect(35, 45, 55, 60, NO, ON); //Minuto glcd_text57(39, 49, min, 1, ON); glcd_rect(65, 45, 85, 60, YES, ON); //AM PM glcd_text57(69, 49, aop, 1, OFF); glcd_rect(5, 20, 25, 35, YES, OFF); glcd_rect(5, 20, 25, 35, NO, ON); //DoW glcd_text57(9, 24, dow, 1, ON); glcd_update(); if ((up==!PRESSED)&&(down==PRESSED)) { if (aop[0]==0x41) { aop[0] = "P"; } else if (aop[0]==0x50) { aop[0] = "M"; } else if (aop[0]==0x4D) { aop[0] = "A"; } glcd_rect(65, 45, 85, 60, YES, ON); //Minuto glcd_text57(69, 49, aop, 1, OFF); glcd_update(); } if ((up==PRESSED)&&(down==!PRESSED)) { if (aop[0]==0x41) { aop[0] = "M"; } else if (aop[0]==0x50) { aop[0] = "A"; } else if (aop[0]==0x4D) { aop[0] = "P"; } glcd_rect(65, 45, 85, 60, YES, ON); //Minuto glcd_text57(69, 49, aop, 1, OFF); glcd_update(); } break; } case 10: // SET { glcd_fillscreen(OFF); glcd_text57(0, 0, MENU1, 1, ON); glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_rect(5, 20, 25, 35, YES, ON); //DoW glcd_text57(9, 24, dow, 1, OFF); glcd_rect(5, 20, 25, 35, NO, ON); //Dia glcd_text57(9, 24, dia, 1, ON); glcd_rect(35, 20, 55, 35, NO, ON); //Mes glcd_text57(39, 24, mes, 1, ON); glcd_rect(65, 20, 85, 35, NO, ON); //Año glcd_text57(69, 24, ao, 1, ON); glcd_rect(5, 45, 25, 60, NO, ON); //Hora glcd_text57(9, 49, hora, 1, ON); glcd_rect(35, 45, 55, 60, NO, ON); //Minuto glcd_text57(39, 49, min, 1, ON); glcd_rect(65, 45, 85, 60, NO, ON); // AM/PM. glcd_text57(69, 49, aop, 1, ON); glcd_update(); break; } } button = !PRESSED; if (control==10) { /*GRABAR EN RTC*/ ds1307_set_date_time(atoi(dia),atoi(mes),atoi(ao),(k+1),atoi(hora),atoi(min),0,aop[0]); return; } } }
/************************************************************************ * * * Purpose: Draw and handle the submenu * * * * Proposito: Dibuja y maneja cada submenu * * * * Passed: SubMenu position identifier * * Argumento: Identificador de posicion del submenu * * Returned: None * * Retorno: Nada * * Note: * * * * * ************************************************************************/ void menu_submenu(char menu) { switch (menu) { case 1: { menu_timemenu(); i=0; return; break; } case 2: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU2, 1, ON) ; glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU2ITEM1, 1, ON) ; glcd_text57(0, 23, MENU2ITEM2, 1, ON) ; glcd_update(); i = 0; break; } case 3: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU3, 1, ON) ; glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU3ITEM1, 1, ON) ; glcd_text57(0, 23, MENU3ITEM2, 1, ON) ; glcd_update(); i = 0; break; } case 4: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU4, 1, ON) ; glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU4ITEM1, 1, ON) ; glcd_text57(0, 23, MENU4ITEM2, 1, ON) ; glcd_text57(0, 32, MENU4ITEM3, 1, ON) ; glcd_update(); i = 0; break; } } while(1) { readbuttons(); if ((up==!PRESSED)&&(down==PRESSED)) { i+=1; menu_select(i,menu); } if ((up==PRESSED)&&(down==!PRESSED)) { i-=1; menu_select(i,menu); } if (left==PRESSED) { i = 0; button = !PRESSED; break; } if (enter==PRESSED) { switch (menu) { case 2: { switch (i) { case 1: { UniTemp = "C"; break; } case 2: { UniTemp = "F"; break; } } break; } case 3: { switch (i) { case 1: { UniPres = "mBa"; break; } case 2: { UniPres = "Pa"; break; } } break; } case 4: { switch (i) { case 1: { UniVel = "Nud"; break; } case 2: { UniVel = "km/h"; break; } case 3: { UniVel = "m/s"; break; } } break; } } i=0; button = !PRESSED; break; } button = !PRESSED; } button = !PRESSED; }
/************************************************************************ * * * Purpose: Draw the selected item * * * * Proposito: Dibuja el item seleccionado * * * * Passed: char item - Nº of item * * char menu - The menu it belongs * * Argumento: char item - Posicion del item * * char menu - El menu al que pertenece * * Returned: None * * Retorno: Nada * * Note: * * * * * ************************************************************************/ void menu_select(char item, char menu) { switch (menu) { case 0: { switch (item) { case 1: { menu_drawmain(); glcd_bar(0, 17, 127, 17, 9, ON); //selected glcd_text57(0, 14, MENU1, 1, OFF); menu_entrar(14,OFF); glcd_update(); break; } case 2: { menu_drawmain(); glcd_bar(0, 26, 127, 26, 9, ON); //selected glcd_text57(0, 23, MENU2, 1, OFF); glcd_text57(100, 23, UniTemp, 1, OFF); menu_entrar(23,OFF); glcd_update(); break; } case 3: { menu_drawmain(); glcd_bar(0, 35, 127, 35, 9, ON); //selected glcd_text57(0, 32, MENU3, 1, OFF); glcd_text57(100, 32, UniPres, 1, OFF); menu_entrar(32,OFF); glcd_update(); break; } case 4: { menu_drawmain(); glcd_bar(0, 44, 127, 44, 9, ON); //selected glcd_text57(0, 41, MENU4, 1, OFF); glcd_text57(100, 41, UniVel, 1, OFF); menu_entrar(41,OFF); glcd_update(); break; } } break; } case 1: { break; } case 2: { switch (item) { case 1: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU2, 1, ON) ; //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_bar(0, 17, 127, 17, 9, ON); //selected glcd_text57(0, 14, MENU2ITEM1, 1, OFF); glcd_text57(0, 23, MENU2ITEM2, 1, ON) ; glcd_update(); break; } case 2: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU2, 1, ON); //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU2ITEM1, 1, ON); glcd_bar(0, 26, 127, 26, 9, ON); //selected glcd_text57(0, 23, MENU2ITEM2, 1, OFF); glcd_update(); break; } } break; } case 3: { switch (item) { case 1: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU3, 1, ON) ; //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_bar(0, 17, 127, 17, 9, ON); //selected glcd_text57(0, 14, MENU3ITEM1, 1, OFF); glcd_text57(0, 23, MENU3ITEM2, 1, ON) ; glcd_update(); break; } case 2: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU3, 1, ON); //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU3ITEM1, 1, ON); glcd_bar(0, 26, 127, 26, 9, ON); //selected glcd_text57(0, 23, MENU3ITEM2, 1, OFF); glcd_update(); break; } } break; } case 4: { switch (item) { case 1: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU4, 1, ON) ; //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_bar(0, 17, 127, 17, 9, ON); //selected glcd_text57(0, 14, MENU4ITEM1, 1, OFF); glcd_text57(0, 23, MENU4ITEM2, 1, ON) ; glcd_text57(0, 32, MENU4ITEM3, 1, ON) ; glcd_update(); break; } case 2: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU4, 1, ON); //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU4ITEM1, 1, ON); glcd_bar(0, 26, 127, 26, 9, ON); //selected glcd_text57(0, 23, MENU4ITEM2, 1, OFF); glcd_text57(0, 32, MENU4ITEM3, 1, ON) ; glcd_update(); break; } case 3: { glcd_fillScreen(OFF); glcd_text57(0, 0, MENU4, 1, ON); //Titulo glcd_bar(0, 9, 127, 9, 2, ON); //div glcd_text57(0, 14, MENU4ITEM1, 1, ON); glcd_text57(0, 23, MENU4ITEM2, 1, ON); glcd_bar(0, 35, 127, 35, 9, ON); //selected glcd_text57(0, 32, MENU4ITEM3, 1, OFF) ; glcd_update(); break; } } break; } } }