📄 debug.c
字号:
break;
case '4':
put_string(0x90, "输入洋葱头价格:");
break;
case '5':
put_string(0x90, "输入油菜价格:");
break;
case '6':
put_string(0x90, "输入油麦菜价格:");
break;
case '7':
put_string(0x90, "输入圆茄子价格:");
break;
case '8':
put_string(0x90, "输入竹笋价格:");
break;
default:
break;
}
write_cmd(0x9a);
put_string(0x9a, "(元 公斤)");
put_string(0x9c, a); ////第4行第5列显示中文字符'/'
}
//显示己存信息
void info_screen()
{
char idata i;
write_cmd(0x01); //清除当前显示
put_string(0x80, " ");
put_string(0x80, "发送以下信息吗?");
// receive_SMS(); //receive SMS,judge the center_phone change
for (i = info_page_index * 3; (i < info_page_index *3+3) &amt; &amt; (i <
info_count); i++)
put_string(0x88 + 8 *(i - info_page_index * 3), info_string(i));
}
//返回第x条信息对应的字符串
char *info_string(char x)
{
char idata i, j = - 1, info[8], type[9]; //, price[6];
static char idata total[17];
//读取第x条蔬菜信息存到info[]数组
for (i = 0; i < strlen(sms_deliver.PDUData); i++)
{
if (sms_deliver.PDUData[i] == ',')
j++;
if (j == x)
break;
}
i++; //i为第x条信息的第一个字符的索引号
j = 0;
while (sms_deliver.PDUData[i] != ',' &amt; &amt; sms_deliver.PDUData[i] !=
'\0')
{
info[j] = sms_deliver.PDUData[i];
j++;
i++;
}
info[j] = '\0';
if (info[0] == '0')
switch (info[1])
{
case '1':
strcpy(type, "白萝卜:");
break;
case '2':
strcpy(type, "菠菜: ");
break;
case '3':
strcpy(type, "菜花: ");
break;
case '4':
strcpy(type, "长茄子:");
break;
case '5':
strcpy(type, "大白菜:");
break;
case '6':
strcpy(type, "大葱: ");
break;
case '7':
strcpy(type, "大蒜: ");
break;
case '8':
strcpy(type, "冬瓜: ");
break;
case '9':
strcpy(type, "豆角: ");
break;
default:
break;
}
else if (info[0] == '1')
switch (info[1])
{
case '0':
strcpy(type, "佛手: ");
break;
case '1':
strcpy(type, "荷兰豆:");
break;
case '2':
strcpy(type, "红尖椒:");
break;
case '3':
strcpy(type, "胡萝卜:");
break;
case '4':
strcpy(type, "黄豆牙:");
break;
case '5':
strcpy(type, "黄瓜: ");
break;
case '6':
strcpy(type, "茴香: ");
break;
case '7':
strcpy(type, "鸡腿菇:");
break;
case '8':
strcpy(type, "尖椒: ");
break;
case '9':
strcpy(type, "茭白: ");
break;
default:
break;
}
else if (info[0] == '2')
switch (info[1])
{
case '0':
strcpy(type, "芥菜: ");
break;
case '1':
strcpy(type, "金针菇:");
break;
case '2':
strcpy(type, "韭菜: ");
break;
case '3':
strcpy(type, "空心菜:");
break;
case '4':
strcpy(type, "苦瓜: ");
break;
case '5':
strcpy(type, "莲藕菜:");
break;
case '6':
strcpy(type, "绿豆牙:");
break;
case '7':
strcpy(type, "绿尖椒:");
break;
case '8':
strcpy(type, "毛豆: ");
break;
case '9':
strcpy(type, "木耳: ");
break;
default:
break;
}
else if (info[0] == '3')
switch (info[1])
{
case '0':
strcpy(type, "南瓜: ");
break;
case '1':
strcpy(type, "平菇: ");
break;
case '2':
strcpy(type, "茄子: ");
break;
case '3':
strcpy(type, "芹菜: ");
break;
case '4':
strcpy(type, "青椒: ");
break;
case '5':
strcpy(type, "山药: ");
break;
case '6':
strcpy(type, "生菜: ");
break;
case '7':
strcpy(type, "生姜: ");
break;
case '8':
strcpy(type, "丝瓜: ");
break;
case '9':
strcpy(type, "蒜苗: ");
break;
default:
break;
}
else if (info[0] == '4')
switch (info[1])
{
case '0':
strcpy(type, "蒜薹: ");
break;
case '1':
strcpy(type, "茼蒿: ");
break;
case '2':
strcpy(type, "土豆: ");
break;
case '3':
strcpy(type, "莴笋: ");
break;
case '4':
strcpy(type, "西红柿:");
break;
case '5':
strcpy(type, "西葫芦:");
break;
case '6':
strcpy(type, "西兰花:");
break;
case '7':
strcpy(type, "西洋芹:");
break;
case '8':
strcpy(type, "香菜: ");
break;
case '9':
strcpy(type, "香椿: ");
break;
default:
break;
}
else if (info[0] == '5')
switch (info[1])
{
case '0':
strcpy(type, "香菇: ");
break;
case '1':
strcpy(type, "小白菜:");
break;
case '2':
strcpy(type, "小葱: ");
break;
case '3':
strcpy(type, "洋白菜:");
break;
case '4':
strcpy(type, "洋葱头:");
break;
case '5':
strcpy(type, "油菜: ");
break;
case '6':
strcpy(type, "油麦菜:");
break;
case '7':
strcpy(type, "圆茄子:");
break;
case '8':
strcpy(type, "竹笋: ");
break;
default:
break;
}
strcpy(total, type);
total[8] = ' ';
//拷贝蔬菜价格到数组total[]中
for (j = 2; j < strlen(info); j++)
total[7+j] = info[j];
for (j += 7; j < 14; j++)
total[j] = ' ';
//空余的数组字节置空格
total[14] = 0xd4;
total[15] = 0xaa; //'元'的中文字库码为0xd4aa
total[16] = '\0';
return (total);
}
///////////////////////////////////////////////////////////////////////////////////////
/////////////按键相关函数//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
//数字键的响应函数
void key_num(char x)
{
char c = 0x30 + x; //数字x转换成ASC字符
if (display_type == 0)
//蔬菜品种界面
{
if (vege_type[0] == '\0' &amt; &amt; vege_type[1] == '\0')
//尚未设定蔬菜品种
vege_type[0] = c;
//把x变换成字符保存到蔬菜品种第0位
else if (vege_type[0] != '\0' &amt; &amt; vege_type[1] == '\0')
vege_type[1] = c;
//保存到第1位
put_string(0x9d, vege_type); // 在第4行第6列处显示蔬菜种类代号
return ;
}
if (display_type == 1)
{
if (vege_price[0] == '\0')
vege_price[0] = c;
//保存蔬菜价格
else if (vege_price[1] == '\0')
vege_price[1] = c;
else if (vege_price[1] == '.' &amt; &amt; vege_price[2] == '\0')
vege_price[2] = c;
else if ((vege_price[1] == '.' || vege_price[2] == '.') &amt; &amt;
vege_price[3] == '\0')
vege_price[3] = c;
else if (vege_price[2] == '.' &amt; &amt; vege_price[4] == '\0')
vege_price[4] = c;
vege_price[5] = '\0';
put_string(0x8a, vege_price); //显示输入的价格
}
}
// . 键的响应函数
void key_dot()
{
if (display_type == 1)
if (vege_price[0] != '\0')
if (vege_price[1] != '.' &amt; &amt; vege_price[2] != '.')
{
if (vege_price[1] == '\0')
vege_price[1] = '.';
else if (vege_price[2] == '\0')
vege_price[2] = '.';
put_string(0x8a, vege_price); //显示价格
}
return ;
}
//取消键的响应函数
void key_cancel()
{
uchar idata i;
char chu[3] =
{
0xb3, 0xfd, '\0'
}; //'除'字的中文字库为0xB3FD
if (display_type == 0)
{
if (vege_type[1] != '\0')
vege_type[1] = '\0';
else if (vege_type[0] != '\0')
vege_type[0] = '\0';
put_string(0x9d, " "); //清除当前的代号显示
put_string(0x9d, vege_type); //显示取消后的vege_type
}
else if (display_type == 1)
//价格界面
{
if (vege_price[4] != '\0')
vege_price[4] = '\0';
else if (vege_price[3] != '\0')
vege_price[3] = '\0';
else if (vege_price[2] != '\0')
vege_price[2] = '\0';
else if (vege_price[1] != '\0')
vege_price[1] = '\0';
else if (vege_price[0] != '\0')
vege_price[0] = '\0';
else if (vege_price[0] == '\0')
//如果没有输入价格
{
display_type = 0;
write_cmd(0x01); //清除当前界面
delay_160ms(); //如果没这句经常会乱屏
type_screen(); //返回到品种界面
return ;
}
put_string(0x8a, " "); //清除正在显示的价格
put_string(0x8a, vege_price); //在第3行第4列显示当前蔬菜价格
}
else if (display_type == 2)
//信息界面
{
//清除各全局变量
info_count = 0;
info_page_index = 0;
vege_type[0] = vege_type[1] = vege_type[2] = '\0';
vege_price[0] = vege_price[1] = vege_price[2] = vege_price[3] =
vege_price[4];
vege_price[5] = '\0';
for (i = 0; i < 140; i++)
sms_deliver.PDUData[i] = '\0';
display_type = 0;
write_cmd(0x01);
put_string(0x90, " ");
put_string(0x90, "所有信息已删 !");
put_string(0x96, chu);
delay_1s();
type_screen();
}
}
//确认键
void key_confirm()
{
char idata i;
if (display_type == 0)
//蔬菜品种界面
{
if ((vege_type[0] <= '5' &amt; &amt; vege_type[0] >= '0') &amt; &amt;
(vege_type[1] <= '9' &amt; &amt; vege_type[1] >= '0') &amt; &amt; !
(vege_type[0] == '5' &amt; &amt; vege_type[1] == '9') &amt; &amt; !
(vege_type[0] == '0' &amt; &amt; vege_type[1] == '0'))
//合理的类型(没有蔬菜类型59和00)
{
display_type = 1; //价格界面
price_screen(); //显示价格界面
}
else
{
put_string(0x9d, "代号错");
delay_160ms();
put_string(0x9d, " ");
vege_type[0] = '\0'; //蔬菜品种清除
vege_type[1] = '\0';
}
}
if (display_type == 1)
//价格界面
{
if (vege_price[0] != '\0')
{
if (sms_deliver.PDUData[0] == '\0')
{
sms_deliver.PDUData[0] = 'P';
sms_deliver.PDUData[1] = 'R';
}
if (sms_deliver.PDUData[0] == 'P')
sms_deliver.PDUData[strlen(sms_deliver.PDUData)] = ',';
//蔬菜信息间隔逗号
strcat(sms_deliver.PDUData, vege_type); //保存此条菜价信息
strcat(sms_deliver.PDUData, vege_price);
info_count++; //信息条数加1
write_cmd(0x01); //清除当前显示
put_string(0x90, " "); //第二行第一列
for (i = 0; i < 1; i++)
{
put_string(0x90, "该信息存储成功。");
//间隔160ms闪烁显示"该信息存储成功"
delay_500ms();
write_cmd(0x01);
delay_160ms();
}
vege_type[0] = vege_type[1] = vege_price[0] = vege_price[1] =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -