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.
unsigned char WaitForInput(void){
unsigned char done = 0; //DONE Var will determine if done and hold key
while(!done){ //while done == 0
if (Button(&PORTA, MENU, 1, 0)){
Delay_ms(10);
done = MENU;
}
if (Button(&PORTA, UP, 1, 0)){
Delay_ms(10);
done = UP;
}
if (Button(&PORTA, DOWN, 1, 0)){
Delay_ms(10);
done = DOWN;
}
}
return done; //Return our done/key var
}
do {
switch(WaitForInput()){
case MENU:
Delay_ms(100);
MainMenu();
break;
}
read_temp();
} while (1);
for(tmp=0;tmp<5;tmp++){
ADCON0bits.GO = 1; //Start the conversion
while(ADCON0bits.DONE); //Wait until it’s done
result = ADRESH; //Load ADRESH into result
result <<= 8; //Shift over Result 8 bits to the left
result |= ADRESL; //OR in our LOW byte to finish off out INT
avg[tmp] = result;
[B] if(KeyPORT == MENU) MainMenu();[/B]
DelayMS(40);
}
result = 0;
for(tmp=0;tmp<5;tmp++){
result += avg[tmp];
}
result /= 5;
if(result==oldresult) goto tSame;
DegC = (result*5)/10;
DegC--;
DegF = DegC * 9;
DegF/=5;
DegF+=32;
//clear LCD temp buffer
[B] if(KeyPORT == MENU) MainMenu();[/B]
for(tmp=0;tmp<16;tmp++)
lcdtmp[tmp] = ' ';
if(MyView == 'F'){
lcdtmp[0] = DECtoASCII(DegF,'h');
lcdtmp[1] = DECtoASCII(DegF,'l');
lcdtmp[2] = 0xDF;
lcdtmp[3] = 'F';
lcdtmp[4] = ' ';
} else {
lcdtmp[0] = DECtoASCII(DegC,'h');
lcdtmp[1] = DECtoASCII(DegC,'l');
lcdtmp[2] = 0xDF;
lcdtmp[3] = 'C';
lcdtmp[4] = ' ';
}
[B] if(KeyPORT == MENU) MainMenu();[/B]
LCD_LINE(2);
LCD_STR((unsigned rom char*)"Temp: ");
LCD_STR2(lcdtmp);
DelayMS(DelayTime);
oldresult = result;