tml = DS18b20ReadByte(); //Read the temperature value, a total of 16 bits, read the low byte first
tmh = DS18b20ReadByte(); // read high byte again
temp = tmh;
temp <<= 8;
temp |= tml;
if(tmh>0x07)
{
temp=~temp+1;
temp=temp*6.25;
temp=temp+5;
temp=temp/10;
temp=temp+10000;
}
else
{
temp=temp*6.25;
temp=temp+5;
temp=temp/10;
}
return temp;
}
/***********************************************************************************************************
* Function name: xianshiwendu()
* Input parameters: void
* Output parameters: void
*
* Function: Convert temperature data
*
* Note: None
*
*
* Completion date: 2019.12.25
************************************************************************************************************/
void getFile()
{
wendu=DS18b20ReadTemp();
if(wendu<10000) xianshi5(28,wendu%1000/100,wendu%100/10+17,wendu%10,12);
if(wendu>10000) xianshi5(27,wendu%1000/100,wendu%100/10+17,wendu%10,12);
}
Menu program (main logic):
#include <STC8.H>
#include #include #include #include #include #include #include #include <18b20.H> extern uchar shijian[13]; extern uint ms1; // used for flashing timing extern uint ms2; //Used to long press the button to quickly increase the timing extern uint ms4; // used for loop display timing bit changan=0; //Long press flag uint n=0; //Calculate the leap year uint y=0; //Calculate the month bit runnian=1; //leap year flag uchar yue=0; //big month flag 1 big month 2 February 0 small month uchar tiaozheng[13]={0,0,0,0,0,0,0,0,0,0,0,0,0}; //Adjust the time data temporary storage array uchar cd=0; //Menu bit aj1,aj2,aj3,aj4; extern int nao_kaiguan,nao_shi,nao_fen,nao2_kaiguan,nao2_shi,nao2_fen,wendu_kaiguan; //eeprom data bit s; //Alarm 1, 2 switch flag extern int wendu; //temperature information /*********************************************************************************************************** * Function name: caidan() * Input parameters: void * Output parameters: void * * Function: Menu program * * Note: This program is the core of this work *Level 0 menu is used to display time, date and temperature normally; * Level 1 menu is used to flash all time (prompt whether to modify) *Level 2 menu is used to display the full flash of the date (prompt whether to modify it) *Level 3 menu is used to flash al (prompt whether to modify the alarm information) * Level 4 menu is used to flash temp (prompt whether to modify the temperature switch) * Level 5 menu reserved *10-level menu for flashing hour digits *Level 11 menu for flashing minute digits *12-level menu for flashing seconds *13-level menu is used to flash the year position *14-level menu is used to flash the moon position *15-level menu for flashing day position *16-level menu for flashing alarm 1 switch *17-level menu is used to flash the time position of the alarm clock *18-level menu for flashing alarm 1 minute position *19-level menu for flashing temperature switch *20-level menu for flashing alarm 1 and alarm 2 selection bits * Level 21 menu is used to turn on and off the flashing alarm 2 * Level 22 menu is used to flash the time position of alarm 2 * Level 23 menu is used to flash the second minute position of the alarm clock * * * Completion date: 2019.12.25 ************************************************************************************************************/ void caidan() { zhuanhuan(); //Get time information naozhong(); //Detect alarm clock if(cd==0)//0 level menu { if(ms4>0&&ms4<10000) xianshi(shijian[6],shijian[7],27,shijian[8],shijian[9],27,shijian[10],shijian[11]); if(ms4>10000&&ms4<10100) wendu=DS18b20ReadTemp(); if(ms4>10100&&ms4<15000) xianshi(2,0,shijian[0],shijian[1]+17,shijian[2],shijian[3]+17,shijian[4],shijian[5]); if(wendu_kaiguan==0&&ms4>15000) ms4=0; if(ms4>15200&&ms4<20000) xianshiwendu(); if(ms4>20000) ms4=0; if(anjian1==0&&aj1==0) { delay(5); if(anjian1==0) aj1=1; } if(anjian1==1&&aj1==1) aj1=0,cd=1,ms1=0; //Press and release button 1 to go to level 1 menu } if(cd==1) //1st level menu flashes all the time { if(ms1>0&&ms1<300) xianshi(shijian[6],shijian[7],27,shijian[8],shijian[9],27,shijian[10],shijian[11]); if(ms1>300&&ms1<600) xianshi(28,28,27,28,28,27,28,28); if(ms1>600) ms1=0; if(anjian1==0&&aj1==0)//Detect key 1 { delay(5); if(anjian1==0) aj1=1; } if(anjian1==1&&aj1==1) aj1=0,cd=2,ms1=0; //Press and release button 1 to go to level 2 menu if(anjian2==0&&aj2==0)//Detect key 2 { delay(5); if(anjian2==0) aj2=1; } if(anjian2==1&&aj2==1) { tiaozheng[0]=shijian[0]; tiaozheng[1]=shijian[1]; tiaozheng[2]=shijian[2]; tiaozheng[3]=shijian[3]; tiaozheng[4]=shijian[4]; tiaozheng[5]=shijian[5]; tiaozheng[6]=shijian[6]; tiaozheng[7]=shijian[7]; tiaozheng[8]=shijian[8]; tiaozheng[9]=shijian[9]; tiaozheng[10]=shijian[10]; tiaozheng[11]=shijian[11]; aj2=0; cd=10; ms1=0; //Press and release button 2 to go to level 10 menu } } if(cd==2) //Level 2 menu flashes all dates { if(ms1>0&&ms1<300) xianshi(2,0,shijian[0],shijian[1]+17,shijian[2],shijian[3]+17,shijian[4],shijian[5]); if(ms1>300&&ms1<600) xianshi(28,28,28,29,28,29,28,28); if(ms1>600) ms1=0; if(anjian1==0&&aj1==0)//Detect key 1 { delay(5); if(anjian1==0) aj1=1; } if(anjian1==1&&aj1==1) aj1=0,cd=3,ms1=0; //Press and release button 1 to go to level 3 menu if(anjian2==0&&aj2==0)//Detect key 2 { delay(5); if(anjian2==0) aj2=1; } if(anjian2==1&&aj2==1) { tiaozheng[0]=shijian[0]; tiaozheng[1]=shijian[1]; tiaozheng[2]=shijian[2]; tiaozheng[3]=shijian[3]; tiaozheng[4]=shijian[4]; tiaozheng[5]=shijian[5]; tiaozheng[6]=shijian[6]; tiaozheng[7]=shijian[7]; tiaozheng[8]=shijian[8]; tiaozheng[9]=shijian[9]; tiaozheng[10]=shijian[10]; tiaozheng[11]=shijian[11]; aj2=0; cd=13; ms1=0; //Press and release button 2 to go to level 13 menu } } if(cd==3) //Level 3 menu displays the alarm clock { if(ms1>0&&ms1<300) xianshi(27,27,27,30,31,27,27,27); if(ms1>300&&ms1<600) xianshi(27,27,27,28,28,27,27,27); if(ms1>600) ms1=0; if(anjian1==0&&aj1==0)//Detect key 1 { delay(5); if(anjian1==0) aj1=1; } if(anjian1==1&&aj1==1) aj1=0,cd=4,ms1=0; //Press and release button 1 to go to level 4 menu if(anjian2==0&&aj2==0)//Detect key 2 { delay(5); if(anjian2==0) aj2=1; } if(anjian2==1&&aj2==1) { aj2=0; cd=20; dunaozhong(); //Read alarm data ms1=0; //Press and release button 2 to go to level 20 menu } } if(cd==4) //Level 4 menu displays temp temperature { if(ms1>0&&ms1<300) xianshi(27,27,32,33,34,33,27,27); if(ms1>300&&ms1<600) xianshi(27,27,28,28,28,28,27,27); if(ms1>600) ms1=0; if(anjian1==0&&aj1==0)//Detect key 1 { delay(5); if(anjian1==0) aj1=1; } if(anjian1==1&&aj1==1) aj1=0,cd=0,ms1=0; //Press and release button 1 to go to level 0 menu if(anjian2==0&&aj2==0)//Detect key 2 { delay(5); if(anjian2==0) aj2=1; } if(anjian2==1&&aj2==1) { aj2=0; cd=19; wendu_kaiguan=IapRead(0x0800); ms1=0; //Press and release button 2 to go to level 19 menu
Previous article:Stepper Motor Control and Simulation Based on 51 Single Chip Microcomputer
Next article:51 MCU 12864 display electronic password lock source code
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- C language algorithm 19: Prime factorization
- EEWORLD University - The principle and use of oscilloscope
- F12 debugging, no need to worry about the essence watermark being blocked anymore
- Qorvo will meet you in Beijing
- Has anyone used the MS41909 lens driver chip for network cameras and surveillance cameras?
- 【BLE 5.3 wireless MCU CH582】5. Hardware I2C drive 0.96-inch OLED
- [Top Micro Smart Display Screen Review] 2.2 SGTools Graphics Editing Software: Keyboard, Curve, QR Code Application
- [Topmicro Intelligent Display Module Review] 8. How to download the Lua script for the smart display?
- 【Home Smart Dashboard】Use GUI Guider to design the interface
- "Money-saving" national standard will be issued, DRA can save 9 billion in patent fees by replacing Dolby