资源简介

我的博客文章的源代码,包括UI,闹钟部分。其他请参考原子的EMWIN代码。

资源截图

代码片段和文件信息

#include “ALARM.h“

/*
存储闹铃组到后备寄存器
*/
void StoreAlarmsToBkp(const xAlarms_TypeDef* pAl)
{
    char i;
    RTC_WriteBackupRegister(RTC_BKP_DR2pAl->num);   
    RTC_WriteBackupRegister(RTC_BKP_DR3pAl->availableNum);
    
    for(i=0;inum;i++)
    {
        RTC_WriteBackupRegister(RTC_BKP_DR4+ipAl->alarm._alarmx[i] );
    }
}
/*
从后备寄存器加载到闹铃组
*/
void LoadAlarmsFromBkp(xAlarms_TypeDef* pAl)
{
    char i;
    if(RTC_ReadBackupRegister(RTC_BKP_DR0)==RTCBKP_KEYVALUE)       
    {
        pAl->num= RTC_ReadBackupRegister(RTC_BKP_DR2);
        if(pAl->num==0)return;
        
        pAl->availableNum= RTC_ReadBackupRegister(RTC_BKP_DR3);
        for(i=0;inum;i++)
        {
            pAl->alarm._alarmx[i] = RTC_ReadBackupRegister(RTC_BKP_DR4+i);
        }
    }
}
//根据Alarms给Listbox添加item
char AddListBoxItemAccordingToAlarms(LISTBOX_Handle hObjconst xAlarms_TypeDef* axs)
{
    char numi;
    unsigned char pBuffer[20];
    
    num=axs->num;
    if(num>ALARM_NUM_MAX) num=ALARM_NUM_MAX;
    for(i=0;i    {    
        unsigned char en = axs->alarm._alarm[i].en ;
        if( (en&0x01) == 0 )
        pBuffer[0]=‘!‘;
        else pBuffer[0]=‘ ‘;
        pBuffer[1]=‘ ‘;
        pBuffer[2]=axs->alarm._alarm[i].hour/10+‘0‘;
        pBuffer[3]=axs->alarm._alarm[i].hour%10+‘0‘;
        pBuffer[4]=‘:‘;
        pBuffer[5]=axs->alarm._alarm[i].minute/10+‘0‘;
        pBuffer[6]=axs->alarm._alarm[i].minute%10+‘0‘;
        pBuffer[7]=‘‘;
        pBuffer[8]=axs->alarm._alarm[i].duration/10+‘0‘;
        pBuffer[9]=axs->alarm._alarm[i].duration%10+‘0‘;
        pBuffer[10]=‘‘;
        switch( (en)>>4)
        {
            case 0:
                pBuffer[11]=‘S‘pBuffer[12]=‘i‘pBuffer[13]=‘n‘pBuffer[14]=‘g‘pBuffer[15]=‘l‘pBuffer[16]=‘e‘pBuffer[17]=0;
            break;
            case 1:
                pBuffer[11]=‘W‘pBuffer[12]=‘o‘pBuffer[13]=‘r‘pBuffer[14]=‘k‘pBuffer[15]=‘d‘pBuffer[16]=‘a‘pBuffer[17]=‘y‘pBuffer[18]=0;
            break;
            case 2:
                pBuffer[11]=‘E‘pBuffer[12]=‘v‘pBuffer[13]=‘e‘pBuffer[14]=‘r‘pBuffer[15]=‘y‘pBuffer[16]=‘d‘pBuffer[17]=‘a‘pBuffer[18]=‘y‘pBuffer[19]=0;
            break;
            default:pBuffer[12]=0 ;
        }
        LISTBOX_AddString(hObj(const char*)pBuffer);
    }
    return num+1;
}
//根据对话框各个选项给Listbox添加item
char AddListBoxItemAccordingToDialog(LISTBOX_Handle hObjconst xAlarm_TypeDef ax)
{
    char num=0;
    char pBuffer[20];
    num=LISTBOX_GetNumItems(hObj);
    if(num>=ALARM_NUM_MAX) return 0;
    pBuffer[0]=‘ ‘;
    pBuffer[1]=‘ ‘;
    pBuffer[2]=ax.hour/10+‘0‘;
    pBuffer[3]=ax.hour%10+‘0‘;
    pBuffer[4]=‘:‘;
    pBuffer[5]=ax.minute/10+‘0‘;
    pBuffer[6]=ax.minute%10+‘0‘;
    pBuffer[7]=‘‘;
    pBuffer[8]=ax.duration/10+‘0‘;
    pBuffer[9]=ax.duration%10+‘0‘;
    pBuffer[10]=‘‘;
    switch(ax.en>>4)
    {
        case 0:
            pBuffer[11]=‘S‘pBuff

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         174  2018-11-05 11:43  UI.h
     文件        6072  2018-11-05 14:26  alarm.c
     文件        1364  2018-11-05 14:21  alarm.h
     文件      873009  2018-11-04 20:21  fontx.h
     文件       38342  2018-11-05 14:21  UI.c

评论

共有 条评论