void LCD_Str(unsigned char x,unsigned char y,unsigned char ch[]) { unsigned char c, i, j; int len = strlen(ch); if (len > 16) len = 16; for (j = 0; j < len; ++j) { if (32 <= ch[j] && ch[j] <= 32 + 94) { c = ch[j] - 32; } else { c = 0; } if(x > 120) { x = 0; y++; } LCD_Set_Pos(x,y); for (i = 0; i < 8; i++) { LCD_WrDat(F8X16[c*16+i]); } LCD_Set_Pos(x,y+1); for (i = 0; i < 8; i++) { LCD_WrDat(F8X16[c*16+i+8]); } x += 8; } }
/** * @brief Invert a pixel @param x(from 0 to 127): X position y(from 0 to 63) : Y position @retval None */ void OLED_InvertPoint(u8 x, u8 y) { unsigned char pos, bx, temp = 0; #if OLED_REFRESH_OPTIMIZE_EN if (UpdateOLEDJustNow == true) LCD_Set_Pos(x, y); #else LCD_Set_Pos(x, y); #endif if (x > 127 || y > 63)return;//Out of range pos = 7 - y / 8; bx = y % 8; temp = 1 << (7 - bx); if ((OLED_GRAM[x][pos] & temp) > 0) { OLED_GRAM[x][pos] &= ~temp; } else OLED_GRAM[x][pos] |= temp; #if OLED_REFRESH_OPTIMIZE_EN if (UpdateOLEDJustNow == true) OLED_WR_Byte(OLED_GRAM[x][pos], OLED_DATA); else { GRAM_Changing = true; GRAM_Changed = true; } #else OLED_WR_Byte(OLED_GRAM[x][pos], OLED_DATA); #endif }
//输出汉字字符串 void LCD_P14x16Str(u8 x,u8 y,u8 ch[]) { u8 wm=0,ii = 0; u16 adder=1; while(ch[ii] != '\0') { wm = 0; adder = 1; while(F14x16_Idx[wm] > 127) { if(F14x16_Idx[wm] == ch[ii]) { if(F14x16_Idx[wm + 1] == ch[ii + 1]) { adder = wm * 14; break; } } wm += 2; } if(x>118){x=0;y++;} LCD_Set_Pos(x , y); if(adder != 1)// 显示汉字 { LCD_Set_Pos(x , y); for(wm = 0;wm < 14;wm++) { LCD_WrDat(F14x16[adder]); adder += 1; } LCD_Set_Pos(x,y + 1); for(wm = 0;wm < 14;wm++) { LCD_WrDat(F14x16[adder]); adder += 1; } } else //显示空白字符 { ii += 1; LCD_Set_Pos(x,y); for(wm = 0;wm < 16;wm++) { LCD_WrDat(0); } LCD_Set_Pos(x,y + 1); for(wm = 0;wm < 16;wm++) { LCD_WrDat(0); } } x += 14; ii += 2; } }
/***************************************************************************** 函 数 名 : LED_PrintImage 功能描述 : 将图像显示出来 输入参数 : unsigned char *pucTable 二维图像数组的地址 USHORT16 usRowNum 二维图像的行数1~64 USHORT16 usColumnNum 二维图像的列数1~128 输出参数 : none 返 回 值 : none *****************************************************************************/ void LED_PrintImage(unsigned char *pucTable, uint16 usRowNum, uint16 usColumnNum) { unsigned char ucData; uint16 i,j,k,m,n; uint16 usRowTmp; m = usRowNum >> 3; //计算图片行数以8位为一组完整的组数 n = usRowNum % 8; //计算分完组后剩下的行数 for(i = 0; i < m; i++) //完整组行扫描 { LCD_Set_Pos(0,(unsigned char)i); usRowTmp = i << 3; //计算当前所在行的下标 for(j = 0; j < usColumnNum; j++) //列扫描 { ucData = 0; for(k = 0; k < 8; k++) //在i组中对这8行扫描 { ucData = ucData >> 1; if((pucTable + (usRowTmp + k) * usColumnNum)[j] == LED_IMAGE_WHITE) { ucData = ucData | 0x80; } } LCD_WrDat(ucData); } } LCD_Set_Pos(0,(unsigned char)i); //设置剩下的行显示的起始坐标 usRowTmp = i << 3; //计算当前所在行的下标 for(j = 0; j < usColumnNum; j++) //列扫描 { ucData = 0; for(k = 0; k < n; k++) //对剩下的行扫描 { ucData = ucData >> 1; if((pucTable + (usRowTmp + k) * usColumnNum)[j] == LED_IMAGE_WHITE) { ucData = ucData | 0x80; } } ucData = ucData >> (8 - n); LCD_WrDat(ucData); } return; }
/* ================================================================================= LCD_Dis_16x16( ); Function : Display 16x16 INTPUT : page, the page of the LCD, 0-7 column, the column of the LCD, 0-127 p_data, the data array for display OUTPUT : None ================================================================================= */ void LCD_Dis_16x16( INT8U page, INT8U column, const INT8U *p_data ) { INT8U i; LCD_Set_Pos( page, column ); for( i = 0; i < 16; i ++ ) { LCD_WrDat( *p_data ++ ); } LCD_Set_Pos( page+1, column ); for( i = 0; i < 16; i ++ ) { LCD_WrDat( *p_data ++ ); } }
/*******************功能描述:显示8*16一组标准ASCII字符串 显示的坐标(x,y),y为页范围0~7****************/ void LCD_P8x16Str(unsigned char x, unsigned char y,unsigned char ch[]) { unsigned char c=0,i=0,j=0; while (ch[j]!='\0') { c =ch[j]-32; if(x>120){x=0;y++;} LCD_Set_Pos(x,y); for(i=0;i<8;i++) LCD_WrDat(F8X16[c*16+i]); LCD_Set_Pos(x,y+1); for(i=0;i<8;i++) LCD_WrDat(F8X16[c*16+i+8]); x+=8; j++; } }
/* x代表横坐标由0~127 y代表纵坐标由0~7,N表示从哪个字开始显示 */ void LCD_sign(unsigned char x, unsigned char y, unsigned char N) { unsigned char wm=0; unsigned int adder=32*N; LCD_Set_Pos(x , y); for(wm = 0;wm < 16;wm++) { LCD_WrDat(sign[adder]); adder += 1; } LCD_Set_Pos(x,y + 1); for(wm = 0;wm < 16;wm++) { LCD_WrDat(sign[adder]); adder += 1; } }
/*****************功能描述:显示16*16点阵 显示的坐标(x,y),y为页范围0~7****************************/ void LCD_P16x16Ch(unsigned char x, unsigned char y, unsigned char N) { unsigned char wm=0; unsigned int adder=32*N; // LCD_Set_Pos(x , y); for(wm = 0; wm < 16; wm++) // { LCD_WrDat(F16x16[adder]); adder += 1; } LCD_Set_Pos(x,y + 1); for(wm = 0; wm < 16; wm++) // { LCD_WrDat(F16x16[adder]); adder += 1; } }
void LCD_P8x16Str(u8 x,u8 y,u8 ch[])//----------------------------------------------------------- { u8 c=0,i=0,j=0; while (ch[j]!='\0') { c =ch[j]-32; if(x>120){x=0;y++;} LCD_Set_Pos(x,y); for(i=0;i<8;i++) LCD_WrDat(F8X16[c*16+i]); LCD_Set_Pos(x,y+1); for(i=0;i<8;i++) LCD_WrDat(F8X16[c*16+i+8]); x+=8; j++; } }
//============================================================== //函数名:LCD_P8x16Str(byte x,byte y,byte *p) //功能描述:写入一组标准ASCII字符串 //参数:显示的位置(x,y),y为页范围0~7,要显示的字符串 //返回:无 //============================================================== void LCD_P8x16Str(byte x,byte y,byte ch[]) { byte c=0,i=0,j=0; while (ch[j]!='\0') { c =ch[j]-32; if(x>120){x=0;y++;} LCD_Set_Pos(x,y); for(i=0;i<8;i++) LCD_WrDat(F8X16[c*16+i]); LCD_Set_Pos(x,y+1); for(i=0;i<8;i++) LCD_WrDat(F8X16[c*16+i+8]); x+=8; j++; } }
/* ================================================================================= LCD_Dis_Str( ); Function : Display a character INTPUT : page, 0-7 column, 0-128 ch, the character to be displayed OUTPUT : None ================================================================================= */ void LCD_Dis_Char( INT8U page, INT8U column, char ch ) { INT16U pos; INT8U j; if( ch < ' ' ) { return; } pos = 16*( ch - ' ' ); LCD_Set_Pos( page, column ); for( j = 0; j < 8; j ++ ) { LCD_WrDat( Font8x16[ pos++ ] ); } LCD_Set_Pos( page+1, column ); for( j = 0; j < 8; j ++ ) { LCD_WrDat( Font8x16[ pos++ ] ); } }
//============================================================== //函数名: void LCD_PutPixel(byte x,byte y) //功能描述:绘制一个点(x,y) //参数:真实坐标值(x,y),x的范围0~127,y的范围0~64 //返回:无 //============================================================== void LCD_PutPixel(u8 x,u8 y) { u8 data1; //data1当前点的数据 LCD_Set_Pos(x,y); data1 = 0x01<<(y%8); LCD_WrCmd(0xb0+(y>>3)); LCD_WrCmd(((x&0xf0)>>4)|0x10); LCD_WrCmd((x&0x0f)|0x00); LCD_WrDat(data1); }
void LCD_Char(byte x,byte y,byte ch) { byte c=0,i=0; c =ch-32; if(x>120) { x=0; y++; } LCD_Set_Pos(x,y); for(i=0;i<8;i++) { LCD_WrDat(F8X16[(c<<4)+i]); } LCD_Set_Pos(x,y+1); for(i=0;i<8;i++) { LCD_WrDat(F8X16[(c<<4)+i+8]); } }
//============================================================== //函数名:LCD_P6x8Str(byte x,byte y,byte *p) //功能描述:写入一组标准ASCII字符串 //参数:显示的位置(x,y),y为页范围0~7,要显示的字符串 //返回:无 //============================================================== void LCD_P6x8Str(u8 x,u8 y,u8 ch[]) { u8 c=0,i=0,j=0; while (ch[j]!='\0') { c =ch[j]-32; if(x>126){x=0;y++;} LCD_Set_Pos(x,y); for(i=0;i<6;i++) LCD_WrDat(F6x8[c][i]); x+=6; j++; } }
void Draw_LQLogo(void) { u16 ii=0; u8 x,y; for(y=0;y<8;y++) { LCD_Set_Pos(16,y); for(x=16;x<112;x++) { LCD_WrDat(longqiu96x64[ii++]); } } }
void Draw_LibLogo(void) { u16 ii=0; u8 x,y; for(y=0;y<8;y++) { LCD_Set_Pos(34,y); for(x=34;x<94;x++) { LCD_WrDat(LIBLOGO60x58[ii++]); } } }
void oledInit() { //设置GPIOD pin14,pin15为GPIO口 // PORTC_PCR19=(0|PORT_PCR_MUX(1));//LCD_DC // // PORTC_PCR17=(0|PORT_PCR_MUX(1)); //LCD_SCL // // PORTC_PCR16=(0|PORT_PCR_MUX(1));//LCD_SDA // // PORTC_PCR18=(0|PORT_PCR_MUX(1));//LCD_RST // // //设置GPIOD pin14,pin15为输出方向 // GPIOC_PDDR=GPIO_PDDR_PDD(GPIO_PIN(16)|GPIO_PIN(17)|GPIO_PIN(18)|GPIO_PIN(19)); LCD_SCL_HIGH;//LCD_SCL LCD_RST_LOW;//LCD_RST LCD_DLY_ms(50); LCD_RST_HIGH;//LCD_RST LCD_WrCmd(0xae);//--turn off oled panel LCD_WrCmd(0x00);//---set low column address LCD_WrCmd(0x10);//---set high column address LCD_WrCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F) LCD_WrCmd(0x81);//--set contrast control register LCD_WrCmd(0xcf); // Set SEG Output Current Brightness LCD_WrCmd(0xa1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常 LCD_WrCmd(0xc8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常 LCD_WrCmd(0xa6);//--set normal display LCD_WrCmd(0xa8);//--set multiplex ratio(1 to 64) LCD_WrCmd(0x3f);//--1/64 duty LCD_WrCmd(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F) LCD_WrCmd(0x00);//-not offset LCD_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency LCD_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec LCD_WrCmd(0xd9);//--set pre-charge period LCD_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock LCD_WrCmd(0xda);//--set com pins hardware configuration LCD_WrCmd(0x12); LCD_WrCmd(0xdb);//--set vcomh LCD_WrCmd(0x40);//Set VCOM Deselect Level LCD_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02) LCD_WrCmd(0x02);// LCD_WrCmd(0x8d);//--set Charge Pump enable/disable LCD_WrCmd(0x14);//--set(0x10) disable LCD_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5) LCD_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) LCD_WrCmd(0xaf);//--turn on oled panel LCD_Fill(0x00); //初始清屏 LCD_Set_Pos(0,0); }
//============================================================== //函数名: void Draw_BMP(byte x,byte y) //功能描述:显示BMP图片128×64 //参数:起始点坐标(x,y),x的范围0~127,y为页的范围0~7 //返回:无 //============================================================== void Draw_BMP(byte x0,byte y0,byte x1,byte y1,byte bmp[]) { word ii=0; byte x,y; if(y1%8==0) y=y1/8; else y=y1/8+1; for(y=y0;y<=y1;y++) { LCD_Set_Pos(x0,y); for(x=x0;x<x1;x++) { LCD_WrDat(bmp[ii++]); } } }
/***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0~127,y为页的范围0~7*****************/ void Draw_BMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]) { unsigned int j=0; unsigned char x,y; if(y1%8==0) y=y1/8; else y=y1/8+1; for(y=y0; y<y1; y++) { LCD_Set_Pos(x0,y); for(x=x0; x<x1; x++) { LCD_WrDat(BMP[j++]); } } }
//============================================================== //函数名: void Draw_BMP(byte x,byte y) //功能描述:显示BMP图片128×64 //参数:起始点坐标(x,y),x的范围0~127,y为页的范围0~7 //返回:无 //============================================================== void Draw_BMP(u8 x0,u8 y0,u8 x1,u8 y1,u8 bmp[]) { u16 ii=0; u8 x,y; if(y1%8==0) y=y1/8; else y=y1/8+1; for(y=y0;y<=y1;y++) { LCD_Set_Pos(x0,y); for(x=x0;x<x1;x++) { LCD_WrDat(bmp[ii++]); } } }
void LCD_Init(void) { pinMode(10, OUTPUT); pinMode(5, OUTPUT); pinMode(14, OUTPUT); pinMode(12, OUTPUT); pinMode(6, OUTPUT); digitalWrite(14, 1); digitalWrite(10, 1); digitalWrite(6, 0); delay(50); digitalWrite(6, 1); LCD_WrCmd(0xae); LCD_WrCmd(0x00); LCD_WrCmd(0x10); LCD_WrCmd(0x40); LCD_WrCmd(0x81); LCD_WrCmd(0xcf); LCD_WrCmd(0xa1); LCD_WrCmd(0xc8); LCD_WrCmd(0xa6); LCD_WrCmd(0xa8); LCD_WrCmd(0x3f); LCD_WrCmd(0xd3); LCD_WrCmd(0x00); LCD_WrCmd(0xd5); LCD_WrCmd(0x80); LCD_WrCmd(0xd9); LCD_WrCmd(0xf1); LCD_WrCmd(0xda); LCD_WrCmd(0x12); LCD_WrCmd(0xdb); LCD_WrCmd(0x40); LCD_WrCmd(0x20); LCD_WrCmd(0x02); LCD_WrCmd(0x8d); LCD_WrCmd(0x14); LCD_WrCmd(0xa4); LCD_WrCmd(0xa6); LCD_WrCmd(0xaf); LCD_Fill(0x00); LCD_Set_Pos(0,0); }
/***************功能描述:显示6*8一组标准ASCII字符串 显示的坐标(x,y),y为页范围0~7****************/ void LCD_P6x8Str(unsigned char x, unsigned char y,unsigned char ch[]) { unsigned char c=0,i=0,j=0; while (ch[j]!='\0') { c =ch[j]-32; if(x>126){x=0;y++;} LCD_Set_Pos(x,y); if(c > 0 && c < 92) { for(i=0;i<6;i++) LCD_WrDat(F6x8[c][i]); } x+=6; j++; } }
void LED_P6x8Char(unsigned char ucIdxX, unsigned char ucIdxY, unsigned char ucData) { unsigned char i, ucDataTmp; ucDataTmp = ucData-32; if(ucIdxX > 122) { ucIdxX = 0; ucIdxY++; } LCD_Set_Pos(ucIdxX, ucIdxY); for(i = 0; i < 6; i++) { LCD_WrDat(F6x8[ucDataTmp][i]); } }
void LCD_Init(void) { //DDRA=0XFF; LCD_SCL=1; //LCD_CS=1; //预制SLK和SS为高电平 LCD_RST=0; LCD_DLY_ms(50); LCD_RST=1; LCD_WrCmd(0xae);//--turn off oled panel LCD_WrCmd(0x00);//---set low column address LCD_WrCmd(0x10);//---set high column address LCD_WrCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F) LCD_WrCmd(0x81);//--set contrast control register LCD_WrCmd(0xcf); // Set SEG Output Current Brightness LCD_WrCmd(0xa1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常 LCD_WrCmd(0xc8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常 LCD_WrCmd(0xa6);//--set normal display LCD_WrCmd(0xa8);//--set multiplex ratio(1 to 64) LCD_WrCmd(0x3f);//--1/64 duty LCD_WrCmd(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F) LCD_WrCmd(0x00);//-not offset LCD_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency LCD_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec LCD_WrCmd(0xd9);//--set pre-charge period LCD_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock LCD_WrCmd(0xda);//--set com pins hardware configuration LCD_WrCmd(0x12); LCD_WrCmd(0xdb);//--set vcomh LCD_WrCmd(0x40);//Set VCOM Deselect Level LCD_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02) LCD_WrCmd(0x02);// LCD_WrCmd(0x8d);//--set Charge Pump enable/disable LCD_WrCmd(0x14);//--set(0x10) disable LCD_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5) LCD_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) LCD_WrCmd(0xaf);//--turn on oled panel LCD_Fill(0x00); //初始清屏 LCD_Set_Pos(0,0); }
void OLED_Configuration(void) { GPIO_InitTypeDef gpio; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE); gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOC, &gpio); LCD_SCL_1; LCD_RST_0; delay_ms(200); LCD_RST_1; Set_Display_On_Off(0x00); // Display Off (0x00/0x01) Set_Display_Clock(0x80); // Set Clock as 100 Frames/Sec Set_Multiplex_Ratio(0x3F); // 1/64 Duty (0x0F~0x3F) Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x3F) SetStartLine(0x00); // Set Mapping RAM Display Start Line (0x00~0x3F) Set_Charge_Pump(0x04); // Enable Embedded DC/DC Converter (0x00/0x04) SetAddressingMode(0x02); // Set Page Addressing Mode (0x00/0x01/0x02) Set_Segment_Remap(0x01); // Set SEG/Column Mapping Set_Common_Remap(0x08); // Set COM/Row Scan Direction Set_Common_Config(0x10); // Set Sequential Configuration (0x00/0x10) SetContrastControl(0xCF); // Set SEG Output Current Set_Precharge_Period(0xF1); // Set Pre-Charge as 15 Clocks & Discharge as 1 Clock Set_VCOMH(0x40); // Set VCOM Deselect Level Set_Entire_Display(0x00); // Disable Entire Display On (0x00/0x01) Set_Inverse_Display(0x00); // Disable Inverse Display On (0x00/0x01) Set_Display_On_Off(0x01); // Display On (0x00/0x01) OLED_Clear(); LCD_Set_Pos(0,0); }
void LCD_Init_Oled(void) { //设置PORTA pin14,pin15为GPIO口 // PORTC_PCR12=(0|PORT_PCR_MUX(1)); // PORTC_PCR13=(0|PORT_PCR_MUX(1)); // PORTC_PCR14=(0|PORT_PCR_MUX(1)); // PORTC_PCR15=(0|PORT_PCR_MUX(1)); PORTE_PCR24=(0|PORT_PCR_MUX(1)); PORTA_PCR14=(0|PORT_PCR_MUX(1)); PORTE_PCR25=(0|PORT_PCR_MUX(1)); PORTA_PCR16=(0|PORT_PCR_MUX(1)); //设置PORTA pin14,pin15为输出方向;pin16,pin17为输入方向 // GPIOC_PDDR=GPIO_PDDR_PDD(GPIO_PIN(12)|GPIO_PIN(13)|GPIO_PIN(14)|GPIO_PIN(15)); GPIOA_PDDR=GPIO_PDDR_PDD(GPIO_PIN(14)|GPIO_PIN(16)); GPIOE_PDDR=GPIO_PDDR_PDD(GPIO_PIN(24)|GPIO_PIN(25)); // GPIOC_PDOR |= GPIO_PDOR_PDO(GPIO_PIN(12)); // //LCD_CS=1; //预制SLK和SS为高电平 // // GPIOC_PDOR &= ~GPIO_PDOR_PDO(GPIO_PIN(14)); // LCD_DLY_ms(50); // GPIOC_PDOR |= GPIO_PDOR_PDO(GPIO_PIN(14)); GPIOE_PDOR |= GPIO_PDOR_PDO(GPIO_PIN(25)); //LCD_CS=1; //预制SLK和SS为高电平 GPIOA_PDOR &= ~GPIO_PDOR_PDO(GPIO_PIN(14)); LCD_DLY_ms(50); GPIOA_PDOR |= GPIO_PDOR_PDO(GPIO_PIN(14)); LCD_WrCmd(0xae);//--turn off oled panel LCD_WrCmd(0x00);//---set low column address LCD_WrCmd(0x10);//---set high column address LCD_WrCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F) LCD_WrCmd(0x81);//--set contrast control register LCD_WrCmd(0xcf); // Set SEG Output Current Brightness LCD_WrCmd(0xa1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常 LCD_WrCmd(0xc8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常 LCD_WrCmd(0xa6);//--set normal display LCD_WrCmd(0xa8);//--set multiplex ratio(1 to 64) LCD_WrCmd(0x3f);//--1/64 duty LCD_WrCmd(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F) LCD_WrCmd(0x00);//-not offset LCD_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency LCD_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec LCD_WrCmd(0xd9);//--set pre-charge period LCD_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock LCD_WrCmd(0xda);//--set com pins hardware configuration LCD_WrCmd(0x12); LCD_WrCmd(0xdb);//--set vcomh LCD_WrCmd(0x40);//Set VCOM Deselect Level LCD_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02) LCD_WrCmd(0x02);// LCD_WrCmd(0x8d);//--set Charge Pump enable/disable LCD_WrCmd(0x14);//--set(0x10) disable LCD_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5) LCD_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) LCD_WrCmd(0xaf);//--turn on oled panel LCD_Fill(0x00); //初始清屏 LCD_Set_Pos(0,0); }