void Write_e2() { Sector_Erase(0x2000); // 擦除单片机内部EEPROM的数据 EEPROM_Write(0x2000, 18); EEPROM_Write(0x2001, A_shi); EEPROM_Write(0x2002, A_fen); EEPROM_Write(0x2003, A_miao); EEPROM_Write(0x2004, B_shi); EEPROM_Write(0x2005, B_fen); EEPROM_Write(0x2006, B_miao); EEPROM_Write(0x2007, C_shi); EEPROM_Write(0x2008, C_fen); EEPROM_Write(0x2009, C_miao); EEPROM_Write(0x200a, D_shi); EEPROM_Write(0x200b, D_fen); EEPROM_Write(0x200c, D_miao); EEPROM_Write(0x200d, shui1); EEPROM_Write(0x200e, shui2); EEPROM_Write(0x200f, shui3); EEPROM_Write(0x2011, shui4); } void Set_Positi() { switch(menu) { case 0: LcdWriteCommand(0x0c, 1); break; case 1: LocateXY(1,1); LcdWriteCommand(0x0f, 1); break; case 2: LocateXY(4,1); LcdWriteCommand(0x0f, 1); break; case 3: LocateXY(7,1); LcdWriteCommand(0x0f, 1); break; case 4: LocateXY(10,1); LcdWriteCommand(0x0f, 1); break; case 5: LocateXY(13,1); LcdWriteCommand(0x0f, 1); break; case 6: LocateXY(2,1); LcdWriteCommand(0x0f, 1); break; case 7: LocateXY(5,1); LcdWriteCommand(0x0f, 1); break; case 8: LocateXY(8,1); LcdWriteCommand(0x0f, 1); break; case 9: LocateXY(15,1); LcdWriteCommand(0x0f, 1); break; case 10: LocateXY(2,1); LcdWriteCommand(0x0f, 1); break; case 11: LocateXY(5,1); LcdWriteCommand(0x0f, 1); break; case 12: LocateXY(8,1); LcdWriteCommand(0x0f, 1); break; case 13: LocateXY(15,1); LcdWriteCommand(0x0f, 1); break; case 14: LocateXY(2,1); LcdWriteCommand(0x0f, 1); break; case 15: LocateXY(5,1); LcdWriteCommand(0x0f, 1); break; case 16: LocateXY(8,1); LcdWriteCommand(0x0f, 1); break; case 17: LocateXY(15,1); LcdWriteCommand(0x0f, 1); break; case 18: LocateXY(2,1); LcdWriteCommand(0x0f, 1); break; case 19: LocateXY(5,1); LcdWriteCommand(0x0f, 1); break; case 20: LocateXY(8,1); LcdWriteCommand(0x0f, 1); break; case 21: LocateXY(15,1); LcdWriteCommand(0x0f, 1); break; case 22: LocateXY(8,0); LcdWriteCommand(0x0f, 1); break; } } 对这段代码进行逐条注释
时间: 2023-11-22 12:53:16 浏览: 139
```
void Write_e2() { // 写入EEPROM数据的函数
Sector_Erase(0x2000); // 擦除单片机内部EEPROM的数据
EEPROM_Write(0x2000, 18); // 写入数据长度为18
EEPROM_Write(0x2001, A_shi); // 写入A的小时
EEPROM_Write(0x2002, A_fen); // 写入A的分钟
EEPROM_Write(0x2003, A_miao); // 写入A的秒钟
EEPROM_Write(0x2004, B_shi); // 写入B的小时
EEPROM_Write(0x2005, B_fen); // 写入B的分钟
EEPROM_Write(0x2006, B_miao); // 写入B的秒钟
EEPROM_Write(0x2007, C_shi); // 写入C的小时
EEPROM_Write(0x2008, C_fen); // 写入C的分钟
EEPROM_Write(0x2009, C_miao); // 写入C的秒钟
EEPROM_Write(0x200a, D_shi); // 写入D的小时
EEPROM_Write(0x200b, D_fen); // 写入D的分钟
EEPROM_Write(0x200c, D_miao); // 写入D的秒钟
EEPROM_Write(0x200d, shui1); // 写入水泵1的状态
EEPROM_Write(0x200e, shui2); // 写入水泵2的状态
EEPROM_Write(0x200f, shui3); // 写入水泵3的状态
EEPROM_Write(0x2011, shui4); // 写入水泵4的状态
}
void Set_Positi() { // 设置LCD显示位置的函数
switch(menu) { // 根据菜单编号设置LCD显示位置
case 0: // 如果是菜单0,清屏
LcdWriteCommand(0x0c, 1);
break;
case 1: // 如果是菜单1,显示在第一行第一列
LocateXY(1,1);
LcdWriteCommand(0x0f, 1);
break;
case 2: // 如果是菜单2,显示在第一行第四列
LocateXY(4,1);
LcdWriteCommand(0x0f, 1);
break;
case 3: // 如果是菜单3,显示在第一行第七列
LocateXY(7,1);
LcdWriteCommand(0x0f, 1);
break;
case 4: // 如果是菜单4,显示在第一行第十列
LocateXY(10,1);
LcdWriteCommand(0x0f, 1);
break;
case 5: // 如果是菜单5,显示在第一行第十三列
LocateXY(13,1);
LcdWriteCommand(0x0f, 1);
break;
case 6: // 如果是菜单6,显示在第一行第二列
LocateXY(2,1);
LcdWriteCommand(0x0f, 1);
break;
case 7: // 如果是菜单7,显示在第一行第五列
LocateXY(5,1);
LcdWriteCommand(0x0f, 1);
break;
case 8: // 如果是菜单8,显示在第一行第八列
LocateXY(8,1);
LcdWriteCommand(0x0f, 1);
break;
case 9: // 如果是菜单9,显示在第一行第十五列
LocateXY(15,1);
LcdWriteCommand(0x0f, 1);
break;
case 10: // 如果是菜单10,显示在第一行第二列
LocateXY(2,1);
LcdWriteCommand(0x0f, 1);
break;
case 11: // 如果是菜单11,显示在第一行第五列
LocateXY(5,1);
LcdWriteCommand(0x0f, 1);
break;
case 12: // 如果是菜单12,显示在第一行第八列
LocateXY(8,1);
LcdWriteCommand(0x0f, 1);
break;
case 13: // 如果是菜单13,显示在第一行第十五列
LocateXY(15,1);
LcdWriteCommand(0x0f, 1);
break;
case 14: // 如果是菜单14,显示在第一行第二列
LocateXY(2,1);
LcdWriteCommand(0x0f, 1);
break;
case 15: // 如果是菜单15,显示在第一行第五列
LocateXY(5,1);
LcdWriteCommand(0x0f, 1);
break;
case 16: // 如果是菜单16,显示在第一行第八列
LocateXY(8,1);
LcdWriteCommand(0x0f, 1);
break;
case 17: // 如果是菜单17,显示在第一行第十五列
LocateXY(15,1);
LcdWriteCommand(0x0f, 1);
break;
case 18: // 如果是菜单18,显示在第一行第二列
LocateXY(2,1);
LcdWriteCommand(0x0f, 1);
break;
case 19: // 如果是菜单19,显示在第一行第五列
LocateXY(5,1);
LcdWriteCommand(0x0f, 1);
break;
case 20: // 如果是菜单20,显示在第一行第八列
LocateXY(8,1);
LcdWriteCommand(0x0f, 1);
break;
case 21: // 如果是菜单21,显示在第一行第十五列
LocateXY(15,1);
LcdWriteCommand(0x0f, 1);
break;
case 22: // 如果是菜单22,显示在第一行第八列第一行
LocateXY(8,0);
LcdWriteCommand(0x0f, 1);
break;
}
}
```
阅读全文