-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy patholed_12864_driver.ino
More file actions
executable file
·102 lines (90 loc) · 2.24 KB
/
oled_12864_driver.ino
File metadata and controls
executable file
·102 lines (90 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <U8glib.h>
/************************* LCD io *************************/
#define LCD_CS 42
#define LCD_RES 43
#define LCD_CD 44
#define LCD_SCK 30
#define LCD_MOSI 35
U8GLIB_SH1106_128X64 u8g(LCD_SCK, LCD_MOSI, LCD_CS, LCD_CD); // SW SPI Com: SCK = 52, MOSI = 51, CS = 42, CD = 44
void setup() {
// put your setup code here, to run once:
pinMode(LCD_RES, OUTPUT);
digitalWrite(LCD_RES, HIGH);
u8g.firstPage();
do{
draw();
u8g.setColorIndex(1);
} while(u8g.nextPage());
}
void loop() {
// put your main code here, to run repeatedly:
}
void drawColorBox(void)
{
u8g_uint_t w, h;
u8g_uint_t r, g, b;
w = u8g.getWidth() / 32;
h = u8g.getHeight() / 8;
for ( b = 0; b < 4; b++ )
for ( g = 0; g < 8; g++ )
for ( r = 0; r < 8; r++ )
{
u8g.setColorIndex((r << 5) | (g << 2) | b );
u8g.drawBox(g * w + b * w * 8, r * h, w, h);
}
}
void drawLogo(uint8_t d)
{
#ifdef MINI_LOGO
u8g.setFont(u8g_font_gdr17r);
u8g.drawStr(0 + d, 22 + d, "U");
u8g.setFont(u8g_font_gdr20n);
u8g.drawStr90(17 + d, 8 + d, "8");
u8g.setFont(u8g_font_gdr17r);
u8g.drawStr(39 + d, 22 + d, "g");
u8g.drawHLine(2 + d, 25 + d, 34);
u8g.drawVLine(32 + d, 22 + d, 12);
#else
u8g.setFont(u8g_font_gdr25r);
u8g.drawStr(0 + d, 30 + d, "U");
u8g.setFont(u8g_font_gdr30n);
u8g.drawStr90(23 + d, 10 + d, "8");
u8g.setFont(u8g_font_gdr25r);
u8g.drawStr(53 + d, 30 + d, "g");
u8g.drawHLine(2 + d, 35 + d, 47);
u8g.drawVLine(45 + d, 32 + d, 12);
#endif
}
void drawURL(void)
{
#ifndef MINI_LOGO
u8g.setFont(u8g_font_4x6);
if ( u8g.getHeight() < 59 )
{
u8g.drawStr(53, 9, "code.google.com");
u8g.drawStr(77, 18, "/p/u8glib");
}
else
{
u8g.drawStr(1, 54, "code.google.com/p/u8glib");
u8g.drawStr(1, 64, "https://www.ufactory.cc");
}
#endif
}
void draw(void)
{
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
{
drawColorBox();
}
u8g.setColorIndex(1);
if ( U8G_MODE_GET_BITS_PER_PIXEL(u8g.getMode()) > 1 )
{
drawLogo(2);
u8g.setColorIndex(2);
drawLogo(1);
u8g.setColorIndex(3);
}
drawLogo(0);
drawURL();
}