Skip to content

Commit c5f1912

Browse files
committed
added new functionality to peripheral mode and fixed wake on touchpads on inkplate 10
1 parent aeae3f4 commit c5f1912

File tree

4 files changed

+666
-28
lines changed

4 files changed

+666
-28
lines changed

examples/Inkplate10/Advanced/DeepSleep/Inkplate10_Wake_Up_On_Touchpads/Inkplate10_Wake_Up_On_Touchpads.ino

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
/*
2-
Inkplate10_Wake_Up_On_Touchpads example for Soldered Inkplate 10
3-
For this example you will need USB cable and an Inkplate 10
4-
Select "e-radionica Inkplate10" or "Soldered Inkplate10" from Tools -> Board menu.
5-
Don't have "e-radionica Inkplate10" or "Soldered Inkplate10" option? Follow our tutorial and add it:
2+
Inkplate10_Wake_Up_On_Touchpads example for e-radionica Inkplate 10 (older ones that have touchpads)
3+
For this example you will need USB cable and an Inkplate 10.
4+
Select "e-radionica Inkplate10" from Tools -> Board menu.
5+
Don't have "e-radionica Inkplate10" option? Follow our tutorial and add it:
66
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
77
88
Here is shown how to use I/O Expander and ESP interrupts to wake up the MCU from deepsleep when touchpad is pressed.
9+
10+
NOTE: This is an example for the old Inkplates that have touchpads.
11+
If you select new Inkplate boards, you won't be able to compile the example.
912
1013
Want to learn more about Inkplate? Visit www.inkplate.io
1114
Looking to get support? Write on our forums: https://forum.soldered.com/
12-
11 February 2021 by Soldered
15+
15 March 2023 by Soldered
1316
*/
1417

1518
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
16-
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
17-
#error "Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
19+
#if !defined(ARDUINO_INKPLATE10)
20+
#error "Wrong board selection for this example, please select e-radionica Inkplate10 in the boards menu."
1821
#endif
1922

2023
#include <Inkplate.h>
2124

2225
// Conversion factor for micro seconds to seconds
2326
#define uS_TO_S_FACTOR 1000000
27+
2428
// Time ESP32 will go to sleep (in seconds)
2529
#define TIME_TO_SLEEP 30
2630

27-
// bitmask for GPIO_34 which is connected to I/O Expander INT pin
31+
// Bitmask for GPIO_34 which is connected to I/O Expander INT pin
2832
#define TOUCHPAD_WAKE_MASK (int64_t(1) << GPIO_NUM_34)
2933

3034
// Initiate Inkplate object
@@ -35,20 +39,15 @@ RTC_DATA_ATTR int bootCount = 0;
3539

3640
void setup()
3741
{
42+
// Init serial communication and Inkplate library (you should call this functions only once)
3843
Serial.begin(115200);
3944
display.begin();
4045

41-
// Different I/O expander has been used on Soldered Inkplate V2 board and original Soldered Inkplate.
42-
#ifdef ARDUINO_INKPLATE10
46+
// Set interrupt pins
4347
display.setIntOutput(1, false, false, HIGH, IO_INT_ADDR);
4448
display.setIntPin(PAD1, RISING, IO_INT_ADDR);
4549
display.setIntPin(PAD2, RISING, IO_INT_ADDR);
4650
display.setIntPin(PAD3, RISING, IO_INT_ADDR);
47-
#elif ARDUINO_INKPLATE10V2
48-
display.setIntPin(PAD1, IO_INT_ADDR);
49-
display.setIntPin(PAD2, IO_INT_ADDR);
50-
display.setIntPin(PAD3, IO_INT_ADDR);
51-
#endif
5251

5352
++bootCount;
5453

@@ -58,16 +57,17 @@ void setup()
5857
// Go to sleep for TIME_TO_SLEEP seconds
5958
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
6059

61-
// Enable wakup from deep sleep on gpio 36
62-
esp_sleep_enable_ext1_wakeup((1ULL << 36), ESP_EXT1_WAKEUP_ALL_LOW);
63-
60+
// Enable wakup from deep sleep on gpio 34
61+
esp_sleep_enable_ext1_wakeup(TOUCHPAD_WAKE_MASK, ESP_EXT1_WAKEUP_ANY_HIGH);
62+
6463
// Go to sleep
6564
esp_deep_sleep_start();
6665
}
6766

6867
void loop()
6968
{
70-
// Never here
69+
// Never here! If you are using deep sleep, the whole program should be in setup() because the board restarts each
70+
// time. loop() must be empty!
7171
}
7272

7373
// Function that will write number of boots and boot reason to screen

examples/Inkplate10/Diagnostics/Inkplate10_Peripheral_Mode/Inkplate10_Peripheral_Mode.ino

Lines changed: 189 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
3030
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
31-
#error "Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
31+
#error \
32+
"Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
3233
#endif
3334

3435
#include <Inkplate.h>
@@ -72,7 +73,11 @@ void loop()
7273
{
7374
if ((e - s) > 0)
7475
{
75-
int x, x1, x2, y, y1, y2, x3, y3, l, c, w, h, r, n, rx, ry, xc, yc;
76+
int x, x1, x2, y, y1, y2, x3, y3, l, c, w, h, r, n, rx, ry, xc, yc, yr;
77+
uint8_t hr, min, sec, wday, day, mon, k, as, am, ah, ad, aw, amc, v;
78+
bool ie, ip;
79+
System::rtcCountdownSrcClock sc;
80+
uint32_t ep, ae;
7681
char b;
7782
char temp[150];
7883
switch (*(s + 1))
@@ -259,11 +264,6 @@ void loop()
259264
sscanf(s + 3, "%c", &b);
260265
if (b == '?')
261266
{
262-
// if (0 == 0) {
263-
// Serial.println("#J(0)*");
264-
//} else {
265-
// Serial.println("#J(1)*");
266-
//}
267267
if (display.getDisplayMode() == INKPLATE_1BIT)
268268
{
269269
Serial.println("#J(0)*");
@@ -408,6 +408,188 @@ void loop()
408408
// Serial.print(temp);
409409
display.fillElipse(rx, ry, xc, yc, c);
410410
break;
411+
case 'W':
412+
sscanf(s + 3, "%d,%d,%d", &hr, &min, &sec);
413+
// sprintf(temp, "display.rtcSetTime(%d, %d, %d);\n\r", hr, min, sec);
414+
// Serial.println(temp);
415+
display.rtcSetTime(hr, min, sec);
416+
break;
417+
case 'X':
418+
sscanf(s + 3, "%d,%d,%d,%d", &wday, &day, &mon, &yr);
419+
// sprintf(temp, "display.rtcSetDate(%d, %d, %d, %d);\n\r", wday, day, mon, yr);
420+
// Serial.println(temp);
421+
display.rtcSetDate(wday, day, mon, yr);
422+
break;
423+
case 'Y':
424+
sscanf(s + 3, "%d", &ep);
425+
// sprintf(temp, "display.rtcSetEpoch(%d);\n\r", ep);
426+
// Serial.println(temp);
427+
display.rtcSetEpoch(ep);
428+
break;
429+
case 'Z':
430+
sscanf(s + 3, "%c", &b);
431+
if (b == '?')
432+
{
433+
display.rtcGetRtcData();
434+
Serial.print("#Z(");
435+
Serial.print(display.rtcGetEpoch());
436+
Serial.println(")*");
437+
Serial.flush();
438+
}
439+
break;
440+
case 'a':
441+
sscanf(s + 3, "%d", &k);
442+
if (k > 6)
443+
{
444+
Serial.println("INVALID");
445+
break;
446+
}
447+
display.rtcGetRtcData();
448+
Serial.print("#a(");
449+
switch (k)
450+
{
451+
case 0:
452+
Serial.print(display.rtcGetSecond());
453+
break;
454+
case 1:
455+
Serial.print(display.rtcGetMinute());
456+
break;
457+
case 2:
458+
Serial.print(display.rtcGetHour());
459+
break;
460+
case 3:
461+
Serial.print(display.rtcGetDay());
462+
break;
463+
case 4:
464+
Serial.print(display.rtcGetWeekday());
465+
break;
466+
case 5:
467+
Serial.print(display.rtcGetMonth());
468+
break;
469+
case 6:
470+
Serial.print(display.rtcGetYear());
471+
break;
472+
}
473+
Serial.println(")*");
474+
Serial.flush();
475+
break;
476+
case 'b':
477+
sscanf(s + 3, "%d,%d,%d,%d,%d", &as, &am, &ah, &ad, &aw);
478+
// sprintf(temp, "display.rtcSetAlarm(%d, %d, %d, %d, %d);\n\r", as, am, ah, ad, aw);
479+
// Serial.println(temp);
480+
display.rtcSetAlarm(as, am, ah, ad, aw);
481+
break;
482+
case 'c':
483+
sscanf(s + 3, "%d,%d", &ae, &amc);
484+
// sprintf(temp, "display.rtcSetAlarmEpoch(%d, %d);\n\r", ae, amc);
485+
// Serial.println(temp);
486+
display.rtcSetAlarmEpoch(ae, amc);
487+
break;
488+
case 'd':
489+
sscanf(s + 3, "%c", &b);
490+
if (b == '?')
491+
{
492+
Serial.print("#d(");
493+
Serial.print(display.rtcCheckAlarmFlag());
494+
Serial.println(")*");
495+
Serial.flush();
496+
}
497+
break;
498+
case 'e':
499+
sscanf(s + 3, "%c", &b);
500+
if (b == '1')
501+
{
502+
// Serial.println("display.rtcClearAlarmFlag()");
503+
display.rtcClearAlarmFlag();
504+
Serial.flush();
505+
}
506+
break;
507+
case 'f':
508+
sscanf(s + 3, "%d", &k);
509+
if (k > 4)
510+
{
511+
Serial.println("INVALID");
512+
break;
513+
}
514+
Serial.print("#f(");
515+
switch (k)
516+
{
517+
case 0:
518+
Serial.print(display.rtcGetAlarmSecond());
519+
break;
520+
case 1:
521+
Serial.print(display.rtcGetAlarmMinute());
522+
break;
523+
case 2:
524+
Serial.print(display.rtcGetAlarmHour());
525+
break;
526+
case 3:
527+
Serial.print(display.rtcGetAlarmDay());
528+
break;
529+
case 4:
530+
Serial.print(display.rtcGetAlarmWeekday());
531+
break;
532+
}
533+
Serial.println(")*");
534+
Serial.flush();
535+
break;
536+
case 'g':
537+
sscanf(s + 3, "%d,%d,%d,%d", &sc, &v, &ie, &ip);
538+
539+
if (sc > 3)
540+
{
541+
Serial.println("ERROR");
542+
break;
543+
}
544+
545+
// sprintf(temp, "display.rtcTimerSet(%d, %d, %d, %d);\n\r", sc, v, ie, ip);
546+
// Serial.println(temp);
547+
display.rtcTimerSet(sc, v, ie, ip);
548+
break;
549+
case 'h':
550+
sscanf(s + 3, "%c", &b);
551+
if (b == '?')
552+
{
553+
Serial.print("#h(");
554+
Serial.print(display.rtcCheckTimerFlag());
555+
Serial.println(")*");
556+
Serial.flush();
557+
}
558+
break;
559+
case 'i':
560+
sscanf(s + 3, "%c", &b);
561+
if (b == '1')
562+
{
563+
// Serial.println("display.rtcClearTimerFlag()");
564+
display.rtcClearTimerFlag();
565+
}
566+
break;
567+
case 'j':
568+
sscanf(s + 3, "%c", &b);
569+
if (b == '1')
570+
{
571+
// Serial.println("display.rtcDisableTimer()");
572+
display.rtcDisableTimer();
573+
}
574+
break;
575+
case 'k':
576+
sscanf(s + 3, "%c", &b);
577+
if (b == '?')
578+
{
579+
Serial.print("#k(");
580+
Serial.print(display.rtcIsSet());
581+
Serial.println(")*");
582+
Serial.flush();
583+
}
584+
break;
585+
case 'l':
586+
sscanf(s + 3, "%c", &b);
587+
if (b == '1')
588+
{
589+
// Serial.println("display.rtcReset()");
590+
display.rtcReset();
591+
}
592+
break;
411593
}
412594
*s = 0;
413595
*e = 0;

0 commit comments

Comments
 (0)