AtomSoft
Well-Known Member
Try this as your usermenu stuff. The slow speed might be because of that 2 second delay you have in the menu using timer1:
Holding Home down will take you home.
EDIT: If you can read this try the code again. I edited it/
Code:
void userMenu(char pos){
lcd_clear();
lcd_goto_L1();
switch(pos){
case 0:
lcd_puts(" HEIGHT ");
break;
case 1:
lcd_puts(" RANGE ");
break;
case 2:
lcd_puts(" SURFACE AREA ");
break; //
case 3:
lcd_puts(" MEASURED ");
while(WaitForInput(1) != 2){ //Wait for user to press enter to leave loop
// wait for 2 seconds, uses TMR1 free running at 1Mhz
while(!TMR1IF) // wait for TMR1 overflow
TMR1IF = 0; // clear overflow flag
bres += 65536; // add 65536uS to bres value
if(bres >= 2000000) // if reached 2 seconds!
{
bres -= 2000000; // subtract 2 seconds, keep error
// read the ADC voltage RA1 (Sharp GP2 sensor)
GODONE=1; // initiate conversion on the channel 0
while(GODONE) continue; // Wait convertion done
calc_distance(); // convert ADC value to distance
lcd_goto_L2(); //Only change line 2
lcd_data(cm10 + '0');
lcd_data(cm + '0');
lcd_puts(" [cm] "); //comment this out if you want
}
}
lcd_goto_L1();
lcd_puts(" OK ");
lcd_goto_L2();
lcd_puts(" ");
break;
}
if(pos == 3) return;
lcd_goto_L2();
lcd_puts("Press Up/Down"); //home screen message (line 2)
}
EDIT: If you can read this try the code again. I edited it/
Last edited: