#include "stm32f0xx.h"
#include "ST7567a.h"
#include "stdlib.h"
#include
extern __IO uint8_t UC1701x_index;
extern __IO uint16_t SysTick_count;
int ST7567_RefreshFlag=0;
int ST7567_BlinkFlag=0;
int pwr_offFlag=0;
__IO uint8_t ST7567_GRAM[55];
//LCD数据缓冲区总共55个寄存器,分两页显示,第一页0~24,第二页25~50
void Delay_nms(uint16_t nms)
{
uint16_t i,j;
for(i = 0 ; i < nms ;i++)
for(j = 0 ; j <1150 ; j++);
}
//lcd驱动指令/数据函数
void ST7567_WR_Byte(uint8_t chData, uint8_t chCmd)
{
uint8_t i;
ST7567_CS_0; //
if(chCmd==1)
{
ST7567_A0_1;//
}
else
{
ST7567_A0_0;
}
for(i=0;i<8;i++)
{
ST7567_SCLK_0;//
if(chData&0x80)
{
ST7567_SDIN_1;//
}
else
{
ST7567_SDIN_0;//
}
ST7567_SCLK_1;//
chData<<=1;
}
ST7567_CS_1; //
ST7567_A0_1; //
}
//void Worng_power_off(void)
//{
// UC1701X_Clear(0);
// UC1701X_RST_0;
// Delay_nms(100);
// UC1701X_RST_1;
// Delay_nms(20);
// UC1701X_WR_Byte(0xe2, UC1701X_CMD);//软复位
// Delay_nms(5);
//}
//lcd初始化程序
void ST7567_Init(uint8_t tpye)
{
// int16_t temp=0;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// LED_OFF;
// LCD_light_1;
ST7567_RST_1;
Delay_nms(20);
ST7567_RST_0;
Delay_nms(100);
ST7567_RST_1;
Delay_nms(20);
ST7567_WR_Byte(0xe2, ST7567_CMD);//软复位
Delay_nms(5);
ST7567_WR_Byte(0x2c, ST7567_CMD);//内部电源管理
Delay_nms(5);
ST7567_WR_Byte(0x2e, ST7567_CMD);//三条指令间隔时间2um
Delay_nms(5);
ST7567_WR_Byte(0x2f, ST7567_CMD);//电源控制3 电压跟随器打开
Delay_nms(5);
ST7567_WR_Byte(0x25, ST7567_CMD);//
ST7567_WR_Byte(0x81, ST7567_CMD);//电压模式选择
ST7567_WR_Byte(0x1d, ST7567_CMD);//电压调整寄存器低位 范围0x00-0x3f
// ST7567_WR_Byte(0x22, ST7567_CMD);//电压调整寄存器高位 范围0x21-0x27 值越大,显示效果越浓(底影越浓)LCD电阻率0x20~0x27
ST7567_WR_Byte(0x23, ST7567_CMD);//电压调整寄存器高位 范围0x21-0x27 值越大,显示效果越浓(底影越浓)LCD电阻率0x20~0x27
ST7567_WR_Byte(0xa3, ST7567_CMD);//设置LCD偏置比 A3:1/5(bias) A2:1/6
ST7567_WR_Byte(0xa0, ST7567_CMD);//设置SEG方向镜像选择 0xa0正常 0xa1左右镜像
ST7567_WR_Byte(0xc0, ST7567_CMD);//设置COM方向 0xc0正常 0xc8上下镜像
ST7567_WR_Byte(0x40, ST7567_CMD);//设置滚动行
ST7567_WR_Byte(0xaf, ST7567_CMD);//显示开
ST7567_Clear(0);
}
//设置寄存器页地址
void ST7567_Set_Adress(uint8_t chXpos)
{
ST7567_WR_Byte(0x0f,ST7567_CMD); //设置列地址-低四位 重点
ST7567_WR_Byte(0x10,ST7567_CMD); //设置列地址-高四位
ST7567_WR_Byte(0xb0+chXpos,ST7567_CMD); //设置页地址(0~7)
}
//缓冲区数据更新,寄存器数据更新
void ST7567_Refresh_Gram(void)
{
uint8_t n;
ST7567_Set_Adress(0);
for(n=0;n<55;n++)
{
ST7567_WR_Byte(ST7567_GRAM[n],1);
}
}
//清屏,缓冲区清零,寄存器清零
void ST7567_Clear(uint8_t a)
{
uint8_t j;
ST7567_Set_Adress(0);
for(j = 0 ; j < 55 ; j++)
{
ST7567_WR_Byte(a , ST7567_DATA);
ST7567_GRAM[j]=a;
}
ST7567_Refresh_Gram();
}
void ST7567_Task()
{
if(ST7567_RefreshFlag)
{
ST7567_RefreshFlag=0;
ST7567_Refresh_Gram();
}
if(pwr_offFlag)
{
pwr_offFlag = 0;
//// Worng_power_off();
}
}
void ST7567_TaskTrig(int BlinkFlag)
{
ST7567_BlinkFlag = BlinkFlag;
ST7567_RefreshFlag = 1;
}
void pwr_offTrig()
{
pwr_offFlag =1;
}
void ST7567_battery_show()
{
ST7567_GRAM[0]=0xea;
ST7567_Refresh_Gram();
}
void ST7567_disk_show()
{
ST7567_GRAM[1]=0xd5;
ST7567_GRAM[2]=0xc5;
ST7567_Refresh_Gram();
}
void ST7567_memory_show()
{
ST7567_GRAM[3]=0x7d;
ST7567_GRAM[4]=0xd4;
ST7567_GRAM[5]=0x55;
ST7567_GRAM[6]=0x54;
ST7567_Refresh_Gram();
}
void ST7567_laser_show()
{
ST7567_GRAM[7]=0xf0;
ST7567_GRAM[8]=0x15;
ST7567_GRAM[9]=0x54;
ST7567_GRAM[10]=0xd5;
ST7567_GRAM[11]=0x44;
ST7567_Refresh_Gram();
}
void ST7567_temperature_show()
{
ST7567_GRAM[11]|=0x01;
ST7567_GRAM[12]|=0x15;
ST7567_GRAM[14]|=0x55;
ST7567_GRAM[15]|=0x15;
ST7567_GRAM[16]|=0x55;
ST7567_Refresh_Gram();
}
void ST7567_image_show()
{
ST7567_GRAM[12]|=0xea;
ST7567_GRAM[14]|=0xaa;
ST7567_GRAM[15]|=0xea;
ST7567_GRAM[16]|=0x80;
ST7567_Refresh_Gram();
}
void ST7567_symbol_show()
{
ST7567_GRAM[11]|=0xb0;//H5 T41 T44
ST7567_GRAM[16]|=0x2a;//T48 T46 T49
ST7567_GRAM[17]|=0x40;//H6
ST7567_GRAM[54]|=0x81;//T42 T45
ST7567_GRAM[13]|=0x02;//H7
ST7567_Refresh_Gram();
}
//lcd 数字0~9显示 组合编码 适用于第一行 1-5数码管
const unsigned char ascii_num1_1[10]={0xaa,0x28,0x8a,0xaa,0x28,0xa2,0xa2,0x2a,0xaa,0xaa};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num1_2[10]={0x22,0x00,0x28,0x08,0x0a,0x0a,0x2a,0x00,0x2a,0x0a};
//适用于第二行 6-10数码管
const unsigned char ascii_num2_1[10]={0x55,0x14,0x51,0x55,0x14,0x45,0x45,0x54,0x55,0x55};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num2_2[10]={0x44,0x00,0x14,0x10,0x50,0x50,0x54,0x00,0x54,0x50};
//适用于第三行 11-15数码管
const unsigned char ascii_num3_1[10]={0x11,0x00,0x14,0x04,0x05,0x05,0x15,0x00,0x15,0x05};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num3_2[10]={0x55,0x14,0x45,0x55,0x14,0x51,0x51,0x15,0x55,0x55};
//适用于第四行 16-20数码管
const unsigned char ascii_num4_1[10]={0x88,0x00,0x28,0x20,0xa0,0xa0,0xa8,0x00,0xa8,0xa0};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num4_2[10]={0xaa,0x28,0xa2,0xaa,0x28,0x8a,0x8a,0xa8,0xaa,0xaa};
//适用于第21号小数码管
const unsigned char ascii_num5_1[10]={0xaa,0x28,0x8a,0xaa,0x28,0xa2,0xa2,0x2a,0xaa,0xaa};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num5_2[10]={0x88,0x00,0xa0,0x20,0x28,0x28,0xa8,0x00,0xa8,0x28};
//适用于第22,23,24小数码管
const unsigned char ascii_num6_1[10]={0xaa,0x28,0x8a,0xaa,0x28,0xa2,0xa2,0x2a,0xaa,0xaa};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num6_2[10]={0x22,0x00,0x28,0x08,0x0a,0x0a,0x2a,0x00,0x2a,0x0a};
//适用于第25号小数码管
const unsigned char ascii_num7_1[10]={0x55,0x14,0x51,0x55,0x14,0x45,0x45,0x54,0x55,0x55};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num7_2[10]={0x11,0x00,0x05,0x04,0x14,0x14,0x15,0x00,0x15,0x14};
//适用于第26,27,28小数码管
const unsigned char ascii_num8_1[10]={0x55,0x14,0x51,0x55,0x14,0x45,0x45,0x54,0x55,0x55};
// 0 1 2 3 4 5 6 7 8 9
const unsigned char ascii_num8_2[10]={0x44,0x00,0x14,0x10,0x50,0x50,0x54,0x00,0x54,0x50};
//适用于第29号小数码管
const unsigned char ascii_num9_1[10]={0x44,0x00,0x50,0x10,0x14,0x14,0x54,0x00,0x54,0x14};
// 0 1 2 3 4 5 6 7 8 9
const unsig
到此这篇st7735s与st7735区别(st7567与st7567a的区别)的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/bcyy/44832.html