#include "msp430F2619.h"
#include "LCD.h"
#include "stdio.h"
#include "PKT.h"
#include "UART.h"
#include "type.h"
#include "M25P80.h"
struct LCD g_menuLCD = {
0x00, 0x00, 0x00,\
0, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00,\
20, {0, 0, 0, 0, 0, 0}, 0, 0, 0x00, 0x00, 0x00, 0x00,\
{0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
{0, 0, 0, 0, 0, 0, 0, 0},\
{0, 0, 0, 0, 0, 0, 0, 0},\
0x00, 0x00 // cursor
};
struct Date_struct dateTimeBuf;
// LCD显示数据偏移地址
struct LCD_dataShowOffset dataShowOffset = {
{0x03, 0x04, 0x05},\
{0x03, 0x04, 0x05, 0x06, 0x07}
};
unsigned char lineAddr[4] = {0x80, 0x90, 0x88, 0x98};
// 数据显示全局变量
unsigned char g_num_tmp = 0x00;
unsigned char tmp_c_0 = 0x00; // 临时变量
unsigned char g_num_total = 0x00; // 总水位计数
unsigned char g_line_tmp = 0x00; // 数据显示行变量
unsigned char g_i_485 = 0x00; // 485设备总数
unsigned char g_i_485_WS = 0x00; // 伟思 显示数据当前计数值
unsigned char g_i_485_JE = 0x00; // 捷尔 显示数据当前计数值
unsigned char g_i_485_YLN = 0x00; // 亿立能 显示数据当前计数值
unsigned char g_i_485_OTT = 0x00; // OTT 显示数据当前计数值
unsigned char g_i_mA = 0x00; // 4-20mA 显示数据当前计数值
unsigned char g_tmp0_val, g_tmp1_val; // 基值设置
unsigned char g_debugModeFlag = 0; // 调试模式标志
// 人工置数变量
unsigned char g_setValFlag; // 人工置数标志位
long tmp_val[8]; // 人工置数数值
unsigned int tmp_i0;
#define NUM_RANGE_TIMING 8
unsigned char tmp_timing = 0x00;// 定时下标
unsigned char rangeOfTiming[NUM_RANGE_TIMING] = {2, 3, 4, 6, 8, 12, 24, 1};
unsigned char g_dayOfMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
unsigned char tmp_rainRes = 0x00;// 雨量计分辨率下标
unsigned char rainOfRes[4] = {1, 2, 5, 10}; // 雨量计分辨率
unsigned char tmp_sampIntervalOfRain = 0x00;// 雨量计采样间隔下标
unsigned char sampIntervalOfRain[4] = {1, 5, 10, 30}; // 雨量计采样间隔
unsigned char indexOfCursor[4] = {0x04, 0x01, 0x02, 0x03}; // 上下移下标
// test
unsigned char tmp_state = 0x00;
void glEnter(void)
{
// 液晶显示器插拔显示处理
P5OUT |= BIT0; //CS置高
glSendLCDcmd(0x30); //发送基本指令声明、8位数据位
glDelay(1);
glSendLCDcmd(0x03); //设定游标的移动方向
glDelay(1);
glSendLCDcmd(0x0c); //开显示、开游标,反白
glDelay(1);
glSendLCDcmd(0x06); //进入设定点控制字
glDelay(1);
P5OUT &= ~BIT0; //CS置低
// 初始化,打开显示屏
if(g_menuLCD.first == FIRST_0)
{
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_1, MENU_2, MENU_3, MENU_4); // 显示主菜单
glPointToLine(1);
g_menuLCD.first = 1;
g_menuLCD.second = 0;
g_menuLCD.third = 0;
}
// 参数设置
else if(g_menuLCD.first == FIRST_1) // 1 参数设置
{
switch( g_menuLCD.second )
{
case 0: glSecond_sub0(); break; // 1.0 密码
case 1: glSecond_sub0_1(); break;
case 2: glSecond_sub1(); break; // 1.1 站点类型
case 3: glSecond_sub2(); break; // 1.2 站点编码
case 4: glSecond_sub3(); break; // 1.3 时间校准
case 5: glSecond_sub4(); break; // 1.4 波特率
case 6: glSecond_sub5(); break; // 1.5 传感器数量
case 7: glSecond_sub6(); break; // 1.6 雨量计参数
case 8: glSecond_sub7(); break; // 1.7 水位计参数
case 9: glSecond_sub8(); break; // 1.8 水位计量程
case 10: glSecond_sub9(); break; // 1.9 水位基值
case 11: glSecond_sub10(); break; // 1.10 上电延时时间
case 12: glSecond_sub11(); break; // 1.11 定时报段制
case 13: glSecond_sub12(); break; // 1.12 清除历史数据
case 14: glSecond_sub13(); break; // 1.13 恢复出厂设置//复位设置
case 15: glSecond_sub14(); break; // 1.14 人工置数
default: glSecond_sub_ret(); break; // 1.15 返回上一级菜单
}
}
// 当前时间
else if(g_menuLCD.first == FIRST_2) // 2 当前时间
{
if(g_menuLCD.second == 0)
{
glSendLCDcmd(LCD_CLEAR);
glShowAll("","2013年01月01日"," 00 :00 :00","" );
glSetTime_realtime_mid(0x92, g_LCD_dateTime.YY);
glSetTime_realtime_mid(0x94, g_LCD_dateTime.MM);
glSetTime_realtime_mid(0x96, g_LCD_dateTime.DD);
glSetTime_realtime_mid(0x8a, g_LCD_dateTime.HH);
glSetTime_realtime_mid(0x8c, g_LCD_dateTime.mm);
glSetTime_realtime_mid(0x8e, g_LCD_dateTime.SS);
g_menuLCD.second++;
}
else
{
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_1, MENU_2, MENU_3, MENU_4);
glPointToLine(2);
g_menuLCD.second = 0;
}
}
// 当前数据显示
else if(g_menuLCD.first == FIRST_3) // 3 当前数据显示
{
if(g_menuLCD.second == 0)
{
glUp_FIRST3();
g_menuLCD.second++;
}
else if( (g_menuLCD.second == 1)||(g_menuLCD.second == 2) ) //返回一级菜单
{
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_1, MENU_2, MENU_3, MENU_4);
glPointToLine(3);
g_menuLCD.second = 0;
}
}
// 降水量
else if(g_menuLCD.first == FIRST_4) // 4 日降水量
{
if(g_menuLCD.second == 0) {
uint tmp_i;
glSendLCDcmd(LCD_CLEAR);
// 当前降水量显示(实际值)
glSendLCDcmd(0x80);
glSendLCDstring("当降水量 mm");
tmp_i = syspara_struct.rainTotal;
glSetNum(0x84, tmp_i/1000);
glSetNum(0x85, tmp_i%1000/10);
glSendLCDcmd(0x86);
glSendLCDdata('.');
glSendLCDdata((tmp_i%10) + 0x30);
// 日降水量显示(实际值)
glSendLCDcmd(0x90);
glSendLCDstring("日降水量 mm");
tmp_i = syspara_struct.rainTotal_last;
glSetNum(0x94, tmp_i/1000);
glSetNum(0x95, tmp_i%1000/10);
glSendLCDcmd(0x96);
glSendLCDdata('.');
glSendLCDdata((tmp_i%10) + 0x30);
// 累计降水量显示(实际值)
glSendLCDcmd(0x88);
glSendLCDstring("累降水量 mm");
tmp_i = syspara_struct.rainTotal_oneYear;
glSetNum(0x8c, tmp_i/1000);
glSetNum(0x8d, tmp_i%1000/10);
glSendLCDcmd(0x8e);
glSendLCDdata('.');
glSendLCDdata((tmp_i%10) + 0x30);
g_menuLCD.second++;
}
else {
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_1, MENU_2, MENU_3, MENU_4);
glPointToLine(4);
g_menuLCD.second = 0;
}
}
// 上报实时数据
else if(g_menuLCD.first == FIRST_5) // 5 上报实时数据
{
if (g_menuLCD.second == 0)
{
frm_struct.funCodeUp = FUNC_QueryRealtime;
glSendLCDcmd(LCD_CLEAR);
glShowAll("", "指令发送完成!", "", "");
g_menuLCD.second++;
}
else if (g_menuLCD.second == 1)
{
glUp_FIRST3();
g_menuLCD.second++;
}
else
{
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_5, MENU_6, MENU_7, MENU_8);
glPointToLine(1);
g_menuLCD.second = 0;
}
}
// 存储器状态
else if(g_menuLCD.first == FIRST_6) // 6 存储器状态
{
if(g_menuLCD.second == 0)
{
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_FLASH, "", "", "");
// 容量
glSetNum(0x86, (unsigned char)(99 - syspara_struct.flashAddr_start*100/0xfffff));
glPointToLine(1);
g_menuLCD.second++;
}
else
{
glSendLCDcmd(LCD_CLEAR);
glShowAll(MENU_5, MENU_6, MENU_7, MENU_8);
glPointToLine(2);
g_menuLCD.second = 0;
}
}
// 调试模式
else if(g_menuLCD.first == FIRST_7) // 7 调试模式
{
if (g_menuLCD.second == 0)
{
glSen