2022-01-18 00:58:54 +08:00

532 lines
18 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*********************************************************************************************************************
* COPYRIGHT NOTICE
* Copyright (c) 2020,<2C><><EFBFBD>ɿƼ<C9BF>
* All rights reserved.
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<51><C8BA><EFBFBD><EFBFBD>Ⱥ<EFBFBD><C8BA>824575535
*
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>;<EFBFBD><CDBE>
* <20><>ӭ<EFBFBD><D3AD>λʹ<CEBB>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC>İ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @file OLED
* @company <09>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD>޹<EFBFBD>˾
* @author <09><><EFBFBD>ɿƼ<C9BF>(QQ3184284598)
* @version <09>鿴doc<6F><63>version<6F>ļ<EFBFBD> <20>汾˵<E6B1BE><CBB5>
* @Software ADS v1.2.2
* @Target core TC264D
* @Taobao https://seekfree.taobao.com/
* @date 2020-3-23
* @note
<09><><EFBFBD>߶<EFBFBD><DFB6>
------------------------------------
OLEDҺ<44><D2BA> <20><>Ƭ<EFBFBD><C6AC>
D0 <09>鿴SEEKFREE_OLED<45>ļ<EFBFBD><C4BC>ڵ<EFBFBD>OLED_SCL_PIN <20><EFBFBD><EAB6A8>
D1 <09>鿴SEEKFREE_OLED<45>ļ<EFBFBD><C4BC>ڵ<EFBFBD>OLED_SDA_PIN <20><EFBFBD><EAB6A8>
RES <09>鿴SEEKFREE_OLED<45>ļ<EFBFBD><C4BC>ڵ<EFBFBD>OLED_RST_PIN <20><EFBFBD><EAB6A8>
DC <09>鿴SEEKFREE_OLED<45>ļ<EFBFBD><C4BC>ڵ<EFBFBD>OLED_DC_PIN <20><EFBFBD><EAB6A8>
CS <09>鿴SEEKFREE_OLED<45>ļ<EFBFBD><C4BC>ڵ<EFBFBD>OLED_CS_PIN <20><EFBFBD><EAB6A8>
------------------------------------
********************************************************************************************************************/
#include "zf_assert.h"
#include "zf_gpio.h"
#include "zf_stm_systick.h"
#include "SEEKFREE_FONT.h"
#include "SEEKFREE_PRINTF.h"
#include "SEEKFREE_OLED.h"
#define OLED_SCL(x) gpio_set (OLED_SCL_PIN , x)
#define OLED_SDA(x) gpio_set (OLED_SDA_PIN , x)
#define OLED_RST(x) gpio_set (OLED_RST_PIN , x)
#define OLED_DC(x) gpio_set (OLED_DC_PIN , x)
#define OLED_CS(x) gpio_set (OLED_CS_PIN , x)
//-------------------------------------------------------------------------------------------------------------------
// @brief <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param void
// @return
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_wrdat(uint8 data)
{
uint8 i=8;
OLED_CS(0); //ʹ<><CAB9><EFBFBD>źŶˣ<C5B6><CBA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
OLED_DC(1);
OLED_SCL(0);
while(i--)
{
if(data&0x80){OLED_SDA(1);}
else{OLED_SDA(0);}
OLED_SCL(1);
OLED_SCL(0);
data<<=1;
}
OLED_CS(1); //ʹ<><CAB9><EFBFBD>źŶˣ<C5B6><CBA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param void
// @return
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_wr6dat(uint8 data)
{
uint8 i=6;
OLED_CS(0); //ʹ<><CAB9><EFBFBD>źŶˣ<C5B6><CBA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
OLED_DC(1);
OLED_SCL(0);
while(i--)
{
if(data&0x80){OLED_SDA(1);}
else{OLED_SDA(0);}
OLED_SCL(1);
OLED_SCL(0);
data<<=1;
}
OLED_CS(1); //ʹ<><CAB9><EFBFBD>źŶˣ<C5B6><CBA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param void
// @return
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_wrcmd(uint8 cmd)
{
uint8 i=8;
OLED_CS(0); //ʹ<><CAB9><EFBFBD>źŶˣ<C5B6><CBA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
OLED_DC(0);
OLED_SCL(0);;
while(i--)
{
if(cmd&0x80){OLED_SDA(1);}
else{OLED_SDA(0);}
OLED_SCL(1);
OLED_SCL(0);
cmd<<=1;
}
OLED_CS(1); //ʹ<><CAB9><EFBFBD>źŶˣ<C5B6><CBA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param void
// @return
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_hexascii(uint16 hex,int8 * Print)
{
uint8 hexcheck ;
uint8 TEMP ;
TEMP = 6 ;
Print[TEMP ]='\0';
while(TEMP)
{
TEMP -- ;
hexcheck = hex%10 ;
hex /=10 ;
Print[TEMP ] = hexcheck + 0x30 ;
}
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param NULL
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_init(void)
{
gpio_init (OLED_SCL_PIN, GPO,1,PUSHPULL);
gpio_init (OLED_SDA_PIN, GPO,0,PUSHPULL);
gpio_init (OLED_RST_PIN, GPO,1,PUSHPULL);
gpio_init (OLED_DC_PIN , GPO,1,PUSHPULL);
gpio_init (OLED_CS_PIN , GPO,1,PUSHPULL);
OLED_SCL(1);
OLED_RST(0);
systick_delay_ms(STM0, 50);
OLED_RST(1);
oled_wrcmd(0xae);//--turn off oled panel
oled_wrcmd(0x00);//---set low column address
oled_wrcmd(0x10);//---set high column address
oled_wrcmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
oled_wrcmd(0x81);//--set contrast control register
oled_wrcmd(Brightness); // Set SEG Output Current Brightness
#if (0 == OLED_DISPLAY_DIR)
oled_wrcmd(0xa1);//--Set SEG/Column Mapping 0xa0<61><30><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD> 0xa1<61><31><EFBFBD><EFBFBD>
oled_wrcmd(0xc8);//Set COM/Row Scan Direction 0xc0<63><30><EFBFBD>·<EFBFBD><C2B7><EFBFBD> 0xc8<63><38><EFBFBD><EFBFBD>
#else
oled_wrcmd(0xa0);//--Set SEG/Column Mapping 0xa0<61><30><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD> 0xa1<61><31><EFBFBD><EFBFBD>
oled_wrcmd(0xc0);//Set COM/Row Scan Direction 0xc0<63><30><EFBFBD>·<EFBFBD><C2B7><EFBFBD> 0xc8<63><38><EFBFBD><EFBFBD>
#endif
oled_wrcmd(0xa6);//--set normal display
oled_wrcmd(0xa8);//--set multiplex ratio(1 to 64)
oled_wrcmd(0x3f);//--1/64 duty
oled_wrcmd(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
oled_wrcmd(0x00);//-not offset
oled_wrcmd(0xd5);//--set display clock divide ratio/oscillator frequency
oled_wrcmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
oled_wrcmd(0xd9);//--set pre-charge period
oled_wrcmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
oled_wrcmd(0xda);//--set com pins hardware configuration
oled_wrcmd(0x12);
oled_wrcmd(0xdb);//--set vcomh
oled_wrcmd(0x40);//Set VCOM Deselect Level
oled_wrcmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
oled_wrcmd(0x02);//
oled_wrcmd(0x8d);//--set Charge Pump enable/disable
oled_wrcmd(0x14);//--set(0x10) disable
oled_wrcmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
oled_wrcmd(0xa6);// Disable Inverse Display On (0xa6/a7)
oled_wrcmd(0xaf);//--turn on oled panel
oled_fill(0x00); //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
oled_set_pos(0,0);
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_set_pos(uint8 x, uint8 y)
{
ZF_ASSERT(X_WIDTH>x); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
ZF_ASSERT((Y_WIDTH/8)>y);
oled_wrcmd(0xb0+y);
oled_wrcmd(((x&0xf0)>>4)|0x10);
oled_wrcmd((x&0x0f)|0x00);
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param bmp_data <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫѡ<C9AB><D1A1>(0x00 or 0xff)
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_fill(uint8 bmp_data)
{
uint8 y,x;
for(y=0;y<8;y++)
{
oled_wrcmd(0xb0+y);
oled_wrcmd(0x01);
oled_wrcmd(0x10);
for(x=0;x<X_WIDTH;x++) oled_wrdat(bmp_data);
}
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD><EFBFBD><EFBFBD>صĵ<D8B5><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϩ<EFBFBD><CFA8>
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @return void
// @since v1.0
// Sample usage: oled_putpixel(0,0,0xff);//<2F><>0,0<><30><EFBFBD><EFBFBD> 8<><38><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Sample usage: oled_putpixel(0,0,0x01);//<2F><>0,0<><30><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>7<EFBFBD><37>Ϩ<EFBFBD><CFA8>
// @note ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD><EFBFBD><EFBFBD>صĵ<D8B5><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϩ<EFBFBD><CFA8>
//-------------------------------------------------------------------------------------------------------------------
void oled_putpixel(uint8 x,uint8 y,uint8 data1)
{
oled_set_pos(x,y);
oled_wrcmd(0xb0+y);
oled_wrcmd(((x&0xf0)>>4)|0x10);
oled_wrcmd((x&0x0f)|0x00);
oled_wrdat(data1);
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45>ر<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_clrpixel(uint8 x,uint8 y)
{
oled_set_pos(x,y);
oled_wrcmd(0xb0+y);
oled_wrcmd(((x&0xf0)>>4)|0x10);
oled_wrcmd((x&0x0f)|0x00);
oled_wrdat(0x00);
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>(6*8<><38><EFBFBD><EFBFBD>)
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @param ch[] <20>ַ<EFBFBD><D6B7><EFBFBD>
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_p6x8str(uint8 x,uint8 y,const int8 ch[])
{
uint8 c=0,i=0,j=0;
while (ch[j]!='\0')
{
c =ch[j]-32;
if(x>126){x=0;y++;}
oled_set_pos(x,y);
for(i=0;i<6;i++) oled_wrdat(oled_6x8[c][i]);
x+=6;
j++;
}
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>(8*16<31><36><EFBFBD><EFBFBD>)
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @param ch[] <20>ַ<EFBFBD><D6B7><EFBFBD>
// @return void
// @since v1.0
// Sample usage: <09><><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>и<EFBFBD>λ16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><79><D3A6><EFBFBD><EFBFBD>ÿ<EFBFBD>ε<EFBFBD><CEB5><EFBFBD>2
//-------------------------------------------------------------------------------------------------------------------
void oled_p8x16str(uint8 x,uint8 y,const int8 ch[])
{
uint8 c=0,i=0,j=0;
while (ch[j]!='\0')
{
c =ch[j]-32;
if(x>120){x=0;y++;}
oled_set_pos(x,y);
for(i=0;i<8;i++) oled_wrdat(oled_8x16[c*16+i]);
oled_set_pos(x,y+1);
for(i=0;i<8;i++) oled_wrdat(oled_8x16[c*16+i+8]);
x+=8;
j++;
}
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ<EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>(6*8<><38><EFBFBD><EFBFBD>)
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @param num <20>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_uint16(uint8 x, uint8 y, uint16 num)
{
int8 ch[7];
oled_hexascii(num,ch);
oled_p6x8str(x, y, &ch[1]); //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> 6*8<><38><EFBFBD><EFBFBD>
//oled_p8x16str(x, y, &ch[1]); //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> 8*16<31><36><EFBFBD><EFBFBD>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ<EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>(6*8<><38><EFBFBD><EFBFBD>)
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @param num <20>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>
// @return void
// @since v1.0
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void oled_int16(uint8 x, uint8 y, int16 num)
{
int8 ch[7];
if(num<0) {num = -num;oled_p6x8str(x, y, "-");}
else oled_p6x8str(x, y, " ");
x+=6;
oled_hexascii(num,ch);
oled_p6x8str(x, y, &ch[1]); //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> 6*8<><38><EFBFBD><EFBFBD>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ32λ<32>з<EFBFBD><D0B7><EFBFBD><><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>0)
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @param dat <09><>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>uint32
// @param num <09><>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD><CABE>λ<EFBFBD><CEBB> <20><><EFBFBD><EFBFBD>10λ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @return void
// @since v1.0
// Sample usage: oled_printf_int32(0,0,x,5);//x<><78><EFBFBD><EFBFBD>Ϊint32 uint16 int16 uint8 int8<74><38><EFBFBD><EFBFBD>
// Sample usage: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾһ<CABE><D2BB> <20><>-<2D><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾһ<CABE><D2BB><EFBFBD>ո<EFBFBD>
//-------------------------------------------------------------------------------------------------------------------
void oled_printf_int32(uint16 x,uint16 y,int32 dat,uint8 num)
{
int8 buff[34];
uint32 length;
if(10<num) num = 10;
num++;
if(0>dat) length = zf_sprintf( &buff[0],"%d",dat);//<2F><><EFBFBD><EFBFBD>
else
{
buff[0] = ' ';
length = zf_sprintf( &buff[1],"%d",dat);
length++;
}
while(length < num)
{
buff[length] = ' ';
length++;
}
buff[num] = '\0';
oled_p6x8str((uint8)x, (uint8)y, buff); //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>0)
// @param x x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-127
// @param y y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7
// @param dat <09><>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>float<61><74>double
// @param num <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>10λ
// @param pointnum С<><D0A1>λ<EFBFBD><CEBB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
// @return void
// @since v1.0
// Sample usage: oled_printf_float(0,0,x,2,3);//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾС<><D0A1><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>λ
// @note <20>ر<EFBFBD>ע<EFBFBD><EFBFBD><E2B5B1><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD>µģ<C2B5><C4A3><EFBFBD><E2B2A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD>аٶ<D0B0>ѧϰ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾһ<CABE><D2BB> <20><>-<2D><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾһ<CABE><D2BB><EFBFBD>ո<EFBFBD>
//-------------------------------------------------------------------------------------------------------------------
void oled_printf_float(uint16 x,uint16 y,double dat,uint8 num,uint8 pointnum)
{
uint32 length;
int8 buff[34];
int8 start,end,point;
if(6<pointnum) pointnum = 6;
if(10<num) num = 10;
if(0>dat) length = zf_sprintf( &buff[0],"%f",dat);//<2F><><EFBFBD><EFBFBD>
else
{
length = zf_sprintf( &buff[1],"%f",dat);
length++;
}
point = (int8)(length - 7); //<2F><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
start = point - num - 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ
end = point + pointnum + 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
while(0>start)//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> ĩβӦ<CEB2><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>
{
buff[end] = ' ';
end++;
start++;
}
if(0>dat) buff[start] = '-';
else buff[start] = ' ';
buff[end] = '\0';
oled_p6x8str((uint8)x, (uint8)y, buff); //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
}
//-------------------------------------------------------------------------------------------------------------------
// @brief OLED<45><44>ʾͼ<CABE><CDBC>
// @param high ͼ<><CDBC><EFBFBD>߶<EFBFBD>
// @param width ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param *p ͼ<><CDBC><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
// @param value <09><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ֵ
// @return void
// @since v1.0
// Sample usage:
// @Note ʹ<><CAB9>Image2lcd V3.2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡģ C<><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˮƽɨ<C6BD><C9A8>
// <20><><EFBFBD>ȸ߶<C8B8><DFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ɫ<EFBFBD><C9AB>ת 256ɫ
//-------------------------------------------------------------------------------------------------------------------
void oled_dis_bmp(uint16 high, uint16 width, uint8 *p,uint8 value)
{
int16 i,j;
int16 temp,temp1;
uint8 dat;
temp1 = high%8;
if(temp1 == 0) temp = high/8;
else temp = high/8+1;
for(i=0; i<temp; i++)
{
oled_set_pos(0,(uint8)i);
for(j=0; j<width; j++)
{
dat = 0;
dat |= (*(p+i*8*width+j+width*0) > value? 1: 0)<<0;
if( i<(temp-1) || !temp1 || temp1>=2)dat |= (*(p+i*8*width+j+width*1) > value? 1: 0)<<1;
if( i<(temp-1) || !temp1 || temp1>=3)dat |= (*(p+i*8*width+j+width*2) > value? 1: 0)<<2;
if( i<(temp-1) || !temp1 || temp1>=4)dat |= (*(p+i*8*width+j+width*3) > value? 1: 0)<<3;
if( i<(temp-1) || !temp1 || temp1>=5)dat |= (*(p+i*8*width+j+width*4) > value? 1: 0)<<4;
if( i<(temp-1) || !temp1 || temp1>=6)dat |= (*(p+i*8*width+j+width*5) > value? 1: 0)<<5;
if( i<(temp-1) || !temp1 || temp1>=7)dat |= (*(p+i*8*width+j+width*6) > value? 1: 0)<<6;
if( i<(temp-1) || !temp1 || temp1>=8)dat |= (*(p+i*8*width+j+width*7) > value? 1: 0)<<7;
oled_wrdat(dat);
}
}
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
// @param x <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0-127
// @param y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0-7
// @param size ȡģ<C8A1><C4A3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>õĺ<C3B5><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>õĵ<C3B5><C4B5>󳤿<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ٸ<EFBFBD><D9B8>㣬ȡģ<C8A1><C4A3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ġ<EFBFBD>
// @param *p <20><>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param len <20><>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>λ
// @return void
// @since v1.0
// Sample usage:
// @Note ʹ<><CAB9>PCtoLCD2002<30><32><EFBFBD><EFBFBD>ȡģ <20><><EFBFBD><EFBFBD><EBA1A2><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>˳<EFBFBD><CBB3> 16*16
//-------------------------------------------------------------------------------------------------------------------
void oled_print_chinese(uint8 x, uint8 y, uint8 size, const uint8 *p, uint8 len)
{
int16 i,j,k;
for(i=0; i<len; i++)
{
for(j=0; j<(size/8); j++)
{
oled_set_pos(x+i*size,y+j);
for(k=0; k<16; k++)
{
oled_wrdat(*p);
p++;
}
}
}
}