【MT32F006】MT32F006之HT1628驱动LED

本文最后修改时间:2023年03月30日

一、本节简介

本文介绍如何使用MT32F006连接HT1628芯片驱动LED。

二、实验平台

库版本:V1.0.0

编译软件:MDK5.37

硬件平台:MT32F006开发板(主芯片MT32F006)

仿真器:JLINK

传感器:HT1628

三、版权声明

1)作者:甜甜的大香瓜

2)声明:喝水不忘挖井人,转载请注明出处。

3)纠错/业务合作:[email protected]

4)香瓜嵌入式之STM8/STM32群:164311667

5)本文出处:原创连载资料《简单粗暴学MT32F006》

6)完整开源资料下载地址(电脑端打开):opengua.taobao.com

四、实验前提

1、在进行本文步骤前,请先阅读以下章节:

1)《简单粗暴学MT32F006》的第一章和第二章章节

2、在进行本文步骤前,请先实现以下章节:

1)《简单粗暴学MT32F006》的《MT32F006之定时器延时》。

五、基础知识

1、什么是HT1628?

答:HT1628的完整型号HT1628BRWZ(封装SOP-28-300mil),品牌是HTCSEMI(海天芯)。

3.3V~4.2V 电压、4位*13段或7位*10段的阴极型的LED面板显示驱动。

打个比方,如果要点亮5个8字的数码管,一共要5*7=35个led。

方法一:使用mcu来控制,35个IO口对应控制35个led,此方法非常占用mcu的IO口。

方法二:使用mcu来控制,用行与列的方式,5个IO作为行、7个IO作为列,此方法需要5+7=12个IO口,也很占用mcu的IO口。

方法三(推荐):使用mcu+HT1628驱动芯片,mcu只需要3个IO(DIO数据信号、CLK时钟信号、STB信号是否有效脚)控制HT1628,HT1628再去控制LED。实际占用的是HT1628的IO口。

2、网上很多TM1628的驱动资料,与HT1628通用吗?

 

答:封装和引脚一样,但驱动代码不通用。

3、HT1628连接LED必须按一定规律顺序吗?

答:有规律会比较方便写代码,但是没规律也可以按独立的灯来写。

4、HT1628的操作逻辑是怎么样的?

1)配置DIO、CLK、STB三个IO。

2)延时等待稳定。

3)发送3条设置指令,主要设置:几位几段、地址自动增加模式、设置显示地址为0开始

4)第3条设置指令后紧跟着一串LED数据:

【MT32F006】MT32F006之HT1628驱动LED_第1张图片

如上图,一共14个字节,每个字节又分为HL低字节、HU高字节,这些字节会被存在HT1628的寄存器里,每个位都只对应1个位置(也就是对应1个LED灯)。

例如左上角第一个00HL地址的4个位(4个LED)分别是SG1-DIG1、SG2-DIG1、SG3-DIG1、SG4-DIG1。

注:位digits;段segments。

5)发送第4条设置指令,主要设置:亮度、开启显示。

六、硬件原理

1、MCU与HT1628连接

【MT32F006】MT32F006之HT1628驱动LED_第2张图片

【MT32F006】MT32F006之HT1628驱动LED_第3张图片

由上图可知:

HT1628引脚

MT32F006引脚

DIO

PIO1_5

CLK

PIO1_4

STB

PIO1_1

2、HT1628与LED的连接

【MT32F006】MT32F006之HT1628驱动LED_第4张图片

【MT32F006】MT32F006之HT1628驱动LED_第5张图片

【MT32F006】MT32F006之HT1628驱动LED_第6张图片

七、实验步骤

1、编写并添加串口驱动

1)编写驱动GUA_HT1628.c(存放在“……\Projects\MT006_StdPeriph_Templates\GUA”)

//**********************************************************************

//name:         GUA_HT1628.c

//introduce:    LED驱动

//author:       甜甜的大香瓜     

//email:        [email protected]  

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

#include "mt006.h"

#include "GUA_Delay.h"

#include "GUA_HT1628.h"

#include "string.h"

//SEG Code

//const GUA_U8 LEDseg[11]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0};

/*********************宏定义************************/

#define GUA_STB_H                 GPIO_WriteBit(GPIO1, GPIO_Pin_1, Bit_SET)

#define GUA_STB_L                 GPIO_WriteBit(GPIO1, GPIO_Pin_1, Bit_RESET)

#define GUA_CLK_H                 GPIO_WriteBit(GPIO1, GPIO_Pin_4, Bit_SET)

#define GUA_CLK_L                 GPIO_WriteBit(GPIO1, GPIO_Pin_4, Bit_RESET)

#define GUA_DIO_H                 GPIO_WriteBit(GPIO1, GPIO_Pin_5, Bit_SET)

#define GUA_DIO_L                 GPIO_WriteBit(GPIO1, GPIO_Pin_5, Bit_RESET)

/*********************内部变量************************/

GUA_U8 gGUA_HT1628_Ram[14] = {0};

GUA_HT1628_DISPLAY stGUA_HT1628_Display;

/*********************内部函数声明************************/

static void GUA_HT1628_DataConvert(void);

static void GUA_HT1628_GPIO_Init(void);

static void GUA_HT1628_SendCMD(GUA_U8 nGUA_CMD);

static void GUA_HT1628_SendData(GUA_U8 nGUA_Data);

//**********************************************************************

//name:         GUA_HT1628_DataConvert

//introduce:    HT1628的GPIO初始化

//parameter:    none

//return:       none

//author:       甜甜的大香瓜

//email:        [email protected]

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

static void GUA_HT1628_DataConvert(void)

{

      //清空内存缓冲区

      memset(gGUA_HT1628_Ram, 0, 14);

     

      //left_button D1 D2 D3

      if(stGUA_HT1628_Display.left_button == GUA_LIGHT_PART_ON)

      {

           //D1 D2 D3: 1 1 1

           gGUA_HT1628_Ram[12] |= (1<<2)|(1<<1)|(1<<0);

      }

      else

      {

           //D1 D2 D3: 0 0 0

           gGUA_HT1628_Ram[12] &= ~(1<<0);   //D1

           gGUA_HT1628_Ram[12] &= ~(1<<1);   //D2

           gGUA_HT1628_Ram[12] &= ~(1<<2);   //D3

      }

     

      //right_button D62 D63 D64

      if(stGUA_HT1628_Display.right_button == GUA_LIGHT_PART_ON)

      {

           //D62 D63 D64:1 1 1

           gGUA_HT1628_Ram[0] |= (1<<3)|(1<<2)|(1<<1);

      }

      else

      {

           //D62 D63 D64:0 0 0

           gGUA_HT1628_Ram[0] &= ~(1<<1);    //D62

           gGUA_HT1628_Ram[0] &= ~(1<<2);    //D63

           gGUA_HT1628_Ram[0] &= ~(1<<3);    //D64

      }    

     

      //lb D22

      if(stGUA_HT1628_Display.lb == GUA_LIGHT_PART_ON)

      {

           gGUA_HT1628_Ram[8] |= (1<<1);

      }

      else

      {

           gGUA_HT1628_Ram[8] &= ~(1<<1);

      }         

     

      //kg D23

      if(stGUA_HT1628_Display.kg == GUA_LIGHT_PART_ON)

      {

           gGUA_HT1628_Ram[8] |= (1<<2);

      }

      else

      {

           gGUA_HT1628_Ram[8] &= ~(1<<2);

      }

      //oz D60

      if(stGUA_HT1628_Display.oz == GUA_LIGHT_PART_ON)

      {

           gGUA_HT1628_Ram[3] |= (1<<1);

      }

      else

      {

           gGUA_HT1628_Ram[3] &= ~(1<<1);

      }

      //g D61

      if(stGUA_HT1628_Display.g == GUA_LIGHT_PART_ON)

      {

           gGUA_HT1628_Ram[0] |= (1<<0);

      }

      else

      {

           gGUA_HT1628_Ram[0] &= ~(1<<0);

      }    

     

      //point D45

      if(stGUA_HT1628_Display.point == GUA_LIGHT_PART_ON)

      {

           gGUA_HT1628_Ram[4] |= (1<<4);

      }

      else

      {

           gGUA_HT1628_Ram[4] &= ~(1<<4);

      }         

     

      //num1 D8 D10 D13 D14 D12 D9 D11**********************

      switch(stGUA_HT1628_Display.num1)

      {

           //D8 D10 D13 D14 D12 D9 D11:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] |= (1<<1);    //D12

                 gGUA_HT1628_Ram[13] |= (1<<0);    //D9

                 gGUA_HT1628_Ram[10] &= ~(1<<0);   //D11                            

                 break;               

           }

          

           //D8 D10 D13 D14 D12 D9 D11:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {               

                 gGUA_HT1628_Ram[12] &= ~(1<<7);   //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] &= ~(1<<3);   //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] &= ~(1<<0);   //D9

                 gGUA_HT1628_Ram[10] &= ~(1<<0);   //D11                            

                 break;               

           }    

          

           //D8 D10 D13 D14 D12 D9 D11:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] &= ~(1<<2);   //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] |= (1<<1);    //D12

                 gGUA_HT1628_Ram[13] &= ~(1<<0);   //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }

          

           //D8 D10 D13 D14 D12 D9 D11:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] &= ~(1<<0);   //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }

          

           //D8 D10 D13 D14 D12 D9 D11:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[12] &= ~(1<<7);   //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] &= ~(1<<3);   //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] |= (1<<0);    //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }    

          

           //D8 D10 D13 D14 D12 D9 D11:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] &= ~(1<<1);   //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] |= (1<<0);    //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }    

          

           //D8 D10 D13 D14 D12 D9 D11:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] &= ~(1<<1);   //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] |= (1<<1);    //D12

                 gGUA_HT1628_Ram[13] |= (1<<0);    //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }    

          

           //D8 D10 D13 D14 D12 D9 D11:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] &= ~(1<<3);   //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] &= ~(1<<0);   //D9

                 gGUA_HT1628_Ram[10] &= ~(1<<0);   //D11                            

                 break;               

           }    

          

           //D8 D10 D13 D14 D12 D9 D11:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] |= (1<<1);    //D12

                 gGUA_HT1628_Ram[13] |= (1<<0);    //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }               

          

           //D8 D10 D13 D14 D12 D9 D11:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {               

                 gGUA_HT1628_Ram[12] |= (1<<7);    //D8

                 gGUA_HT1628_Ram[13] |= (1<<1);    //D10

                 gGUA_HT1628_Ram[10] |= (1<<2);    //D13

                 gGUA_HT1628_Ram[10] |= (1<<3);    //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] |= (1<<0);    //D9

                 gGUA_HT1628_Ram[10] |= (1<<0);    //D11                            

                 break;               

           }

          

           //D8 D10 D13 D14 D12 D9 D11:0 0 0 0 0 0 0

           default:

           {               

                 gGUA_HT1628_Ram[12] &= ~(1<<7);   //D8

                 gGUA_HT1628_Ram[13] &= ~(1<<1);   //D10

                 gGUA_HT1628_Ram[10] &= ~(1<<2);   //D13

                 gGUA_HT1628_Ram[10] &= ~(1<<3);   //D14

                 gGUA_HT1628_Ram[10] &= ~(1<<1);   //D12

                 gGUA_HT1628_Ram[13] &= ~(1<<0);   //D9

                 gGUA_HT1628_Ram[10] &= ~(1<<0);   //D11                                 

                 break;               

           }

      }

     

      //num2 D15 D17 D20 D21 D19 D16 D18**********************

      switch(stGUA_HT1628_Display.num2)

      {

           //D15 D17 D20 D21 D19 D16 D18:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] |= (1<<0);    //D19

                 gGUA_HT1628_Ram[10] |= (1<<5);    //D16

                 gGUA_HT1628_Ram[10] &= ~(1<<7);   //D18                            

                 break;               

           }

          

           //D15 D17 D20 D21 D19 D16 D18:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {               

                 gGUA_HT1628_Ram[10] &= ~(1<<4);   //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  &= ~(1<<0);   //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] &= ~(1<<5);   //D16

                 gGUA_HT1628_Ram[10] &= ~(1<<7);   //D18                            

                 break;                                

           }    

          

           //D15 D17 D20 D21 D19 D16 D18:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] &= ~(1<<1);   //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] |= (1<<0);    //D19

                 gGUA_HT1628_Ram[10] &= ~(1<<5);   //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                      

                 break;               

           }

          

           //D15 D17 D20 D21 D19 D16 D18:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] &= ~(1<<5);   //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                                            

                 break;               

           }

          

           //D15 D17 D20 D21 D19 D16 D18:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[10] &= ~(1<<4);   //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  &= ~(1<<0);   //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] |= (1<<5);    //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                                            

                 break;               

           }    

          

           //D15 D17 D20 D21 D19 D16 D18:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] &= ~(1<<6);   //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] |= (1<<5);    //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                                            

                 break;               

           }    

          

           //D15 D17 D20 D21 D19 D16 D18:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {    

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] &= ~(1<<6);   //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] |= (1<<0);    //D19

                 gGUA_HT1628_Ram[10] |= (1<<5);    //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                            

                 break;               

           }    

          

           //D15 D17 D20 D21 D19 D16 D18:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  &= ~(1<<0);   //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] &= ~(1<<5);   //D16

                 gGUA_HT1628_Ram[10] &= ~(1<<7);   //D18                                            

                 break;               

           }    

          

           //D15 D17 D20 D21 D19 D16 D18:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] |= (1<<0);    //D19

                 gGUA_HT1628_Ram[10] |= (1<<5);    //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                                            

                 break;               

           }               

          

           //D15 D17 D20 D21 D19 D16 D18:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {               

                 gGUA_HT1628_Ram[10] |= (1<<4);    //D15

                 gGUA_HT1628_Ram[10] |= (1<<6);    //D17

                 gGUA_HT1628_Ram[11] |= (1<<1);    //D20

                 gGUA_HT1628_Ram[8]  |= (1<<0);    //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] |= (1<<5);    //D16

                 gGUA_HT1628_Ram[10] |= (1<<7);    //D18                                            

                 break;               

           }

          

           //D15 D17 D20 D21 D19 D16 D18:0 0 0 0 0 0 0

           default:

           {               

                 gGUA_HT1628_Ram[10] &= ~(1<<4);   //D15

                 gGUA_HT1628_Ram[10] &= ~(1<<6);   //D17

                 gGUA_HT1628_Ram[11] &= ~(1<<1);   //D20

                 gGUA_HT1628_Ram[8]  &= ~(1<<0);   //D21

                 gGUA_HT1628_Ram[11] &= ~(1<<0);   //D19

                 gGUA_HT1628_Ram[10] &= ~(1<<5);   //D16

                 gGUA_HT1628_Ram[10] &= ~(1<<7);   //D18                                                  

                 break;               

           }

      }    

      //num3 D24 D26 D29 D30 D28 D25 D27**********************

      switch(stGUA_HT1628_Display.num3)

      {

           //D24 D26 D29 D30 D28 D25 D27:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] |= (1<<7);          //D28

                 gGUA_HT1628_Ram[8] |= (1<<4);          //D25

                 gGUA_HT1628_Ram[8] &= ~(1<<6);    //D27                            

                 break;               

           }

          

           //D24 D26 D29 D30 D28 D25 D27:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {               

                 gGUA_HT1628_Ram[8] &= ~(1<<3);    //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] &= ~(1<<1);    //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] &= ~(1<<4);    //D25

                 gGUA_HT1628_Ram[8] &= ~(1<<6);    //D27                            

                 break;                                

           }    

          

           //D24 D26 D29 D30 D28 D25 D27:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] &= ~(1<<0);    //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] |= (1<<7);          //D28

                 gGUA_HT1628_Ram[8] &= ~(1<<4);    //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                 

                 break;               

           }

          

           //D24 D26 D29 D30 D28 D25 D27:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] &= ~(1<<4);    //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                                             

                 break;               

           }

          

           //D24 D26 D29 D30 D28 D25 D27:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[8] &= ~(1<<3);    //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] &= ~(1<<1);    //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] |= (1<<4);          //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                                       

                 break;               

           }    

          

           //D24 D26 D29 D30 D28 D25 D27:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] &= ~(1<<5);    //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] |= (1<<4);          //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                                       

                 break;               

           }    

          

           //D24 D26 D29 D30 D28 D25 D27:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {    

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] &= ~(1<<5);    //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] |= (1<<7);          //D28

                 gGUA_HT1628_Ram[8] |= (1<<4);          //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                       

                 break;               

           }    

          

           //D24 D26 D29 D30 D28 D25 D27:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] &= ~(1<<1);    //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] &= ~(1<<4);    //D25

                 gGUA_HT1628_Ram[8] &= ~(1<<6);    //D27                                                        

                 break;               

           }    

          

           //D24 D26 D29 D30 D28 D25 D27:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] |= (1<<7);          //D28

                 gGUA_HT1628_Ram[8] |= (1<<4);          //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                                       

                 break;               

           }               

          

           //D24 D26 D29 D30 D28 D25 D27:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {               

                 gGUA_HT1628_Ram[8] |= (1<<3);          //D24

                 gGUA_HT1628_Ram[8] |= (1<<5);          //D26

                 gGUA_HT1628_Ram[9] |= (1<<0);          //D29

                 gGUA_HT1628_Ram[9] |= (1<<1);          //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] |= (1<<4);          //D25

                 gGUA_HT1628_Ram[8] |= (1<<6);          //D27                                                       

                 break;               

           }

          

           //D24 D26 D29 D30 D28 D25 D27:0 0 0 0 0 0 0

           default:

           {               

                 gGUA_HT1628_Ram[8] &= ~(1<<3);    //D24

                 gGUA_HT1628_Ram[8] &= ~(1<<5);    //D26

                 gGUA_HT1628_Ram[9] &= ~(1<<0);    //D29

                 gGUA_HT1628_Ram[9] &= ~(1<<1);    //D30

                 gGUA_HT1628_Ram[8] &= ~(1<<7);    //D28

                 gGUA_HT1628_Ram[8] &= ~(1<<4);    //D25

                 gGUA_HT1628_Ram[8] &= ~(1<<6);    //D27                                                             

                 break;               

           }

      }

      //num4 D31 D33 D36 D37 D35 D32 D34**********************

      switch(stGUA_HT1628_Display.num4)

      {

           //D31 D33 D36 D37 D35 D32 D34:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    |= (1<<4); //D35

                 gGUA_HT1628_Ram[6]    |= (1<<1); //D32

                 gGUA_HT1628_Ram[6]    &= ~(1<<3);      //D34                            

                 break;               

           }

          

           //D31 D33 D36 D37 D35 D32 D34:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {               

                 gGUA_HT1628_Ram[6]    &= ~(1<<0);      //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  &= ~(1<<6);   //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    &= ~(1<<1);      //D32

                 gGUA_HT1628_Ram[6]    &= ~(1<<3);      //D34                                            

                 break;                                

           }    

          

           //D31 D33 D36 D37 D35 D32 D34:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {         

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    &= ~(1<<5);      //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    |= (1<<4); //D35

                 gGUA_HT1628_Ram[6]    &= ~(1<<1);      //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                      

                 break;               

           }

          

           //D31 D33 D36 D37 D35 D32 D34:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {         

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    &= ~(1<<1);      //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                                            

                 break;               

           }

          

           //D31 D33 D36 D37 D35 D32 D34:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[6]    &= ~(1<<0);      //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  &= ~(1<<6);   //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    |= (1<<1); //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                                                             

                 break;               

           }    

          

           //D31 D33 D36 D37 D35 D32 D34:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {         

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    &= ~(1<<2);      //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    |= (1<<1); //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                                                  

                 break;               

           }    

          

           //D31 D33 D36 D37 D35 D32 D34:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {    

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    &= ~(1<<2);      //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    |= (1<<4); //D35

                 gGUA_HT1628_Ram[6]    |= (1<<1); //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                                            

                 break;               

           }    

          

           //D31 D33 D36 D37 D35 D32 D34:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  &= ~(1<<6);   //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    &= ~(1<<1);      //D32

                 gGUA_HT1628_Ram[6]    &= ~(1<<3);      //D34                                                             

                 break;               

           }    

          

           //D31 D33 D36 D37 D35 D32 D34:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    |= (1<<4); //D35

                 gGUA_HT1628_Ram[6]    |= (1<<1); //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                                                             

                 break;               

           }               

          

           //D31 D33 D36 D37 D35 D32 D34:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {         

                 gGUA_HT1628_Ram[6]    |= (1<<0); //D31

                 gGUA_HT1628_Ram[6]    |= (1<<2); //D33

                 gGUA_HT1628_Ram[6]    |= (1<<5); //D36

                 gGUA_HT1628_Ram[6]  |= (1<<6);    //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    |= (1<<1); //D32

                 gGUA_HT1628_Ram[6]    |= (1<<3); //D34                                            

                 break;               

           }

          

           //D31 D33 D36 D37 D35 D32 D34:0 0 0 0 0 0 0

           default:

           {               

                 gGUA_HT1628_Ram[6]    &= ~(1<<0);      //D31

                 gGUA_HT1628_Ram[6]    &= ~(1<<2);      //D33

                 gGUA_HT1628_Ram[6]    &= ~(1<<5);      //D36

                 gGUA_HT1628_Ram[6]  &= ~(1<<6);   //D37

                 gGUA_HT1628_Ram[6]    &= ~(1<<4);      //D35

                 gGUA_HT1628_Ram[6]    &= ~(1<<1);      //D32

                 gGUA_HT1628_Ram[6]    &= ~(1<<3);      //D34                                                                        

                 break;               

           }

      }

      //num5 D38 D40 D43 D44 D42 D39 D41**********************

      switch(stGUA_HT1628_Display.num5)

      {

           //D38 D40 D43 D44 D42 D39 D41:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {                          

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    |= (1<<1); //D42

                 gGUA_HT1628_Ram[7]    |= (1<<0); //D39

                 gGUA_HT1628_Ram[4]    &= ~(1<<0);      //D41                      

                 break;               

           }

          

           //D38 D40 D43 D44 D42 D39 D41:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {               

                 gGUA_HT1628_Ram[6]    &= ~(1<<7);      //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  &= ~(1<<3);   //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    &= ~(1<<0);      //D39

                 gGUA_HT1628_Ram[4]    &= ~(1<<0);      //D41                                            

                 break;                                

           }    

          

           //D38 D40 D43 D44 D42 D39 D41:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {         

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    &= ~(1<<2);      //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    |= (1<<1); //D42

                 gGUA_HT1628_Ram[7]    &= ~(1<<0);      //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                

                 break;               

           }

          

           //D38 D40 D43 D44 D42 D39 D41:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    &= ~(1<<0);      //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                                                        

                 break;               

           }

          

           //D38 D40 D43 D44 D42 D39 D41:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[6]    &= ~(1<<7);      //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  &= ~(1<<3);   //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    |= (1<<0); //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                                                             

                 break;               

           }    

          

           //D38 D40 D43 D44 D42 D39 D41:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {         

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    &= ~(1<<1);      //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    |= (1<<0); //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                                       

                 break;               

           }    

          

           //D38 D40 D43 D44 D42 D39 D41:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {    

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    &= ~(1<<1);      //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    |= (1<<1); //D42

                 gGUA_HT1628_Ram[7]    |= (1<<0); //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                                       

                 break;               

           }    

          

           //D38 D40 D43 D44 D42 D39 D41:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  &= ~(1<<3);   //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    &= ~(1<<0);      //D39

                 gGUA_HT1628_Ram[4]    &= ~(1<<0);      //D41                                                       

                 break;               

           }    

          

           //D38 D40 D43 D44 D42 D39 D41:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    |= (1<<1); //D42

                 gGUA_HT1628_Ram[7]    |= (1<<0); //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                                                        

                 break;               

           }               

          

           //D38 D40 D43 D44 D42 D39 D41:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {               

                 gGUA_HT1628_Ram[6]    |= (1<<7); //D38

                 gGUA_HT1628_Ram[7]    |= (1<<1); //D40

                 gGUA_HT1628_Ram[4]    |= (1<<2); //D43

                 gGUA_HT1628_Ram[4]  |= (1<<3);    //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    |= (1<<0); //D39

                 gGUA_HT1628_Ram[4]    |= (1<<0); //D41                                                        

                 break;               

           }

          

           //D38 D40 D43 D44 D42 D39 D41:0 0 0 0 0 0 0

           default:

           {         

                 gGUA_HT1628_Ram[6]    &= ~(1<<7);      //D38

                 gGUA_HT1628_Ram[7]    &= ~(1<<1);      //D40

                 gGUA_HT1628_Ram[4]    &= ~(1<<2);      //D43

                 gGUA_HT1628_Ram[4]  &= ~(1<<3);   //D44

                 gGUA_HT1628_Ram[4]    &= ~(1<<1);      //D42

                 gGUA_HT1628_Ram[7]    &= ~(1<<0);      //D39

                 gGUA_HT1628_Ram[4]    &= ~(1<<0);      //D41                                            

                 break;               

           }

      }

      //num6 D46 D48 D51 D52 D50 D47 D49**********************

      switch(stGUA_HT1628_Display.num6)

      {

           //D46 D48 D51 D52 D50 D47 D49:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {               

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    |= (1<<1); //D50

                 gGUA_HT1628_Ram[4]    |= (1<<6); //D47

                 gGUA_HT1628_Ram[5]    &= ~(1<<0);      //D49                      

                 break;               

           }

          

           //D46 D48 D51 D52 D50 D47 D49:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {         

                 gGUA_HT1628_Ram[4]    &= ~(1<<5);      //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  &= ~(1<<1);   //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    &= ~(1<<6);      //D47

                 gGUA_HT1628_Ram[5]    &= ~(1<<0);      //D49                            

                 break;                                

           }    

          

           //D46 D48 D51 D52 D50 D47 D49:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {    

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    &= ~(1<<0);      //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    |= (1<<1); //D50

                 gGUA_HT1628_Ram[4]    &= ~(1<<6);      //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                

                 break;               

           }

          

           //D46 D48 D51 D52 D50 D47 D49:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {         

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    &= ~(1<<6);      //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                                                  

                 break;               

           }

          

           //D46 D48 D51 D52 D50 D47 D49:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[4]    &= ~(1<<5);      //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  &= ~(1<<1);   //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    |= (1<<6); //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                                                             

                 break;               

           }    

          

           //D46 D48 D51 D52 D50 D47 D49:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {               

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    &= ~(1<<7);      //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    |= (1<<6); //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                                                             

                 break;               

           }    

          

           //D46 D48 D51 D52 D50 D47 D49:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {    

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    &= ~(1<<7);      //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    |= (1<<1); //D50

                 gGUA_HT1628_Ram[4]    |= (1<<6); //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                                            

                 break;               

           }    

          

           //D46 D48 D51 D52 D50 D47 D49:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  &= ~(1<<1);   //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    &= ~(1<<6);      //D47

                 gGUA_HT1628_Ram[5]    &= ~(1<<0);      //D49                                                             

                 break;               

           }    

          

           //D46 D48 D51 D52 D50 D47 D49:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    |= (1<<1); //D50

                 gGUA_HT1628_Ram[4]    |= (1<<6); //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                                                             

                 break;               

           }               

          

           //D46 D48 D51 D52 D50 D47 D49:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {               

                 gGUA_HT1628_Ram[4]    |= (1<<5); //D46

                 gGUA_HT1628_Ram[4]    |= (1<<7); //D48

                 gGUA_HT1628_Ram[2]    |= (1<<0); //D51

                 gGUA_HT1628_Ram[2]  |= (1<<1);    //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    |= (1<<6); //D47

                 gGUA_HT1628_Ram[5]    |= (1<<0); //D49                                                             

                 break;               

           }

          

           //D46 D48 D51 D52 D50 D47 D49:0 0 0 0 0 0 0

           default:

           {               

                 gGUA_HT1628_Ram[4]    &= ~(1<<5);      //D46

                 gGUA_HT1628_Ram[4]    &= ~(1<<7);      //D48

                 gGUA_HT1628_Ram[2]    &= ~(1<<0);      //D51

                 gGUA_HT1628_Ram[2]  &= ~(1<<1);   //D52

                 gGUA_HT1628_Ram[5]    &= ~(1<<1);      //D50

                 gGUA_HT1628_Ram[4]    &= ~(1<<6);      //D47

                 gGUA_HT1628_Ram[5]    &= ~(1<<0);      //D49                                                                        

                 break;               

           }

      }

      //num7 D53 D55 D58 D59 D57 D54 D56**********************

      switch(stGUA_HT1628_Display.num7)

      {

           //D53 D55 D58 D59 D57 D54 D56:1 1 1 1 1 1 0

           case GUA_LIGHT_NUMBER0:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    |= (1<<6); //D57

                 gGUA_HT1628_Ram[2]    |= (1<<3); //D54

                 gGUA_HT1628_Ram[2]    &= ~(1<<5);      //D56                            

                 break;               

           }

          

           //D53 D55 D58 D59 D57 D54 D56:0 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER1:

           {               

                 gGUA_HT1628_Ram[2]    &= ~(1<<2);      //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  &= ~(1<<0);   //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    &= ~(1<<3);      //D54

                 gGUA_HT1628_Ram[2]    &= ~(1<<5);      //D56                                                  

                 break;                                

           }    

          

           //D53 D55 D58 D59 D57 D54 D56:1 1 0 1 1 0 1

           case GUA_LIGHT_NUMBER2:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    &= ~(1<<7);      //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    |= (1<<6); //D57

                 gGUA_HT1628_Ram[2]    &= ~(1<<3);      //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                            

                 break;               

           }

          

           //D53 D55 D58 D59 D57 D54 D56:1 1 1 1 0 0 1

           case GUA_LIGHT_NUMBER3:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    &= ~(1<<3);      //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                                        

                 break;               

           }

          

           //D53 D55 D58 D59 D57 D54 D56:0 1 1 0 0 1 1

           case GUA_LIGHT_NUMBER4:

           {               

                 gGUA_HT1628_Ram[2]    &= ~(1<<2);      //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  &= ~(1<<0);   //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    |= (1<<3); //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                                        

                 break;               

           }    

          

           //D53 D55 D58 D59 D57 D54 D56:1 0 1 1 0 1 1

           case GUA_LIGHT_NUMBER5:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    &= ~(1<<4);      //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    |= (1<<3); //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                                        

                 break;               

           }    

          

           //D53 D55 D58 D59 D57 D54 D56:1 0 1 1 1 1 1

           case GUA_LIGHT_NUMBER6:

           {    

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    &= ~(1<<4);      //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    |= (1<<6); //D57

                 gGUA_HT1628_Ram[2]    |= (1<<3); //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                       

                 break;               

           }    

          

           //D53 D55 D58 D59 D57 D54 D56:1 1 1 0 0 0 0

           case GUA_LIGHT_NUMBER7:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  &= ~(1<<0);   //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    &= ~(1<<3);      //D54

                 gGUA_HT1628_Ram[2]    &= ~(1<<5);      //D56                                                       

                 break;               

           }    

          

           //D53 D55 D58 D59 D57 D54 D56:1 1 1 1 1 1 1

           case GUA_LIGHT_NUMBER8:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    |= (1<<6); //D57

                 gGUA_HT1628_Ram[2]    |= (1<<3); //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                                        

                 break;               

           }               

          

           //D53 D55 D58 D59 D57 D54 D56:1 1 1 1 0 1 1

           case GUA_LIGHT_NUMBER9:

           {               

                 gGUA_HT1628_Ram[2]    |= (1<<2); //D53

                 gGUA_HT1628_Ram[2]    |= (1<<4); //D55

                 gGUA_HT1628_Ram[2]    |= (1<<7); //D58

                 gGUA_HT1628_Ram[3]  |= (1<<0);    //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    |= (1<<3); //D54

                 gGUA_HT1628_Ram[2]    |= (1<<5); //D56                                                        

                 break;               

           }

          

           //D53 D55 D58 D59 D57 D54 D56:0 0 0 0 0 0 0

           default:

           {               

                 gGUA_HT1628_Ram[2]    &= ~(1<<2);      //D53

                 gGUA_HT1628_Ram[2]    &= ~(1<<4);      //D55

                 gGUA_HT1628_Ram[2]    &= ~(1<<7);      //D58

                 gGUA_HT1628_Ram[3]  &= ~(1<<0);   //D59

                 gGUA_HT1628_Ram[2]    &= ~(1<<6);      //D57

                 gGUA_HT1628_Ram[2]    &= ~(1<<3);      //D54

                 gGUA_HT1628_Ram[2]    &= ~(1<<5);      //D56                                                             

                 break;               

           }

      }    

}

//**********************************************************************

//name:         GUA_HT1628_GPIO_Init

//introduce:    HT1628的GPIO初始化

//parameter:    none

//return:       none

//author:       甜甜的大香瓜

//email:        [email protected]

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

static void GUA_HT1628_GPIO_Init(void)

{

      GPIO_InitTypeDef GPIO_InitStructure;

      //PIO1_1 STB,注意不能同时初始化多个IO

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

      GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

      GPIO_Init(GPIO1, &GPIO_InitStructure);

     

      //PIO1_4 CLK,注意不能同时初始化多个IO

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

      GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

      GPIO_Init(GPIO1, &GPIO_InitStructure);

     

      //PIO1_5 DIO,注意不能同时初始化多个IO

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

      GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

      GPIO_Init(GPIO1, &GPIO_InitStructure);

      //初始化io的电平

      GUA_STB_H;

      GUA_DIO_H;

      GUA_CLK_H;

}

//**********************************************************************

//name:         GUA_HT1628_SendCMD

//introduce:    发送指令函数

//parameter:    nGUA_CMD:要发送的指令

//return:       none

//author:       甜甜的大香瓜

//email:        [email protected]

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

static void GUA_HT1628_SendCMD(GUA_U8 nGUA_CMD)

{

  GUA_U8 i;

      //拉高

      GUA_STB_H;

      GUA_Delay_Us(1);

     

      //拉低

      GUA_STB_L;

      GUA_Delay_Us(1);

     

     

      //按位写入

  for(i=0; i<8; i++)

  {   

    GUA_CLK_L;

           GUA_Delay_Us(1);

          

    if(nGUA_CMD & 0x01)

    {

      GUA_DIO_H;

    }

    else 

    {

      GUA_DIO_L;

    }     

    nGUA_CMD >>= 1;

          

    GUA_CLK_H;

           GUA_Delay_Us(1);

  }

}

//**********************************************************************

//name:         GUA_HT1628_SendData

//introduce:    发送数据函数

//parameter:    nGUA_Data:要发送的数据

//return:       none

//author:       甜甜的大香瓜

//email:        [email protected]

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

static void GUA_HT1628_SendData(GUA_U8 nGUA_Data)

{

  GUA_U8 i;

      //按位写入

  for(i=0; i<8; i++)

  {   

    GUA_CLK_L;

           GUA_Delay_Us(1);

          

    if (nGUA_Data & 0x01)  

    {

      GUA_DIO_H;

    }

    else 

    {

      GUA_DIO_L;

    }

    nGUA_Data >>= 1;

          

    GUA_CLK_H;

           GUA_Delay_Us(1);

  }

}

//**********************************************************************

//name:         GUA_HT1628_Display

//introduce:    将结构体数据对应显示到led上

//parameter:    none

//return:       none

//author:       甜甜的大香瓜

//email:        [email protected]

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

void GUA_HT1628_Display(void)

{

      GUA_U8 i = 0;

      //将结构体数据转换到数组中

      GUA_HT1628_DataConvert();

     

  //3条设置指令

  GUA_HT1628_SendCMD(0x03);   //指令1 7位10段

  GUA_HT1628_SendCMD(0x40);   //指令2 地址自动增加模式

  GUA_HT1628_SendCMD(0xC0);   //指令3 设置显示地址为00

      //指令3带的14个字节数据初始化

      for(i=0; i<14; i++)

      {

           GUA_HT1628_SendData(gGUA_HT1628_Ram[i]);    

      }

 

      //最后一条设置指令

  GUA_HT1628_SendCMD((0x80|stGUA_HT1628_Display.pulse_width|stGUA_HT1628_Display.onoff));

}

//**********************************************************************

//name:         GUA_HT1628_Init

//introduce:    初始化函数

//parameter:    none

//return:       none

//author:       甜甜的大香瓜

//email:        [email protected]

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

void GUA_HT1628_Init(void)

{

      //初始化IO

      GUA_HT1628_GPIO_Init();

     

      //延时,如果不加延时,全速时会写入不正常

      GUA_Delay_Ms(1);

     

      //填充初始数据

      stGUA_HT1628_Display.left_button = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.right_button = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.num1 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.num2 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.num3 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.num4 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.num5 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.num6 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.num7 = GUA_LIGHT_NUMBER8;

      stGUA_HT1628_Display.lb = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.kg = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.oz = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.g = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.point = GUA_LIGHT_PART_ON;

      stGUA_HT1628_Display.pulse_width = GUA_LIGHT_PULSE_WIDTH_13_16;   

      stGUA_HT1628_Display.onoff = GUA_LIGHT_ON;  

     

      //数据显示

      GUA_HT1628_Display();

}

2)编写驱动头文件GUA_HT1628.h

(存放在“……\Projects\MT006_StdPeriph_Templates\GUA”)

//**********************************************************************

//name:         GUA_HT1628.h

//introduce:    LED驱动的头文件

//author:       甜甜的大香瓜     

//email:        [email protected]  

//shop:         opengua.taobao.com

//changetime:   2023.02.02

//**********************************************************************

#ifndef _GUA_HT1628_H_

#define _GUA_HT1628_H_

/*********************宏定义************************/

//类型宏

#ifndef GUA_C

typedef char GUA_C;

#endif

#ifndef GUA_U8

typedef unsigned char GUA_U8;

#endif

#ifndef GUA_8

typedef signed char GUA_8;

#endif

#ifndef GUA_U16

typedef unsigned short GUA_U16;

#endif

#ifndef GUA_16

typedef signed short GUA_16;

#endif

#ifndef GUA_U32

typedef unsigned long GUA_U32;

#endif

#ifndef GUA_32

typedef signed long GUA_32;

#endif

//显示结构体使用的宏

//数码管之外的灯用的宏

#define GUA_LIGHT_PART_ON                          1        //开启对应功能的灯

#define GUA_LIGHT_PART_OFF                     0        //关闭对应功能的灯

//数码管用的宏

#define GUA_LIGHT_NUMBER0                          0

#define GUA_LIGHT_NUMBER1                          1

#define GUA_LIGHT_NUMBER2                          2

#define GUA_LIGHT_NUMBER3                          3

#define GUA_LIGHT_NUMBER4                          4

#define GUA_LIGHT_NUMBER5                          5

#define GUA_LIGHT_NUMBER6                           6

#define GUA_LIGHT_NUMBER7                          7

#define GUA_LIGHT_NUMBER8                          8

#define GUA_LIGHT_NUMBER9                          9

#define GUA_LIGHT_NUMBER_OFF                   255

//控制亮度的宏

#define GUA_LIGHT_PULSE_WIDTH_1_16   0        //PWM 1/16 最暗

#define GUA_LIGHT_PULSE_WIDTH_2_16   1        //PWM 2/16

#define GUA_LIGHT_PULSE_WIDTH_4_16   2        //PWM 4/16

#define GUA_LIGHT_PULSE_WIDTH_10_16  3        //PWM 10/16

#define GUA_LIGHT_PULSE_WIDTH_11_16  4        //PWM 11/16

#define GUA_LIGHT_PULSE_WIDTH_12_16  5        //PWM 12/16

#define GUA_LIGHT_PULSE_WIDTH_13_16  6        //PWM 13/16 最亮

//控制总开关的宏

#define GUA_LIGHT_ON                                    0x08//打开显示的总开关

#define GUA_LIGHT_OFF                                   0x00//关闭显示的总开关

/*********************外部变量************************/

typedef struct

{

     GUA_U8 left_button;

     GUA_U8 right_button;

     GUA_U8 num1;

     GUA_U8 num2;

     GUA_U8 num3;

     GUA_U8 num4;

     GUA_U8 num5;

     GUA_U8 num6;

     GUA_U8 num7;

     GUA_U8 lb;

     GUA_U8 kg;

     GUA_U8 oz;

     GUA_U8 g;

     GUA_U8 point;

     GUA_U8 pulse_width;

     GUA_U8 onoff;

}GUA_HT1628_DISPLAY;

extern GUA_HT1628_DISPLAY stGUA_HT1628_Display;

/*********************外部函数声明************************/

extern void GUA_HT1628_Display(void);

extern void GUA_HT1628_Init(void);

#endif

3)工程中添加驱动文件

【MT32F006】MT32F006之HT1628驱动LED_第7张图片  【MT32F006】MT32F006之HT1628驱动LED_第8张图片

4)在MDK设置中添加驱动源文件路径

【MT32F006】MT32F006之HT1628驱动LED_第9张图片

2、添加库的驱动

1)添加库的驱动文件(为了方便一次性都添加进来,已有则不用添加)【MT32F006】MT32F006之HT1628驱动LED_第10张图片

2)添加库的驱动头文件(mt006_conf.h 中)(为了方便一次性都添加进来,已有则不用添加)

【MT32F006】MT32F006之HT1628驱动LED_第11张图片

3、在应用层中调用

1)添加驱动头文件(main.c中)

#include "GUA_HT1628.h"

2)添加驱动初始化代码(main.c的main函数中)

    //LED初始化

    GUA_HT1628_Init(); 

3)添加测试代码(main.c的main函数中)

                    //填充初始数据

                    stGUA_HT1628_Display.left_button = GUA_LIGHT_PART_ON;

                    stGUA_HT1628_Display.right_button = GUA_LIGHT_PART_OFF;

                    stGUA_HT1628_Display.num1 = GUA_LIGHT_NUMBER0;

                    stGUA_HT1628_Display.num2 = GUA_LIGHT_NUMBER_OFF;

                    stGUA_HT1628_Display.num3 = GUA_LIGHT_NUMBER_OFF;

                    stGUA_HT1628_Display.num4 = GUA_LIGHT_NUMBER_OFF;

                    stGUA_HT1628_Display.num5 = GUA_LIGHT_NUMBER_OFF;

                    stGUA_HT1628_Display.num6 = GUA_LIGHT_NUMBER_OFF;

                    stGUA_HT1628_Display.num7 = GUA_LIGHT_NUMBER_OFF;

                    stGUA_HT1628_Display.lb = GUA_LIGHT_PART_OFF;

                    stGUA_HT1628_Display.kg = GUA_LIGHT_PART_OFF;

                    stGUA_HT1628_Display.oz = GUA_LIGHT_PART_OFF;

                    stGUA_HT1628_Display.g = GUA_LIGHT_PART_OFF;

                    stGUA_HT1628_Display.point = GUA_LIGHT_PART_OFF;

                    stGUA_HT1628_Display.pulse_width = GUA_LIGHT_PULSE_WIDTH_13_16;   

                    stGUA_HT1628_Display.onoff = GUA_LIGHT_ON; 

                   

                    //数据显示

                    GUA_HT1628_Display();  

这里是只亮左边触摸按键边上的3个led灯,其他灭。

八、注意事项

暂无

九、实验结果

暂无

 

你可能感兴趣的:(MT32F006,单片机)