Skip to content

Commit 71a9278

Browse files
committed
Added internal MCP protection on first 9 pins, removed NTP from quotables
1 parent eb7131d commit 71a9278

File tree

19 files changed

+317
-320
lines changed

19 files changed

+317
-320
lines changed

examples/Inkplate10/Advanced_Inkplate_Features/Inkplate_MCP23017_Expander/Inkplate_MCP23017_Expander.ino

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@
99
You will have to connect one side of 330 Ohm resistor to GPB7, than other side to anode of LED and finally, cathode
1010
pin of LED to GND.
1111
12-
This example will show you how you can manipulate with I/Os of MCP23017 Expander.
13-
You can only manipulate with Port B of MCP23017 (GPB1-GPB7). Port A is used for epaper panel and TPS65186 PMIC.
14-
GPB0 is used for ESP32 GPIO0 so you can't use it either.
15-
GPB1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad)
16-
GPB2, GPB3 and GPB4 are used for reading touchpad (if Touchpad solder bridges are bridged between second pad and
17-
third pad). If every thing is connected ok, after you upload code, LED should blink.
18-
19-
DANGER: DO NOT USE GPA0-GPA7 and GPB0. In code those are pins from 0-8!!! Using those, you might permanently damage
20-
the screen. You should only use pins from 9-15.
12+
This example will show you how you can manipulate with I/Os of external MCP23017 Expander.
13+
On this expander all pins are free to use, nothing is connected by the default.
2114
2215
Want to learn more about Inkplate? Visit www.inkplate.io
2316
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
@@ -36,18 +29,14 @@
3629

3730
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)
3831

39-
// If your Inkplate doesn't have external (or second) MCP I/O expander, you should uncomment next line,
40-
// otherwise your code could hang out when you send code to your Inkplate.
41-
// You can easily check if your Inkplate has second MCP by turning it over and
42-
// if there is missing chip near place where "MCP23017-2" is written, but if there is
43-
// chip soldered, you don't have to uncomment line and use external MCP I/O expander
44-
4532
void setup()
4633
{
4734
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
4835
display.pinModeMCP(
4936
LED_PIN,
50-
OUTPUT); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
37+
OUTPUT); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
38+
// If we do not specify which MCP we want to use, by the default external MCP will be used of the one
39+
// with header named MCP23017-2
5140
}
5241

5342
void loop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Inkplate_MCP23017 example for e-radionica.com Inkplate 10
3+
For this example you will need only a micro USB cable, Inkplate10, 330 Ohm resistor and LED diode.
4+
Select "Inkplate 10(ESP32)" from Tools -> Board menu.
5+
Don't have "Inkplate 10(ESP32)" option? Follow our tutorial and add it:
6+
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
7+
8+
Connect resistor to GPB7 pin on MCP23017 header at bottom right corner on the backside (component side) of Inkplate.
9+
You will have to connect one side of 330 Ohm resistor to GPB7, than other side to anode of LED and finally, cathode
10+
pin of LED to GND.
11+
12+
This example will show you how you can manipulate with I/Os of internal MCP23017 Expander.
13+
You can only manipulate with Port B of MCP23017 (GPB1-GPB7). Port A is used for epaper panel and TPS65186 PMIC.
14+
GPB0 is used for ESP32 GPIO0 so you can't use it either.
15+
GPB1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad)
16+
GPB2, GPB3 and GPB4 are used for reading touchpad (if Touchpad solder bridges are bridged between second pad and
17+
third pad). If every thing is connected ok, after you upload code, LED should blink.
18+
19+
DANGER: DO NOT USE GPA0-GPA7 and GPB0. In code those are pins from 0-8!!! Using those, you might permanently damage
20+
the screen. You should only use pins from 9-15.
21+
22+
Want to learn more about Inkplate? Visit www.inkplate.io
23+
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
24+
19 May 2022 by Soldered.com
25+
*/
26+
27+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
28+
#ifndef ARDUINO_INKPLATE10
29+
#error "Wrong board selection for this example, please select Inkplate 10 in the boards menu."
30+
#endif
31+
32+
#include "Inkplate.h" //Include Inkplate library to the sketch
33+
34+
#define LED_PIN MCP23017_PIN_B7 // We are going to use pin GPB7 (remember! GPA0 = 0, GPA1 = 1, ..., GPA7 = 7, GPB0 = 8, GBP1 = 9, ..., GPB7 =
35+
// 15)
36+
37+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)
38+
39+
void setup()
40+
{
41+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
42+
display.pinModeMCP(
43+
LED_PIN,
44+
OUTPUT, MCP23017_INT_ADDR); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
45+
// and specify that we want use internal MCP or MCP with header named MCP23017-1
46+
}
47+
48+
void loop()
49+
{
50+
display.digitalWriteMCP(LED_PIN, LOW, MCP23017_INT_ADDR); // Set output to low (LED does not light up)
51+
delay(1000); // Wait for one second
52+
display.digitalWriteMCP(LED_PIN, HIGH, MCP23017_INT_ADDR); // Set output to high (LED lights up)
53+
delay(1000); // Wait for one second
54+
}

examples/Inkplate10/Projects/Quotables_Example/Network.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,6 @@ void Network::begin()
6262
setTime();
6363
}
6464

65-
// Gets time from ntp server
66-
void Network::getTime(char *timeStr)
67-
{
68-
// Get seconds since 1.1.1970.
69-
time_t nowSecs = time(nullptr);
70-
71-
// Used to store time
72-
struct tm timeinfo;
73-
gmtime_r(&nowSecs, &timeinfo);
74-
75-
// Copies time string into timeStr
76-
strncpy(timeStr, asctime(&timeinfo) + 4, 12);
77-
78-
// Setting time string timezone
79-
int hr = 10 * timeStr[7] + timeStr[8] + timeZone;
80-
81-
// Better defined modulo, in case timezone makes hours to go below 0
82-
hr = (hr % 24 + 24) % 24;
83-
84-
// Adding time to '0' char makes it into whatever time char, for both digits
85-
timeStr[7] = hr / 10 + '0';
86-
timeStr[8] = hr % 10 + '0';
87-
}
88-
8965
bool Network::getData(char* text, char* auth)
9066
{
9167
bool f = 0;
@@ -189,29 +165,3 @@ bool Network::getData(char* text, char* auth)
189165

190166
return !f;
191167
}
192-
193-
// Function for initial time setting ovet the ntp server
194-
void Network::setTime()
195-
{
196-
// Used for setting correct time
197-
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
198-
199-
Serial.print(F("Waiting for NTP time sync: "));
200-
time_t nowSecs = time(nullptr);
201-
while (nowSecs < 8 * 3600 * 2)
202-
{
203-
delay(500);
204-
Serial.print(F("."));
205-
yield();
206-
nowSecs = time(nullptr);
207-
}
208-
209-
Serial.println();
210-
211-
// Used to store time info
212-
struct tm timeinfo;
213-
gmtime_r(&nowSecs, &timeinfo);
214-
215-
Serial.print(F("Current time: "));
216-
Serial.print(asctime(&timeinfo));
217-
}

examples/Inkplate10/Projects/Quotables_Example/Network.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ class Network
4545
public:
4646
// Functions we can access in main file
4747
void begin();
48-
void getTime(char *timeStr);
4948
bool getData(char* text, char* auth);
5049

5150
private:
5251
// Functions called from within our class
53-
void setTime();
5452
};
5553

5654
#endif

examples/Inkplate5/Advanced_Inkplate_Features/Inkplate_MCP23017_Expander/Inkplate_MCP23017_Expander.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@
99
You will have to connect one side of 330 Ohm resistor to GPB7, than other side to anode of LED and finally, cathode
1010
pin of LED to GND.
1111
12-
This example will show you how you can manipulate with I/Os of MCP23017 Expander.
13-
You can only manipulate with Port B of MCP23017 (GPB1-GPB7). Port A is used for epaper panel and TPS65186 PMIC.
14-
GPB0 is used for ESP32 GPIO0 so you can't use it either.
15-
GPB1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad)
16-
GPB2, GPB3 and GPB4 are used for reading touchpad (if Touchpad solder bridges are bridged between second pad and
17-
third pad). If every thing is connected ok, after you upload code, LED should blink.
18-
19-
DANGER: DO NOT USE GPA0-GPA7 and GPB0. In code those are pins from 0-8!!! Using those, you might permanently damage
20-
the screen. You should only use pins from 9-15.
12+
This example will show you how you can manipulate with I/Os of external MCP23017 Expander.
13+
On this expander all pins are free to use, nothing is connected by the default.
2114
2215
Want to learn more about Inkplate? Visit www.inkplate.io
2316
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
@@ -42,6 +35,8 @@ void setup()
4235
display.pinModeMCP(
4336
LED_PIN,
4437
OUTPUT); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
38+
// If we do not specify which MCP we want to use, by the default external MCP will be used of the one
39+
// with header named MCP23017-2
4540
}
4641

4742
void loop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Inkplate_MCP23017 example for e-radionica.com Inkplate 5
3+
For this example you will need only a micro USB cable, Inkplate5, 330 Ohm resistor and LED diode.
4+
Select "Inkplate 5(ESP32)" from Tools -> Board menu.
5+
Don't have "Inkplate 5(ESP32)" option? Follow our tutorial and add it:
6+
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
7+
8+
Connect resistor to GPB7 pin on MCP23017 header at bottom right corner on the backside (component side) of Inkplate.
9+
You will have to connect one side of 330 Ohm resistor to GPB7, than other side to anode of LED and finally, cathode
10+
pin of LED to GND.
11+
12+
This example will show you how you can manipulate with I/Os of internal MCP23017 Expander.
13+
You can only manipulate with Port B of MCP23017 (GPB1-GPB7). Port A is used for epaper panel and TPS65186 PMIC.
14+
GPB0 is used for ESP32 GPIO0 so you can't use it either.
15+
GPB1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad)
16+
GPB2, GPB3 and GPB4 are used for reading touchpad (if Touchpad solder bridges are bridged between second pad and
17+
third pad). If every thing is connected ok, after you upload code, LED should blink.
18+
19+
DANGER: DO NOT USE GPA0-GPA7 and GPB0. In code those are pins from 0-8!!! Using those, you might permanently damage
20+
the screen. You should only use pins from 9-15.
21+
22+
Want to learn more about Inkplate? Visit www.inkplate.io
23+
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
24+
19 May 2022 by Soldered.com
25+
*/
26+
27+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
28+
#ifndef ARDUINO_INKPLATE5
29+
#error "Wrong board selection for this example, please select Inkplate 5 in the boards menu."
30+
#endif
31+
32+
#include "Inkplate.h" //Include Inkplate library to the sketch
33+
34+
#define LED_PIN MCP23017_PIN_B7 // We are going to use pin GPB7 (remember! GPA0 = 0, GPA1 = 1, ..., GPA7 = 7, GPB0 = 8, GBP1 = 9, ..., GPB7 =
35+
// 15)
36+
37+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)
38+
39+
void setup()
40+
{
41+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
42+
display.pinModeMCP(
43+
LED_PIN,
44+
OUTPUT, MCP23017_INT_ADDR); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
45+
// and specify that we want use internal MCP or MCP with header named MCP23017-1
46+
}
47+
48+
void loop()
49+
{
50+
display.digitalWriteMCP(LED_PIN, LOW, MCP23017_INT_ADDR); // Set output to low (LED does not light up)
51+
delay(1000); // Wait for one second
52+
display.digitalWriteMCP(LED_PIN, HIGH, MCP23017_INT_ADDR); // Set output to high (LED lights up)
53+
delay(1000); // Wait for one second
54+
}

examples/Inkplate6/Advanced_Inkplate_Features/Inkplate_MCP23017_Expander/Inkplate_MCP23017_Expander.ino

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@
88
Connect resistor to GPB7 pin on MCP23017 header at bottom right corner on the backside (component side) of Inkplate.
99
You will have to connect one side of 330 Ohm resistor to GPB7, than other side to anode of LED and finally, cathode
1010
pin of LED to GND.
11-
12-
This example will show you how you can manipulate with I/Os of MCP23017 Expander.
13-
You can only manipulate with Port B of MCP23017 (GPB1-GPB7). Port A is used for epaper panel and TPS65186 PMIC.
14-
GPB0 is used for ESP32 GPIO0 so you can't use it either.
15-
GPB1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad)
16-
GPB2, GPB3 and GPB4 are used for reading touchpad (if Touchpad solder bridges are bridged between second pad and
17-
third pad). If every thing is connected ok, after you upload code, LED should blink.
18-
19-
DANGER: DO NOT USE GPA0-GPA7 and GPB0. In code those are pins from 0-8!!! Using those, you might permanently damage
20-
the screen. You should only use pins from 9-15.
11+
12+
This example will show you how you can manipulate with I/Os of external MCP23017 Expander.
13+
On this expander all pins are free to use, nothing is connected by the default.
2114
2215
Want to learn more about Inkplate? Visit www.inkplate.io
2316
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
@@ -44,6 +37,8 @@ void setup()
4437
display.pinModeMCP(
4538
LED_PIN,
4639
OUTPUT); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
40+
// If we do not specify which MCP we want to use, by the default external MCP will be used of the one
41+
// with header named MCP23017-2
4742
}
4843

4944
void loop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Inkplate_MCP23017 example for e-radionica.com Inkplate 6
3+
For this example you will need only a micro USB cable, Inkplate6, 330 Ohm resistor and LED diode.
4+
Select "Inkplate 6(ESP32)" from Tools -> Board menu.
5+
Don't have "Inkplate 6(ESP32)" option? Follow our tutorial and add it:
6+
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
7+
8+
Connect resistor to GPB7 pin on MCP23017 header at bottom right corner on the backside (component side) of Inkplate.
9+
You will have to connect one side of 330 Ohm resistor to GPB7, than other side to anode of LED and finally, cathode
10+
pin of LED to GND.
11+
12+
This example will show you how you can manipulate with I/Os of internal MCP23017 Expander.
13+
You can only manipulate with Port B of MCP23017 (GPB1-GPB7). Port A is used for epaper panel and TPS65186 PMIC.
14+
GPB0 is used for ESP32 GPIO0 so you can't use it either.
15+
GPB1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad)
16+
GPB2, GPB3 and GPB4 are used for reading touchpad (if Touchpad solder bridges are bridged between second pad and
17+
third pad). If every thing is connected ok, after you upload code, LED should blink.
18+
19+
DANGER: DO NOT USE GPA0-GPA7 and GPB0. In code those are pins from 0-8!!! Using those, you might permanently damage
20+
the screen. You should only use pins from 9-15.
21+
22+
Want to learn more about Inkplate? Visit www.inkplate.io
23+
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
24+
19 May 2022 by Soldered.com
25+
*/
26+
27+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
28+
#ifndef ARDUINO_ESP32_DEV
29+
#error "Wrong board selection for this example, please select Inkplate 6 in the boards menu."
30+
#endif
31+
32+
#include "Inkplate.h" //Include Inkplate library to the sketch
33+
34+
#define LED_PIN MCP23017_PIN_B7 // We are going to use pin GPB7 (remember! GPA0 = 0, GPA1 = 1, ..., GPA7 = 7, GPB0 = 8, GBP1 = 9, ..., GPB7 =
35+
// 15)
36+
37+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)
38+
39+
void setup()
40+
{
41+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
42+
display.pinModeMCP(
43+
LED_PIN,
44+
OUTPUT, MCP23017_INT_ADDR); // Set pin 15 (or GPB7) to output. On that pin, we sholud connect LED with current limiting resistor
45+
// and specify that we want use internal MCP or MCP with header named MCP23017-1
46+
}
47+
48+
void loop()
49+
{
50+
display.digitalWriteMCP(LED_PIN, LOW, MCP23017_INT_ADDR); // Set output to low (LED does not light up)
51+
delay(1000); // Wait for one second
52+
display.digitalWriteMCP(LED_PIN, HIGH, MCP23017_INT_ADDR); // Set output to high (LED lights up)
53+
delay(1000); // Wait for one second
54+
}

0 commit comments

Comments
 (0)