hey friends...
i am doing a programmable timer switch and i am stuck at producing a routine that do the setting of time.
i have three buttons to use,initially the display will be showing current time and the SELECT button is used to toggle between setting minutes and setting hours states where at each of the states two zeros will be displayed and the user will be allowed to press the SET button to increment to where they want to set the digits.
the mode button is then used to save the settings.
I am asking for help in constructing this routine in c language.thanks in advance..
i have this following part that toggles between minutes and hours, i dont know how include the part that does the incrementing.
change prev_press to prev_SELECT_press to make it clear which button was pressed
use one function for both hours and minutes
replace your code with this..............of course, I just using pseudo code, not actual C code
Code:
if ( prev_select_press )
{ prev_select_press = 0; rc = Set_time(1);} // set_TIME hours
else
{ prev_select_press = 1; rc = Set_time(0);} // set_TIME minutes
if ( rc < 0 )
{ ..............} // mode changed, no change in time
else
{ ...................} // time changed, set the time variable, rc is the new time
// call function to re display time
return;
}
Code:
// now you need the function set_time
int Set_time(int hour_min_mode)
{
int new_time = 0;
while (1)
{
Display_change_time(hour_min_mode, new_time); // blink the time being changed with the new time
if ( Set_button_pressed() ) return new_time;
if ( Incr_button_pressed() ) { ++new_time; if ( new_time > 59 ) new_time = 0; }
if ( Select_button_pressed() ) return -1;
}
return 0;
}