Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#define setupBtn 0x08
#define downBtn 0x02
#define upBtn 0x01
#define selectBtn 0x10
nice setup! i understand. I have mines like when you press menu it shows the menu then you can press up or down to go through the list. Then Enter/Select to select it then it will ask you seperate items. Mainly because i caught a headache doing it for the time.
When i set the time it shows the time and you can press up/down and set it while seeing the whole thing. Including the am/pm.
Its cool. Thanks for the info on how yours is. I know you must have caugt a headache when first making it. I might rewrite my whole code since i learned so much now. But ill keep my menu type. Like up/down to scroll instead of Menu a few times to pick. I like being able to go back and forth .
/***********************************
LCD / RTC stuff
************************************
Show Menu
************************************/
void showMenu(void){
char item, isEnter;
isEnter = 0;
item = 1; //Default to first menu item
while(1){
/******************************
Which item are we viewing
*******************************/
switch(item){
case 0:
item=3; //user went do down too far start from 3
break;
case 1:
sprintf(string2,"1.Set Time ",0);
break;
case 2:
sprintf(string2,"2.Set Date ",0);
break;
case 3:
sprintf(string2,"3.Set Alarm ",0);
break;
case 4:
item=1; //user went too up far start them from 1
break;
}
/*****************************
Determine Button Pressed
******************************/
switch(readBtn()){
case upBtn:
item++;
break;
case downBtn:
item--;
break;
case selectBtn:
isEnter = 1;
break;
}
/*****************************
Enter is pressed
******************************/
if(isEnter == 1){
if(item==1)
setTime('t');
if(item==2){
setDate();
}
if(item==3){
//Set Alarm
}
item=9; //a overkill number incase i want to add more functions.
}
/*************************
Show Menu to the user
**************************/
lcd_line(1);
sprintf(string," Settings ",0);
lcd_string(&string);
lcd_line(2);
lcd_string(&string2);
/**************************
Check if user is done.
***************************/
if(item==9)
break; //leave while(1) loop
}//end of while loop
}
unsigned char bcd2dec(unsigned char aBCD, char type)
{
char lowNyb = aBCD & 0x0F;
char highNyb = aBCD >> 4;
char MyDec = lowNyb;
char x;
switch(type)
case 0:
highNyb &= 0x0F;
break;
case 1:
highNyb &= 0x01;
break;
case 2:
highNyb &= 0x03;
break;
case 3:
highNyb &= 0x07;
break;
}
for(x=0;x<highNyb;x++){
MyDec += 10;
}
return MyDec;
}
/************************************
Convert BCD to Char(byte)
************************************/
unsigned char bcd2dec(unsigned char aBCD, char type)
{
char lowNyb = aBCD & 0x0F;
char highNyb = aBCD >> 4;
char MyDec = lowNyb;
char x;
switch(type){
case 0:
highNyb &= 0x0F;
break;
case 1:
highNyb &= 0x01;
break;
case 2:
highNyb &= 0x03;
break;
case 3:
highNyb &= 0x07;
break;
}
for(x=0;x<highNyb;x++){
MyDec += 10;
}
return MyDec;
}
Address Symbol Name Value Hex Decimal Binary Char
09A theHour "09"
09A [0] '0' 0x30 48 00110000 '0'
09B [1] '9' 0x39 57 00111001 '9'
09C theMin "01"
09C [0] '0' 0x30 48 00110000 '0'
09D [1] '1' 0x31 49 00110001 '1'
09E theSec "34"
09E [0] '3' 0x33 51 00110011 '3'
09F [1] '4' 0x34 52 00110100 '4'
--------------------------------------------------------------------------
After the:
decSec = bcd2dec(decSec,3);
decMin = bcd2dec(decMin,3);
decHour = bcd2dec(decHour,1);
0A0 decHour 0x09 0x09 9 00001001 '.'
0A1 decMin 0x01 0x01 1 00000001 '.'
0A2 decSec 0x22 0x22 34 00100010 '"'