void enter_graphic_menu(uint8_t menu_no, uint8_t submenu_no) { char s[20]; LcdFillLine(1); slide_down(); // animacja LcdClear(); if(menu_no==0 && submenu_no==2) // Menu 1.2 { LcdRectangle(0, 0, 83, 47,TRANSPARENT); // ramka rez=enter_integer(rez,-10,100,2,3, "WART." , "s"); // funkcja obslugi danej pozycji menu } LcdRectangle(0, 0, 83, 47,TRANSPARENT); // przykladowy kod po powrocie z funkcji obslugi menu LcdClearArea(3,2,13); LcdGotoXY(2,3); sprintf(s,"MENU %1u.%1u:%d",menu_no + 1, submenu_no, rez); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)s); delay_ms(1000); LcdFillLine(1); // powrot do menu LcdGotoXY(2,1); slide_up(); // animacja LcdStr(FONT_1X,FONT_NEGATIVE,"MENU"); slide_down(); // animacja show_graphic_menu(menu_item,submenu_item); // pokazanie menu }
void exit_from_menu(void) { LcdClear(); LcdFillLine(1); LcdGotoXY(1,1); LcdStr(FONT_1X,FONT_NEGATIVE," LCD DEMO "); LcdFillLine(6); LcdGotoXY(1,6); LcdStr(FONT_1X,FONT_NEGATIVE," LCD DEMO ");}
void exit_from_graphic_menu() { uint8_t i; slide_up(); // animacja LcdClear(); // powrot do trybu normalnego LcdFillLine(1); LcdGotoXY(1,1); LcdStr(FONT_1X,FONT_NEGATIVE," LCD DEMO "); LcdFillLine(6); LcdGotoXY(1,6); LcdStr(FONT_1X,FONT_NEGATIVE," LCD DEMO "); }
void enter_menu(uint8_t menu_no, uint8_t submenu_no) { char s[20]; if(menu_no==0 && submenu_no==2) // Menu 1.2 rez=enter_integer(rez,-10,100,1,3, "WARTOSC" , "s"); LcdClearLine(3); LcdGotoXY(1,3); sprintf(s,"ENTER %1u.%1u:%d",menu_no + 1, submenu_no, rez); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)s); delay_ms(1000); LcdClearLine(3); }
void OutOneColumn(Graph_t* Array, int8_t ColumnNum) { int8_t OffsetMin,OffsetMax; uint32_t Column = 0; int8_t PrevMin; int8_t PrevMax; int8_t Prev; int8_t Next; Next = GraphCurrentPoint + 1; if ( Next >= GRAPH_SIZE) Next = 0; if( ColumnNum == Next) { Column = 0xFFFFFFFF; goto draw; } if ( ColumnNum%10 == 0) { Column = (1<<1)+(1<<3)+(1<<5)+(1<<7)+(1<<9)+(1<<11)+ (1<<13)+(1<<15)+(1<<17)+(1<<19)+(1<<21)+(1<<23)+(1<<25)+(1<<27)+(1<<29)+(1u<<31); } if ( ColumnNum%2 == 0) Column |= (1<<1)+(1<<11)+(1<<21)+(1u<<31); Prev = ColumnNum - 1; if (Prev < 0) Prev = GRAPH_SIZE - 1; if ( Array[ColumnNum].Min != 32000) { int8_t Delta; OffsetMin = Offsetmin(Array, ColumnNum); OffsetMax = Offsetmax(Array, ColumnNum); if ( Array[Prev].Min != 32000) { PrevMin = Offsetmin(Array, Prev); PrevMax = Offsetmax(Array, Prev); } else { PrevMin = OffsetMin; PrevMax = OffsetMax; } Delta = OffsetMax - PrevMax - 1; while (Delta > 0) { Column |= (1<<(OffsetMax-Delta)); Delta--; } Delta = PrevMin - OffsetMin - 1; while (Delta > 0) { Column |= (1<<(PrevMin-Delta)); Delta--; } Delta = PrevMax - OffsetMax - 1; while (Delta > 0) { Column |= (1<<(PrevMax-Delta)); Delta--; } Delta = OffsetMin - PrevMin - 1; while (Delta > 0) { Column |= (1<<(OffsetMin-Delta)); Delta--; } Column |= (1<<OffsetMin); Column |= (1<<OffsetMax); } draw: Column = __RBIT(Column); LcdGotoXY(ColumnNum, 5); LcdSend(Column>>24, LCD_DATA); LcdGotoXY(ColumnNum, 4); LcdSend(Column>>16, LCD_DATA); LcdGotoXY(ColumnNum, 3); LcdSend(Column>>8, LCD_DATA); LcdGotoXY(ColumnNum, 2); LcdSend(Column, LCD_DATA); }
void LcdChr ( uint32_t Ctrl, const char* Str ) { unsigned char ch; uint8_t Inverse; #if defined(BIG) #define INTERNAL_BIG_DOWN uint32_t Big = Ctrl; #endif Inverse = ((Ctrl & INVERSE) != 0); LcdGotoXY((Ctrl/X_POSITION & 0x0F)*6 + ((Ctrl/X_OFFSET)& 0x3F), (Ctrl/Y_POSITION) & 0x07); Ctrl = Ctrl & 0x7F; /* Only Len */ while ( Ctrl != 0 ) { const uint8_t* Start; if ( (ch = *Str) != 0) Str++; Ctrl--; if ( ch == 0 ) ch = ' '; if ( (ch < 0x20) || (ch > 0x7b) ) { // Convert to a printable character. ch = 92; } ch = ch - 32; Start = &FontLookup[ch*4+ch]; #if defined(BIG) if ( (Big & (BIG_UP|BIG_DOWN)) == 0 ) #endif { int i; for (i=0; i<=4; i++) { uint8_t E = Start[i]; if ( Inverse ) { E = ~E; } LcdSend( E, LCD_DATA ); } if ( !Inverse ) LcdSend( 0, LCD_DATA ); else LcdSend( 0xFF, LCD_DATA ); } #if defined(BIG) else { int i; for (i=0; i<=4; i++) { uint8_t Element = 0; uint8_t E = Start[i]; if ( Big & BIG_UP ) { if(E & 0x01) Element |= 0x03; if(E & 0x02) Element |= 0x0C; if(E & 0x04) Element |= 0x30; if(E & 0x08) Element |= 0xC0; } else { if(E & 0x10) Element |= 0x03; if(E & 0x20) Element |= 0x0C; if(E & 0x40) Element |= 0x30; if(E & 0x80) Element |= 0xC0; } if (Inverse) Element = ~Element; LcdSend( Element, LCD_DATA ); LcdSend( Element, LCD_DATA ); } /* For */ if ( !Inverse ) { LcdSend( 0, LCD_DATA ); LcdSend( 0, LCD_DATA ); } else { LcdSend( 0xFF, LCD_DATA ); LcdSend( 0xFF, LCD_DATA ); } } #endif /* BIG */ } }
void show_menu(uint8_t menu_no, uint8_t submenu_no) { LcdClearLine(2); LcdGotoXY(1,2); LcdStr(FONT_1X,FONT_POSITIVE, (unsigned char*)menu_strings[submenu_item][menu_item]); }
void show_graphic_menu(uint8_t menu_no, uint8_t submenu_no) { volatile uint8_t i,j; volatile uint8_t x_size, y_size; int a; i=1; y_size = sizeof(menu_strings)/sizeof(menu_strings[0]); // makzymalna ilosc podmenu x_size = sizeof(menu_strings[0])/sizeof(menu_strings[0][0]); // ilosc menu a=0; do // rzeczywista ilosc podmenu { // a=strlen(menu_strings[i][menu_no]); // }while(a>0 && i++ < (y_size - 1) ); // y_size=i; // LcdFillLine(1); LcdGotoXY(2,1); LcdStr(FONT_1X,FONT_NEGATIVE,"MENU"); for(i=2;i<7;i++) LcdClearLine(i); // wyczyszczenie sektora wyswietlajacego pozycje menu if(submenu_no==0) // jezeli menu glowne { i=0; if (menu_no<5) j=0; // jezeli ilosc pozycji przekracza wielkosc ekranu else j=menu_no-4; // to menu trzeba przewijac do { LcdClearLine(i+2); LcdGotoXY(2, i+2); if(j==menu_no) // podswietlanie wybranego menu LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)menu_strings[0][j]); // else LcdStr(FONT_1X,FONT_POSITIVE,(unsigned char*)menu_strings[0][j]); j++; }while((++i)!=x_size && i < 6); LcdRectangle(0, 0, 83, 47,TRANSPARENT); // rysowanie ramki LcdVerticalScrollBar(((menu_no*100)/(x_size-1)),79,8,83,47);// i suwaka pionowego } else if(submenu_no>0) // jezeli podmenu { i=0; if (submenu_no<5) j=1; // jezeli ilosc pozycji podmenu przekracza romiar ekranu else j=submenu_no-4; // to menu trzeba przewijac do { i++; LcdGotoXY(2,1); LcdStr(FONT_1X,FONT_NEGATIVE,"MENU>"); LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)menu_strings[0][menu_no]); LcdClearArea(i + 1,2,14); LcdGotoXY(2,i + 1); if(j==submenu_no) // podswietlanie wybranej pozycji menu LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)menu_strings[j][menu_no]); else LcdStr(FONT_1X,FONT_POSITIVE,(unsigned char*)menu_strings[j][menu_no]); j++; }while(j!=y_size && i < 6); LcdRectangle(0, 0, 83, 47,TRANSPARENT); // ramka LcdVerticalScrollBar((100 * (submenu_no-1)/(y_size-2)),79,8,83,47); // suwak } }
void graphic_menu() { Key_t key; uint8_t x_size, y_size, exit; volatile uint8_t i; menu_item=0; submenu_item=0; exit=0; y_size = sizeof(menu_strings)/sizeof(menu_strings[0]); // ilosc podmenu x_size = sizeof(menu_strings[0])/sizeof(menu_strings[0][0]); // ilosc menu LcdFillLine(1); LcdGotoXY(2,1); LcdStr(FONT_1X,FONT_NEGATIVE,"MENU"); slide_down(); // anmacja show_graphic_menu(menu_item, submenu_item); // pokazanie menu do { key=getkey(); if(key==KEY_DN) // menu(submenu) + { if(submenu_item==0) // jezelipoziom glowny menu { if((++menu_item)==x_size) menu_item=0; // menu + } else // jezeli poziom podmenu if((++submenu_item)==y_size) submenu_item=y_size - 1; // submenu max if((menu_strings[submenu_item][menu_item])=="") submenu_item--; // puste submenu show_graphic_menu(menu_item, submenu_item); } else if(key==KEY_UP) // menu(submenu) - { if(submenu_item==0) // jezeli poziom glowny menu { if((--menu_item)<0) menu_item=x_size-1; // menu - } else // jezeli poziom podmenu if((--submenu_item)==0) submenu_item=1; // submenu = 1 show_graphic_menu(menu_item, submenu_item); } else if(key==KEY_OK) // ENTER { if(submenu_item==0) // jezeli poziom glowny menu if(menu_strings[1][menu_item]!="") // jezeli menu poziada jakies podmenu { submenu_item++; // submenu + ( w zasadzie submenu = 1) slide_up(); // animacja slide_down(); // show_graphic_menu(menu_item, submenu_item); } else // jezeli menu nie posiada zadnych podmenu { slide_up(); // animacja enter_graphic_menu(menu_item, submenu_item); // wejscie w obsluge menu } else // jezeli poziom podmenu { slide_up(); // animacja enter_graphic_menu(menu_item, submenu_item); // wejscie w obsluge podmenu } } if(key==KEY_L) // ESC { if(submenu_item>0) // jezeli poziom podmenu submenu_item=0; // wyjscie do poziomu glownego menu else // jezeli poziom glowny menu exit=1; // wyjscie z obslugi menu if(exit==0) { slide_up(); // animacja slide_down(); // show_graphic_menu(menu_item, submenu_item); } } }while(exit==0); // koniec procedury exit_from_graphic_menu(); }
int16_t enter_integer(int16_t val, int16_t min, int16_t max, uint8_t x, uint8_t y, char *var_name, char *var_unit ) { int16_t temp_val; char s[10]; volatile Key_t key; char *format; if(min>0 && max>0) // wprowadzane beda wartosci dodatnie { if (max<10) format="%01d"; else if(max<100) format = "%02d"; else if(max<1000) format = "%03d"; else if(max<10000) format = "%04d"; else format = "%05d"; } else // moze sie zdazyc wartosc ujemna { if (max<10) format="%+02d"; else if(max<100) format = "%+03d"; else if(max<1000) format = "%+04d"; else if(max<10000) format = "%+05d"; else format = "%+06d"; } temp_val=val; LcdGotoXY(x,y); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name); LcdStr(FONT_1X, FONT_POSITIVE,": "); sprintf(s,format,temp_val); LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s); LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit); do { key=getkey(); switch(key) { case KEY_UP: if(temp_val++ >= max) temp_val=min; LcdGotoXY(x,y); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name); LcdStr(FONT_1X, FONT_POSITIVE,": "); sprintf(s,format,temp_val); LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s); LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit); break; case KEY_DN: if(--temp_val< min) temp_val=max; LcdGotoXY(x,y); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name); LcdStr(FONT_1X, FONT_POSITIVE,": "); sprintf(s,format,temp_val); LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s); LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit); break; } LcdGotoXY(x,y); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name); LcdStr(FONT_1X, FONT_POSITIVE,": "); sprintf(s,format,temp_val); /*if(TDelay>500) //miganie wartosci wprowadzanej LcdStr(FONT_1X,FONT_POSITIVE,(unsigned char*)s); // else*/ // LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s); // LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit); }while(key!=KEY_OK/* & key!=KEY_ESC*/); // if(key==KEY_ESC) // temp_val=0xff; // zwracanie przez funkcje wartosci 0xff oznacza ze nacisnieto ESC LcdGotoXY(x,y); LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name); LcdStr(FONT_1X, FONT_POSITIVE,": "); sprintf(s,format,val); LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s); LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit); return(temp_val); }