Add uOLED-96-G1 C Sample Code.
[frickel.git] / projects / geeknamensschilder_c / testapp.pde
blobe548b7b13cfd801429b81ca255c2ebcdfa60a70e
1 #define BAUD            115200  
2 #define DELAY           1000
3 #define RST             2
5 #define INIT_SEQ        0x55
6 #define CMD_CLEAR       0x45
7 #define CMD_BGCOLOR     0x42
8 #define CMD_CPYPASTE    0x63
9 #define CMD_LINE        0x4C
10 #define CMD_CIRCLE      0x43
11 #define CMD_FILLCIRCLE  0x69
12 #define CMD_PUTPIXEL    0x50
13 #define CMD_READPIXEL   0x52
14 #define CMD_RECTANGLE   0x72
15 #define CMD_PAINTAREA   0x70
16 #define CMD_SETFNTSIZE  0x46
17 #define FONT_5X7        0x01
18 #define FONT_8x8        0x02
19 #define FONT_8x12       0x03
20 #define CMD_FMTTEXT     0x54
21 #define CMD_CTL         0x59
22 #define CMD_DSPL        0x01
23 #define CMD_CONTRAST    0x02
24 #define CMD_POWER       0x03
25 #define RESPONSE_ACK    0x06
26 #define RESPONSE_NAK    0x15
28 void displayReset()
30         digitalWrite(RST, LOW);
31         delay(20);
32         digitalWrite(RST, HIGH);
33         delay(20);
37 char getDisplayResponse()
39         byte incomingByte = RESPONSE_ACK;
41         while(!Serial.available()) { delay(1); }
42         incomingByte = Serial.read();
43         return incomingByte;
46 void displayInit()
48         displayReset();
49         delay(DELAY);
50         Serial.print(INIT_SEQ, BYTE);
51         getDisplayResponse();
54 void displayClear()
56         Serial.print(CMD_CLEAR, BYTE);
57         delay(20);
58         getDisplayResponse();
61 void displayDrawChar(char col, char row, char size, char myChar, int color)
63         Serial.print(CMD_FMTTEXT, BYTE);
64         Serial.print(myChar, BYTE);
65         Serial.print(col, BYTE);
66         Serial.print(row, BYTE);
67         Serial.print(color >> 8, BYTE);         // MSB
68         Serial.print(color & 0xFF, BYTE);       // LSB
69         getDisplayResponse();
72 void setup()
74         Serial.begin(BAUD);     // The OLED-Display is connected via UART
76         pinMode(RST, OUTPUT);   // The OLED-Display's Reset-Pin is an OUTPUT.
78         displayInit();
79         displayClear();
80         displayDrawChar(1, 1, 10, '4', 52333);
83 void loop()
85         // Do nothing