7.1.4 SPI驱动程序
/**
* @brief SPI send data/command
* @param dat
*/
void SendDataSPI(unsigned char dat)
{
unsigned char i;
for(i=0; i<8; i++)
{
LCD_SCL_LOW;
if( (dat&0x80)!=0 ){
LCD_SDA_HIGH;
}else{
LCD_SDA_LOW;
}
dat <<= 1;
LCD_SCL_HIGH;
}
}
/**
* @brief this function is write command to lcd.
* @param command : 写进去的命令值.
* @retval none
*/
void WriteComm(unsigned char command)
{
LCD_CS_LOW;
LCD_RS_LOW;//拉低选择发送命令
SendDataSPI(command);
LCD_CS_HIGH;
}
/**
* @brief this function is write data to lcd.
* @param data : the data to write.
* @retval none
*/
void WriteData(unsigned char data)
{
LCD_CS_LOW;
LCD_RS_HIGH;//拉高选择发送数据
SendDataSPI(data);
LCD_CS_HIGH;
}
/**
* @brief configures the oled.
* this function must be called before any write/read operation
* on the oled.
*/
void OLED_init(void)
{
lcd_port_init();
delay_ms(1);
LCD_RS_HIGH;
LCD_CS_HIGH;
LCD_RESET_LOW; // OLED复位
delay_ms(100); //复位延时
LCD_RESET_HIGH; //结束复位
WriteComm(0xAE); //Display Off
WriteComm(0xD5); //SET DISPLAY CLOCK
WriteComm(0x80); //105HZ
WriteComm(0xA8); //Select Multiplex Ratio
WriteComm(0x3F); //Default => 0x3F (1/64 Duty)
WriteComm(0xD3); //Setting Display Offset
WriteComm(0x00); //00H Reset
WriteComm(0x40); //Set Display Start Line
WriteComm(0x8D); //Set Charge Pump
//Write_Command(0x10); //Disable Charge Pump
WriteComm(0x14); //Enable Charge Pump
WriteComm(0xAD); // Internal IREF Setting
WriteComm(0x20); // Disable internal IREF
//Write_command(0x30); // Enable internal IREF
WriteComm(0xA1); //Set Segment Re-Map Default
WriteComm(0xC8); //Set COM Output Scan Direction
WriteComm(0xDA); //Set COM Hardware Configuration
WriteComm(0x12); //Alternative COM Pin
WriteComm(0x81); //Set Contrast Control
WriteComm(0X0F);
WriteComm(0xD9); //Set Pre-Charge period
WriteComm(0xF1);
WriteComm(0xDB); //Set Deselect Vcomh level
WriteComm(0x30);
WriteComm(0xA4); //Entire Display ON
WriteComm(0xA6); //Set Normal Display
//Clear_Ram();
WriteComm(0xAF); //Display ON
}
void lcd_address(unsigned char page,unsigned char column)
{
column=column-1; //我们平常所说的第 1 列,在 LCD 驱动 IC 里是第 0 列。所以在这里减去 1.
page=page-1;
//设置页地址。每页是 8 行。一个画面的 64 行被分成 8 个页。我们平常所说的第 1 页,在 LCD 驱动IC 里是第 0 页,所以在这里减去 1
WriteComm(0xb0+page);
WriteComm(((column>>4)&0x0f)+0x10); //设置列地址的高 4 位
WriteComm(column&0x0f); //设置列地址的低 4 位
}
//全屏清屏
void full_display(unsigned short color)
{
unsigned char data1,data2, i,j;
data1 = color >> 8;
data2 = color;
for(i=0;i<8;i++)
{
lcd_address(i+1,1);
for(j=0;j<64;j++)
{
WriteData(data1);
WriteData(data2);
}
}
}
uint8_t OLED_GRAM1[128][8];
//更新显存到LCD
void OLED_Refresh_Gram(void)
{
uint8_t i,n;
for(i=0;i<8;i++)
{
WriteComm (0xB0+i); //设置页地址(0~7)
WriteComm (0x00); //设置显示位置—列低地址
WriteComm (0x10); //设置显示位置—列高地址
for(n=0;n<128;n++)
WriteData(OLED_GRAM1[n][i]);
}
}
//画点
//x:0~127
//y:0~63
//t:1 填充 0,清空
void OLED_DrawPoint1(uint8_t x,uint8_t y,uint8_t t)
{
uint8_t pos,bx,temp=0;
if(x>127||y>63)return;//超出范围了.
pos=7-y/8;
bx=y%8;
temp=1<<(7-bx);
if(t)OLED_GRAM1[x][pos]|=temp;
else OLED_GRAM1[x][pos]&=~temp;
OLED_Refresh_Gram();
-
- GT-HMI Designer用户手册
- GT-HMI Engine用户手册
- 高通字库芯片开发资料
- GTDB-X7ESP高通智匠AI开发板规格书
- GTC-480480TFT40XP模块使用手册
- GTC-480272TFT43XP模块使用手册
- GTC-800480TFT50G模块使用手册
- GTC-800480TFT70GP模块使用手册
- GTC-1024600TFT101GP模块使用手册
- GT-GUI LCD 1.9寸液晶模组数据手册
- GT-GUI LCD 2.8寸液晶模组数据手册
- GT-GUI LCD 3.5寸液晶模组数据手册
- GT-GUI LCD 7.0寸液晶模组数据手册
- GUI-LCD开发板使用手册
- GT5GL128B标准GUI芯片规格书
- GT5GL64芯片产品规格书
高通字库交流群
GT-HMI交流群