Beispiel #1
0
void Set_VCOMH(unsigned char d)
{
	// Set VCOMH Deselect Level
   SSD1306SendCommand(0xDB);			
	SSD1306SendCommand(d);			
   //   Default => 0x20 (0.77*VCC)
}
/* Function		: setAddress(char page, char column)
 * Description	: sets position of LCD RAM
 * Input		: page (0-7), column (0-127)
 * Output		: none
 */
void setAddress( char page, char column )
{

	char pageAddress[] = {SSD1306_PAGE_START_ADDRESS};
	char columnAddress[] = { SSD1306_COLUMNADDRESS, SSD1306_COLUMNADDRESS_MSB, SSD1306_COLUMNADDRESS_LSB };

	if (page > SSD1306_MAXROWS)
	{
		page = SSD1306_MAXROWS;
	}

	if (column > SSD1306_LCDWIDTH)
	{
		column = SSD1306_LCDWIDTH;
	}

	pageAddress[0] = SSD1306_PAGE_START_ADDRESS | (SSD1306_MAXROWS - page);

	columnAddress[0] = SSD1306_COLUMNADDRESS;
	columnAddress[1] = SSD1306_COLUMNADDRESS_MSB | column;
	columnAddress[2] = SSD1306_COLUMNADDRESS_LSB;

	//__no_operation();

	SSD1306SendCommand(pageAddress, 1);
	SSD1306SendCommand(columnAddress, 3);

}
Beispiel #3
0
void Set_Contrast_Control(unsigned char d)
{
	// Set Contrast Control
   SSD1306SendCommand(0x81);			
	//   Default => 0x7F
   SSD1306SendCommand(d);			
}
Beispiel #4
0
void Set_Multiplex_Ratio(unsigned char d)
{
	// Set Multiplex Ratio
   SSD1306SendCommand(0xA8);			
	SSD1306SendCommand(d);			
   //   Default => 0x3F (1/64 Duty)
}
Beispiel #5
0
void Set_Display_Offset(unsigned char d)
{
	// Set Display Offset
   SSD1306SendCommand(0xD3);			
	//   Default => 0x00
   SSD1306SendCommand(d);			
}
Beispiel #6
0
void Set_Display_Clock(unsigned char d)
{
	// Set Display Clock Divide Ratio / Oscillator Frequency
   SSD1306SendCommand(0xD5);			
	SSD1306SendCommand(d);		
   //   Default => 0x80
	//     D[3:0] => Display Clock Divider
	//     D[7:4] => Oscillator Frequency
}
Beispiel #7
0
void Set_Precharge_Period(unsigned char d)
{
	// Set Pre-Charge Period
   SSD1306SendCommand(0xD9);			
	SSD1306SendCommand(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
}
Beispiel #8
0
void Set_Charge_Pump(unsigned char d)
{
	// Set Charge Pump
   SSD1306SendCommand(0x8D);			
	//   Default => 0x10.
   SSD1306SendCommand(0x10|d);			
	//     0x10 (0x00) => Disable Charge Pump
	//     0x14 (0x04) => Enable Charge Pump
}
Beispiel #9
0
void Set_Common_Config(unsigned char d)
{
	// Set COM Pins Hardware Configuration
   SSD1306SendCommand(0xDA);			
	SSD1306SendCommand(0x02|d);			
   //   Default => 0x12 (0x10)
	//     Alternative COM Pin Configuration
	//     Disable COM Left/Right Re-Map
}
Beispiel #10
0
void Set_Page_Address(unsigned char a, unsigned char b)
{
	// Set Page Address
   SSD1306SendCommand(0x22);		
	//   Default => 0x00 (Page Start Address)
   SSD1306SendCommand(a);			
	//   Default => 0x07 (Page End Address)
   SSD1306SendCommand(b);			
}
Beispiel #11
0
void Set_Column_Address(unsigned char a, unsigned char b)
{
	// Set Column Address
   SSD1306SendCommand(0x21);		
	//   Default => 0x00 (Column Start Address)
   SSD1306SendCommand(a);			
	//   Default => 0x7F (Column End Address)
   SD1306SendCommand(b);			
}
Beispiel #12
0
/* Function    : Set_Start_Column
 * Description : Sets a start column to start writing at.
 * Input       : column[0-127]
 * Output      : None
 */
void Set_Start_Column(unsigned char d)
{
	// Set Lower Column Start Address for Page Addressing Mode. Default => 0x00
   SSD1306SendCommand(0x00+d%16);		
	
	// Set Higher Column Start Address for Page Addressing Mode. Default => 0x10
   SSD1306SendCommand(0x10+d/16);		
						
}
Beispiel #13
0
void Set_Addressing_Mode(unsigned char d)
{
	// Set Memory Addressing Mode
   SSD1306SendCommand(0x20);		
	//   Default => 0x02
   SSD1306SendCommand(d);			
   //     0x00 => Horizontal Addressing Mode
   //     0x01 => Vertical Addressing Mode
   //     0x02 => Page Addressing Mode
}
Beispiel #14
0
void Set_Inverse_Display(unsigned char d)
{
	// Set Inverse Display On/Off
   SSD1306SendCommand(0xA6|d);			
	//   Default => 0xA6
	//     0xA6 (0x00) => Normal Display
	//     0xA7 (0x01) => Inverse Display On
}
Beispiel #15
0
void Set_Common_Remap(unsigned char d)
{
	// Set COM Output Scan Direction
   SSD1306SendCommand(0xC0|d);			
   //   Default => 0xC0
   //     0xC0 (0x00) => Scan from COM0 to 63
   //     0xC8 (0x08) => Scan from COM63 to 0
}
Beispiel #16
0
void Set_Segment_Remap(unsigned char d)
{
	// Set Segment Re-Map
   SSD1306SendCommand(0xA0|d);			
   //   Default => 0xA0
   //     0xA0 (0x00) => Column Address 0 Mapped to SEG0
   //     0xA1 (0x01) => Column Address 0 Mapped to SEG127
}
Beispiel #17
0
void Set_Entire_Display(unsigned char d)
{
	// Set Entire Display On / Off
   SSD1306SendCommand(0xA4|d);			
   //   Default => 0xA4
   //     0xA4 (0x00) => Normal Display
   //     0xA5 (0x01) => Entire Display On
}
/* Function    : SSD1306Init()
 * Description : Initializes the OLED display
 * Input       : None
 * Output      : None
 */
void SSD1306Init( void )
{
	OLED_DESELECT;

	OLED_COMMAND;

	OLED_RES_LOW;

   // Delay for 200ms at 16Mhz
   __delay_cycles(200000);

   OLED_RES_HIGH;

   __delay_cycles(100000);

   //TRIGGER;

   SSD1306SendCommand(SSD1306_init, sizeof SSD1306_init);

}
Beispiel #19
0
void Set_Start_Line(unsigned char d)
{
	// Set Display Start Line
   SSD1306SendCommand(0x40|d);			
	//   Default => 0x40 (0x00)					
}
Beispiel #20
0
/* Function    : Set_Start_Page
 * Description : Sets a start page to start writing at.
 * Input       : column[0-7]
 * Output      : None
 */
void Set_Start_Page(unsigned char d)
{
	// Set Page Start Address for Page Addressing Mode. Default => 0xB0 (0x00)
   SSD1306SendCommand(0xB0|d);			
						
}
Beispiel #21
0
/* Function    : SSD1306Init()
 * Description : Initializes the OLED display
 * Input       : None
 * Output      : None
 */
void SSD1306Init( void )
{

   SSD1306SendCommand(0xae);//--turn off oled panel 
   SSD1306SendCommand(0x00);//---set low column address 
   SSD1306SendCommand(0x10);//---set high column address 
   SSD1306SendCommand(0x40);//--set start line address 
   SSD1306SendCommand(0x81);//--set contrast control register 
   SSD1306SendCommand(0xcf); 
   SSD1306SendCommand(0xa1);//--set segment re-map 95 to 0 
   SSD1306SendCommand(0xa6);//--set normal display 
   SSD1306SendCommand(0xa8);//--set multiplex ratio(1 to 64) 
   SSD1306SendCommand(0x3f);//--1/64 duty 
   SSD1306SendCommand(0xd3);//-set display offset 
   SSD1306SendCommand(0x00);//-not offset 
   SSD1306SendCommand(0xd5);//--set display clock divide ratio/oscillator frequency 
   SSD1306SendCommand(0x80);//--set divide ratio 
   SSD1306SendCommand(0xd9);//--set pre-charge period 
   SSD1306SendCommand(0xf1); 
   SSD1306SendCommand(0xda);//--set com pins hardware configuration 
   SSD1306SendCommand(0x12); 
   SSD1306SendCommand(0xdb);//--set vcomh 
   SSD1306SendCommand(0x40); 
   SSD1306SendCommand(0x8d);//--set Charge Pump enable/disable 
   SSD1306SendCommand(0x14);//--set(0x10) disable 
   SSD1306SendCommand(0xaf);//--turn on oled panel
   Fill_RAM(0x00);				// Clear Screen
}