部分源代码展示:
/**********************************************************************
文件名: 12864液晶显示电子台历
编 写: 21ic论坛 --- DIY讨论区 --- ID: henangongda123(阿勇)
EEWORLD论坛 --- DIY/开源硬件专区 --- ID: henangongda-123(阿勇)
电子发烧友论坛 --- 单片机/MCU论坛 --- ID: henangongda(阿勇)
时 间: 2018年05月26日
修 改:
2018.05.26 建立初始版本;
2018.07.08 发布简易V1.0版(无LCD背光调节等功能);
2018.07.12 移植网友公开公历转农历算法成功;
2018.07.20 修改网友公开24节气查表算法成功;
2018.07.21 增加十二生肖显示及温度负数处理;
2018.07.26 发布V2.0版(带农历显示、背光亮度调节等功能);
备 注:
1. CPU主时钟选择内部16MHz RC振荡器;
2. 接口说明:
STM8S207CBT6 ----- 外部设备
******** 12864液晶显示器 ********
PD2 ----- YJ_RS
PD3 ----- YJ_RW
PD4 ----- YJ_E
PC1 ----- YJ_PSB
PC2(T1_CH2) ----- YJ_ON(PWM背光调节)
PB0-7 ----- YJ_DB0-7
******** STM8S硬件I2C ********
PE1 ----- DS3231/SHT31_SCL
PE2 ----- DS3231/SHT31_SDA
******** 照度传感器 ********
PE7/AIN8 ---- ON9658/ADC
******** 按键开关 ********
PC4 ---- S1
PC5 ---- S2
PC6 ---- S3
PC7 ---- S4
声明: 1. 本DIY液晶显示部分参考了【杜洋老师】2007年发布的【DIY12864电子
钟】小制作,非常感谢杜洋老师对电子爱好初学者所做的工作,谢谢!
2. 本DIY公历转农历算法为直接移植网友【赖皮】于2007年发布的【最强
万年历】原创程序,在此非常感谢其无私的共享精神,谢谢!
3. 本DIY中24节气算法为修改自网友【未查到原始作者ID名】公开查表算
法,其算法解析详见注释.
**********************************************************************/
//加载头文件
#include "stm8s207CB.h"
//宏定义
#define uchar unsigned char
#define uint unsigned int
#define ushort unsigned short
#define EEP_BASE 0x4000 //STM8S大容量Data EEPROM起始地址
#define EEPROM_Lock() FLASH_IAPSR&=(~0x08)
#define EEPROM_Wait_Read_Over() while(!(FLASH_IAPSR&0x04))
#define EEPROM_Wrover_Clear() FLASH_IAPSR&=(~0x04)
//全局变量
uchar DS3231_R_Data[7]; //定义、保存读取DS3231数据寄存器值
uchar DS3231_W_Data[7]; //定义、保存写入DS3231数据寄存器值
uchar sec,min,hour,day,month,year,week;//定义、保存液晶显示用的年月日时分秒等时间数据
uchar sec_r,min_r,hour_r,day_r,month_r,year_r,week_r;//定义、保存DS3231读取的年月日时分秒等时间数据
int sec_w,min_w,hour_w,day_w,month_w,year_w,week_w;//定义、保存写入DS3231的年月日时分秒等时间数据
uchar year_n,day_n,month_n; //定义保存农历年月日数据
uchar SHT31_R_Data[6]; //定义、保存读取SHT31数据值
int temperature; //定义、保存SHT31读取的温度数值
int humidity; //定义、保存SHT31读取的湿度数值
int mother_day,father_day; //定义、保存西方母亲节、父亲节日期
uint ADC_Data[3]; //定义、保存三次ADC采样数值
//系统运行全局标志
uchar mode=0; //系统工作模式
uchar display=0; //系统显示界面
uchar set_flicker=0; //参数调节闪烁
int brightness_set; //背光亮度选择
uchar month_n_moonday; //农历大小月
uchar solar_term; //24节气值
uchar ADC_Number=0; //ADC采样次数
/*================= 定制化化开机界面图片(宽度x高度=128*64)==================*/
//"欢迎使用 阿勇赠"
const uchar Pic_1[64][16] = {
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,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,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,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,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,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X00,0X00,0X00,0X0F,0XE0,
0X00,0X00,0X78,0X00,0X00,0X00,0X60,0X00,0X00,0X00,0X03,0X80,0X00,0X00,0X7F,0XF0,
0X00,0X00,0XFC,0X00,0X00,0X00,0XF0,0X00,0X00,0X00,0X03,0X80,0X00,0X01,0XF8,0X38,
0X00,0X00,0X9C,0X00,0X00,0X01,0XF0,0X00,0X00,0X02,0X01,0XC0,0X00,0X0F,0XF8,0X38,
0X00,0X00,0X1C,0X00,0X03,0X83,0XFD,0XE0,0X00,0X03,0X81,0XF0,0X00,0X07,0X1C,0X38,
0X00,0X00,0X38,0X00,0X01,0XDF,0XCF,0XF0,0X00,0X03,0XCF,0XF0,0X00,0X07,0X1C,0X38,
0X00,0X00,0X38,0X00,0X01,0XEF,0X0F,0X70,0X00,0X07,0XFF,0XC0,0X00,0X06,0X1F,0X30,
0X00,0X3C,0X31,0XC0,0X01,0XCF,0X0F,0X30,0X00,0X0F,0XCF,0X80,0X00,0X06,0XFF,0XB0,
0X00,0X7E,0X77,0XE0,0X00,0X03,0X9E,0X30,0X00,0X0F,0X8F,0XF0,0X00,0X07,0XFF,0X30,
0X03,0XFE,0X7F,0XE0,0X00,0X03,0XBE,0X70,0X00,0X1E,0X13,0XF8,0X00,0X06,0XFC,0X30,
0X01,0XFE,0XFD,0XE0,0X07,0XE3,0XE6,0X70,0X00,0X3E,0X27,0XF8,0X00,0X06,0X3C,0X30,
0X00,0X9C,0XF9,0XC0,0X07,0XE3,0XE7,0X60,0X00,0X7C,0X5F,0XF8,0X00,0X06,0X3F,0X30,
0X00,0X1C,0XF7,0X80,0X01,0XE3,0XC7,0XE0,0X00,0X7C,0X7F,0XF0,0X00,0X06,0X7F,0XB0,
0X03,0XFC,0XFE,0X00,0X00,0XE3,0XC7,0XE0,0X00,0X7C,0X73,0XE0,0X00,0X06,0XFF,0XB0,
0X0F,0XF8,0XF0,0X00,0X00,0XC3,0X86,0XC0,0X00,0X6C,0X7F,0XE0,0X00,0X07,0XFC,0X30,
0X00,0XF8,0X70,0X00,0X00,0X60,0X86,0X00,0X00,0X0C,0X7F,0X00,0X00,0X06,0XFC,0X30,
0X00,0XFC,0X70,0X00,0X00,0X30,0X06,0X00,0X00,0X0F,0X9F,0X00,0X00,0X0C,0X1C,0X38,
0X01,0XFC,0X7F,0X00,0X00,0X30,0X06,0X00,0X00,0X1D,0XE7,0X00,0X00,0X0C,0X1C,0X38,
0X03,0XCC,0XE7,0XC0,0X00,0X7C,0X06,0X00,0X00,0X1C,0X7E,0X00,0X00,0X0C,0X1C,0X38,
0X0F,0X85,0XE1,0XF0,0X01,0XFF,0XFE,0X00,0X00,0X1C,0X1E,0X00,0X00,0X0C,0X1F,0X38,
0X07,0X03,0XC0,0XF8,0X01,0XF3,0XFF,0XFF,0X00,0X1C,0X0F,0X80,0X00,0X18,0X19,0XF8,
0X00,0X0F,0X80,0X38,0X00,0X00,0X3F,0XFE,0X00,0X1B,0X3F,0XE0,0X00,0X10,0X08,0XF8,
0X00,0X00,0X00,0X1C,0X00,0X00,0X03,0XF0,0X00,0X18,0XF9,0XFC,0X00,0X00,0X08,0X78,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X18,0X00,0XFF,0X80,0X00,0X08,0X38,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X00,0X7F,0XC0,0X00,0X00,0X18,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0X80,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,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,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,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0F,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X7B,0X80,0X00,0X00,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X60,0X00,0X00,0X6F,0X00,0X00,0X05,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XF0,0X00,0X00,0X4F,0X00,0X03,0X89,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0XE0,0X7C,0X00,0X0E,0X80,0X04,0XC2,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X7F,0XE0,0X00,0X7E,0XC0,0X08,0XC7,0XB0,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X78,0X20,0X00,0X7E,0XC0,0X0B,0XFB,0X30,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X25,0X20,0X00,0X7C,0XC0,0X0B,0XFF,0XA0,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XEF,0XA0,0X00,0X5E,0XC0,0X0B,0X7F,0X60,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XEF,0XA0,0X00,0X5C,0X80,0X0B,0X57,0XC0,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XCF,0X20,0X00,0X1F,0X80,0X0B,0X5F,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X8F,0X20,0X00,0X3F,0XC0,0X0B,0X77,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X00,0X20,0X00,0XFC,0XC0,0X0E,0XC7,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X00,0X20,0X00,0XD8,0XC0,0X06,0X8C,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X00,0X20,0X00,0X31,0X80,0X05,0X8F,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X02,0X60,0X00,0X71,0X80,0X08,0X8C,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XE0,0X00,0X4B,0X00,0X18,0X0F,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X60,0X00,0X8F,0X00,0X00,0X05,0X80,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X20,0X03,0X06,0X00,0X00,0X00,0X80,
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,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,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
}; |
@山东电子小菜鸟 :可以转载 请注明出处,哈哈
@山东电子小菜鸟 :可以转载 请注明出处,哈哈
非常棒 可以转载吗