void SetStartColumn(unsigned char d) { OLED_WrCmd(0x00+d%16); // Set Lower Column Start Address for Page Addressing Mode // Default => 0x00 OLED_WrCmd(0x10+d/16); // Set Higher Column Start Address for Page Addressing Mode // Default => 0x10 }
void SetStartColumn(uchar8 ucData) { OLED_WrCmd(0x00+ucData % 16); // Set Lower Column Start Address for Page Addressing Mode // Default => 0x00 OLED_WrCmd(0x10+ucData / 16); // Set Higher Column Start Address for Page Addressing Mode // Default => 0x10 }
void SetPrechargePeriod(uchar8 ucData) { OLED_WrCmd(0xD9); // Set Pre-Charge Period OLED_WrCmd(ucData); // Default => 0x22 (2 Display Clocks [Phase 2] / 2 Display Clocks [Phase 1]) // D[3:0] => Phase 1 Period in 1~15 Display Clocks // D[7:4] => Phase 2 Period in 1~15 Display Clocks }
void SetCommonConfig(uchar8 ucData) { OLED_WrCmd(0xDA); // Set COM Pins Hardware Configuration OLED_WrCmd(0x02|ucData); // Default => 0x12 (0x10) // Alternative COM Pin Configuration // Disable COM Left/Right Re-Map }
void Set_Charge_Pump(unsigned char d) { OLED_WrCmd(0x8D); // Set Charge Pump OLED_WrCmd(0x10|d); // Default => 0x10 // 0x10 (0x00) => Disable Charge Pump // 0x14 (0x04) => Enable Charge Pump }
void SetDisplayClock(uchar8 ucData) { OLED_WrCmd(0xD5); // Set Display Clock Divide Ratio / Oscillator Frequency OLED_WrCmd(ucData); // Default => 0x80 // D[3:0] => Display Clock Divider // D[7:4] => Oscillator Frequency }
void Set_Display_Clock(unsigned char d) { OLED_WrCmd(0xD5); // Set Display Clock Divide Ratio / Oscillator Frequency OLED_WrCmd(d); // Default => 0x80 // D[3:0] => Display Clock Divider // D[7:4] => Oscillator Frequency }
void Set_Precharge_Period(unsigned char d) { OLED_WrCmd(0xD9); // Set Pre-Charge Period OLED_WrCmd(d); // Default => 0x22 (2 Display Clocks [Phase 2] / 2 Display Clocks [Phase 1]) // D[3:0] => Phase 1 Period in 1~15 Display Clocks // D[7:4] => Phase 2 Period in 1~15 Display Clocks }
void Set_Common_Config(unsigned char d) { OLED_WrCmd(0xDA); // Set COM Pins Hardware Configuration OLED_WrCmd(0x02|d); // Default => 0x12 (0x10) // Alternative COM Pin Configuration // Disable COM Left/Right Re-Map }
void SetChargePump(uchar8 ucData) { OLED_WrCmd(0x8D); // Set Charge Pump OLED_WrCmd(0x10|ucData); // Default => 0x10 // 0x10 (0x00) => Disable Charge Pump // 0x14 (0x04) => Enable Charge Pump }
void SetAddressingMode(uchar8 ucData) { OLED_WrCmd(0x20); // Set Memory Addressing Mode OLED_WrCmd(ucData); // Default => 0x02 // 0x00 => Horizontal Addressing Mode // 0x01 => Vertical Addressing Mode // 0x02 => Page Addressing Mode }
void SetAddressingMode(unsigned char d) { OLED_WrCmd(0x20); // Set Memory Addressing Mode OLED_WrCmd(d); // Default => 0x02 // 0x00 => Horizontal Addressing Mode // 0x01 => Vertical Addressing Mode // 0x02 => Page Addressing Mode }
void OLED_clear_line(unsigned int line) { unsigned char x; OLED_WrCmd(0xb0+line); OLED_WrCmd(0x01); OLED_WrCmd(0x10); for(x=0;x<X_WIDTH;x++) OLED_WrDat(0x00); }
void OLED_draw_line(unsigned int data[]) { unsigned char y,x; for(y=0;y<4;y++) { OLED_WrCmd(0xb0+y); OLED_WrCmd(0x01); OLED_WrCmd(0x10); for(x=0;x<X_WIDTH;x++) OLED_WrDat(data[x]); } }
/*********************LCD全屏************************************/ void OLED_Fill(unsigned char bmp_dat) { unsigned char 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_dat); } }
/*********************LCD复位************************************/ void OLED_CLS(void) { unsigned char 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(0); } }
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); } }
/***************************************************************************** 函 数 名 : OLED_Fill 功能描述 : 对全屏写入同一个字符函数 如 OLED_Fill(0x01); 对于某一位0为不亮 1为亮 ------------------------------------------------------ 共128列 1 1 1 共 0 0 0 8 0 0 0 组 0 ……0 ………… 0 字 0 0 0 符 0 0 0 即 0 0 0 8 0 0 0 页 1 1 1 64 0 0 0 行 . . . . . ………… . . . . . . . 0 0 0 ------------------------------------------------------ 输入参数 : uchar8 ucData 输出参数 : NONE 返 回 值 : NONE *****************************************************************************/ void OLED_Fill(uchar8 ucData) { uchar8 ucPage,ucColumn; for(ucPage = 0; ucPage < 8; ucPage++) { OLED_WrCmd(0xb0 + ucPage); //0xb0+0~7表示页0~7 OLED_WrCmd(0x00); //0x00+0~16表示将128列分成16组其地址在某组中的第几列 OLED_WrCmd(0x10); //0x10+0~16表示将128列分成16组其地址所在第几组 for(ucColumn = 0; ucColumn < 128; ucColumn++) { OLED_WrDat(ucData); } } }
/* * 清屏函数 */ void OLED_Clear(void) { uint8_t 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(0); } } }
void Set_Common_Remap(unsigned char d) { OLED_WrCmd(0xC0|d); // Set COM Output Scan Direction // Default => 0xC0 // 0xC0 (0x00) => Scan from COM0 to 63 // 0xC8 (0x08) => Scan from COM63 to 0 }
void SetSegmentRemap(uchar8 ucData) { OLED_WrCmd(0xA0|ucData); // Set Segment Re-Map // Default => 0xA0 // 0xA0 (0x00) => Column Address 0 Mapped to SEG0 // 0xA1 (0x01) => Column Address 0 Mapped to SEG127 }
void SetEntireDisplay(uchar8 ucData) { OLED_WrCmd(0xA4|ucData); // Set Entire Display On / Off // Default => 0xA4 // 0xA4 (0x00) => Normal Display // 0xA5 (0x01) => Entire Display On }
void SetCommonRemap(uchar8 ucData) { OLED_WrCmd(0xC0|ucData); // Set COM Output Scan Direction // Default => 0xC0 // 0xC0 (0x00) => Scan from COM0 to 63 // 0xC8 (0x08) => Scan from COM63 to 0 }
void SetDisplayOnOff(uchar8 ucData) { OLED_WrCmd(0xAE|ucData); // Set Display On/Off // Default => 0xAE // 0xAE (0x00) => Display Off // 0xAF (0x01) => Display On }
void SetInverseDisplay(uchar8 ucData) { OLED_WrCmd(0xA6|ucData); // Set Inverse Display On/Off // Default => 0xA6 // 0xA6 (0x00) => Normal Display // 0xA7 (0x01) => Inverse Display On }
void Set_Display_On_Off(unsigned char d) { OLED_WrCmd(0xAE|d); // Set Display On/Off // Default => 0xAE // 0xAE (0x00) => Display Off // 0xAF (0x01) => Display On }
void Set_Inverse_Display(unsigned char d) { OLED_WrCmd(0xA6|d); // Set Inverse Display On/Off // Default => 0xA6 // 0xA6 (0x00) => Normal Display // 0xA7 (0x01) => Inverse Display On }
void Set_Entire_Display(unsigned char d) { OLED_WrCmd(0xA4|d); // Set Entire Display On / Off // Default => 0xA4 // 0xA4 (0x00) => Normal Display // 0xA5 (0x01) => Entire Display On }
void Set_Segment_Remap(unsigned char d) { OLED_WrCmd(0xA0|d); // Set Segment Re-Map // Default => 0xA0 // 0xA0 (0x00) => Column Address 0 Mapped to SEG0 // 0xA1 (0x01) => Column Address 0 Mapped to SEG127 }
//============================================================== //函数名: void LCD_PutPixel(uint8 x,uint8 y) //功能描述:绘制一个点(x,y) //参数:真实坐标值(x,y),x的范围0~127,y的范围0~64 //返回:无 //============================================================== void OLED_PutPixel(uint8 x,uint8 y) { uint8 data1; //data1当前点的数据 OLED_Set_Pos(x,y); data1 = 0x01<<(y%8); OLED_WrCmd(0xb0+(y>>3)); OLED_WrCmd(((x&0xf0)>>4)|0x10); OLED_WrCmd((x&0x0f)|0x00); OLED_WrDat(data1); }