disp_mode=mode[mode_counter];
}
break;
case 1: //year adjustment
disp_mode=3;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Year++;
if(CurrentTime.Year>99) CurrentTime.Year=0;
DS1302_SetTime(DS1302_YEAR,(CurrentTime.Year));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Year>0) CurrentTime.Year--;
if(CurrentTime.Year==0) CurrentTime.Year=99;
DS1302_SetTime(DS1302_YEAR,(CurrentTime.Year));
}
break;
case 2: //monthly adjustment
disp_mode=4;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Month++;
if(CurrentTime.Month>12) CurrentTime.Month=1;
DS1302_SetTime(DS1302_MONTH,(CurrentTime.Month));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Month>0) CurrentTime.Month--;
if(CurrentTime.Month==0) CurrentTime.Month=12;
DS1302_SetTime(DS1302_MONTH,(CurrentTime.Month));
}
break;
case 3: //Daily adjustment
disp_mode=5;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Day++;
if(CurrentTime.Day>31) CurrentTime.Day=1;
DS1302_SetTime(DS1302_DAY,(CurrentTime.Day));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Day>0) CurrentTime.Day--;
if(CurrentTime.Day==0) CurrentTime.Day=31;
DS1302_SetTime(DS1302_DAY,(CurrentTime.Day));
}
break;
case 4: //week adjustment
disp_mode=6;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Week++;
if(CurrentTime.Week>7) CurrentTime.Week=1;
DS1302_SetTime(DS1302_WEEK,(CurrentTime.Week));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Week>1) CurrentTime.Week--;
if(CurrentTime.Week==1) CurrentTime.Week=7;
DS1302_SetTime(DS1302_WEEK,(CurrentTime.Week));
}
break;
case 5: //Hour adjustment
disp_mode=2;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Hour++;
if(CurrentTime.Hour>23) CurrentTime.Hour=0;
DS1302_SetTime(DS1302_HOUR,(CurrentTime.Hour));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Hour>0) CurrentTime.Hour--;
if(CurrentTime.Hour==0) CurrentTime.Hour=23;
DS1302_SetTime(DS1302_HOUR,(CurrentTime.Hour));
}
break;
case 6: //Minute adjustment
disp_mode=2;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Minute++;
if(CurrentTime.Minute>59) CurrentTime.Minute=0;
DS1302_SetTime(DS1302_MINUTE,(CurrentTime.Minute));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Minute>0) CurrentTime.Minute--;
if(CurrentTime.Minute==0) CurrentTime.Minute=59;
DS1302_SetTime(DS1302_MINUTE,(CurrentTime.Minute));
}
break;
case 7: //seconds adjustment
disp_mode=2;
if(add_flag==1)
{
add_flag=0;
CurrentTime.Second++;
if(CurrentTime.Second>59) CurrentTime.Second=0;
DS1302_SetTime(DS1302_SECOND,(CurrentTime.Second));
}
if(dec_flag==1)
{
dec_flag=0;
if(CurrentTime.Second>0) CurrentTime.Second--;
if(CurrentTime.Second==0) CurrentTime.Second=59;
DS1302_SetTime(DS1302_SECOND,(CurrentTime.Second));
}
break;
default:
break;
}
}
Previous article:51 MCU NY3P035 voice broadcast source program
Next article:Single chip LCD12864 with font library can call display function can reverse display source program
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- I want to ask why this motor cannot start? The voltage from B+ to B- is normal, but after starting, the voltage from B+ to M- jumps and the motor vibrates.
- Summary of equivalent circuits of common electronic components
- Comparison of several MicroPython IDEs
- [RVB2601 Creative Application Development] @fxyc87 RVB2601-Snake Game
- AD7190 Issues
- Pingtouge Xuantie VirtualZone: Security extension based on RISC-V architecture
- SPI, I2C, UART, I2S, GPIO, SDIO, CAN, can you tell them apart?
- DSP 2812 SPI dual-machine communication implementation
- Why can't this reset circuit be used?
- DSP Implementation of Square Root Operation