void task0(void)
{
typedef enum {
DISPLAY_TIME,
SET_WEEK_DAY,
SET_MONTH,
GO_BACK
} my_states;
//static uint8_t state;
static my_states state_var = DISPLAY_TIME;
int button_input;
switch (state_var) {
DISPLAY_TIME :
display_time();//display time
button_input = button_is_pressed();//read button
if (button_input==1)//if button pressed, state = b;
{
state_var = SET_WEEK_DAY;
}else //else
{
display_time();//read ds1307 into time structure
//read time struct and display on lcd
}
break; // break;
SET_WEEK_DAY: //set date
lcd_cmd(0x01);//clear lcd
lcd_cmd(0x0F);//view cursor
lcd_xy(0,0);//put in the position 0,0 to edit
_delay_ms(250);
lcd_string("Enter new day:");
lcd_xy(1,0);
lcd_string(weekday[ds1307_addr[3]]);//display day of the week
lcd_xy(1,0);//return the cursor to the front
button_input = button_is_pressed();//read button
if (button_input==2) //if button 2 pressed
{
lcd_string(weekday[ds1307_addr[3]+1]);//increase day of the week
}
state_var = SET_MONTH;
break;
SET_MONTH:
state_var =GO_BACK;
break;
GO_BACK:
state_var = DISPLAY_TIME;
break;
default:
break; //default
}//end of switch
task_timers[0] = 10; //every 100ms
reset_task(0);
}