/************ OLED Display.c *********/
#include "OLED Display.h"
char OLEDSetUp ( void )
{
__delay_ms ( 1 ); // As OLDE VDD goes high sooner than VCC,
OLED_RESET_PIN = OFF; // we must wait to stabilize VCC
__delay_ms ( 1 ); // OLED Reset pin.
OLED_RESET_PIN = ON;
// 1. Fundamental Commands.
OLEDCommand ( OLED_SETCONTRAST ); // 0x81
OLEDCommand ( 0x2f ); // was 0x9F.
OLEDCommand ( OLED_DISPLAYALLON_RESUME ); // 0xA5
OLEDCommand ( OLED_NORMALDISPLAY ); // 0xA6
OLEDCommand ( OLED_DISPLAYON );//--turn on oled panel
// 2. Scrolling.
// 3. Addressing.
OLEDCommand ( OLED_MEMORYMODE ); // 0x20
OLEDCommand ( 0x00 );
// 4. Hardware Configuration.
OLEDCommand ( OLED_SETSTARTLINE | 0x00 ); // line #0
OLEDCommand ( OLED_SEGREMAP | 0x01 ); // WTF???
OLEDCommand ( OLED_SETMULTIPLEX ); // 0xA8
OLEDCommand ( 0x3F );
OLEDCommand ( 0xC8 ); // WTF???
OLEDCommand ( OLED_SETDISPLAYOFFSET ); // 0xD3
OLEDCommand ( 0x0 ); // no offset
OLEDCommand ( OLED_SETCOMPINS ); // 0xDA
OLEDCommand ( 0x12 );
// 5. Timing.
OLEDCommand ( OLED_SETDISPLAYCLOCKDIV ); // 0xD5
OLEDCommand ( 0x80 ); // the suggested ratio 0x80
OLEDCommand ( OLED_SETPRECHARGE ); // 0xd9
OLEDCommand ( 0x22 );
OLEDCommand ( OLED_SETVCOMDETECT ); // 0xDB
OLEDCommand ( 0x40 );
// 6?. Other
OLEDCommand ( OLED_CHARGEPUMP ); // 0x8D
OLEDCommand ( 0x10 );
return 0x00;
}