#include "OLED.h"
#include "hal_iic.h"
#include "Map.h"
const IIC_PIN OLED_GPIO =
{
.SCL_PORT = IIC_SCL_GPIO_Port,
.SCL_PIN = IIC_SCL_Pin,
.SDA_PORT = IIC_SDA_GPIO_Port,
.SDA_PIN = IIC_SDA_Pin,
.DelayTick = 1,
.ADDR = 0x78
};
OLED_Refresh OLED_Refresh_Flag = {0};
OLED_Refresh_Word1 OLED_Refresh_Word1_Flag = {0};
OLED_Refresh_Word2 OLED_Refresh_Word2_Flag = {0};
uint8_t OLED_Page = 0;
void OLED_init(void)
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
Oled_Open();
IIC_Init(&OLED_GPIO);
OledCS_Set();
OledCS_Clr();
OledCS_Set();
OLED_send_byte(0xae, OLED_CMD);
OLED_send_byte(0x00, OLED_CMD);
OLED_send_byte(0x10, OLED_CMD);
OLED_send_byte(0x40, OLED_CMD);
OLED_send_byte(0x81, OLED_CMD);
OLED_send_byte(0xff, OLED_CMD);
OLED_send_byte(0xa1, OLED_CMD);
OLED_send_byte(0xc8, OLED_CMD);
OLED_send_byte(0xa6, OLED_CMD);
OLED_send_byte(0xa8, OLED_CMD);
OLED_send_byte(0x3f, OLED_CMD);
OLED_send_byte(0xd3, OLED_CMD);
OLED_send_byte(0x00, OLED_CMD);
OLED_send_byte(0xd5, OLED_CMD);
OLED_send_byte(0x80, OLED_CMD);
OLED_send_byte(0xd9, OLED_CMD);
OLED_send_byte(0xf1, OLED_CMD);
OLED_send_byte(0xda, OLED_CMD);
OLED_send_byte(0x12, OLED_CMD);
OLED_send_byte(0xdb, OLED_CMD);
OLED_send_byte(0x40, OLED_CMD);
OLED_send_byte(0x20, OLED_CMD);
OLED_send_byte(0x02, OLED_CMD);
OLED_send_byte(0x8d, OLED_CMD);
OLED_send_byte(0x14, OLED_CMD);
OLED_send_byte(0xa4, OLED_CMD);
OLED_send_byte(0xa6, OLED_CMD);
OLED_cls();
OLED_open_BL(0, 0);
OLED_open_display();
}
void OLED_send_byte(const uint8_t dat, const uint8_t cmd)
{
IIC_Start(&OLED_GPIO);
IIC_WriteByte(&OLED_GPIO, OLED_GPIO.ADDR);
IIC_Wait_ACK(&OLED_GPIO);
if (cmd == 0)
{
IIC_WriteByte(&OLED_GPIO, 0x00);
}
else if (cmd == 1)
{
IIC_WriteByte(&OLED_GPIO, 0x40);
}
IIC_Wait_ACK(&OLED_GPIO);
IIC_WriteByte(&OLED_GPIO, dat);
IIC_Wait_ACK(&OLED_GPIO);
IIC_Stop(&OLED_GPIO);
}
void OLED_open_BL(uint8_t x, uint8_t y)
{
x += 2;
OLED_send_byte(0xb0 + y, OLED_CMD);
OLED_send_byte(((x & 0xf0) >> 4) | 0x10, OLED_CMD);
OLED_send_byte((x & 0x0f) | 0x01, OLED_CMD);
}
void OLED_cls(void)
{
uint8_t i, n;
for (i = 0; i < 8; i++)
{
OLED_send_byte(0xb0 + i, OLED_CMD);
OLED_send_byte(0x01, OLED_CMD);
OLED_send_byte(0x10, OLED_CMD);
for (n = 0; n < 129; n++)
{
OLED_send_byte(0x00, OLED_DATA);
}
}
}
void OLED_cls1(void)
{
uint8_t i, n;
for (i = 0; i < 8; i++)
{
OLED_send_byte(0xb0 + i, OLED_CMD);
OLED_send_byte(0x01, OLED_CMD);
OLED_send_byte(0x10, OLED_CMD);
for (n = 0; n < 129; n++)
{
OLED_send_byte(0x00, OLED_DATA);
}
}
}
void OLED_open_display(void)
{
OLED_send_byte(0X8D, OLED_CMD);
OLED_send_byte(0X14, OLED_CMD);
OLED_send_byte(0XAF, OLED_CMD);
}
void OLED_off_display(void)
{
OLED_send_byte(0X8D, OLED_CMD);
OLED_send_byte(0X10, OLED_CMD);
OLED_send_byte(0XAE, OLED_CMD);
}
void OLED_Draw_BMP(const uint8_t Start_x, const uint8_t Start_y, \
const uint8_t Size_x, const uint8_t Size_y, const uint8_t N, const uint8_t BMP[])
{
uint16_t adder = N * (Size_x * Size_y) / 8;
uint8_t Now_X = 0, Now_Y = 0;
for (Now_X = 0; Now_X < (Size_x / 8); Now_X++)
{
OLED_open_BL(Start_x, Start_y + Now_X);
for (Now_Y = 0; Now_Y < Size_y; Now_Y++)
{
if (N == 0xFF)
{
OLED_send_byte(0x00, OLED_DATA);
}
else
{
OLED_send_byte(BMP[adder], OLED_DATA);
}
adder += 1;
}
}
}
static void Draw_48X72BMP(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 48, 72, N, BMP);
}
static void Draw_48X72BMP_cls(uint8_t x, uint8_t y)
{
OLED_Draw_BMP(x, y, 48, 72, 0XFF, 0x00);
}
static void OLED_P8x16Str(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 8, 16, N, BMP);
}
static void OLED_P8x16Str_cls(uint8_t x, uint8_t y)
{
OLED_Draw_BMP(x, y, 8, 16, 0XFF, 0x00);
}
static void OLED_P24x16Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 24, 16, N, BMP);
}
static void OLED_P24x16Ch_cls(uint8_t x, uint8_t y)
{
OLED_Draw_BMP(x, y, 24, 16, 0XFF, 0x00);
}
static void OLED_P32x12Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 32, 12, N, BMP);
}
static void OLED_P32x12Ch_cls(uint8_t x, uint8_t y)
{
OLED_Draw_BMP(x, y, 32, 12, 0XFF, 0x00);
}
static void OLED_P24x32Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 24, 32, N, BMP);
}
static void OLED_P24x32Ch_cls(uint8_t x, uint8_t y)
{
OLED_Draw_BMP(x, y, 24, 32, 0XFF, 0x00);
}
static void OLED_P32x16Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 32, 16, N, BMP);
}
static void OLED_P16x32Ch_cls(uint8_t x, uint8_t y)
{
OLED_Draw_BMP(x, y, 16, 32, 0XFF, 0x00);
}
static void OLED_P64x32Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 64, 32, N, BMP);
}
static void OLED_P16x16Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 16, 16, N, BMP);
}
static void OLED_P48x16Ch(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
OLED_Draw_BMP(x, y, 48, 16, N, BMP);
}
void Draw_BMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t BMP[])
{
uint16_t j = 0;
uint8_t x = 0, y = 0;
for (y = y0; y < y1; y++)
{
OLED_open_BL(x0, y);
for (x = x0; x < x1; x++)
{
OLED_send_byte(BMP[j++], OLED_DATA);
}
}
}
void OLED_show_Battery_Max(const uint8_t OnOff)
{
if (OnOff == 1)
{
if (Battery_old != EG2801_RAM_DATA.StateOfCharge)
{
Battery_old = EG2801_RAM_DATA.StateOfCharge;
OLED_Refresh_Flag.StandbyBattery = 1;
}
if (OLED_Refresh_Flag.StandbyBattery == 1)
{
OLED_Refresh_Flag.StandbyBattery = 0;
OLED_off_display();
if (Battery_old == 0)
{
Draw_48X72BMP(30, 1, 0, LowBatter);
}
else if (Battery_old <= 25)
{
Draw_48X72BMP(30, 1, 2, LowBatter);
}
else if (Battery_old > 25 && Battery_old <= 50)
{
Draw_48X72BMP(30, 1, 3, LowBatter);
}
else if (Battery_old > 50 && Battery_old <= 75)
{
Draw_48X72BMP(30, 1, 4, LowBatter);
}
else if (Battery_old > 75 && Battery_old <= 100)
{
Draw_48X72BMP(30, 1, 5, LowBatter);
}
if (Battery_old < 100)
{
OLED_P8x16Str(14, 2, 11, SDigital);
OLED_P8x16Str(14, 3, Battery_old / 10, SDigital);
OLED_P8x16Str(14, 4, Battery_old % 10, SDigital);
}
else
{
OLED_P24x16Ch(14, 2, 0, SHundred);
}
OLED_P8x16Str(14, 5, 10, SDigital);
OLED_open_display();
}
}
else
{
Draw_48X72BMP_cls(30, 1);
OLED_P24x16Ch_cls(14, 2);
OLED_P8x16Str_cls(14, 5);
}
}
void OLED_show_Battery_Charge(const uint8_t OnOff)
{
static uint8_t time = 0;
if (OnOff == 1)
{
if (Battery_old != EG2801_RAM_DATA.StateOfCharge || OLED_Page != 4)
{
Battery_old = EG2801_RAM_DATA.StateOfCharge;
OLED_Refresh_Flag.StandbyBattery = 1;
}
if (OLED_Refresh_Flag.StandbyBattery == 1)
{
OLED_Refresh_Flag.StandbyBattery = 0;
if (Battery_old <= 25)
{
Draw_48X72BMP(30, 1, 1, LowBatter);
}
else if (Battery_old > 25 && Battery_old <= 50)
{
Draw_48X72BMP(30, 1, 2, LowBatter);
}
else if (Battery_old > 50 && Battery_old <= 75)
{
Draw_48X72BMP(30, 1, 3, LowBatter);
}
else if (Battery_old > 75 && Battery_old < 100)
{
Draw_48X72BMP(30, 1, 4, LowBatter);
}
else
{
Draw_48X72BMP(30, 1, 5, LowBatter);
}
if (Battery_old < 100)
{
OLED_P8x16Str(14, 2, 11, SDigital);
OLED_P8x16Str(14, 3, Battery_old / 10, SDigital);
OLED_P8x16Str(14, 4, Battery_old % 10, SDigital);
}
else
{
OLED_P24x16Ch(14, 2, 0, SHundred);
}
OLED_P8x16Str(14, 5, 10, SDigital);
OLED_open_display();
}
if (Battery_old <= 25)
{
if (time < 15 && ++time < 10)
{
if (time == 1)
{
OLED_P32x12Ch(36, 2, 0, MaxBatter_lattice);
}
else if (time == 6)
{
OLED_P32x12Ch_cls(36, 2);
}
}
else
{
time = 0;
}
}
else if (Battery_old > 25 && Battery_old <= 50)
{
if (time < 15 && ++time < 10)
{
if (time == 1)
{
OLED_P32x12Ch(50, 2, 0, MaxBatter_lattice);
}
else if (time == 6)
{
OLED_P32x12Ch_cls(50, 2);
}
}
else
{
time = 0;
}
}
else if (Battery_old > 50 && Battery_old <= 75)
{
if (time < 15 && ++time < 10)
{
if (time == 1)
{
OLED_P32x12Ch(66, 2, 0, MaxBatter_lattice);
}
else if (time == 6)
{
OLED_P32x12Ch_cls(66, 2);
}
}
else
{
time = 0;
}
}
else if (Battery_old > 75 && Battery_old < 100)
{
if (time < 15 && ++time < 10)
{
if (time == 1)
{
OLED_P32x12Ch(80, 2, 0, MaxBatter_lattice);
}
else if (time == 6)
{
OLED_P32x12Ch_cls(80, 2);
}
}
else
{
time = 0;
}
}
else
{
OLED_P32x12Ch(80, 2, 0, MaxBatter_lattice);
}
}
else
{
Draw_48X72BMP_cls(30, 1);
OLED_P24x16Ch_cls(14, 2);
OLED_P8x16Str_cls(14, 5);
}
}
void OLED_Show_Logo(void)
{
OLED_off_display();
OLED_cls();
Draw_BMP(12, 2, 124, 6, Logo);
OLED_open_display();
}
void OLED_Show_UpInfor(void)
{
static uint8_t Light_type_old = 0, Battery_Square_old = 0;
if (OLED_Refresh_Flag.Light_type == 2)
{
OLED_Refresh_Flag.Light_type = 1;
Light_type_old = SystemReg.Mode;
}
if (OLED_Refresh_Flag.Battery_Square == 2)
{
OLED_Refresh_Flag.Battery_Square = 1;
Battery_Square_old = (EG2801_RAM_DATA.StateOfCharge / 20) + 1;
}
if ((EG2801_RAM_DATA.StateOfCharge / 20) + 1 > Battery_Square_old)
{
Battery_Square_old = (EG2801_RAM_DATA.StateOfCharge / 20) + 1;
OLED_Refresh_Flag.Battery_Square = 1;
}
if (Light_type_old != SystemReg.Mode)
{
Light_type_old = SystemReg.Mode;
OLED_Refresh_Flag.Light_type = 1;
}
if (EG2801_RAM_DATA.Flags == 0xFFFF)
{
Battery_Square_old = 5;
OLED_Refresh_Flag.Battery_Square = 1;
}
if (OLED_Refresh_Flag.Battery_Square == 1)
{
switch (Battery_Square_old)
{
case 0:
case 1:
OLED_P48x16Ch(110, 2, 0, BatteryCapacity);
break;
case 2:
OLED_P48x16Ch(110, 2, 1, BatteryCapacity);
break;
case 3:
OLED_P48x16Ch(110, 2, 2, BatteryCapacity);
break;
case 4:
OLED_P48x16Ch(110, 2, 3, BatteryCapacity);
break;
case 5:
case 6:
OLED_P48x16Ch(110, 2, 4, BatteryCapacity);
break;
default:
break;
}
OLED_Refresh_Flag.Battery_Square = 0;
}
if (OLED_Refresh_Flag.Light_type == 1)
{
switch (Light_type_old)
{
case 0:
OLED_P16x16Ch(110, 0, 1, ControlGear);
break;
case 1:
OLED_P16x16Ch(110, 0, 2, ControlGear);
break;
case 2:
OLED_P16x16Ch(110, 0, 3, ControlGear);
break;
case 3:
OLED_P16x16Ch(110, 0, 4, ControlGear);
break;
case 4:
OLED_P16x16Ch(110, 0, 5, ControlGear);
break;
default:
break;
}
OLED_Refresh_Flag.Light_type = 0;
}
}
void OLED_Show_work1(const uint8_t ch)
{
static uint8_t Battery_Flag = 0;
static uint8_t Battery_Err = 0;
if (ch == 0)
{
OLED_off_display();
OLED_cls();
OLED_Refresh_Word1_Flag.BootBatteryVal = 1;
OLED_Refresh_Flag.Light_type = 1;
OLED_Refresh_Flag.Battery_Square = 1;
}
if (Battery_old != EG2801_RAM_DATA.StateOfCharge)
{
Battery_old = EG2801_RAM_DATA.StateOfCharge;
OLED_Refresh_Word1_Flag.BootBatteryVal = 1;
}
if (OLED_Refresh_Word1_Flag.BootBatteryVal == 1)
{
if (Battery_old < 100)
{
if (EG2801_RAM_DATA.Flags == 0xFFFF)
{
Draw_48X72BMP(30, 1, 6, LowBatter);
Battery_Err = 1;
}
else
{
if (Battery_Flag == 1)
{
OLED_P64x32Ch(55, 0, 1, BHundred);
}
if (Battery_Err == 1)
{
Battery_Err = 0;
Draw_48X72BMP_cls(30, 1);
OLED_Refresh_Flag.Light_type = 2;
OLED_Refresh_Flag.Battery_Square = 2;
}
OLED_P24x32Ch(55, 4, Battery_old % 10, BDigital);
OLED_P24x32Ch(55, 1, Battery_old / 10, BDigital);
Battery_Flag = 0;
}
}
else
{
OLED_P64x32Ch(55, 0, 0, BHundred);
Battery_Flag = 1;
}
if (EG2801_RAM_DATA.Flags != 0xFFFF)
{
OLED_P16x16Ch(35, 5, 0, ControlGear);
}
if (EG2801_RAM_DATA.Flags != 0xFFFF)
{
OLED_Refresh_Word1_Flag.BootBatteryVal = 0;
}
}
OLED_Show_UpInfor();
OLED_open_display();
}
void OLED_Show_work2(const uint8_t ch)
{
static uint8_t Hour_old = 0, Min_old = 0;
static uint8_t Battery_Err = 0;
uint16_t TimeToEmpty = 0;
if (ch == 0)
{
OLED_off_display();
OLED_cls();
OLED_Refresh_Word2_Flag.Hour_Time = 1;
OLED_Refresh_Word2_Flag.Min_Time = 1;
OLED_Refresh_Flag.Light_type = 1;
OLED_Refresh_Flag.Battery_Square = 1;
OLED_P32x16Ch(54, 2, 0, SignRatio);
}
if (SystemReg.Mode != 0)
{
TimeToEmpty = EG2801_RAM_DATA.TimeToEmpty * (1.5 * temp_time);
}
else
{
TimeToEmpty = EG2801_RAM_DATA.TimeToEmpty;
}
if (Hour_old != TimeToEmpty / 60)
{
Hour_old = TimeToEmpty / 60;
OLED_Refresh_Word2_Flag.Hour_Time = 1;
}
if (Min_old != TimeToEmpty % 60)
{
Min_old = TimeToEmpty % 60;
OLED_Refresh_Word2_Flag.Min_Time = 1;
}
if (EG2801_RAM_DATA.Flags == 0xFFFF)
{
if (Battery_Err == 0)
{
OLED_P24x32Ch_cls(72, 1);
OLED_P24x32Ch_cls(72, 4);
OLED_P16x32Ch_cls(54, 2);
OLED_P24x32Ch_cls(22, 1);
OLED_P24x32Ch_cls(22, 4);
}
Draw_48X72BMP(30, 1, 6, LowBatter);
OLED_Refresh_Word2_Flag.Hour_Time = 0;
OLED_Refresh_Word2_Flag.Min_Time = 0;
Battery_Err = 1;
}
else
{
if (Battery_Err == 1)
{
Battery_Err = 0;
Draw_48X72BMP_cls(30, 1);
OLED_Refresh_Word2_Flag.Hour_Time = 1;
OLED_Refresh_Word2_Flag.Min_Time = 1;
OLED_Refresh_Flag.Light_type = 2;
OLED_Refresh_Flag.Battery_Square = 2;
OLED_P32x16Ch(54, 2, 0, SignRatio);
}
if (OLED_Refresh_Word2_Flag.Hour_Time == 1)
{
OLED_P24x32Ch(72, 1, Hour_old / 10, BDigital);
OLED_P24x32Ch(72, 4, Hour_old % 10, BDigital);
OLED_Refresh_Word2_Flag.Hour_Time = 0;
}
if (OLED_Refresh_Word2_Flag.Min_Time == 1)
{
OLED_P24x32Ch(22, 1, Min_old / 10, BDigital);
OLED_P24x32Ch(22, 4, Min_old % 10, BDigital);
OLED_Refresh_Word2_Flag.Min_Time = 0;
}
}
OLED_Show_UpInfor();
OLED_open_display();
}
void OLED_Show_LowPower(void)
{
if (OLED_Page != 3)
{
OLED_Refresh_Flag.Battery_Low = 1;
}
if (OLED_Refresh_Flag.Battery_Low == 1)
{
OLED_Refresh_Flag.Battery_Low = 0;
OLED_off_display();
OLED_cls();
Draw_48X72BMP(30, 1, 0, LowBatter);
OLED_open_display();
OLED_Page = 3;
}
}
void OLED_P16x32Ch_NTC(uint8_t x, uint8_t y, uint8_t N, const uint8_t BMP[])
{
uint16_t adder = 64 * N;
uint8_t wm = 0, i = 0;
for (i = 0; i < 4; i++)
{
OLED_open_BL(x, y + i);
for (wm = 0; wm < 16; wm++)
{
OLED_send_byte(BMP[adder], OLED_DATA);
adder += 1;
}
}
}
void OLED_Show_NTC(void)
{
if (OLED_Page != 5)
{
OLED_Refresh_Flag.Temp_Err = 1;
}
if (OLED_Refresh_Flag.Temp_Err == 1 && OLED_Page != 5)
{
OLED_Refresh_Flag.Temp_Err = 0;
OLED_off_display();
OLED_cls();
OLED_P16x32Ch_NTC(72, 12, 0, NTC);
OLED_P16x32Ch_NTC(56, 12, 1, NTC);
OLED_P16x32Ch_NTC(40, 12, 2, NTC);
OLED_P16x32Ch_NTC(88, 0, 3, NTC);
OLED_P16x32Ch_NTC(72, 0, 4, NTC);
OLED_P16x32Ch_NTC(56, 0, 5, NTC);
OLED_P16x32Ch_NTC(40, 0, 6, NTC);
OLED_P16x32Ch_NTC(24, 0, 7, NTC);
OLED_open_display();
OLED_Page = 5;
}
}
void OLED_Show_Battery_Err2(void)
{
if (OLED_Page != 7)
{
OLED_Refresh_Flag.Battery_Err2 = 1;
}
if (OLED_Refresh_Flag.Battery_Err2 == 1 && OLED_Page != 7)
{
OLED_Refresh_Flag.Battery_Err2 = 0;
OLED_off_display();
OLED_cls();
Draw_48X72BMP(30, 1, 6, LowBatter);
OLED_open_display();
OLED_Page = 7;
}
}
#ifndef __OLED_
#define __OLED_
#include "main.h"
#include "hal_iic.h"
extern uint8_t OLED_Page;
typedef struct
{
uint8_t StandbyBattery :1;
uint8_t Light_type :2;
uint8_t Battery_Square :2;
uint8_t Word1 :1;
uint8_t Word2 :1;
uint8_t Temp_Err :1;
uint8_t Battery_Err1 :1;
uint8_t Battery_Err2 :1;
uint8_t Battery_Low :1;
} OLED_Refresh;
extern OLED_Refresh OLED_Refresh_Flag;
typedef struct
{
uint8_t BootBatteryVal :1;
} OLED_Refresh_Word1;
extern OLED_Refresh_Word1 OLED_Refresh_Word1_Flag;
typedef struct
{
uint8_t Hour_Time :1;
uint8_t Min_Time :1;
} OLED_Refresh_Word2;
extern OLED_Refresh_Word2 OLED_Refresh_Word2_Flag;
#define OLED_CMD 0
#define OLED_DATA 1
#define MAX_COLUMNC 132
extern const unsigned char Battery[];
extern const unsigned char logo[];
#define OledCS_Clr() HAL_GPIO_WritePin(GPIOB,GPIO_Pin_1,GPIO_PIN_RESET)
#define OledCS_Set() HAL_GPIO_WritePin(GPIOB,GPIO_Pin_1,GPIO_PIN_SET)
#define Oled_Close() HAL_GPIO_WritePin(GPIOA,GPIO_Pin_5,GPIO_PIN_RESET)
#define Oled_Open() HAL_GPIO_WritePin(GPIOA,GPIO_Pin_5,GPIO_PIN_SET)
void OLED_init(void);
void OLED_send_byte(const uint8_t dat, const uint8_t cmd);
void OLED_open_BL(uint8_t x, uint8_t y);
void OLED_cls(void);
void OLED_cls1(void);
void OLED_open_display(void);
void OLED_off_display(void);
void OLED_show_char(uint8_t x, uint8_t y, uint8_t str, uint8_t size);
void OLED_show_str(uint8_t x, uint8_t y, uint8_t *str, uint8_t size);
void OLED_show_BMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t BMP[]);
void OLED_cls_BMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
void OLED_Show_Logo(void);
void OLED_Show_work1(const uint8_t ch);
void OLED_Show_work2(const uint8_t ch);
void OLED_show_Battery(uint8_t x0, uint8_t y0, uint8_t Nom,uint8_t size);
void OLED_show_Battery_Max(const uint8_t OnOff);
void OLED_show_Battery_Charge(const uint8_t OnOff);
void OLED_Show_LowPower(void);
void OLED_Show_NTC(void);
void OLED_Show_Battery_Err2(void);
#endif