You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
315 lines
9.1 KiB
315 lines
9.1 KiB
void settime ()
|
|
{boolean ret=0;
|
|
byte cur=1;
|
|
DateTime now = rtc.now();
|
|
//*********************************
|
|
hour1 = now.hour();
|
|
minute1 = now.minute();
|
|
second1 = now.second();
|
|
month1 =now.month();
|
|
day1= now.day();
|
|
year1 =now.year();
|
|
|
|
if (hour1>23){hour1=8;}
|
|
if (minute1>59){minute1=0;}
|
|
if (month1>12){month1=1;}
|
|
if (day1>31){day1=1;}
|
|
if (year1>2099){year1=2010;}
|
|
//****************************************
|
|
|
|
|
|
do {
|
|
//irem();
|
|
// button();
|
|
delay (200);
|
|
DateTime now = rtc.now();
|
|
second1 = now.second();
|
|
|
|
u8g.firstPage();
|
|
do {
|
|
|
|
u8g.setColorIndex(1);
|
|
u8g.drawXBMP(0, 0, 128, 64, setmenu);
|
|
u8g.setFont(u8g_font_unifont);
|
|
u8g.setPrintPos(10, 28);
|
|
u8g.print(hour1/10,DEC);
|
|
u8g.print(hour1%10,DEC);
|
|
u8g.print(":");
|
|
u8g.print(minute1/10,DEC);
|
|
u8g.print(minute1%10,DEC);
|
|
u8g.print(":");
|
|
u8g.print(second1/10,DEC);
|
|
u8g.print(second1%10,DEC);
|
|
|
|
u8g.setPrintPos(8, 48);
|
|
u8g.print(day1/10,DEC);
|
|
u8g.print(day1%10,DEC);
|
|
u8g.print("/");
|
|
u8g.print(month1/10,DEC);
|
|
u8g.print(month1%10,DEC);
|
|
u8g.print("/");
|
|
u8g.print(year1,DEC);
|
|
|
|
if (cur==1){u8g.drawBox(10,30,16,1);}
|
|
if (cur==2){u8g.drawBox(34,30,16,1);}
|
|
if (cur==3){u8g.drawBox(8,50,16,1);}
|
|
if (cur==4){u8g.drawBox(32,50,16,1);}
|
|
if (cur==5){u8g.drawBox(56,50,32,1);}
|
|
if (cur==6){u8g.drawBox(58,30,16,1);}
|
|
|
|
|
|
} while( u8g.nextPage() );
|
|
//**********************PDY********************
|
|
if (irrecv.decode(&results))
|
|
{
|
|
irrecv.resume(); // Receive the next value
|
|
digitalWrite(13, HIGH);
|
|
if(results.value == 0xE908B15) //down
|
|
{ if(cur==1)
|
|
{ hour1=hour1-1;
|
|
if (hour1<0){hour1=23;}
|
|
}
|
|
if(cur==2)
|
|
{ minute1=minute1-1;
|
|
if (minute1<0){minute1=59;}
|
|
}
|
|
if(cur==3)
|
|
{ day1=day1-1;
|
|
if ((month1==1)||(month1==3)||(month1==5)||(month1==7)||(month1==8)||(month1==10)||(month1==12))
|
|
{if (day1<1){day1=31;}
|
|
}
|
|
if ((month1==4)||(month1==6)||(month1==9)||(month1==11))
|
|
{if (day1<1){day1=30;}
|
|
}
|
|
if (month1==2)
|
|
{if (day1<1){day1=29;}
|
|
}
|
|
}
|
|
if(cur==4)
|
|
{month1=month1-1;
|
|
if (month1<1){month1=12;}
|
|
}
|
|
if(cur==5)
|
|
{year1=year1-1;
|
|
if (year1<2010){year1=2099;}
|
|
}
|
|
if(cur==6)
|
|
{if (second1>35)
|
|
{if ( minute1==59)
|
|
{minute1=0;
|
|
hour1=hour1+1;
|
|
if (hour1>23){hour1=0;}
|
|
}
|
|
else
|
|
{ minute1=minute1+1;
|
|
}
|
|
}
|
|
second1=0;
|
|
rtc.adjust(DateTime(year1, month1, day1, hour1, minute1, second1));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(results.value == 0xE900B95) //up E900B95
|
|
{
|
|
if(cur==1)
|
|
{ hour1=hour1+1;
|
|
if (hour1>23){hour1=0;}
|
|
}
|
|
if(cur==2)
|
|
{ minute1=minute1+1;
|
|
if (minute1>59){minute1=0;}
|
|
}
|
|
if(cur==3)
|
|
{ day1=day1+1;
|
|
if ((month1==1)||(month1==3)||(month1==5)||(month1==7)||(month1==8)||(month1==10)||(month1==12))
|
|
{if (day1>31){day1=1;}
|
|
}
|
|
if ((month1==4)||(month1==6)||(month1==9)||(month1==11))
|
|
{if (day1>30){day1=1;}
|
|
}
|
|
if (month1==2)
|
|
{if (day1>29){day1=1;}
|
|
}
|
|
}
|
|
if(cur==4)
|
|
{month1=month1+1;
|
|
if (month1>12){month1=1;}
|
|
}
|
|
if(cur==5)
|
|
{year1=year1+1;
|
|
if (year1>2099){year1=2010;}
|
|
}
|
|
if(cur==6)
|
|
{if (second1>35)
|
|
{if ( minute1==59)
|
|
{minute1=0;
|
|
hour1=hour1+1;
|
|
if (hour1>23){hour1=0;}
|
|
}
|
|
else
|
|
{ minute1=minute1+1;
|
|
}
|
|
}
|
|
second1=0;
|
|
rtc.adjust(DateTime(year1, month1, day1, hour1, minute1, second1));
|
|
}
|
|
}
|
|
|
|
if(results.value == 0xE101A04) //enter E101A04
|
|
{rtc.adjust(DateTime(year1, month1, day1, hour1, minute1, second1));
|
|
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
|
|
settim=0;
|
|
ret=1;
|
|
} //выход с сохранением
|
|
if(results.value == 0xE106A74) //menu E106A74
|
|
{
|
|
settim=0;
|
|
ret=1;
|
|
} //выход без сохранения
|
|
|
|
|
|
if(results.value == 0xE904BD5) //right E904BD5
|
|
{
|
|
cur=cur+1;
|
|
if (cur>6){cur=1;}
|
|
}
|
|
if(results.value == 0xE90CB55) //left E90CB55
|
|
{
|
|
cur=cur-1;
|
|
if (cur<1){cur=6;}
|
|
}
|
|
|
|
|
|
|
|
delay (100);
|
|
irrecv.resume(); // Receive the next value
|
|
digitalWrite(13, LOW);
|
|
}//ir
|
|
//**********************PDY********************
|
|
|
|
but ();
|
|
//***************************BUT*****************************************
|
|
if((b == 5)|| (b == 15))//down
|
|
{ if(cur==1)
|
|
{ hour1=hour1-1;
|
|
if (hour1<0){hour1=23;}
|
|
}
|
|
if(cur==2)
|
|
{ minute1=minute1-1;
|
|
if (minute1<0){minute1=59;}
|
|
}
|
|
if(cur==3)
|
|
{ day1=day1-1;
|
|
if ((month1==1)||(month1==3)||(month1==5)||(month1==7)||(month1==8)||(month1==10)||(month1==12))
|
|
{if (day1<1){day1=31;}
|
|
}
|
|
if ((month1==4)||(month1==6)||(month1==9)||(month1==11))
|
|
{if (day1<1){day1=30;}
|
|
}
|
|
if (month1==2)
|
|
{if (day1<1){day1=29;}
|
|
}
|
|
}
|
|
if(cur==4)
|
|
{month1=month1-1;
|
|
if (month1<1){month1=12;}
|
|
}
|
|
if(cur==5)
|
|
{year1=year1-1;
|
|
if (year1<2010){year1=2099;}
|
|
}
|
|
if(cur==6)
|
|
{if (second1>35)
|
|
{if ( minute1==59)
|
|
{minute1=0;
|
|
hour1=hour1+1;
|
|
if (hour1>23){hour1=0;}
|
|
}
|
|
else
|
|
{ minute1=minute1+1;
|
|
}
|
|
}
|
|
second1=0;
|
|
rtc.adjust(DateTime(year1, month1, day1, hour1, minute1, second1));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if((b == 4)|| (b == 14)) //up E900B95
|
|
{
|
|
if(cur==1)
|
|
{ hour1=hour1+1;
|
|
if (hour1>23){hour1=0;}
|
|
}
|
|
if(cur==2)
|
|
{ minute1=minute1+1;
|
|
if (minute1>59){minute1=0;}
|
|
}
|
|
if(cur==3)
|
|
{ day1=day1+1;
|
|
if ((month1==1)||(month1==3)||(month1==5)||(month1==7)||(month1==8)||(month1==10)||(month1==12))
|
|
{if (day1>31){day1=1;}
|
|
}
|
|
if ((month1==4)||(month1==6)||(month1==9)||(month1==11))
|
|
{if (day1>30){day1=1;}
|
|
}
|
|
if (month1==2)
|
|
{if (day1>29){day1=1;}
|
|
}
|
|
}
|
|
if(cur==4)
|
|
{month1=month1+1;
|
|
if (month1>12){month1=1;}
|
|
}
|
|
if(cur==5)
|
|
{year1=year1+1;
|
|
if (year1>2099){year1=2010;}
|
|
}
|
|
if(cur==6)
|
|
{if (second1>35)
|
|
{if ( minute1==59)
|
|
{minute1=0;
|
|
hour1=hour1+1;
|
|
if (hour1>23){hour1=0;}
|
|
}
|
|
else
|
|
{ minute1=minute1+1;
|
|
}
|
|
}
|
|
second1=0;
|
|
rtc.adjust(DateTime(year1, month1, day1, hour1, minute1, second1));
|
|
}
|
|
}
|
|
|
|
if((b == 3)|| (b == 13)) //enter E101A04
|
|
{rtc.adjust(DateTime(year1, month1, day1, hour1, minute1, second1));
|
|
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
|
|
settim=0;
|
|
ret=1;
|
|
} //выход с сохранением
|
|
if((b == 1)|| (b == 11)) //menu E106A74
|
|
{
|
|
settim=0;
|
|
ret=1;
|
|
} //выход без сохранения
|
|
|
|
|
|
if((b == 6)|| (b == 16)) //right E904BD5
|
|
{
|
|
cur=cur+1;
|
|
if (cur>6){cur=1;}
|
|
}
|
|
if((b == 2)|| (b == 12)) //left E90CB55
|
|
{
|
|
cur=cur-1;
|
|
if (cur<1){cur=6;}
|
|
}
|
|
//***************************BUT*****************************************
|
|
}while (ret<1);
|
|
|
|
|
|
|
|
}
|
|
|