本帖最后由 trm999 于 2017-11-5 12:35 编辑
历时一周,由HT1621B驱动写起,LCD正常显示后,加入18B20温度检测程序,
可以正常显示温度后,又加入按键识别,因为是6脚IO,所以只有一个IO可用,
加入短按,2秒长按,5秒长按程序来实现减、加、保存,涉及到保存,
又学习STC单片机的EEPROM,实现保存后由于代码比较多,又进行模块化编程学习,
在这里卡了2天,定时器卡了一下午,终于完成
注意:1.EEPROM操作放到中断里面可以正常操作保存,估计和关闭中断有关系 2.因为继电器会干扰动作,要加电容
// - - * * * * * * * HT1621 段码屏驱动 * * * * * * *
// - - * MCU STC15F104W通过 15F104E未知 内设12M 晶振 *
// - - * C 语言程序 trm999 版本1.0 *
// 温度容差0.5摄氏度,当空调控制器使用,必须要有容差
// - - * * * * * * * * * * * * * * * * * * * * * * *
/*********************************************************************
数码管结构 a f b g e c d dp
seg0 seg1 seg2 seg3 seg4 seg5 seg6 seg7
com0 1a 1f 1b 1g 1e 1c 1d 1dp
com1 2a 2f 2b 2g 2e 2c 2d 2dp
com2 3a 3f 3b 3g 3e 3c 3d 3dp
com3 4a 4f 4b 4g 4e 4c 4d 3dp 数据位4位,结构4321
*********************************************************************/
sbit DQ=P3^5; //18B20
sbit SS=P3^0; //继电器
sbit HT1621_CS=P3^3; // - - HT1621使能引脚
sbit HT1621_WR=P3^2; // - - HT1621时钟引脚
sbit HT1621_DAT=P3^4; // - - HT1621数据引脚
sbit key_sr=P3^1;//对应按键
//shuzi0是左1大8字的代码表格
uchar code Ht1621_shuzi0[][8]={ //0~9数字数组
{0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x00},//0
{0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00},//1
{0x01,0x00,0x01,0x01,0x01,0x00,0x01,0x00},//2
{0x01,0x00,0x01,0x01,0x00,0x01,0x01,0x00},//3
{0x00,0x01,0x01,0x01,0x00,0x01,0x00,0x00},//4
{0x01,0x01,0x00,0x01,0x00,0x01,0x01,0x00},//5
{0x01,0x01,0x00,0x01,0x01,0x01,0x01,0x00},//6
{0x01,0x00,0x01,0x00,0x00,0x01,0x00,0x00},//7
{0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00},//8
{0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x00},//9
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},//AUTO 10
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},// 11
};
//shuzi1是左2大8字的代码表格
uchar code Ht1621_shuzi1[][8]={ //0~9数字数组
{0x02,0x02,0x02,0x00,0x02,0x02,0x02,0x00},//0
{0x00,0x00,0x02,0x00,0x00,0x02,0x00,0x00},//1
{0x02,0x00,0x02,0x02,0x02,0x00,0x02,0x00},//2
{0x02,0x00,0x02,0x02,0x00,0x02,0x02,0x00},//3
{0x00,0x02,0x02,0x02,0x00,0x02,0x00,0x00},//4
{0x02,0x02,0x00,0x02,0x00,0x02,0x02,0x00},//5
{0x02,0x02,0x00,0x02,0x02,0x02,0x02,0x00},//6
{0x02,0x00,0x02,0x00,0x00,0x02,0x00,0x00},//7
{0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00},//8
{0x02,0x02,0x02,0x02,0x00,0x02,0x02,0x00},//9
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02},//hight 10
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},// 11
};
//shuzi2是右小8字的代码表格
uchar code Ht1621_shuzi2[][8]={ //0~9数字数组
{0x04,0x04,0x04,0x00,0x04,0x04,0x04,0x00},//0
{0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00},//1
{0x04,0x00,0x04,0x04,0x04,0x00,0x04,0x00},//2
{0x04,0x00,0x04,0x04,0x00,0x04,0x04,0x00},//3
{0x00,0x04,0x04,0x04,0x00,0x04,0x00,0x00},//4
{0x04,0x04,0x00,0x04,0x00,0x04,0x04,0x00},//5
{0x04,0x04,0x00,0x04,0x04,0x04,0x04,0x00},//6
{0x04,0x00,0x04,0x00,0x00,0x04,0x00,0x00},//7
{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00},//8
{0x04,0x04,0x04,0x04,0x00,0x04,0x04,0x00},//9
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04},//low 10
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},// 11
};
//shuzi3是特殊符号代码表格
uchar code Ht1621_shuzi3[][8]={ //0~9数字数组
{0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//上半圆
{0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00},//圆双线
{0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00},//TEMP
{0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00},//ROOM
{0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00},//SET
{0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00},//下半圆hr
{0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00},//线条
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08},//FAN 7
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},// 8
};
淘宝买的2毛液晶玻璃,接口有变化,com0-com4是反的
要用HT1621B驱动,自己做的板子老是有重影,干脆打板子,做工不错
焊好后,松香不少请无视
15F104E单片机,加的背光,晚上方便
外壳是个问题,基本都是胶粘的,因为汽车使用,所以电源是12V变5V,用的3312模块的一半
左边圆的是按键
正常显示温度,小数字是小数部分,AUTO代表正温度,负温度会显示LOW
设定界面会显示线条,继电器闭合会显示一个小圆圈和两个细线
源文件因为是模块化,所以打包吧
|