色哟哟视频在线观看-色哟哟视频在线-色哟哟欧美15最新在线-色哟哟免费在线观看-国产l精品国产亚洲区在线观看-国产l精品国产亚洲区久久

聚豐項目 > 基于CH32V103的溫濕度智能監控設計

基于CH32V103的溫濕度智能監控設計

本設計基于沁恒RISC-V架構的CH32V103, 在達到額定濃度聲音報警之外還將控制排風扇進行強制通風,由CH32V103采集一氧化碳傳感器的模擬電壓并轉換成有效濃度值,采集DHT11的溫濕度數據,一并輸出給OLED顯示為了更人性化,光敏電阻模塊通過感知光下線,開關OLED,避免晚上成小夜燈(我晚上有光就睡不著).其ADC的模擬看門狗實時檢測CO傳感器電壓,OLED顯示CO濃度.以達到警示保護生命安全.

jf_39858756 jf_39858756

分享
0 喜歡這個項目
團隊介紹

jf_39858756 jf_39858756

團隊成員

jf_39858756 技術員

分享
項目簡介
本設計基于沁恒RISC-V架構的CH32V103, 在達到額定濃度聲音報警之外還將控制排風扇進行強制通風,由CH32V103采集一氧化碳傳感器的模擬電壓并轉換成有效濃度值,采集DHT11的溫濕度數據,一并輸出給OLED顯示為了更人性化,光敏電阻模塊通過感知光下線,開關OLED,避免晚上成小夜燈(我晚上有光就睡不著).其ADC的模擬看門狗實時檢測CO傳感器電壓,OLED顯示CO濃度.以達到警示保護生命安全.
硬件說明

本設計基于沁恒RISC-V架構的CH32V103, 在達到額定濃度聲音報警之外還將控制排風扇進行強制通風,由CH32V103采集一氧化碳傳感器的模擬電壓并轉換成有效濃度值,采集DHT11的溫濕度數據,一并輸出給OLED顯示為了更人性化,光敏電阻模塊通過感知光下線,開關OLED,避免晚上成小夜燈(我晚上有光就睡不著).其ADC的模擬看門狗實時檢測CO傳感器電壓,OLED顯示CO濃度.以達到警示保護生命安全.


32位通用增強型RISC-V單片機 CH32V103


概述

CH32V103系列是以RISC-V3A處理器為核心的32位通用微控制器,該處理器是基于RISC-V開源指令集設計。片上集成了時鐘安全機制、多級電源管理、通用DMA控制器。此系列具有1USB2.0主機/設備接口、多通道12ADC轉換模塊、多通道TouchKey、多組定時器、多路IIC/USART/SPI接口等豐富的外設資源。

系統框圖


產品特點

  • RISC-V3A處理器,最高80MHz系統主頻;

  • 支持單周期乘法和硬件除法

  • 20KB SRAM64KB CodeFlash

  • 供電范圍:2.7V ~ 5.5VGPIO同步供電電壓;

  • 多種低功耗模式:睡眠/停止/待機;

  • 上電/斷電復位(POR/PDR);

  • 可編程電壓監測器(PVD);

  • 7通道DMA控制器;

  • 16TouchKey通道監測;

  • 1612ADC轉換通道;

  • 7個定時器;

  • 1USB2.0主機/設備接口(全速和低速);

  • 2IIC接口(支持SMBus/PMBus);

  • 3USART接口;

  • 2SPI接口(支持MasterSlave模式);

  • 51I/O口,所有的I/O口都可以映射到16個外部中斷;

  • CRC計算單元,96位芯片唯一ID

  • 串行單線調試(SWD)接口;

  • 封裝形式:LQFP64MLQFP48QFN48


其他硬件有如下:

  1. 0.96oled 顯示溫濕度 一氧化碳ppm值

  2. 光敏電阻模塊 通過光敏電阻感知外界光照度變化,白天開燈,夜晚關燈

  3. mq7一氧化碳傳感器 測量一氧化碳濃度

  4. 蜂鳴器 報警

  5. dht11溫濕度傳感器  測量溫濕度變化情況

  6. 5v和3.3v穩壓模塊 輸出穩定的5v和3.3v電壓

軟件說明

首先根據沁恒公司官網提供的教程 http://www.wch.cn/search?q=ch32v103&t=products 把相關資料全部下載下來

下載后打開該參考資料可以看到相關例程圖片.png



使用MounRiver Studio圖片.png  下載地址為http://www.mounriver.com/ (安裝方法以及例程其官網或可以直接在b站搜索即可) 打開例程 

首次打開如圖所示圖片.png圖片.png

首先漢化點  help>language>simple chinese圖片.png


打開例程可直接雙擊如下圖的文件即可 (類似keil)

圖片.png


沁恒入門教程以及相關資料見上面的下載文件


該項目中程序如下:

/*
 * ADC.c
 *
 *
 */

#include "ch32v10x.h"

extern __IO uint16_t ADC_Value;

/*******************************************************************************
* Function Name  : ADC_Function_Init
* Description    : Initializes ADC collection.
* Input          : None
* Return         : None
*******************************************************************************/
void ADC_Function_Init(void)
{
    ADC_InitTypeDef ADC_InitStructure;
    GPIO_InitTypeDef GPIO_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE );
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE );
    RCC_ADCCLKConfig(RCC_PCLK2_Div8);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    ADC_DeInit(ADC1);
    ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
    ADC_InitStructure.ADC_ScanConvMode = DISABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
    ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfChannel = 1;
    ADC_Init(ADC1, &ADC_InitStructure);

    ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_239Cycles5 );

    /* 高閾值:1400, 低閾值:0 */
    ADC_AnalogWatchdogThresholdsConfig(ADC1, 1300, 0);
    ADC_AnalogWatchdogSingleChannelConfig( ADC1, ADC_Channel_1);
    ADC_AnalogWatchdogCmd( ADC1, ADC_AnalogWatchdog_SingleRegEnable);

    NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);




    ADC_Cmd(ADC1, ENABLE);
    ADC_DMACmd(ADC1, ENABLE); // ADC DMA 使能

    ADC_ResetCalibration(ADC1);
    while(ADC_GetResetCalibrationStatus(ADC1));
    ADC_StartCalibration(ADC1);
    while(ADC_GetCalibrationStatus(ADC1));


}

/*******************************************************************************
* Function Name  : DMA_Tx_Init
* Description    : Initializes the DMAy Channelx configuration.
* Input          : DMA_CHx:
*                    x can be 1 to 7.
*                  ppadr: Peripheral base address.
*                  memadr: Memory base address.
*                  bufsize: DMA channel buffer size.
* Return         : None
*******************************************************************************/

void DMA_Tx_Init(void)
{
    DMA_InitTypeDef DMA_InitStructure;

    RCC_AHBPeriphClockCmd( RCC_AHBPeriph_DMA1, ENABLE );

    DMA_DeInit(DMA1_Channel1);
    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->RDATAR;
    DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADC_Value;
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    DMA_InitStructure.DMA_BufferSize = 1;
    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
    DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
    DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
    DMA_Init(DMA1_Channel1, &DMA_InitStructure );
    DMA_Cmd(DMA1_Channel1, ENABLE);


}

/*
 * spi.c
 *
 *
 */
#include "ch32v10x.h"

/*******************************************************************************
* Function Name  : SPI1_Init
* Description    : Configuring the SPI for full-duplex communication.
* Input          : None
* Return         : None
*******************************************************************************/

 //Master:SPI1_SCK(PA5)、SPI1_MOSI(PA7)。
void SPI1_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    SPI_InitTypeDef SPI_InitStructure;

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE );


    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init( GPIOA, &GPIO_InitStructure );

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init( GPIOA, &GPIO_InitStructure );

    SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx   ;
    SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
    SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
    SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
    SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
    SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
    SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
    SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
    SPI_InitStructure.SPI_CRCPolynomial = 7;
    SPI_Init( SPI1, &SPI_InitStructure );

    SPI_Cmd( SPI1, ENABLE );
}


/*
 * DHT11.h
 
 */

#ifndef DHT11_DHT11_H_
#define DHT11_DHT11_H_

//#include "main.h"
#include "ch32v10x.h"


/************************** DHT11 數據類型定義********************************/
typedef struct
{
    uint8_t  humi_int;      //濕度的整數部分
    uint8_t  humi_deci;     //濕度的小數部分
    uint8_t  temp_int;      //溫度的整數部分
    uint8_t  temp_deci;     //溫度的小數部分
    uint8_t  check_sum;     //校驗和

} DHT11_Data_TypeDef;



/************************** DHT11 連接引腳定義********************************/


#define      DHT11_Dout_GPIO_PORT                      GPIOB
#define      DHT11_Dout_GPIO_PIN                       GPIO_Pin_8

/************************** 函數宏定義 方便移植*****************/
#define DHT11_DELAY_US(us)  Delay_Us(us)
#define DHT11_DELAY_MS(ms)  Delay_Ms(ms)



#define      DHT11_Dout_GPIO_CLK                       RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE)
#define      GPIO_PIN_RESET                             Bit_RESET
#define      GPIO_PIN_SET                               Bit_SET

#define      DHT11_Dout_0                               GPIO_ResetBits(DHT11_Dout_GPIO_PORT,  DHT11_Dout_GPIO_PIN)
#define      DHT11_Dout_1                               GPIO_SetBits(DHT11_Dout_GPIO_PORT,  DHT11_Dout_GPIO_PIN )

#define      DHT11_Dout_IN()                            GPIO_ReadInputDataBit(DHT11_Dout_GPIO_PORT,  DHT11_Dout_GPIO_PIN )



/************************** DHT11 函數聲明 ********************************/
void                     DHT11_Init                      ( void );
uint8_t                  DHT11_Read_TempAndHumidity      ( DHT11_Data_TypeDef * DHT11_Data );



#endif /* DHT11_DHT11_H_ */



/*
 * DHT11.c
 *
 *   溫濕度傳感器應用函數接口
 *
 * DATA_IO  :  PB8

 */


#include "DHT11.h"




static void                           DHT11_GPIO_Config                       ( void );
static void                           DHT11_Mode_IPU                          ( void );
static void                           DHT11_Mode_Out_PP                       ( void );
static uint8_t                        DHT11_ReadByte                          ( void );





 /**
  * @brief  DHT11 初始化函數
  * @param  無
  * @retval 無
  */
void DHT11_Init ( void )
{
    DHT11_GPIO_Config ();

    DHT11_Dout_1;               // 拉高GPIOA_15
}


/*
 * 函數名:DHT11_GPIO_Config
 * 描述  :配置DHT11用到的I/O口
 * 輸入  :無
 * 輸出  :無
 */
static void DHT11_GPIO_Config ( void )
{
    /*定義一個GPIO_InitTypeDef類型的結構體*/
    GPIO_InitTypeDef GPIO_InitStructure;


    /*開啟DHT11_Dout_GPIO_PORT的外設時鐘*/

    DHT11_Dout_GPIO_CLK ;

    /*選擇要控制的DHT11_Dout_GPIO_PORT引腳*/
    GPIO_InitStructure.GPIO_Pin = DHT11_Dout_GPIO_PIN;

    /*設置引腳模式為通用推挽輸出*/
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

    /*設置上下拉*/
    //GPIO_InitStructure.GPIO_Pull = GPIO_NOPULL;

    /*設置引腳速率為50MHz */
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    /*調用庫函數,初始化DHT11_Dout_GPIO_PORT*/
     GPIO_Init ( DHT11_Dout_GPIO_PORT, &GPIO_InitStructure );

}


/*
 * 函數名:DHT11_Mode_IPU
 * 描述  :使DHT11-DATA引腳變為上拉輸入模式
 * 輸入  :無
 * 輸出  :無
 */
static void DHT11_Mode_IPU(void)
{
      GPIO_InitTypeDef GPIO_InitStructure;

        /*選擇要控制的DHT11_Dout_GPIO_PORT引腳*/
      GPIO_InitStructure.GPIO_Pin = DHT11_Dout_GPIO_PIN;

       /*設置引腳模式為浮空輸入模式*/
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU ;

      /*調用庫函數,初始化DHT11_Dout_GPIO_PORT*/
       GPIO_Init(DHT11_Dout_GPIO_PORT, &GPIO_InitStructure);

}


/*
 * 函數名:DHT11_Mode_Out_PP
 * 描述  :使DHT11-DATA引腳變為推挽輸出模式
 * 輸入  :無
 * 輸出  :無
 */
static void DHT11_Mode_Out_PP(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;

        /*選擇要控制的DHT11_Dout_GPIO_PORT引腳*/
    GPIO_InitStructure.GPIO_Pin = DHT11_Dout_GPIO_PIN;

    /*設置引腳模式為通用推挽輸出*/
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;;

    /*設置上下拉*/
    //GPIO_InitStructure.Pull = GPIO_NOPULL;

    /*設置引腳速率為50MHz */
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    /*調用庫函數,初始化DHT11_Dout_GPIO_PORT*/
     GPIO_Init(DHT11_Dout_GPIO_PORT, &GPIO_InitStructure);

}


/*
 * 從DHT11讀取一個字節,MSB先行
 */
static uint8_t DHT11_ReadByte ( void )
{
    uint8_t i, temp=0;


    for(i=0;i<8;i++)
    {
        /*每bit以50us低電平標置開始,輪詢直到從機發出 的50us 低電平 結束*/
        while(DHT11_Dout_IN()==GPIO_PIN_RESET);

        /*DHT11 以26~28us的高電平表示“0”,以70us高電平表示“1”,
         *通過檢測 x us后的電平即可區別這兩個狀 ,x 即下面的延時
         */
        DHT11_DELAY_US(40); //延時x us 這個延時需要大于數據0持續的時間即可

        if(DHT11_Dout_IN()==GPIO_PIN_SET)/* x us后仍為高電平表示數據“1” */
        {
            /* 等待數據1的高電平結束 */
            while(DHT11_Dout_IN()==GPIO_PIN_SET);

            temp|=(uint8_t)(0x01<<(7-i));  //把第7-i位置1,MSB先行
        }
        else     // x us后為低電平表示數據“0”
        {
            temp&=(uint8_t)~(0x01<<(7-i)); //把第7-i位置0,MSB先行
        }
    }

    return temp;

}


/*
 * 一次完整的數據傳輸為40bit,高位先出
 * 8bit 濕度整數 + 8bit 濕度小數 + 8bit 溫度整數 + 8bit 溫度小數 + 8bit 校驗和
 */
uint8_t DHT11_Read_TempAndHumidity(DHT11_Data_TypeDef *DHT11_Data)
{
    /*輸出模式*/
    DHT11_Mode_Out_PP();
    /*主機拉低*/
    DHT11_Dout_0;
    /*延時18ms*/
    DHT11_DELAY_MS(18);

    /*總線拉高 主機延時30us*/
    DHT11_Dout_1;

    DHT11_DELAY_US(30);   //延時30us

    /*主機設為輸入 判斷從機響應信號*/
    DHT11_Mode_IPU();

    /*判斷從機是否有低電平響應信號 如不響應則跳出,響應則向下運行*/
    if(DHT11_Dout_IN()==GPIO_PIN_RESET)
    {
        /*輪詢直到從機發出 的80us 低電平 響應信號結束*/
        while(DHT11_Dout_IN()==GPIO_PIN_RESET);

        /*輪詢直到從機發出的 80us 高電平 標置信號結束*/
        while(DHT11_Dout_IN()==GPIO_PIN_SET);

        /*開始接收數據*/
        DHT11_Data->humi_int= DHT11_ReadByte();

        DHT11_Data->humi_deci= DHT11_ReadByte();

        DHT11_Data->temp_int= DHT11_ReadByte();

        DHT11_Data->temp_deci= DHT11_ReadByte();

        DHT11_Data->check_sum= DHT11_ReadByte();


        /*讀取結束,引腳改為輸出模式*/
        DHT11_Mode_Out_PP();
        /*主機拉高*/
        DHT11_Dout_1;

        /*檢查讀取的數據是否正確*/
        if(DHT11_Data->check_sum == DHT11_Data->humi_int + DHT11_Data->humi_deci + DHT11_Data->temp_int+ DHT11_Data->temp_deci)
            return SUCCESS;
        else
            return ERROR;
    }

    else
        return ERROR;

}


/*
 * oled.c
 *
 */

#include "oled.h"
#include "stdlib.h"
#include "oledfont.h"

//extern SPI_HandleTypeDef hspi3;
u8 OLED_GRAM[144][8];

//發送函數
#ifdef HardwareSPI


void OLED_WR_Byte(u8 dat,u8 cmd)
{

    if(cmd)
      OLED_DC_Set();
    else
      OLED_DC_Clr();
      OLED_CS_Clr();
#ifdef HALLibrary
      HAL_SPI_Transmit(&hspi3,&dat,1,1000);
#else

         SPI_I2S_SendData( SPI1, dat );

#endif

      OLED_CS_Set();
      OLED_DC_Set();
}
#else
void OLED_WR_Byte(u8 dat,u8 cmd)
{
    u8 i;
    if(cmd)
      OLED_DC_Set();
    else
      OLED_DC_Clr();
      OLED_CS_Clr();
    for(i=0;i<8;i++)
    {
           OLED_SCLK_Clr();
        if(dat&0x80)
           OLED_SDIN_Set();
        else
           OLED_SDIN_Clr();
           OLED_SCLK_Set();
           dat<<=1;

    }
    OLED_CS_Set();
    OLED_DC_Set();
}


#endif

//反顯函數
void OLED_ColorTurn(u8 i)
{
    if(i==0)
        {
            OLED_WR_Byte(0xA6,OLED_CMD);//正常顯示
        }
    if(i==1)
        {
            OLED_WR_Byte(0xA7,OLED_CMD);//反色顯示
        }
}

//屏幕旋轉180度
void OLED_DisplayTurn(u8 i)
{
    if(i==0)
        {
            OLED_WR_Byte(0xC8,OLED_CMD);//正常顯示
            OLED_WR_Byte(0xA1,OLED_CMD);
        }
    if(i==1)
        {
            OLED_WR_Byte(0xC0,OLED_CMD);//反轉顯示
            OLED_WR_Byte(0xA0,OLED_CMD);
        }
}


//開啟OLED顯示
void OLED_DisPlay_On(void)
{
    OLED_WR_Byte(0x8D,OLED_CMD);//電荷泵使能
    OLED_WR_Byte(0x14,OLED_CMD);//開啟電荷泵
    OLED_WR_Byte(0xAF,OLED_CMD);//點亮屏幕
}

//關閉OLED顯示
void OLED_DisPlay_Off(void)
{
    OLED_WR_Byte(0x8D,OLED_CMD);//電荷泵使能
    OLED_WR_Byte(0x10,OLED_CMD);//關閉電荷泵
    OLED_WR_Byte(0xAF,OLED_CMD);//關閉屏幕
}

//更新顯存到OLED
void OLED_Refresh(void)
{
    u8 i,n;
    for(i=0;i<8;i++)
    {
       OLED_WR_Byte(0xb0+i,OLED_CMD); //設置行起始地址
       OLED_WR_Byte(0x00,OLED_CMD);   //設置低列起始地址
       OLED_WR_Byte(0x10,OLED_CMD);   //設置高列起始地址
       for(n=0;n<128;n++)
         OLED_WR_Byte(OLED_GRAM[n][i],OLED_DATA);
  }
}
//清屏函數
void OLED_Clear(void)
{
    u8 i,n;
    for(i=0;i<8;i++)
    {
       for(n=0;n<128;n++)
            {
             OLED_GRAM[n][i]=0;//清除所有數據
            }
  }
    OLED_Refresh();//更新顯示
}

//畫點
//x:0~127
//y:0~63
void OLED_DrawPoint(u8 x,u8 y)
{
    u8 i,m,n;
    i=y/8;
    m=y%8;
    n=1<<m;
    OLED_GRAM[x][i]|=n;
}

//清除一個點
//x:0~127
//y:0~63
void OLED_ClearPoint(u8 x,u8 y)
{
    u8 i,m,n;
    i=y/8;
    m=y%8;
    n=1<<m;
    OLED_GRAM[x][i]=~OLED_GRAM[x][i];
    OLED_GRAM[x][i]|=n;
    OLED_GRAM[x][i]=~OLED_GRAM[x][i];
}

//畫線
//x:0~128
//y:0~64
void OLED_DrawLine(u8 x1,u8 y1,u8 x2,u8 y2)
{
    u8 i,k,k1,k2;
    if((x1<0)||(x2>128)||(y1<0)||(y2>64)||(x1>x2)||(y1>y2))
        return;
    if(x1==x2)    //畫豎線
    {
            for(i=0;i<(y2-y1);i++)
            {
                OLED_DrawPoint(x1,y1+i);
            }
  }
    else if(y1==y2)   //畫橫線
    {
            for(i=0;i<(x2-x1);i++)
            {
                OLED_DrawPoint(x1+i,y1);
            }
  }
    else      //畫斜線
    {
        k1=y2-y1;
        k2=x2-x1;
        k=k1*10/k2;
        for(i=0;i<(x2-x1);i++)
            {
              OLED_DrawPoint(x1+i,y1+i*k/10);
            }
    }
}
//x,y:圓心坐標
//r:圓的半徑
void OLED_DrawCircle(u8 x,u8 y,u8 r)
{
    int a, b,num;
    a = 0;
    b = r;
    while(2 * b * b >= r * r)
    {
        OLED_DrawPoint(x + a, y - b);
        OLED_DrawPoint(x - a, y - b);
        OLED_DrawPoint(x - a, y + b);
        OLED_DrawPoint(x + a, y + b);

        OLED_DrawPoint(x + b, y + a);
        OLED_DrawPoint(x + b, y - a);
        OLED_DrawPoint(x - b, y - a);
        OLED_DrawPoint(x - b, y + a);

        a++;
        num = (a * a + b * b) - r*r;//計算畫的點離圓心的距離
        if(num > 0)
        {
            b--;
            a--;
        }
    }
}



//在指定位置顯示一個字符,包括部分字符
//x:0~127
//y:0~63
//size:選擇字體 12/16/24
void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 size1)
{
    u8 i,m,temp,size2,chr1;
    u8 y0=y;
    size2=(size1/8+((size1%8)?1:0))*(size1/2);  //得到字體一個字符對應點陣集所占的字節數
    chr1=chr-' ';  //計算偏移后的值
    for(i=0;i<size2;i++)
    {
        if(size1==12)
        {temp=asc2_1206[chr1][i];} //調用1206字體
        else if(size1==16)
        {temp=asc2_1608[chr1][i];} //調用1608字體
        else if(size1==24)
        {temp=asc2_2412[chr1][i];} //調用2412字體
        else return;
                for(m=0;m<8;m++)           //寫入數據
                {
                    if(temp&0x80)OLED_DrawPoint(x,y);
                    else OLED_ClearPoint(x,y);
                    temp<<=1;
                    y++;
                    if((y-y0)==size1)
                    {
                        y=y0;
                        x++;
                        break;
          }
                }
  }
}


//顯示字符串
//x,y:起點坐標
//size1:字體大小
//*chr:字符串起始地址
void OLED_ShowString(u8 x,u8 y,u8 *chr,u8 size1)
{
    while((*chr>=' ')&&(*chr<='~'))//判斷是不是非法字符!
    {
        OLED_ShowChar(x,y,*chr,size1);
        x+=size1/2;
        if(x>128-size1)  //換行
        {
            x=0;
            y+=2;
    }
        chr++;
  }
}

//m^n
u32 OLED_Pow(u8 m,u8 n)
{
    u32 result=1;
    while(n--)
    {
      result*=m;
    }
    return result;
}

////顯示數字
////x,y :起點坐標
////len :數字的位數
////size:字體大小
void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size1)
{
    u8 t,temp;
    for(t=0;t<len;t++)
    {
        temp=(num/OLED_Pow(10,len-t-1))%10;
            if(temp==0)
            {
                OLED_ShowChar(x+(size1/2)*t,y,'0',size1);
      }
            else
            {
              OLED_ShowChar(x+(size1/2)*t,y,temp+'0',size1);
            }
  }
}


//z_len為整數顯示位數,f_len為小數顯示位數,size2為字體大小
void OLED_Showdecimal(u8 x,u8 y,float num,u8 z_len,u8 f_len,u8 size2)
{
    u8 t,temp;
    u8 enshow;
    int z_temp,f_temp;
    z_temp=(int)num;
    //整數部分
    for(t=0;t<z_len;t++)
    {
        temp=(z_temp/OLED_Pow(10,z_len-t-1))%10;
        if(enshow==0 && t<(z_len-1))
        {
            if(temp==0)
            {
                OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
                continue;
            }
            else
            enshow=1;
        }
        OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
    }
    //小數點
    OLED_ShowChar(x+(size2/2)*(z_len),y,'.',size2);

    f_temp=(int)((num-z_temp)*(OLED_Pow(10,f_len)));
  //小數部分
    for(t=0;t<f_len;t++)
    {
        temp=(f_temp/OLED_Pow(10,f_len-t-1))%10;
        OLED_ShowChar(x+(size2/2)*(t+z_len)+5,y,temp+'0',size2);
    }
}
//顯示漢字
//x,y:起點坐標
//array:調用的漢字數組
//num:漢字對應的序號
//size1:字號
void OLED_ShowChinese(u8 x,u8 y,u8 num,u8 size1)
{
    u8 i,m,n=0,temp,chr1;
    u8 x0=x,y0=y;
    u8 size3=size1/8;
    while(size3--)
    {
        chr1=num*size1/8+n;
        n++;
            for(i=0;i<size1;i++)
            {
                if(size1==16)
                        {temp=COAlarm16[chr1][i];}//調用16*16字體
                else if(size1==24)
                        {temp=InitMSG24[chr1][i];}//調用24*24字體
//              else if(size1==32)
//                      {temp=array[chr1][i];}//調用32*32字體
//              else if(size1==64)
//                      {temp=array[chr1][i];}//調用64*64字體
                else return;

                        for(m=0;m<8;m++)
                            {
                                if(temp&0x01)OLED_DrawPoint(x,y);
                                else OLED_ClearPoint(x,y);
                                temp>>=1;
                                y++;
                            }
                            x++;
                            if((x-x0)==size1)
                            {x=x0;y0=y0+8;}
                            y=y0;
             }
    }
}

//num 顯示漢字的個數
//space 每一遍顯示的間隔
void OLED_ScrollDisplay(u8 num,u8 space)
{
    u8 i,n,t=0,m=0,r;
    while(1)
    {
        if(m==0)
        {
        OLED_ShowChinese(128,24,t,16); //寫入一個漢字保存在OLED_GRAM[][]數組中
            t++;
        }
        if(t==num)
            {
                for(r=0;r<16*space;r++)      //顯示間隔
                 {
                    for(i=0;i<144;i++)
                        {
                            for(n=0;n<8;n++)
                            {
                                OLED_GRAM[i-1][n]=OLED_GRAM[i][n];
                            }
                        }
           OLED_Refresh();
                 }
        t=0;
      }
        m++;
        if(m==16){m=0;}
        for(i=0;i<144;i++)   //實現左移
        {
            for(n=0;n<8;n++)
            {
                OLED_GRAM[i-1][n]=OLED_GRAM[i][n];
            }
        }
        OLED_Refresh();
    }
}

//配置寫入數據的起始位置
void OLED_WR_BP(u8 x,u8 y)
{
    OLED_WR_Byte(0xb0+y,OLED_CMD);//設置行起始地址
    OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);
    OLED_WR_Byte((x&0x0f)|0x01,OLED_CMD);
}

//x0,y0:起點坐標
//x1,y1:終點坐標
//BMP[]:要寫入的圖片數組
void OLED_ShowPicture(u8 x0,u8 y0,u8 x1,u8 y1,u8 BMP[])
{
    u32 j=0;
    u8 x=0,y=0;
    if(y%8==0)y=0;
    else y+=1;
    for(y=y0;y<y1;y++)
     {
         OLED_WR_BP(x0,y);
         for(x=x0;x<x1;x++)
         {
             OLED_WR_Byte(BMP[j],OLED_DATA);
             j++;
     }
     }
}
//OLED的初始化
void OLED_Init(void)
{


    OLED_RST_Clr();
#ifdef HALLibrary
    HAL_Delay(200);
#else
    Delay_Ms(200);
#endif
    OLED_RST_Set();

    OLED_WR_Byte(0xAE,OLED_CMD);//--turn off oled panel
    OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
    OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
    OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
    OLED_WR_Byte(0x81,OLED_CMD);//--set contrast control register
    OLED_WR_Byte(0xCF,OLED_CMD);// Set SEG Output Current Brightness
    OLED_WR_Byte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
    OLED_WR_Byte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
    OLED_WR_Byte(0xA6,OLED_CMD);//--set normal display
    OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
    OLED_WR_Byte(0x3f,OLED_CMD);//--1/64 duty
    OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset   Shift Mapping RAM Counter (0x00~0x3F)
    OLED_WR_Byte(0x00,OLED_CMD);//-not offset
    OLED_WR_Byte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
    OLED_WR_Byte(0x80,OLED_CMD);//--set divide ratio, Set Clock as 100 Frames/Sec
    OLED_WR_Byte(0xD9,OLED_CMD);//--set pre-charge period
    OLED_WR_Byte(0xF1,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
    OLED_WR_Byte(0xDA,OLED_CMD);//--set com pins hardware configuration
    OLED_WR_Byte(0x12,OLED_CMD);
    OLED_WR_Byte(0xDB,OLED_CMD);//--set vcomh
    OLED_WR_Byte(0x40,OLED_CMD);//Set VCOM Deselect Level
    OLED_WR_Byte(0x20,OLED_CMD);//-Set Page Addressing Mode (0x00/0x01/0x02)
    OLED_WR_Byte(0x02,OLED_CMD);//
    OLED_WR_Byte(0x8D,OLED_CMD);//--set Charge Pump enable/disable
    OLED_WR_Byte(0x14,OLED_CMD);//--set(0x10) disable
    OLED_WR_Byte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
    OLED_WR_Byte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7)
    OLED_WR_Byte(0xAF,OLED_CMD);
    OLED_Clear();
}


/*
 * oled.h
 *

 */

#ifndef OLED_OLED_H_
#define OLED_OLED_H_

//#include "main.h"
#include "ch32v10x.h"
#include "math.h"
#define HardwareSPI
//-----------------測試LED端口定義----------------

#define LED_ON       HAL_GPIO_WritePin(LD2_GPIO_Port,LD2_Pin, GPIO_PIN_RESET)
#define LED_OFF      HAL_GPIO_WritePin(LD2_GPIO_Port,LD2_Pin, GPIO_PIN_SET)

#define          RES_GPIO_Port          GPIOA
#define          RES_Pin                GPIO_Pin_10

#define          DC_GPIO_Port           GPIOA
#define          DC_Pin                 GPIO_Pin_12

#define          CS_GPIO_Port           GPIOA
#define          CS_Pin                 GPIO_Pin_11



//-----------------OLED端口定義----------------
//如果定義HardwareSPI就用硬件SPI.
#ifndef HardwareSPI
/*
#define OLED_SCLK_Clr() HAL_GPIO_WritePin(GPIOC,GPIO_PIN_10, GPIO_PIN_RESET)//CLK
#define OLED_SCLK_Set() HAL_GPIO_WritePin(GPIOC,GPIO_PIN_10, GPIO_PIN_SET)

#define OLED_SDIN_Clr() HAL_GPIO_WritePin(GPIOC,GPIO_PIN_12, GPIO_PIN_RESET)//DIN
#define OLED_SDIN_Set() HAL_GPIO_WritePin(GPIOC,GPIO_PIN_12, GPIO_PIN_SET)
*/
#endif

//如果定義HALLibrary就用HAL庫,
#ifdef HALLibrary
#define OLED_RST_Clr() HAL_GPIO_WritePin(RES_GPIO_Port,RES_Pin, GPIO_PIN_RESET)//RST
#define OLED_RST_Set() HAL_GPIO_WritePin(RES_GPIO_Port,RES_Pin, GPIO_PIN_SET)

#define OLED_DC_Clr() HAL_GPIO_WritePin(DC_GPIO_Port,DC_Pin, GPIO_PIN_RESET)//DC
#define OLED_DC_Set() HAL_GPIO_WritePin(DC_GPIO_Port,DC_Pin, GPIO_PIN_SET)

#define OLED_CS_Clr()  HAL_GPIO_WritePin(CS_GPIO_Port,CS_Pin, GPIO_PIN_RESET)//CS
#define OLED_CS_Set()  HAL_GPIO_WritePin(CS_GPIO_Port,CS_Pin, GPIO_PIN_SET)

#else

#define OLED_RST_Clr() GPIO_ResetBits(RES_GPIO_Port,RES_Pin)//RST
#define OLED_RST_Set() GPIO_SetBits(RES_GPIO_Port,RES_Pin)

#define OLED_DC_Clr()  GPIO_ResetBits(DC_GPIO_Port,DC_Pin)//DC
#define OLED_DC_Set()  GPIO_SetBits(DC_GPIO_Port,DC_Pin)

#define OLED_CS_Clr()  GPIO_ResetBits(CS_GPIO_Port,CS_Pin)//CS
#define OLED_CS_Set()  GPIO_SetBits(CS_GPIO_Port,CS_Pin)
#endif



#define OLED_CMD  0 //寫命令
#define OLED_DATA 1 //寫數據
#define u8 unsigned char
#define u32 unsigned int

void OLED_ClearPoint(u8 x,u8 y);
void OLED_ColorTurn(u8 i);
void OLED_DisplayTurn(u8 i);
void OLED_WR_Byte(u8 dat,u8 mode);
void OLED_DisPlay_On(void);
void OLED_DisPlay_Off(void);
void OLED_Refresh(void);
void OLED_Clear(void);
void OLED_DrawPoint(u8 x,u8 y);
void OLED_DrawLine(u8 x1,u8 y1,u8 x2,u8 y2);
void OLED_DrawCircle(u8 x,u8 y,u8 r);
void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 size1);
void OLED_ShowString(u8 x,u8 y,u8 *chr,u8 size1);
void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size1);
void OLED_Showdecimal(u8 x,u8 y,float num,u8 z_len,u8 f_len,u8 size2);
void OLED_ShowChinese(u8 x,u8 y,u8 num,u8 size1);
void OLED_ScrollDisplay(u8 num,u8 space);
void OLED_WR_BP(u8 x,u8 y);
void OLED_ShowPicture(u8 x0,u8 y0,u8 x1,u8 y1,u8 BMP[]);
void OLED_Init(void);

#endif /* OLED_OLED_H_ */

/*
 * oledfont.h
 *

 */

#ifndef OLED_OLEDFONT_H_
#define OLED_OLEDFONT_H_

//常用ASCII表
//偏移量32
//ASCII字符集
//偏移量32
//大小:12*6
/************************************6*8的點陣************************************/
//12*12 ASCII字符集點陣
const unsigned char asc2_1206[95][12]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x3F,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/
{0x09,0x00,0x0B,0xC0,0x3D,0x00,0x0B,0xC0,0x3D,0x00,0x09,0x00},/*"#",3*/
{0x18,0xC0,0x24,0x40,0x7F,0xE0,0x22,0x40,0x31,0x80,0x00,0x00},/*"$",4*/
{0x18,0x00,0x24,0xC0,0x1B,0x00,0x0D,0x80,0x32,0x40,0x01,0x80},/*"%",5*/
{0x03,0x80,0x1C,0x40,0x27,0x40,0x1C,0x80,0x07,0x40,0x00,0x40},/*"&",6*/
{0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x40,0x20},/*"(",8*/
{0x00,0x00,0x40,0x20,0x20,0x40,0x1F,0x80,0x00,0x00,0x00,0x00},/*")",9*/
{0x09,0x00,0x06,0x00,0x1F,0x80,0x06,0x00,0x09,0x00,0x00,0x00},/*"*",10*/
{0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x00,0x00},/*"+",11*/
{0x00,0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x20,0x01,0xC0,0x06,0x00,0x38,0x00,0x40,0x00,0x00,0x00},/*"/",15*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"0",16*/
{0x00,0x00,0x10,0x40,0x3F,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"1",17*/
{0x18,0xC0,0x21,0x40,0x22,0x40,0x24,0x40,0x18,0x40,0x00,0x00},/*"2",18*/
{0x10,0x80,0x20,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"3",19*/
{0x02,0x00,0x0D,0x00,0x11,0x00,0x3F,0xC0,0x01,0x40,0x00,0x00},/*"4",20*/
{0x3C,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x23,0x80,0x00,0x00},/*"5",21*/
{0x1F,0x80,0x24,0x40,0x24,0x40,0x34,0x40,0x03,0x80,0x00,0x00},/*"6",22*/
{0x30,0x00,0x20,0x00,0x27,0xC0,0x38,0x00,0x20,0x00,0x00,0x00},/*"7",23*/
{0x1B,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"8",24*/
{0x1C,0x00,0x22,0xC0,0x22,0x40,0x22,0x40,0x1F,0x80,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40},/*"<",28*/
{0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x00,0x00},/*"=",29*/
{0x00,0x00,0x40,0x40,0x20,0x80,0x11,0x00,0x0A,0x00,0x04,0x00},/*">",30*/
{0x18,0x00,0x20,0x00,0x23,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"?",31*/
{0x1F,0x80,0x20,0x40,0x27,0x40,0x29,0x40,0x1F,0x40,0x00,0x00},/*"@",32*/
{0x00,0x40,0x07,0xC0,0x39,0x00,0x0F,0x00,0x01,0xC0,0x00,0x40},/*"A",33*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"B",34*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x80,0x00,0x00},/*"C",35*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"D",36*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x40,0x30,0xC0,0x00,0x00},/*"E",37*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x00,0x30,0x00,0x00,0x00},/*"F",38*/
{0x0F,0x00,0x10,0x80,0x20,0x40,0x22,0x40,0x33,0x80,0x02,0x00},/*"G",39*/
{0x20,0x40,0x3F,0xC0,0x04,0x00,0x04,0x00,0x3F,0xC0,0x20,0x40},/*"H",40*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x00,0x00},/*"I",41*/
{0x00,0x60,0x20,0x20,0x20,0x20,0x3F,0xC0,0x20,0x00,0x20,0x00},/*"J",42*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x0B,0x00,0x30,0xC0,0x20,0x40},/*"K",43*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,0x00,0xC0},/*"L",44*/
{0x3F,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x3F,0xC0,0x00,0x00},/*"M",45*/
{0x20,0x40,0x3F,0xC0,0x0C,0x40,0x23,0x00,0x3F,0xC0,0x20,0x00},/*"N",46*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"O",47*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"P",48*/
{0x1F,0x80,0x21,0x40,0x21,0x40,0x20,0xE0,0x1F,0xA0,0x00,0x00},/*"Q",49*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x26,0x00,0x19,0xC0,0x00,0x40},/*"R",50*/
{0x18,0xC0,0x24,0x40,0x24,0x40,0x22,0x40,0x31,0x80,0x00,0x00},/*"S",51*/
{0x30,0x00,0x20,0x40,0x3F,0xC0,0x20,0x40,0x30,0x00,0x00,0x00},/*"T",52*/
{0x20,0x00,0x3F,0x80,0x00,0x40,0x00,0x40,0x3F,0x80,0x20,0x00},/*"U",53*/
{0x20,0x00,0x3E,0x00,0x01,0xC0,0x07,0x00,0x38,0x00,0x20,0x00},/*"V",54*/
{0x38,0x00,0x07,0xC0,0x3C,0x00,0x07,0xC0,0x38,0x00,0x00,0x00},/*"W",55*/
{0x20,0x40,0x39,0xC0,0x06,0x00,0x39,0xC0,0x20,0x40,0x00,0x00},/*"X",56*/
{0x20,0x00,0x38,0x40,0x07,0xC0,0x38,0x40,0x20,0x00,0x00,0x00},/*"Y",57*/
{0x30,0x40,0x21,0xC0,0x26,0x40,0x38,0x40,0x20,0xC0,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x7F,0xE0,0x40,0x20,0x40,0x20,0x00,0x00},/*"[",59*/
{0x00,0x00,0x70,0x00,0x0C,0x00,0x03,0x80,0x00,0x40,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x20,0x40,0x20,0x7F,0xE0,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x20,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10},/*"_",63*/
{0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x02,0x80,0x05,0x40,0x05,0x40,0x03,0xC0,0x00,0x40},/*"a",65*/
{0x20,0x00,0x3F,0xC0,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"b",66*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x06,0x40,0x00,0x00},/*"c",67*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x24,0x40,0x3F,0xC0,0x00,0x40},/*"d",68*/
{0x00,0x00,0x03,0x80,0x05,0x40,0x05,0x40,0x03,0x40,0x00,0x00},/*"e",69*/
{0x00,0x00,0x04,0x40,0x1F,0xC0,0x24,0x40,0x24,0x40,0x20,0x00},/*"f",70*/
{0x00,0x00,0x02,0xE0,0x05,0x50,0x05,0x50,0x06,0x50,0x04,0x20},/*"g",71*/
{0x20,0x40,0x3F,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"h",72*/
{0x00,0x00,0x04,0x40,0x27,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x10,0x00,0x10,0x04,0x10,0x27,0xE0,0x00,0x00,0x00,0x00},/*"j",74*/
{0x20,0x40,0x3F,0xC0,0x01,0x40,0x07,0x00,0x04,0xC0,0x04,0x40},/*"k",75*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x00,0x40,0x00,0x40,0x00,0x00},/*"l",76*/
{0x07,0xC0,0x04,0x00,0x07,0xC0,0x04,0x00,0x03,0xC0,0x00,0x00},/*"m",77*/
{0x04,0x40,0x07,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"n",78*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"o",79*/
{0x04,0x10,0x07,0xF0,0x04,0x50,0x04,0x40,0x03,0x80,0x00,0x00},/*"p",80*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x50,0x07,0xF0,0x00,0x10},/*"q",81*/
{0x04,0x40,0x07,0xC0,0x02,0x40,0x04,0x00,0x04,0x00,0x00,0x00},/*"r",82*/
{0x00,0x00,0x06,0x40,0x05,0x40,0x05,0x40,0x04,0xC0,0x00,0x00},/*"s",83*/
{0x00,0x00,0x04,0x00,0x1F,0x80,0x04,0x40,0x00,0x40,0x00,0x00},/*"t",84*/
{0x04,0x00,0x07,0x80,0x00,0x40,0x04,0x40,0x07,0xC0,0x00,0x40},/*"u",85*/
{0x04,0x00,0x07,0x00,0x04,0xC0,0x01,0x80,0x06,0x00,0x04,0x00},/*"v",86*/
{0x06,0x00,0x01,0xC0,0x07,0x00,0x01,0xC0,0x06,0x00,0x00,0x00},/*"w",87*/
{0x04,0x40,0x06,0xC0,0x01,0x00,0x06,0xC0,0x04,0x40,0x00,0x00},/*"x",88*/
{0x04,0x10,0x07,0x10,0x04,0xE0,0x01,0x80,0x06,0x00,0x04,0x00},/*"y",89*/
{0x00,0x00,0x04,0x40,0x05,0xC0,0x06,0x40,0x04,0x40,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x04,0x00,0x7B,0xE0,0x40,0x20,0x00,0x00},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/
};
//16*16 ASCII字符集點陣
const unsigned char asc2_1608[95][16]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/
{0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00},/*"#",3*/
{0x00,0x00,0x0E,0x18,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00,0x00,0x00},/*"$",4*/
{0x0F,0x00,0x10,0x84,0x0F,0x38,0x00,0xC0,0x07,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/
{0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x24,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/
{0x08,0x00,0x68,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x20,0x04,0x40,0x02,0x00,0x00},/*"(",8*/
{0x00,0x00,0x40,0x02,0x20,0x04,0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/
{0x02,0x40,0x02,0x40,0x01,0x80,0x0F,0xF0,0x01,0x80,0x02,0x40,0x02,0x40,0x00,0x00},/*"*",10*/
{0x00,0x80,0x00,0x80,0x00,0x80,0x0F,0xF8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00},/*"+",11*/
{0x00,0x01,0x00,0x0D,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"-",13*/
{0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00},/*"/",15*/
{0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/
{0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1",17*/
{0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2",18*/
{0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3",19*/
{0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4",20*/
{0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/
{0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6",22*/
{0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7",23*/
{0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8",24*/
{0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44

演示效果

b站網址

https://www.bilibili.com/video/BV1TZ4y1X7ZV?spm_id_from=333.999.0.0

附件

(0.97 MB)下載

評論區(0 )
主站蜘蛛池模板: 艳鉧动漫片1~6全集在线| 动漫H片在线播放免费高清| 国产精品女上位好爽在线短片| 色橹| 国产精品禁18久久久夂久| 亚洲精品沙发午睡系列| 久久只精品99品免费久| www.色小姐| 亚洲高清无在码在线电影| 快乐激情站| 成人精品视频网站| 亚洲精品色播一区二区| 老鸭窝毛片| 电影 qvod| 亚洲最大成人| 青青草伊人久久| 国产午夜永久福利视频在线观看| 18禁无遮遮挡羞漫画免费阅读 | 99国产精品白浆在线观看免费| 日本夜夜夜| 吉吉影音先锋av资源| old老男人野外树林tv| 小鸟酱喷水| 女人久久WWW免费人成看片| 国产偷国产偷亚洲高清SWAG | 亚洲 日韩 在线 国产 视频| 啦啦啦 中国 日本 高清 在线| 成人性生交大片免费看中文| 亚洲一区免费在线观看| 日韩国产精品欧美一区二区| 久久免费视频1| 国产精品人成视频免费999| 97SE亚洲国产综合自在线不卡| 午夜国产福利| 欧美一区二区视频在线观看 | 国产女合集第六部| 99热在线精品免费全部my| 亚洲精品午夜aaa级久久久久| 热re99久久精品国99热| 久青草国产97香蕉在线视频| 国产熟妇无码一区二|