Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
PaperdinkDeviceBaseClass Class Reference

#include <base.h>

Inheritance diagram for PaperdinkDeviceBaseClass:
Paperdink_Classic Paperdink_Merlot

Public Member Functions

int8_t begin ()
 
virtual int8_t enable_display ()
 
virtual int8_t disable_display ()
 
int8_t enable_sd ()
 
int8_t disable_sd ()
 
int8_t disable_everything ()
 
int8_t deep_sleep_timer_wakeup (uint64_t sleep_time_us)
 
int8_t deep_sleep_button_wakeup (uint8_t gpio_num)
 
int8_t deep_sleep_timer_button_wakeup (uint64_t sleep_time_us, uint8_t gpio_num)
 
int8_t connect_wifi (const char *ssid, const char *password, uint8_t attempts)
 
int8_t connect_wifi (const char *ssid, const char *password)
 

Public Attributes

uint8_t has_color = false
 
int color = GxEPD_BLACK
 

Detailed Description

Definition at line 12 of file base.h.

Member Function Documentation

◆ begin()

int8_t PaperdinkDeviceBaseClass::begin ( )

Definition at line 4 of file base.cpp.

5{
6 pinMode(EPD_EN, OUTPUT);
7 pinMode(EPD_RST, OUTPUT);
8 pinMode(SD_EN, OUTPUT);
9 pinMode(BATT_EN, OUTPUT);
10 pinMode(PCF_INT, INPUT); // Required to lower power consumption
11
12 pinMode(BUTTON_1_PIN, INPUT_PULLUP);
13 pinMode(BUTTON_2_PIN, INPUT_PULLUP);
14 pinMode(BUTTON_3_PIN, INPUT_PULLUP);
15 pinMode(BUTTON_4_PIN, INPUT_PULLUP);
16
17 return 0;
18}
#define BUTTON_3_PIN
#define BUTTON_1_PIN
#define SD_EN
#define EPD_EN
#define PCF_INT
#define BUTTON_4_PIN
#define EPD_RST
#define BUTTON_2_PIN
#define BATT_EN

◆ connect_wifi() [1/2]

int8_t PaperdinkDeviceBaseClass::connect_wifi ( const char * ssid,
const char * password )

Definition at line 128 of file base.cpp.

129{
130 return connect_wifi(ssid, password, 40);
131}
int8_t connect_wifi(const char *ssid, const char *password, uint8_t attempts)
Definition base.cpp:113

◆ connect_wifi() [2/2]

int8_t PaperdinkDeviceBaseClass::connect_wifi ( const char * ssid,
const char * password,
uint8_t attempts )

Definition at line 113 of file base.cpp.

114{
115 WiFi.begin(ssid, password);
116
117 while (WiFi.status() != WL_CONNECTED) {
118 delay(500);
119 Serial.print(".");
120 if (!attempts--)
121 return -1;
122 }
123 Serial.println("Connected");
124
125 return 0;
126}

◆ deep_sleep_button_wakeup()

int8_t PaperdinkDeviceBaseClass::deep_sleep_button_wakeup ( uint8_t gpio_num)

Definition at line 86 of file base.cpp.

87{
88 // Turn off everything
90
91 esp_sleep_enable_ext0_wakeup((gpio_num_t)gpio_num, 0); //1 = High, 0 = Low
92 Serial.printf("Button wakeup on pin %d", gpio_num);
93 // Go to sleep
94 esp_deep_sleep_start();
95
96 return 0;
97}
int8_t disable_everything()
Definition base.cpp:62

◆ deep_sleep_timer_button_wakeup()

int8_t PaperdinkDeviceBaseClass::deep_sleep_timer_button_wakeup ( uint64_t sleep_time_us,
uint8_t gpio_num )

Definition at line 99 of file base.cpp.

100{
101 // Turn off everything
103
104 esp_sleep_enable_timer_wakeup(sleep_time_us);
105 esp_sleep_enable_ext0_wakeup((gpio_num_t)gpio_num, 0); //1 = High, 0 = Low
106 Serial.printf("Timer wakeup after %lld us or button on pin %d", sleep_time_us, gpio_num);
107 // Go to sleep
108 esp_deep_sleep_start();
109
110 return 0;
111}

◆ deep_sleep_timer_wakeup()

int8_t PaperdinkDeviceBaseClass::deep_sleep_timer_wakeup ( uint64_t sleep_time_us)

Definition at line 72 of file base.cpp.

73{
74 // Turn off everything
76
77 esp_sleep_enable_timer_wakeup(sleep_time_us);
78 Serial.printf("Timer wakeup after %lld microseconds...", sleep_time_us);
79
80 // Go to sleep
81 esp_deep_sleep_start();
82
83 return 0;
84}

◆ disable_display()

int8_t PaperdinkDeviceBaseClass::disable_display ( )
virtual

Reimplemented in Paperdink_Classic, and Paperdink_Merlot.

Definition at line 32 of file base.cpp.

33{
34 digitalWrite(EPD_EN, HIGH);
35 digitalWrite(EPD_RST, LOW);
36 delay(50);
37 digitalWrite(EPD_RST, HIGH);
38
39 return 0;
40}

◆ disable_everything()

int8_t PaperdinkDeviceBaseClass::disable_everything ( )

Definition at line 62 of file base.cpp.

63{
65 disable_sd();
66 // TODO: Add disable functions for Batt
67 digitalWrite(BATT_EN, HIGH);
68
69 return 0;
70}
virtual int8_t disable_display()
Definition base.cpp:32

◆ disable_sd()

int8_t PaperdinkDeviceBaseClass::disable_sd ( )

Definition at line 54 of file base.cpp.

55{
56 // Power down SD
57 digitalWrite(SD_EN, HIGH);
58
59 return 0;
60}

◆ enable_display()

int8_t PaperdinkDeviceBaseClass::enable_display ( )
virtual

Reimplemented in Paperdink_Classic, and Paperdink_Merlot.

Definition at line 20 of file base.cpp.

21{
22 // Power up EPD
23 digitalWrite(EPD_EN, LOW);
24 digitalWrite(EPD_RST, LOW);
25 delay(50);
26 digitalWrite(EPD_RST, HIGH);
27 delay(50);
28
29 return 0;
30}

◆ enable_sd()

int8_t PaperdinkDeviceBaseClass::enable_sd ( )

Definition at line 42 of file base.cpp.

43{
44 // Power up SD
45 digitalWrite(SD_EN, LOW);
46 if (!SD.begin(SD_CS)) {
47 Serial.println("SD failed!");
48 return -1;
49 }
50
51 return 0;
52}
#define SD_CS

Member Data Documentation

◆ color

int PaperdinkDeviceBaseClass::color = GxEPD_BLACK

Definition at line 16 of file base.h.

◆ has_color

uint8_t PaperdinkDeviceBaseClass::has_color = false

Definition at line 15 of file base.h.


The documentation for this class was generated from the following files: