📄 main.c.bak
字号:
/*-----------------------------------------------------------------------------
* COMSYS P115 DEMO *
* Copyright (c) *
* 2003-03-06 by Justin Zhang *
* Beijing.China *
* sun_wizard@163.net *
-----------------------------------------------------------------------------*/
#include "Highbios.h"
#include "Menu.h"
#include "Link.h"
#include "GraphicsMenu.h"
char * title_SysMenu = "系统设置";
char * title_FsMenu = "文件系统";
char * title_InputMenu = "输入测试";
char * title_BatteryMenu = "电量记录";
const char * AboutThisProgram[] = {
"----------------",
"山东方锐智能科技",
"油井运行检查系统",
"版本2.00",
"2005-07-20",
"----------------",
};
const char * sysComItems[] = {
"1.串口",
"2.红外",
"3.时钟校准",
};
const char * sysMenuItems[] = {
"1.设置日期",
"2.设置时间",
"3.设置背光",
"4.设置按键铃声",
"5.电量显示",
"6.调节对比度",
};
const char * fsMenuItems[] = {
"1.新建文件",
"2.写文件",
"3.读文件",
"4.删除文件",
"5.格式化",
};
const char * batteryMenuItems[] = {
"1.开始统计",
"2.上传数据",
};
// System config menu
Menu sys_menu;
// File system menu
Menu fs_menu;
// Com menu demo
Menu com_menu;
// Battery ind
Menu battery_menu;
// Graphics menu demo
GraphicsMenu gmenu;
// Images binary
const unsigned char g_Bitmap1[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x70, 0x00, 0x00, 0x0e,
0x60, 0x00, 0x00, 0x06,
0x67, 0xff, 0xff, 0xe6,
0x67, 0xfe, 0x7f, 0xe6,
0x67, 0xe6, 0x67, 0xe6,
0x67, 0xe7, 0xe7, 0xe6,
0x67, 0x3f, 0xfc, 0xe6,
0x67, 0x3f, 0xfc, 0xe6,
0x61, 0xff, 0xff, 0x86,
0x61, 0xff, 0xff, 0x86,
0x67, 0x3f, 0xfc, 0xe6,
0x67, 0x3f, 0xfc, 0xe6,
0x67, 0xe7, 0xe7, 0xe6,
0x67, 0xe6, 0x67, 0xe6,
0x67, 0xfe, 0x7f, 0xe6,
0x67, 0xff, 0xff, 0xe6,
0x60, 0x00, 0x00, 0x06,
0x70, 0x00, 0x00, 0x0e,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x80, 0x00, 0x00, 0x01,
};
const unsigned char g_Bitmap2[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x64, 0x92, 0x49, 0x26,
0x7f, 0xff, 0xff, 0xfe,
0x64, 0x92, 0x49, 0x26,
0x64, 0x92, 0x49, 0x26,
0x7f, 0xc7, 0xff, 0xfe,
0x7f, 0xe0, 0xff, 0xfe,
0x7f, 0xe0, 0x7f, 0xfe,
0x7f, 0xe6, 0x3f, 0xfe,
0x7f, 0xe3, 0x1f, 0xfe,
0x7f, 0xf1, 0x8f, 0xfe,
0x7f, 0xf8, 0xc7, 0xfe,
0x7f, 0xfc, 0x63, 0xfe,
0x7f, 0xfe, 0x31, 0xfe,
0x7f, 0xff, 0x18, 0xfe,
0x7f, 0xff, 0x8c, 0x7e,
0x7f, 0xff, 0xc4, 0x7e,
0x7f, 0xff, 0xe0, 0xfe,
0x7f, 0xff, 0xf1, 0xfe,
0x7f, 0xff, 0xfb, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x80, 0x00, 0x00, 0x01,
};
const unsigned char g_Bitmap3[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x79, 0xff, 0xff, 0x9e,
0x70, 0xff, 0xff, 0x0e,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x66, 0x7f, 0xfe, 0x66,
0x70, 0xff, 0xff, 0x0e,
0x79, 0xff, 0xff, 0x9e,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x80, 0x00, 0x00, 0x01,
};
const unsigned char g_Bitmap4[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x7c, 0x00, 0x00, 0x3e,
0x78, 0x00, 0x00, 0x1e,
0x73, 0xff, 0xff, 0xce,
0x73, 0xff, 0xff, 0xce,
0x78, 0x00, 0x00, 0x1e,
0x7c, 0x00, 0x00, 0x3e,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xe6, 0x67, 0xfe,
0x7f, 0xce, 0x73, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0x9e, 0x79, 0xfe,
0x7f, 0x3e, 0x7c, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x7e, 0x7e, 0x7e, 0x7e,
0x7c, 0xfe, 0x7f, 0x3e,
0x7f, 0xff, 0xff, 0xfe,
0x79, 0xfe, 0x7f, 0x9e,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x80, 0x00, 0x00, 0x01,
};
const unsigned char g_Bitmap5[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xc0, 0x03, 0xfe,
0x7f, 0x80, 0x01, 0xfe,
0x7f, 0x9f, 0xf9, 0xfe,
0x7f, 0x9f, 0xe9, 0xfe,
0x7f, 0x9f, 0xc1, 0xfe,
0x7f, 0x9e, 0x89, 0xfe,
0x7f, 0x9e, 0x19, 0xfe,
0x7f, 0x9e, 0x39, 0xfe,
0x7f, 0x9e, 0x19, 0xfe,
0x7f, 0x9f, 0xf9, 0xfe,
0x7f, 0x9f, 0xf9, 0xfe,
0x7f, 0x9f, 0xf9, 0xfe,
0x7f, 0x9c, 0x39, 0xfe,
0x7f, 0x98, 0x19, 0xfe,
0x7f, 0x9b, 0xd9, 0xfe,
0x7f, 0x98, 0x19, 0xfe,
0x7f, 0x9c, 0x39, 0xfe,
0x7f, 0x9f, 0xf9, 0xfe,
0x7f, 0x80, 0x01, 0xfe,
0x7f, 0xc0, 0x03, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x80, 0x00, 0x00, 0x01,
};
const unsigned char g_Bitmap6[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x7f, 0xf8, 0xff, 0xfe,
0x7f, 0xe0, 0x7f, 0xfe,
0x7f, 0xc1, 0x3f, 0xfe,
0x7f, 0x19, 0x9f, 0xfe,
0x7e, 0x78, 0xc0, 0xfe,
0x7c, 0xf8, 0x60, 0xfe,
0x79, 0xf9, 0x3f, 0xfe,
0x79, 0xf9, 0x9f, 0xfe,
0x79, 0xf9, 0xc0, 0xfe,
0x79, 0xf8, 0xe0, 0xfe,
0x79, 0xf8, 0x7f, 0xfe,
0x79, 0xf9, 0x3f, 0xfe,
0x79, 0xf9, 0x9f, 0xfe,
0x79, 0xf9, 0xc0, 0xfe,
0x79, 0xe0, 0x60, 0xfe,
0x79, 0x86, 0x3f, 0xfe,
0x79, 0x1f, 0x9f, 0xfe,
0x78, 0x7f, 0xc0, 0xfe,
0x79, 0xff, 0xe0, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe,
0x80, 0x00, 0x00, 0x01,
};
const unsigned char g_Bitmap7[] = { // height = 24, width = 32
0x80, 0x00, 0x00, 0x01,
0x3f, 0xbf, 0xff, 0xfe,
0x5f, 0xdf, 0xff, 0xfe,
0x6f, 0xef, 0xff, 0xfe,
0x77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 0x01,
};
const GraphicsMenuItem ImageList[] = {
{ "读取数据", g_Bitmap3 },
{ "上传数据", g_Bitmap2 },
{ "系统设置", g_Bitmap7 },
{ "关于", g_Bitmap8 },
};
void systemConfig(int option)
{
bool done = false;
bool on;
clrscr();
DisplayOkCancel(MB_OK | MB_CANCEL);
switch (option) {
case 0: // back light
DisplayLine(0, "设置背光", ALIGN_CENTER, false);
DisplayMidLine(3, get_blight()?"* 开 关":" 开 * 关", ALIGN_CENTER, false);
while (!done) {
switch (get_key()) {
case vk_ESC:
done = true;
/*
clrscr();
DisplayLine(1, "设置取消", ALIGN_CENTER, true);
*/
return;
case vk_ENTER:
set_blight(on);
done = true;
clrscr();
DisplayLine(1, "设置完成", ALIGN_CENTER, true);
break;
case vk_UP:
on = !on;
DisplayMidLine(3, on?"* 开 关":" 开 * 关", ALIGN_CENTER, false);
break;
case vk_DOWN:
on = !on;
DisplayMidLine(3, on?"* 开 关":" 开 * 关", ALIGN_CENTER, false);
break;
}
}
break;
case 1: // keyboard beep
DisplayLine(0, "按键伴音", ALIGN_CENTER, false);
DisplayMidLine(3, get_beep()?"* 开 关":" 开 * 关", ALIGN_CENTER, false);
while (!done) {
switch (get_key()) {
case vk_ESC:
done = true;
/*
clrscr();
DisplayLine(1, "设置取消", ALIGN_CENTER, true);
*/
return;
case vk_ENTER:
set_beep(on);
done = true;
clrscr();
DisplayLine(1, "设置完成", ALIGN_CENTER, true);
break;
case vk_UP:
on = !on;
DisplayMidLine(3, on?"* 开 关":" 开 * 关", ALIGN_CENTER, false);
break;
case vk_DOWN:
on = !on;
DisplayMidLine(3, on?"* 开 关":" 开 * 关", ALIGN_CENTER, false);
break;
}
}
break;
}
get_key();
}
void showBattery()
{
BYTE power, ret;
int per = 0;
int i;
long current1 = 0, origin1 = -1000;
const int MAX_COUNT = 5;
struct TBattery {
BYTE battery_ret;
BYTE battery_power;
} battery_val_array[MAX_COUNT];
int index = 0;
bool no_battery = false;
clrscr();
ret = battery_handle(&power);
clrline(2);
switch (ret) {
case 0: // 正常情况
DisplayMidLine(1, "电量显示", ALIGN_CENTER, false);
per = 100 * power/ 5;
if (per > 100) per = 100;
ShowProgress(2, per);
break;
case 1: // 正在充电
DisplayMidLine(1, "正在充电", ALIGN_CENTER, false);
per = 100 * power/ 5;
if (per > 100) per = 100;
ShowProgress(2, per);
break;
case 2: // 没有电池
DisplayMidLine(1, "没有电池", ALIGN_CENTER, false);
ShowProgress(2, 0);
break;
}
ret = battery_handle(&power);
while (!inkey()) {
current1 = GetTickCount();
if (current1 > origin1 + 300) {
// 采集电量
origin1 = current1;
battery_val_array[index].battery_ret = battery_handle(&(battery_val_array[index].battery_power));
if (++index >= MAX_COUNT) {
for (i = 0; i < MAX_COUNT; i++) {
if (battery_val_array[i].battery_ret == 2) {
no_battery = true;
break;
}
}
if (i == MAX_COUNT)
no_battery = false;
// 显示最后一次采集的数据
if (!no_battery) {
power = battery_val_array[MAX_COUNT - 1].battery_power;
ret = battery_val_array[MAX_COUNT - 1].battery_ret;
clrline(2);
switch (ret) {
case 0: // 正常情况
DisplayMidLine(1, "电量显示", ALIGN_CENTER, false);
per = 100 * power/ 5;
if (per > 100) per = 100;
ShowProgress(2, per);
break;
case 1: // 正在充电
DisplayMidLine(1, "正在充电", ALIGN_CENTER, false);
per = 100 * power/ 5;
if (per > 100) per = 100;
ShowProgress(2, per);
break;
case 2: // 没有电池
DisplayMidLine(1, "没有电池", ALIGN_CENTER, false);
ShowProgress(2, 0);
break;
}
}
else {
DisplayMidLine(1, "没有电池", ALIGN_CENTER, false);
}
index = 0;
}
}
}
}
void adjustLcd()
{
BYTE origin = LcdGetVolume(), value = origin, percent;
clrscr();
DisplayMidTitle("对比度", NO_REVERSE_STYLE);
percent = (double)(LcdGetVolume() - MIN_LCD_VOLUME) / (double)(MAX_LCD_VOLUME - MIN_LCD_VOLUME) * 100;
ShowProgress(2, percent);
while (true) {
switch (get_key()) {
case vk_DOWN:
if (value > MIN_LCD_VOLUME) {
value--;
LcdSetVolume(value);
percent = (double)(LcdGetVolume() - MIN_LCD_VOLUME) / (double)(MAX_LCD_VOLUME - MIN_LCD_VOLUME) * 100;
clrline(2);
ShowProgress(2, percent);
}
break;
case vk_UP:
if (value < MAX_LCD_VOLUME) {
value++;
LcdSetVolume(value);
percent = (double)(LcdGetVolume() - MIN_LCD_VOLUME) / (double)(MAX_LCD_VOLUME - MIN_LCD_VOLUME) * 100;
ShowProgress(2, percent);
}
break;
case vk_ESC:
LcdSetVolume(origin);
return;
case vk_ENTER:
return;
}
}
}
// --------------------------------------------------------------------------
void onSelectMainMenu(int index)
{
char buffer[100], ch;
int len;
int i;
if (index < 0 || index >= sizeof(ImageList) / sizeof(GraphicsMenuItem)) return;
clrscr();
switch (index) {
case 0: // 读取数据
ShowMenu(&Com_menu);
break;
case 1: // 数据上传
ShowMenu(&battery_menu);
break;
case 2: // 机器设置
ShowMenu(&sys_menu);
break;
case 3: // 关于
DisplayLine(0, "关于", ALIGN_CENTER, false);
ShowMemo(AboutThisProgram, sizeof(AboutThisProgram) / sizeof(char *), ALIGN_CENTER);
break;
}
}
// Main menu OK handler
UINT onMainMenu_Ok(void * arg)
{
Menu * pMenu = (Menu *)arg;
if (pMenu) onSelectMainMenu(pMenu->Current);
return 0;
}
UINT onMainMenu_Cancel(void *arg)
{
GraphicsMenu * pMenu = (GraphicsMenu *)arg;
ShowComsysLogo("山东方锐");
DrawGraphicsMenu(pMenu);
}
UINT onMainMenu_OtherKey(void * arg)
{
GraphicsMenu * pMenu = (Menu *)arg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -