相关连接: [匠人DIY旋转时钟 系列文章 (连载中…)]
//--------------------------------------------------------
// 项目:
// 模块:显示处理
// 说明:
// 设计:程序匠人(版权所有,引用者请保留原作者姓名)
//--------------------------------------------------------
/*
版本说明:
display.c 2008-2-10 15:36
*/
//--------------------------------------------------------
//--------------------------------------------------------
//插入文件包
//--------------------------------------------------------
#include "common.h"
//--------------------------------------------------------
//--------------------------------------------------------
//钟摆轨迹表
//--------------------------------------------------------
const tU08 ZB_TAB[]=
{ //轨迹 毫秒计数器值
75, //0 100
75, //2 98
75, //4 96
76, //6 94
77, //8 92
78, //10 90
79, //12 88
80, //14 86
82, //16 84
84, //18 82
85, //20 80
87, //22 78
89, //24 76
91, //26 74
93, //28 72
95, //30 70
96, //32 68
98, //34 66
100, //36 64
101, //38 62
102, //40 60
103, //42 58
104, //44 56
105, //46 54
105, //48 52
105 //50 50
};
//--------------------------------------------------------
//刷新显示缓冲区
//出口: DISP_QUEUE[] =待显示字符串队列
// H_LINE =时针定位(0~179)
// M_LINE =分针定位(0~179)
// S_LINE =秒针定位(0~179)
//--------------------------------------------------------
void new_display(void)
{
tU08 i,j ;
NEW_DISP_EN_FLAG = 0 ; //显示刷新使能标志=0(0=禁止,1=使能)
if ( MOTOR_ST_FLAG ) //电机状态标志=1?(0=关闭,1=开启)
{
//显示状态
if ( SET_EN_FLAG == 0 )
{
//根据显示状态判断
switch( DISP_MODE )
{
case 0: //显示状态0:模拟钟
//秒针定位
i = 2 * TIME_S ; //秒针定位="秒"*3
S_LINE = i + TIME_S ;
//时针定位
if ( TIME_H > 11 ) i = TIME_H -12 ; //"时"由24小时制转换为12小时制
else i = TIME_H ;
j = i * 16 - i ;
i = TIME_M / 4 ;
H_LINE = j + i ; //时针定位="时"*15+"分"/4
//分针定位
i = 2 * TIME_M ; //分针定位="分"*3
M_LINE = i + TIME_M ;
DISP_QUEUE_FLAG = 0; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 1: //显示状态1:数字钟
//计算显示数值内容
DISP_QUEUE[0] = TIME_H / 10; //时
DISP_QUEUE[1] = TIME_H % 10;
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[3] = TIME_M / 10; //分
DISP_QUEUE[4] = TIME_M % 10;
DISP_QUEUE[5] = 10; //":"
DISP_QUEUE[6] = TIME_S / 10; //秒
DISP_QUEUE[7] = TIME_S % 10;
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
//钟摆定位
i = TIME_MS / 2 ;
if ( i > 25 ) i = 50 - i ;
ZB_LINE = ZB_TAB ; //查表求钟摆中心位置
break;
case 2: //显示状态2:温度计
//计算显示数值内容
DISP_QUEUE[0] = 13; //空白
DISP_QUEUE[1] = 13; //空白
DISP_QUEUE[6] = 13; //空白
DISP_QUEUE[7] = 13; //空白
DISP_QUEUE[2] = 14; //t
DISP_QUEUE[5] = 11; //℃
if ( TEMP_ERR_FLAG || TEMP==0 || TEMP>=110 ) //温度故障?
{
DISP_QUEUE[3] = 15; //"-"
DISP_QUEUE[4] = 15; //"-"
}
else if ( TEMP>=10 ) //温度为正时?
{
i=TEMP-10;
DISP_QUEUE[3] = i / 10; //当前温度
DISP_QUEUE[4] = i % 10;
}
else //温度为负时?
{
i=10-TEMP;
DISP_QUEUE[3] = 15; //"-"
DISP_QUEUE[4] = i ; //当前温度
}
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 3: //显示状态3:闹钟
//计算显示数值内容
DISP_QUEUE[0] = TIMER_H / 10; //闹钟"时"(0~23)
DISP_QUEUE[1] = TIMER_H % 10;
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[3] = TIMER_M / 10; //闹钟"分"(0~59)
DISP_QUEUE[4] = TIMER_M % 10;
DISP_QUEUE[5] = 15; //"-"
DISP_QUEUE[6] = SP_M / 10; //闹铃时间设置值(0~99分)(说明:0=关闭闹钟)
DISP_QUEUE[7] = SP_M % 10;
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
//进度条定位
i = TIME_MS / 2 ;
ZB_LINE = 65 + i ; //查表求钟摆中心位置
break;
default:
break;
}
}
//设置状态
else
{
//根据设置状态判断
switch( SET_MODE )
{
case 0: //设置状态0:时钟"时"
//计算显示数值内容
if ( MS_1HZ_FLAG || (NO_KEY_JSQ<2) )
{
DISP_QUEUE[0] = TIME_H / 10; //时
DISP_QUEUE[1] = TIME_H % 10;
}
else
{
DISP_QUEUE[0] = 13; //空白
DISP_QUEUE[1] = 13; //空白
}
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[3] = TIME_M / 10; //分
DISP_QUEUE[4] = TIME_M % 10;
DISP_QUEUE[5] = 10; //":"
DISP_QUEUE[6] = TIME_S / 10; //秒
DISP_QUEUE[7] = TIME_S % 10;
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 1: //设置状态1:时钟"分"
//计算显示数值内容
DISP_QUEUE[0] = TIME_H / 10; //时
DISP_QUEUE[1] = TIME_H % 10;
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[5] = 10; //":"
if ( MS_1HZ_FLAG || (NO_KEY_JSQ<2) )
{
DISP_QUEUE[3] = TIME_M / 10; //分
DISP_QUEUE[4] = TIME_M % 10;
DISP_QUEUE[6] = TIME_S / 10; //秒
DISP_QUEUE[7] = TIME_S % 10;
}
else
{
DISP_QUEUE[3] = 13; //空白
DISP_QUEUE[4] = 13; //空白
DISP_QUEUE[6] = 13; //空白
DISP_QUEUE[7] = 13; //空白
}
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 2: //设置状态2:闹钟"时"
//计算显示数值内容
if ( MS_1HZ_FLAG || (NO_KEY_JSQ<2) )
{
DISP_QUEUE[0] = TIMER_H / 10; //闹钟"时"(0~23)
DISP_QUEUE[1] = TIMER_H % 10;
}
else
{
DISP_QUEUE[0] = 13; //空白
DISP_QUEUE[1] = 13; //空白
}
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[3] = TIMER_M / 10; //闹钟"分"(0~59)
DISP_QUEUE[4] = TIMER_M % 10;
DISP_QUEUE[5] = 15; //"-"
DISP_QUEUE[6] = SP_M / 10; //闹铃时间设置值(0~99分)(说明:0=关闭闹钟)
DISP_QUEUE[7] = SP_M % 10;
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 3: //设置状态3:闹钟"分"
//计算显示数值内容
DISP_QUEUE[0] = TIMER_H / 10; //闹钟"时"(0~23)
DISP_QUEUE[1] = TIMER_H % 10;
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[5] = 15; //"-"
if ( MS_1HZ_FLAG || (NO_KEY_JSQ<2) )
{
DISP_QUEUE[3] = TIMER_M / 10; //闹钟"分"(0~59)
DISP_QUEUE[4] = TIMER_M % 10;
}
else
{
DISP_QUEUE[3] = 13; //空白
DISP_QUEUE[4] = 13; //空白
}
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 4: //设置状态4:闹铃时间
//计算显示数值内容
DISP_QUEUE[0] = TIMER_H / 10; //闹钟"时"(0~23)
DISP_QUEUE[1] = TIMER_H % 10;
DISP_QUEUE[2] = 10; //":"
DISP_QUEUE[3] = TIMER_M / 10; //闹钟"分"(0~59)
DISP_QUEUE[4] = TIMER_M % 10;
DISP_QUEUE[5] = 15; //"-"
if ( MS_1HZ_FLAG || (NO_KEY_JSQ<2) )
{
DISP_QUEUE[6] = SP_M / 10; //闹铃时间设置值(0~99分)(说明:0=关闭闹钟)
DISP_QUEUE[7] = SP_M % 10;
}
else
{
DISP_QUEUE[6] = 13; //空白
DISP_QUEUE[7] = 13; //空白
}
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
case 5: //设置状态5:报时功能
//显示整点报时标志
if ( FUN_ZDBS_FLAG ) //整点报时标志=1?
{
DISP_QUEUE[0] = 12; //钟摆小球
DISP_QUEUE[1] = 12; //钟摆小球
DISP_QUEUE[2] = 12; //钟摆小球
DISP_QUEUE[3] = 12; //钟摆小球
DISP_QUEUE[4] = 12; //钟摆小球
DISP_QUEUE[5] = 12; //钟摆小球
DISP_QUEUE[6] = 12; //钟摆小球
DISP_QUEUE[7] = 12; //钟摆小球
}
else
{
DISP_QUEUE[0] = 15; //"-"
DISP_QUEUE[1] = 15; //"-"
DISP_QUEUE[2] = 15; //"-"
DISP_QUEUE[3] = 15; //"-"
DISP_QUEUE[4] = 15; //"-"
DISP_QUEUE[5] = 15; //"-"
DISP_QUEUE[6] = 15; //"-"
DISP_QUEUE[7] = 15; //"-"
}
DISP_QUEUE_FLAG = 1; //显缓区(字符串队列)开启标志(0=未开启,1=开启)
break;
default:
break;
}
}
}
}
//--------------------------------------------------------
//
// THE END
//
// 版权所有:程序匠人(引用者请保留原作者姓名)
//
//--------------------------------------------------------
文章评论(0条评论)
登录后参与讨论