Home Article 点阵广告屏驱动制作

点阵广告屏驱动制作

Release time:2021-03-20 15:44:45 Author:一蓑烟雨 Reading volume:312

主控:stm32f103c8t6

驱动芯片:DM13A,SI4956,HC138,HC245

演示效果:

原理图:

广告屏原理图

取模方式:


//advdis.h
#ifndef ADVDIS_H
#define ADVDIS_H

#include "stm32f10x.h"
#include "delay.h"


//74HC138引脚定义
#define HC138_A   GPIO_Pin_0
#define HC138_B		GPIO_Pin_1
#define HC138_C   GPIO_Pin_2
#define HC138_G   GPIO_Pin_3

//DM13A引脚定义
#define DM13_DAI  GPIO_Pin_4
#define DM13_LAT  GPIO_Pin_5
#define DM13_DCK  GPIO_Pin_6

//setbits :拉高    resetbits :拉低
#define HC138A_H   GPIO_SetBits(GPIOA,HC138_A)
#define HC138A_L   GPIO_ResetBits(GPIOA,HC138_A)
#define HC138B_L   GPIO_ResetBits(GPIOA,HC138_B)
#define HC138B_H   GPIO_SetBits(GPIOA,HC138_B)
#define HC138C_L   GPIO_ResetBits(GPIOA,HC138_C)
#define HC138C_H   GPIO_SetBits(GPIOA,HC138_C)
#define HC138G_L   GPIO_ResetBits(GPIOA,HC138_G)
#define HC138G_H   GPIO_SetBits(GPIOA,HC138_G)

#define DAI_L   GPIO_ResetBits(GPIOA,DM13_DAI)
#define DAI_H   GPIO_SetBits(GPIOA,DM13_DAI)
#define DCK_L   GPIO_ResetBits(GPIOA,DM13_DCK)
#define DCK_H   GPIO_SetBits(GPIOA,DM13_DCK)
#define LAT_L   GPIO_ResetBits(GPIOA,DM13_LAT)
#define LAT_H   GPIO_SetBits(GPIOA,DM13_LAT)


void ADVDIS_GPIO_Config(void);//初始化端口
void start(void);
void stop(void);
void ShowString(u8 *chr);
void ShowChinese(u8 length,unsigned char chr[7]);
void shownum( unsigned char length,unsigned char num[14]);



#endif

//advdis.c
#include "advDis.h"


unsigned char position = 8;
unsigned char font[][32] = {
	
{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,0x78,0x48,0x57,0x50,0x61,0x51,0x4A,0x4B,0x48,0x69,0x51,0x42,0x44,0x40,0x40,0x40,0x40,0x40,0xFE,0x80,0x20,0x20,0x20,0xFC,0x20,0x28,0x24,0x22,0x22,0xA0,0x40},/*"陈",1*/
{0x10,0x11,0x3D,0x21,0x41,0xBD,0x11,0x11,0xFD,0x11,0x11,0x11,0x15,0x19,0x11,0x01,0x00,0xF8,0x08,0x08,0xF8,0x08,0x08,0xF8,0x44,0x48,0x30,0x20,0x10,0x48,0x86,0x00},/*"银",2*/
{0x01,0x01,0x01,0x3F,0x21,0x21,0x2F,0x21,0x20,0x20,0x23,0x22,0x22,0x44,0x48,0x90,0x00,0xF8,0x00,0xFC,0x04,0x60,0x88,0x08,0xF8,0x00,0xE0,0x20,0x20,0x24,0x24,0x1C},/*"虎",3*/
{0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x08,0x04,0x02},/*"人",4*/
{0x20,0x13,0x10,0x40,0x47,0x44,0x44,0x44,0x47,0x44,0x44,0x44,0x47,0x40,0x40,0x40,0x00,0xFC,0x04,0x04,0xC4,0x44,0x44,0x44,0xC4,0x44,0x44,0x44,0xC4,0x04,0x14,0x08},/*"间",5*/
{0x10,0x10,0x10,0x20,0x24,0x64,0x64,0xA4,0x24,0x24,0x24,0x24,0x24,0x27,0x20,0x20,0x40,0x40,0x40,0x40,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xFC,0x04,0x00},/*"仙",6*/
{0x20,0x20,0x23,0x21,0xF8,0x27,0x20,0x23,0x22,0x23,0x22,0x3B,0xE1,0x41,0x02,0x0C,0x80,0x40,0xF8,0x10,0xA0,0xFE,0x00,0xF8,0x08,0xF8,0x08,0xF8,0x20,0x22,0x22,0x1E},/*"境",7*/
{0x02,0x02,0x3F,0x02,0x02,0xFF,0x01,0x02,0x0F,0x12,0x24,0x47,0x80,0x00,0x00,0x00,0x00,0x08,0xD0,0x20,0x40,0xFE,0x00,0x00,0xF8,0x00,0x00,0xF0,0x10,0x10,0xA0,0x40},/*"考",8*/
{0x00,0x01,0xFC,0x10,0x10,0x20,0x3C,0x67,0x64,0xA4,0x24,0x24,0x3C,0x25,0x21,0x02,0x00,0xFC,0x88,0x88,0x88,0x88,0x88,0xFE,0x88,0x88,0x88,0x88,0x88,0x08,0x08,0x08},/*"研",9*/
{0x04,0x45,0x54,0x54,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x54,0x54,0x85,0x06,0x00,0xFE,0x20,0x40,0xFC,0x04,0x24,0x24,0x24,0x24,0x24,0x44,0x50,0x88,0x04,0x02},/*"顺",10*/
{0x01,0x07,0x7C,0x04,0x04,0x04,0xFF,0x0C,0x16,0x15,0x24,0x24,0x44,0x84,0x04,0x04,0x04,0x84,0x04,0x24,0x24,0x24,0xA4,0x24,0x24,0x24,0xA4,0x24,0x04,0x04,0x14,0x08},/*"利",11*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"一",12*/
{0x10,0x10,0x10,0x1E,0x10,0x10,0x11,0x10,0x7E,0x42,0x42,0x42,0x42,0x7E,0x42,0x01,0x20,0x28,0x24,0x24,0x20,0x3E,0xE0,0x24,0x24,0x28,0x28,0x10,0x32,0x4A,0x86,0x02},/*"战",13*/
{0x00,0x00,0x00,0x3F,0x20,0x20,0x20,0x3E,0x22,0x22,0x22,0x22,0x2A,0x44,0x40,0x81,0x50,0x48,0x40,0xFE,0x40,0x40,0x44,0x44,0x44,0x28,0x28,0x12,0x32,0x4A,0x86,0x02},/*"成",14*/
{0x00,0x03,0xFC,0x10,0x11,0x21,0x3D,0x65,0x65,0xA5,0x25,0x25,0x3C,0x24,0x21,0x02,0x00,0xFE,0x20,0x40,0xFC,0x04,0x04,0x24,0x24,0x24,0x24,0x44,0x50,0x88,0x04,0x04},/*"硕",15*/
{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"01",16*/	
{0x00,0x00,0x04,0x08,0x09,0x12,0x12,0x2A,0x4A,0x0B,0x0A,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x0C,0x36,0x24,0x24,0xA4,0x3C,0x28,0x20,0x20,0x20,0x20,0x00},/*"仰",0*/
{0x00,0x00,0x00,0x07,0x01,0x01,0x01,0x1F,0x01,0x03,0x02,0x04,0x08,0x30,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x70,0x80,0x00,0x00,0x80,0x40,0x30,0x1C,0x00,0x00},/*"天",1*/
{0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x1F,0x01,0x01,0x02,0x02,0x04,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x80,0x00,0x80,0x80,0x40,0x20,0x38,0x04,0x00},/*"大",2*/
{0x00,0x00,0x04,0x07,0x08,0x16,0x00,0x03,0x06,0x07,0x0B,0x04,0x04,0x08,0x30,0x00,0x00,0x00,0x60,0x70,0x40,0xB0,0xC0,0x00,0x20,0xC0,0x00,0x80,0x60,0x3C,0x00,0x00},/*"笑",3*/
{0x00,0x01,0x01,0x01,0x01,0x19,0x11,0x11,0x1F,0x01,0x11,0x11,0x11,0x1E,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x08,0x08,0xF0,0x10,0x00,0x08,0x08,0xF8,0x10,0x00,0x00},/*"出",4*/
{0x00,0x00,0x0C,0x04,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x18,0xE8,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x08,0x00},/*"门",5*/
{0x00,0x01,0x00,0x01,0x01,0x07,0x01,0x01,0x01,0x7F,0x01,0x02,0x04,0x0F,0x08,0x00,0x00,0x00,0x80,0x00,0x00,0xC0,0x00,0x00,0x3E,0xC0,0x00,0x40,0x20,0xD0,0x00,0x00},/*"去",6*/
{0x00,0x01,0x00,0x00,0x02,0x04,0x04,0x03,0x3C,0x02,0x0C,0x74,0x05,0x0C,0x00,0x00,0x00,0x80,0x80,0x90,0x80,0x80,0xE0,0x80,0x58,0x50,0x20,0x60,0x92,0x0E,0x06,0x00},/*"我",7*/
{0x00,0x02,0x02,0x0E,0x0E,0x02,0x1F,0x01,0x06,0x05,0x0E,0x00,0x3F,0x01,0x01,0x00,0x00,0x40,0x70,0x40,0x60,0x78,0x40,0x20,0xC0,0xA0,0xC0,0xFC,0x80,0x00,0x00,0x00},/*"辈",8*/
{0x00,0x02,0x01,0x01,0x09,0x1F,0x10,0x03,0x04,0x00,0x0F,0x08,0x08,0x08,0x07,0x00,0x00,0x00,0x00,0x30,0x20,0xE0,0x00,0xC0,0x80,0x80,0x00,0x04,0x04,0x0C,0xF0,0x00},/*"岂",9*/
{0x00,0x00,0x07,0x02,0x03,0x02,0x01,0x00,0x3F,0x04,0x0C,0x0B,0x10,0x20,0x00,0x00,0x00,0x00,0xE0,0x20,0x20,0x40,0x80,0xF8,0x80,0xA0,0xC0,0x80,0x80,0x70,0x1C,0x00},/*"是",10*/
{0x00,0x00,0x04,0x3F,0x01,0x01,0x17,0x01,0x06,0x39,0x10,0x17,0x10,0x2F,0x00,0x00,0x00,0x40,0x40,0xB0,0x80,0x40,0x80,0xF0,0xEC,0x80,0xC0,0xE0,0x80,0x80,0x7C,0x00},/*"蓬",11*/
{0x00,0x00,0x04,0x0F,0x11,0x01,0x06,0x0F,0x04,0x07,0x3C,0x27,0x24,0x23,0x00,0x00,0x00,0x60,0x40,0xF0,0x80,0xE0,0x00,0xE0,0x40,0x98,0x6C,0xE8,0x48,0x88,0x18,0x00},/*"蒿",12*/
{0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x03,0x04,0x08,0x08,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x30,0x1C,0x00,0x00,0x00},/*"人",13*/
};

unsigned char ASCII[][16] = {
	
//	  (0) !(1) "(2) #(3) $(4) %(5) &(6) '(7) ((8) )(9) *(10) +(11) ,(12) -(13) .(14) /(15) 0(16) 1(17) 2(18) 3(19) 4(20) 5(21) 6(22) 7(23)
// 8(24) 9(25) :(26) ;(27) <(28) =(29) >(30) ?(31) @(32) A(33) B(34) C(35) D(36) E(37) F(38) G(39) H(40) I(41) J(42) K(43) L(44) M(45) N(46) O(47)
// P(48) Q(49) R(50) S(51) T(52) U(53) V(54) W(55) X(56) Y(57) Z(58) [(59) (60) ](61) ^(62) _(63) `(64) a(65) b(66) c(67) d(68) e(69) f(70) g(71)
// h(72) i(73) j(74) k(75) l(76) m(77) n(78) o(79) p(80) q(81) r(82) s(83) t(84) u(85) v(86) w(87) x(88) y(89) z(90) {(91) |(92) }(93) ~(94)

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x18,0x18,0x00,0x00},/*"!",1*/
{0x00,0x12,0x36,0x24,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*""",2*/
{0x00,0x00,0x00,0x24,0x24,0x24,0xFE,0x48,0x48,0x48,0xFE,0x48,0x48,0x48,0x00,0x00},/*"#",3*/
{0x00,0x00,0x10,0x38,0x54,0x54,0x50,0x30,0x18,0x14,0x14,0x54,0x54,0x38,0x10,0x10},/*"$",4*/
{0x00,0x00,0x00,0x44,0xA4,0xA8,0xA8,0xA8,0x54,0x1A,0x2A,0x2A,0x2A,0x44,0x00,0x00},/*"%",5*/
{0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x50,0x6E,0xA4,0x94,0x88,0x89,0x76,0x00,0x00},/*"&",6*/
{0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00},/*"(",8*/
{0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00},/*")",9*/
{0x00,0x00,0x00,0x00,0x10,0x10,0xD6,0x38,0x38,0xD6,0x10,0x10,0x00,0x00,0x00,0x00},/*"*",10*/
{0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x10,0x00,0x00,0x00},/*"+",11*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x20,0xC0},/*",",12*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00},/*".",14*/
{0x00,0x00,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00},/*"/",15*/
{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"0",16*/
{0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"1",17*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00},/*"2",18*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*"3",19*/
{0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00},/*"4",20*/
{0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*"5",21*/
{0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"6",22*/
{0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00},/*"7",23*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*"8",24*/
{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x20},/*";",27*/
{0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*"<",28*/
{0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00},/*"=",29*/
{0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*">",30*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x62,0x02,0x04,0x08,0x08,0x00,0x18,0x18,0x00,0x00},/*"?",31*/
{0x00,0x00,0x00,0x38,0x44,0x5A,0xAA,0xAA,0xAA,0xAA,0xB4,0x42,0x44,0x38,0x00,0x00},/*"@",32*/
{0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3C,0x44,0x42,0x42,0xE7,0x00,0x00},/*"A",33*/
{0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x78,0x44,0x42,0x42,0x42,0x44,0xF8,0x00,0x00},/*"B",34*/
{0x00,0x00,0x00,0x3E,0x42,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x44,0x38,0x00,0x00},/*"C",35*/
{0x00,0x00,0x00,0xF8,0x44,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x44,0xF8,0x00,0x00},/*"D",36*/
{0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x42,0x42,0xFC,0x00,0x00},/*"E",37*/
{0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x40,0x40,0xE0,0x00,0x00},/*"F",38*/
{0x00,0x00,0x00,0x3C,0x44,0x44,0x80,0x80,0x80,0x8E,0x84,0x44,0x44,0x38,0x00,0x00},/*"G",39*/
{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"H",40*/
{0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"I",41*/
{0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x88,0xF0},/*"J",42*/
{0x00,0x00,0x00,0xEE,0x44,0x48,0x50,0x70,0x50,0x48,0x48,0x44,0x44,0xEE,0x00,0x00},/*"K",43*/
{0x00,0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0xFE,0x00,0x00},/*"L",44*/
{0x00,0x00,0x00,0xEE,0x6C,0x6C,0x6C,0x6C,0x54,0x54,0x54,0x54,0x54,0xD6,0x00,0x00},/*"M",45*/
{0x00,0x00,0x00,0xC7,0x62,0x62,0x52,0x52,0x4A,0x4A,0x4A,0x46,0x46,0xE2,0x00,0x00},/*"N",46*/
{0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00},/*"O",47*/
{0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40,0x40,0xE0,0x00,0x00},/*"P",48*/
{0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0xB2,0xCA,0x4C,0x38,0x06,0x00},/*"Q",49*/
{0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x7C,0x48,0x48,0x44,0x44,0x42,0xE3,0x00,0x00},/*"R",50*/
{0x00,0x00,0x00,0x3E,0x42,0x42,0x40,0x20,0x18,0x04,0x02,0x42,0x42,0x7C,0x00,0x00},/*"S",51*/
{0x00,0x00,0x00,0xFE,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00},/*"T",52*/
{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*"U",53*/
{0x00,0x00,0x00,0xE7,0x42,0x42,0x44,0x24,0x24,0x28,0x28,0x18,0x10,0x10,0x00,0x00},/*"V",54*/
{0x00,0x00,0x00,0xD6,0x92,0x92,0x92,0x92,0xAA,0xAA,0x6C,0x44,0x44,0x44,0x00,0x00},/*"W",55*/
{0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00},/*"X",56*/
{0x00,0x00,0x00,0xEE,0x44,0x44,0x28,0x28,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00},/*"Y",57*/
{0x00,0x00,0x00,0x7E,0x84,0x04,0x08,0x08,0x10,0x20,0x20,0x42,0x42,0xFC,0x00,0x00},/*"Z",58*/
{0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00},/*"[",59*/
{0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x02,0x02},/*"",60*/
{0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00},/*"]",61*/
{0x00,0x1C,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF},/*"_",63*/
{0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x1E,0x22,0x42,0x42,0x3F,0x00,0x00},/*"a",65*/
{0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x64,0x58,0x00,0x00},/*"b",66*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00},/*"c",67*/
{0x00,0x00,0x00,0x06,0x02,0x02,0x02,0x1E,0x22,0x42,0x42,0x42,0x26,0x1B,0x00,0x00},/*"d",68*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x40,0x40,0x42,0x3C,0x00,0x00},/*"e",69*/
{0x00,0x00,0x00,0x0F,0x11,0x10,0x10,0x7E,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"f",70*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x44,0x44,0x38,0x40,0x3C,0x42,0x42,0x3C},/*"g",71*/
{0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"h",72*/
{0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"i",73*/
{0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x1C,0x04,0x04,0x04,0x04,0x04,0x04,0x44,0x78},/*"j",74*/
{0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x4E,0x48,0x50,0x68,0x48,0x44,0xEE,0x00,0x00},/*"k",75*/
{0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"l",76*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x49,0x49,0x49,0x49,0x49,0xED,0x00,0x00},/*"m",77*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"n",78*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*"o",79*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD8,0x64,0x42,0x42,0x42,0x44,0x78,0x40,0xE0},/*"p",80*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x22,0x42,0x42,0x42,0x22,0x1E,0x02,0x07},/*"q",81*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x32,0x20,0x20,0x20,0x20,0xF8,0x00,0x00},/*"r",82*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x40,0x3C,0x02,0x42,0x7C,0x00,0x00},/*"s",83*/
{0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x10,0x10,0x10,0x0C,0x00,0x00},/*"t",84*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x42,0x42,0x42,0x42,0x46,0x3B,0x00,0x00},/*"u",85*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x10,0x10,0x00,0x00},/*"v",86*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00},/*"w",87*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x24,0x18,0x18,0x18,0x24,0x76,0x00,0x00},/*"x",88*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x18,0x10,0x10,0xE0},/*"y",89*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x44,0x08,0x10,0x10,0x22,0x7E,0x00,0x00},/*"z",90*/
{0x00,0x03,0x04,0x04,0x04,0x04,0x04,0x08,0x04,0x04,0x04,0x04,0x04,0x04,0x03,0x00},/*"{",91*/
{0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},/*"|",92*/
{0x00,0x60,0x10,0x10,0x10,0x10,0x10,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x60,0x00},/*"}",93*/
{0x30,0x4C,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"~",94*/
	
};

unsigned char Digits[][16] = {
	
	// 0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7) 8(8) 9(9)  (10)

{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"0",0*/
{0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"1",1*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00},/*"2",2*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*"3",3*/
{0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00},/*"4",4*/
{0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*"5",5*/
{0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"6",6*/
{0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,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,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00},/*"9",9*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",10*/
	
};




//74HC138 IO口配置
void ADVDIS_GPIO_Config(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE); // 使能PC端口时钟  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2|GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5| GPIO_Pin_6;	//选择对应的引脚
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;       
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  //初始化PA端口
}

//开始传入数据
void start(void)
{
		LAT_L;
		Delay_us(1);
}

//传入数据结束
void stop(void)
{
		LAT_H;
		Delay_us(1);
}

// HC138 传值 :0-7
void HC138(unsigned char num)
{
	
	switch(num)
	{
		case 0:HC138A_H;HC138B_H;HC138C_H; break;
		case 1:HC138A_L;HC138B_L;HC138C_L; break;
		case 2:HC138A_H;HC138B_L;HC138C_L; break;
		case 3:HC138A_L;HC138B_H;HC138C_L; break;
		case 4:HC138A_H;HC138B_H;HC138C_L; break;
		case 5:HC138A_L;HC138B_L;HC138C_H; break;
		case 6:HC138A_H;HC138B_L;HC138C_H; break;
		case 7:HC138A_L;HC138B_H;HC138C_H; break;
		
	}

}


// 向DM13A传入16位数据  传入值:dat1,dat2
void Write_byte(unsigned char dat1,unsigned char dat2)
{
	
	unsigned char i;
	for(i = 0;i < 8;i++)
	{
		DCK_L;
		if((dat1 & 0x80) == 0x80)
		{
			DAI_H;
		}
		else
		{
			DAI_L;
		}
		dat1 = dat1 << 1;
		DCK_H;
	}
		for(i = 0;i < 8;i++)
	{
		DCK_L;
		if((dat2 & 0x80) == 0x80)
		{
			DAI_H;
		}
		else
		{
			DAI_L;
		}
		dat2 = dat2<< 1;
		DCK_H;
	}

}


//写入空值,移位,num:移位num*8位
void Write_clear(unsigned char num)
{
	unsigned char i,j;
	
	for(j = 0;j < num;j++)
		{
			for(i = 0;i < 16;i++)
			{
				DCK_L;
				DAI_L;
				DCK_H;
			}
		}
}

//使能并初始化HC138   
void ADVDIS_Init(void)
{
	HC138G_H;
	Delay_ms(1);
	HC138A_L;
	HC138B_L;
	HC138C_L;
	Delay_ms(1);	
}



//显示字符串
//*chr:字符串起始地址 
void ShowString(u8 *chr)
{
	unsigned char i,j,chr1[14],length = 0;
	while((*chr>=' ')&&(*chr<='~'))//判断是不是非法字符!
	{
		chr1[length++]=*chr-' ';
		chr++;
  }
	
	for(i = 0;i < 8;i++)
	{
		start();
		HC138(i);
		HC138G_H;
		Delay_ms(2);
		for(j = 0;j < length;j++)
		{
			Write_byte(ASCII[chr1[j]][i+8],ASCII[chr1[j]][i]);
		}
		HC138G_L;
		Write_clear(14-length);
		stop();
		
	}	
}

//显示汉字
//*chr:字符串起始地址 
void ShowChinese(u8 length,unsigned char chr[7])
{
	unsigned char i,j;
	for(i = 0;i < 8;i++)
	{
		start();
		HC138(i);
		HC138G_H;
		Delay_ms(2);
		for(j = 0;j < length;j++)
		{
			Write_byte(font[chr[j]][i+8],font[chr[j]][i]);
			Write_byte(font[chr[j]][i+24],font[chr[j]][i+16]);
		}
		HC138G_L;
		Write_clear(7-length);
		stop();
		
	}	
}


//显示数字  位置                                                                                           
void shownum( unsigned char length,unsigned char num[14])
{
		unsigned char i,j;
	for(i = 0;i < 8;i++)
	{
		start();
		HC138(i);
		HC138G_H;
		Delay_ms(2);
		for(j = 0;j < length;j++)
		{
			Write_byte(Digits[num[j]][i+8],Digits[num[j]][i]);
		}
		HC138G_L;
		Write_clear(14-length);
		stop();
		
	}	
	
}
//main.c
#include "stm32f10x.h"
#include "delay.h"
#include  "advDis.h"

unsigned char ch[7] = {0};
unsigned char ch1[7] = {0};
unsigned char num[14] ={0};

void initdat()
{
	unsigned char i;
	for(i = 0;i < 7;i++)
	{
		ch[i] = i+17;
		ch1[i] = i+24;
	}

}
int main(void)
{ 

 unsigned int i;	
 SystemInit();	// 配置系统时钟为72M 	
 SysTick_Init();
 ADVDIS_GPIO_Config();
 initdat();
  while (1)
  {
		for(i = 0;i < 150;i++)
		ShowString("Hello World!");
		for(i = 0;i < 150;i++)
		ShowChinese(7,ch);
		for(i = 0;i < 150;i++)
		ShowChinese(7,ch1);
//		for(i = 0;i < 150;i++)
//		shownum( 8,num);
	
  }
}
工程下载:广告屏工程 
时间显示工程:时钟工程
注意:时钟工程年份默认为2021年,如果以后需要改动请自行修改!


  
I want to comment

Search

classification

Leave a message
http://blog.rjxj513.com/index.php/
User login
You have not written any reviews yet!
You have commented!
Can only praise once!
You have a collection!