本帖最后由 jinglixixi 于 2024-11-17 18:53 编辑
#申请原创#
在通常的情况下,我们所用的显示器件多是数码管、液晶屏等。但在公共场合则需要使用较大尺寸规格的显示器件。 常规的广告牌就是由一种称为半板的器件拼接而成,这里是选用一款P4.75的红色半板作为显示器件,其显示分辨率为16*64像素点,外观如图1所示。 图1 外观
该显示板所采用的接口方式为HUB08,各引脚的名称如图2所示。 图2 HUB08接口
显示板与开发板的引脚连接关系为: A---- PB3 B---- PA9 C---- PB4 D---- PB1 R1 ---- PB7 CLK---- PB6 EN ---- PA11 STB---- PA8
对所用引脚的工作模式配置函数为: - void dzp_CONFIG(void)
- {
- __HAL_RCC_GPIOB_CLK_ENABLE();
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Pin = GPIO_PIN_1;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GPIO_PIN_3;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GPIO_PIN_4;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GPIO_PIN_6;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GPIO_PIN_7;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- GPIO_InitStruct.Pin = GPIO_PIN_8;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GPIO_PIN_9;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GPIO_PIN_11;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- }
所用引脚输出高低电平的语句定义为: #define LR1_high HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET) //DIN GPIO29 #define LR1_low HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET)
#define LSTB_high HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET) //LAT/STB GPIO33 #define LSTB_low HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET)
#define LEN_high HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_SET) //OE/EN GPIO34 #define LEN_low HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET)
#define LA_high HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET) //LA GPIO31 #define LA_low HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET)
#define LB_high HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET) //LB GPIO37 #define LB_low HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET)
#define LC_high HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET) //LC GPIO14 CN3-23 #define LC_low HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET)
#define LD_high HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET) //LD GPIO30 CN4-6 #define LD_low HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET)
显示板发送数据的函数为: - void OutByte(uint16_t dat)
- {
- uint8_t i=0 ;
- for(i=0;i<16;i++)
- {
- CLK_low;
- if(dat&0x0001)
- {
- LR1_high;
- }
- else
- {
- LR1_low;
- }
- dat=dat>>1;
- CLK_high;
- }
- }
发送多列数据的函数为: - void DisCol(uint16_t lenght)
- {
- uint16_t dat;
- uint8_t m=0;
- while(lenght--)
- {
- dat=(S[sj[m+1]*16+ScanRow]<<8)+S[sj[m]*16+ScanRow];
- OutByte(dat);
- m=m+2;
- }
- }
输出行地址的函数为: - void SeleRow(uint8_t Nd)
- {
- uint8_t N;
- N=Nd;
- N=N%16;
- if(N&0x01) LA_high;
- else LA_low;
- if (N&0x02) LB_high;
- else LB_low;
- if (N&0x04) LC_high;
- else LC_low;
- if (N&0x08) LD_high;
- else LD_low;
- }
实现显示输出的函数为: - void Display(void)
- {
- DisCol(4);
- LEN_high;
- LSTB_high;
- LSTB_low;
- SeleRow(ScanRow);
- LEN_low;
- ScanRow++;
- if(ScanRow>15) ScanRow=0;
- }
模拟计时显示效果的函数为: - void ShowTime(void)
- {
- sj[0]= 1;
- sj[1]= 2;
- sj[2]= 10;
- sj[3]= 3;
- sj[4]= 0;
- sj[5]= 10;
- sj[6]= 0;
- sj[7]= 8;
- Display();
- }
为进行显示,所配置的字模是由数组来存储,其格式和内容为: - uint8_t S[]={
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"0",0*/
- 0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,/*"1",1*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,/*"2",2*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,/*"3",3*/
- 0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,/*"4",4*/
- 0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,/*"5",5*/
- 0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"6",6*/
- 0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,/*"7",7*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,/*"8",8*/
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,/*"9",9*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,/*":",10*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",11*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
实现显示测试的主程序为: - int main(void)
- {
- HAL_Init();
- SystemClock_Config();
- PeriphCommonClock_Config();
- MX_GPIO_Init();
- dzp_CONFIG();
- ScanRow=0;
- while(1)
- {
- ShowTime();
- }
- }
经程序的编译与下载,其显示效果如图3所示,说明其符合预期的设计目标。 若将它与蓝牙通讯功能相配合,则可实时地控制显示内容的切换。
图3 连接关系与显示效果
|