21 volatile char _cs, _rs, _rst, _sid, _sclk;
23 volatile char _screenLock = 0;
24 volatile char TFTROTATION;
25 volatile char TFTINVERTED = 0;
26 volatile int textsize = 1;
27 volatile char TFTSCROLLING = 0;
28 volatile unsigned int textcolor = 0xFFFF;
29 volatile unsigned int textbgcolor = 0xFFFF;
30 volatile char wrap = 1;
31 volatile int cursor_y = 0;
32 volatile int cursor_x = 0;
33 volatile int _width, _height;
34 volatile int _font[5];
35 volatile char _byteReadyFlag, _byteToSend, _byteType;
43 void oledc_init(
char sid,
char sclk,
char cs,
char rs,
char rst,
char screen_rotation) {
65 if(_rst >= 0 && _rst < 32)
79 oledc_writeCommand(SSD1331_CMD_DISPLAYOFF, 0);
80 oledc_writeCommand(SSD1331_CMD_SETREMAP, 0);
81 oledc_writeCommand(0x72, 0);
82 oledc_writeCommand(SSD1331_CMD_STARTLINE, 0);
83 oledc_writeCommand(0x00, 0);
84 oledc_writeCommand(SSD1331_CMD_DISPLAYOFFSET, 0);
85 oledc_writeCommand(0x00, 0);
86 oledc_writeCommand(SSD1331_CMD_NORMALDISPLAY, 0);
87 oledc_writeCommand(SSD1331_CMD_SETMULTIPLEX, 0);
88 oledc_writeCommand(0x3F, 0);
89 oledc_writeCommand(SSD1331_CMD_SETMASTER, 0);
90 oledc_writeCommand(0x8E, 0);
91 oledc_writeCommand(SSD1331_CMD_POWERMODE, 0);
92 oledc_writeCommand(0x0B, 0);
93 oledc_writeCommand(SSD1331_CMD_PRECHARGE, 0);
94 oledc_writeCommand(0x31, 0);
95 oledc_writeCommand(SSD1331_CMD_CLOCKDIV, 0);
96 oledc_writeCommand(0xF0, 0);
97 oledc_writeCommand(SSD1331_CMD_PRECHARGEA, 0);
98 oledc_writeCommand(0x64, 0);
99 oledc_writeCommand(SSD1331_CMD_PRECHARGEB, 0);
100 oledc_writeCommand(0x78, 0);
101 oledc_writeCommand(SSD1331_CMD_PRECHARGEA, 0);
102 oledc_writeCommand(0x64, 0);
103 oledc_writeCommand(SSD1331_CMD_PRECHARGELEVEL, 0);
104 oledc_writeCommand(0x3A, 0);
105 oledc_writeCommand(SSD1331_CMD_VCOMH, 0);
106 oledc_writeCommand(0x3E, 0);
107 oledc_writeCommand(SSD1331_CMD_MASTERCURRENT, 0);
108 oledc_writeCommand(0x06, 0);
109 oledc_writeCommand(SSD1331_CMD_CONTRASTA, 0);
110 oledc_writeCommand(0x91, 0);
111 oledc_writeCommand(SSD1331_CMD_CONTRASTB, 0);
112 oledc_writeCommand(0x50, 0);
113 oledc_writeCommand(SSD1331_CMD_CONTRASTC, 0);
114 oledc_writeCommand(0x7D, 0);
115 oledc_writeCommand(SSD1331_CMD_DISPLAYON, 0);
117 oledc_setRotation(screen_rotation);
118 TFTROTATION = screen_rotation & 3;
124 char testStr[] = {0,0,0,0,0,0};
125 i2c_in(eeBus, 0b1010000, 43640, 2, testStr, 6);
126 if(testStr[0] ==
'f' &&
131 testStr[5] ==
'!') _font[0] = 1;
140 oledc_clear(0,0,_width,_height);
145 void oledc_startup() {
159 if(_rst >= 0 && _rst < 32)
164 OUTA &= ~(1 << _rst);
172 while(!_byteReadyFlag);
173 oledc_spiWrite(_byteToSend, _byteType);