Skip to content

Commit 4b62968

Browse files
committed
Finished examples
1 parent 1879f0b commit 4b62968

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file Inkplate_6_MOTION_Buttons.ino
5+
* @brief Simply use the onboard buttons on Inkplate 6MOTION
6+
*
7+
* For info on how to quickly get started with Inkplate 6MOTION visit docs.inkplate.com
8+
*
9+
* @authors Borna Biro and Robert Soric for soldered.com
10+
* @date January 2025
11+
***************************************************/
12+
13+
// Include Inkplate Motion Library.
14+
#include <InkplateMotion.h>
15+
16+
17+
Inkplate inkplate; // Create object on Inkplate library
18+
19+
void setup() {
20+
inkplate.begin(); // Init library
21+
inkplate.clearDisplay(); // Clear any data that may have been in (software) frame buffer
22+
// Print info text
23+
inkplate.setTextSize(3); // Make the text a bit bigger so it's visible
24+
inkplate.setCursor(200, 200);
25+
inkplate.print("Buttons example - press the user buttons!");
26+
inkplate.display(); // Clear the display
27+
28+
29+
// Set button pinmodes
30+
pinMode(INKPLATE_USER1, INPUT_PULLUP);
31+
pinMode(INKPLATE_USER2, INPUT_PULLUP);
32+
pinMode(INKPLATE_WAKE, INPUT_PULLUP);
33+
}
34+
35+
void loop() {
36+
inkplate.clearDisplay();
37+
inkplate.setCursor(200, 200);
38+
inkplate.print("Buttons example - press the user buttons!");
39+
inkplate.setCursor(200, 450);
40+
int pressedButton = getButtonPress();
41+
if (pressedButton == 1) {
42+
inkplate.println("USER 1 pressed!");
43+
} else if (pressedButton == 2) {
44+
inkplate.println("USER 2 pressed!");
45+
} else if (pressedButton == 3) {
46+
inkplate.println("WAKE pressed!");
47+
}
48+
inkplate.partialUpdate(); // Update the display
49+
}
50+
51+
int getButtonPress() {
52+
// Wait for button press and return which button was pressed accordingly
53+
while (true) {
54+
if (digitalRead(INKPLATE_USER1) == LOW)
55+
return 1;
56+
if (digitalRead(INKPLATE_USER2) == LOW)
57+
return 2;
58+
if (digitalRead(INKPLATE_WAKE) == LOW)
59+
return 3;
60+
61+
delay(5); // Short debounce delay
62+
}
63+
}

examples/Advanced/Sensors_Other/Inkplate_6_MOTION_Rotary_Encoder/Inkplate_6_MOTION_Rotary_Encoder.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ void setup() {
3131
inkplate.setFullUpdateTreshold(60);
3232

3333
// Enable power to the rotary encoder.
34-
inkplate.peripheralState(INKPLATE_ROTARY_ENCODER_PERIPH, true);
34+
inkplate.peripheralState(INKPLATE_PERIPHERAL_ROTARY_ENCODER, true);
35+
delay(100);
3536
// Initialize rotary encoder.
3637
inkplate.rotaryEncoder.begin();
3738

@@ -64,7 +65,7 @@ void loop() {
6465

6566
void printPosition(int _oldPosition, int _newPos) {
6667
// Redraw the circle.
67-
inkplate.drawCircle(inkplate.width() / 2, inkplate.height() / 2, 310, BLACK);
68+
inkplate.drawCircle(inkplate.width() / 2, inkplate.height() / 2, 305, BLACK);
6869

6970
// Draw the new position.
7071
int _x2 = (300 * cos(DEG2RAD * _newPos)) + (inkplate.width() / 2);

src/boards/Inkplate6Motion/IP6MotionDriver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,14 +923,14 @@ void EPDDriver::peripheralState(uint8_t _peripheral, bool _en)
923923
{
924924
if (_en)
925925
{
926-
// If PWR MOSDET needs to be enabled, set controll pin from the IO Expander to output first.
926+
// If PWR MOSFET needs to be enabled, set controll pin from the IO Expander to output first.
927927
internalIO.pinModeIO(INKPLATE_POSITION_ENC_EN, OUTPUT, true);
928-
// Set the same pin to high, enabling power to the magnetic rotary encoder.
928+
// Set the sa me pin to high, enabling power to the magnetic rotary encoder.
929929
internalIO.digitalWriteIO(INKPLATE_POSITION_ENC_EN, HIGH, true);
930930
}
931931
else
932932
{
933-
// If PWR MOSDET needs to be disabled, firsdt set the pin to LOW.
933+
// If PWR MOSFET needs to be disabled, firsdt set the pin to LOW.
934934
internalIO.digitalWriteIO(INKPLATE_POSITION_ENC_EN, LOW, true);
935935

936936
// Set it to input (external pull-down resistor on the gate will keep it low).

0 commit comments

Comments
 (0)