-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdot222-I2C-grove-OLED.ino
127 lines (108 loc) · 3.79 KB
/
dot222-I2C-grove-OLED.ino
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* b-grove-OLED.ino
*
*
* GNU GENERAL PUBLIC LICENSE
* Use at your own risk.
************************************************ Important stuff if needed ****************************************
*
* Purchase here https://wiki.seeedstudio.com/Grove-OLED_Display_0.96inch/ about $20 USD
*
* Note u8g2 is an arduino search caplble library, easy to install
*
* using 128 x 64 seeeduino OLED
* black GND
* red 3v3 so do not need the protective resistors below
* white SDA D11 // on portenta
* yellow SCL D12 // on portenta
*
* another reference here
* https://github.com/olikraus/u8g2/wiki/u8g2reference#setfont
*
* For platformio you need the following at the bottom of the platformio.ini file
lib_deps = olikraus/U8g2@^2.32.10
*
*
********************************************************** end ****************************************************
*
*
* By Jeremy Ellis twitter @rocksetta
* Webpage http://rocksetta.com
* Arduino High School Robotics Course at
* https://github.com/hpssjellis/arduino-high-school-robotics-course
*
* Update March 28, 2021
*
* MbedI2C myI2C0(PH_8, PH_7); //MbedI2C(int sda, int scl);
* MbedI2C myI2C1(PB_7, PB_6);
* MbedI2C myI2C2(PH_12, PH_11);
*
*/
#include <Arduino.h> // only needed for https://platformio.org/
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
// works
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //(rotation, clock, data [, reset])
// makes it 128 x 32 if you want that
//U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // SSD1306 and SSD1308Z are compatible
//
// Not yet tested, for Portenta Breakout Board
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, PH_7, PH_8, /* reset=*/ U8X8_PIN_NONE); // I2C0 default //(rotation, clock, data [, reset])
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, PB_6, PB_7, /* reset=*/ U8X8_PIN_NONE); // I2C1
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, PH_11, PH_12, /* reset=*/ U8X8_PIN_NONE); // I2C2
void setup(void) {
u8g2.begin();
}
void loop(void) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr);
// FONTS to try
// u8g2_font_ncenB08_tr // normal
// u8g2_font_u8glib_4_tf // small
// u8g2_font_ncenB18_tr // bigger
// u8g2_font_pieceofcake_mel_tr // weird
// u8g2_font_ncenB08_tr // skinny
// u8g2_font_unifont_t_symbols // stretched
// FONT LIST at
//https://github.com/olikraus/u8g2/wiki/fntlistall
// u8g2.setFontDirection(random(3)); // 0, normal, 1,2,3 rotate by 90 degrees
u8g2.drawPixel(random(128), random(64));
u8g2.drawLine(0,0, 127, 0); // horizontal top
u8g2.drawLine(0,63, 127,63); // horizontal bottom
u8g2.drawLine(127,0,127,63); // vertical right
u8g2.drawCircle(90,20, random(15)); // Circle center x,y, random radius
u8g2.drawStr(0,10,"Hello World!"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
/*
* Clickable links for helpful information
* By @rocksetta
* March, 2021
* GNU GENERAL PUBLIC LICENSE
* Use at your own risk.
*
*
*
* Artduino Pro Links:
*
* https://store.arduino.cc/usa/portenta-h7
* https://forum.arduino.cc/index.php?board=148.0
* https://www.arduino.cc/pro/tutorials/portenta-h7
*
* Rocksetta links:
*
* https://twitter.com/rocksetta
* https://github.com/hpssjellis/portenta-pro-community-solutions
* https://github.com/hpssjellis/my-examples-for-the-arduino-portentaH7
* https://github.com/hpssjellis/arduino-high-school-robotics-course
* https://www.youtube.com/playlist?list=PL57Dnr1H_egtm0pi-okmG0iE_X5dROaLw
*
*
*
*/