Skip to content

Commit 5b3ceb8

Browse files
committed
Added GPIO expander functionality for the EPDiy_V7 PCB
1 parent f5a3364 commit 5b3ceb8

File tree

3 files changed

+310
-83
lines changed

3 files changed

+310
-83
lines changed

src/FastEPD.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ int FASTEPD::setMode(int iMode)
110110
return bbepSetMode(&_state, iMode);
111111
/* setMode() */
112112
}
113+
void FASTEPD::ioPinMode(uint8_t u8Pin, uint8_t iMode)
114+
{
115+
if (_state.pfnExtIO) {
116+
(*_state.pfnExtIO)(BB_EXTIO_SET_MODE, u8Pin, iMode);
117+
}
118+
}
119+
void FASTEPD::ioWrite(uint8_t u8Pin, uint8_t iValue)
120+
{
121+
if (_state.pfnExtIO) {
122+
(*_state.pfnExtIO)(BB_EXTIO_WRITE, u8Pin, iValue);
123+
}
124+
}
125+
uint8_t FASTEPD::ioRead(uint8_t u8Pin)
126+
{
127+
uint8_t val = 0;
128+
if (_state.pfnExtIO) {
129+
val = (*_state.pfnExtIO)(BB_EXTIO_READ, u8Pin, 0);
130+
}
131+
return val;
132+
}
133+
113134
void FASTEPD::setFont(int iFont)
114135
{
115136
_state.iFont = iFont;
@@ -125,6 +146,11 @@ void FASTEPD::setFont(const void *pFont, bool bAntiAlias)
125146
_state.anti_alias = (uint8_t)bAntiAlias;
126147
} /* setFont() */
127148

149+
void FASTEPD::setTextWrap(bool bWrap)
150+
{
151+
bbepSetTextWrap(&_state, (int)bWrap);
152+
} /* setTextWrap() */
153+
128154
void FASTEPD::setTextColor(int iFG, int iBG)
129155
{
130156
_state.iFG = iFG;
@@ -196,7 +222,12 @@ int FASTEPD::initCustomPanel(BBPANELDEF *pPanel, BBPANELPROCS *pProcs)
196222
_state.pfnIOInit = pProcs->pfnIOInit;
197223
_state.pfnRowControl = pProcs->pfnRowControl;
198224
return (*(_state.pfnIOInit))(&_state);
199-
} /* setPanelType() */
225+
} /* initCustomPanel() */
226+
227+
int FASTEPD::setPanelSize(int iPanel)
228+
{
229+
return bbepSetDefinedPanel(&_state, iPanel);
230+
}
200231

201232
int FASTEPD::setPanelSize(int width, int height, int flags) {
202233
return bbepSetPanelSize(&_state, width, height, flags);

src/FastEPD.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ enum {
6363
BB_PANEL_CUSTOM,
6464
BB_PANEL_COUNT
6565
};
66+
67+
// Pre-configured displays
68+
enum {
69+
BBEP_DISPLAY_EC060TC1,
70+
BBEP_DISPLAY_ED0970TC1,
71+
BBEP_DISPLAY_ED103TC2,
72+
BBEP_DISPLAY_ED052TC4,
73+
BBEP_DISPLAY_COUNT
74+
};
75+
6676
// A complete description of an EPD panel
6777
typedef struct _paneldef {
6878
uint16_t width;
@@ -96,6 +106,14 @@ typedef struct bbepr {
96106
int h;
97107
} BBEPRECT;
98108

109+
// To access external IO through a single function pointer
110+
// This enum defines the operation
111+
enum {
112+
BB_EXTIO_SET_MODE=0,
113+
BB_EXTIO_WRITE,
114+
BB_EXTIO_READ
115+
};
116+
99117
// Display clearing pass type
100118
enum {
101119
BB_CLEAR_LIGHTEN = 0,
@@ -143,13 +161,16 @@ typedef int (BB_IO_INIT)(void *pBBEP);
143161
typedef void (BB_IO_DEINIT)(void *pBBEP);
144162
// Callback function for controlling the row start/step
145163
typedef void (BB_ROW_CONTROL)(void *pBBEP, int iMode);
164+
// Callback function to access external IO expanders
165+
typedef uint8_t (BB_EXT_IO)(uint8_t iOP, uint8_t iPin, uint8_t iValue);
146166

147167
typedef struct tag_bbeppanelprocs
148168
{
149169
BB_EINK_POWER *pfnEinkPower;
150170
BB_IO_INIT *pfnIOInit;
151171
BB_ROW_CONTROL *pfnRowControl;
152172
BB_IO_DEINIT *pfnIODeInit;
173+
BB_EXT_IO *pfnExtIO;
153174
} BBPANELPROCS;
154175

155176
typedef struct tag_fastepdstate
@@ -172,6 +193,7 @@ typedef struct tag_fastepdstate
172193
BB_SET_PIXEL *pfnSetPixel;
173194
BB_SET_PIXEL_FAST *pfnSetPixelFast;
174195
BB_EINK_POWER *pfnEinkPower;
196+
BB_EXT_IO *pfnExtIO;
175197
BB_IO_INIT *pfnIOInit;
176198
BB_IO_DEINIT *pfnIODeInit;
177199
BB_ROW_CONTROL *pfnRowControl;
@@ -188,10 +210,14 @@ class FASTEPD
188210
FASTEPD() {memset(&_state, 0, sizeof(_state)); _state.iFont = FONT_8x8; _state.iFG = BBEP_BLACK;}
189211
int initPanel(int iPanelType);
190212
int initCustomPanel(BBPANELDEF *pPanel, BBPANELPROCS *pProcs);
213+
int setPanelSize(int iPanel);
191214
int setCustomMatrix(const uint8_t *pMatrix, size_t matrix_size);
192215
int setPanelSize(int width, int height, int flags = BB_PANEL_FLAG_NONE);
193216
int getStringBox(const char *text, BBEPRECT *pRect);
194217
int setMode(int iMode); // set graphics mode
218+
void ioPinMode(uint8_t u8Pin, uint8_t iMode);
219+
void ioWrite(uint8_t u8Pin, uint8_t iValue);
220+
uint8_t ioRead(uint8_t u8Pin);
195221
int getMode(void) {return _state.mode;}
196222
uint8_t *previousBuffer(void) { return _state.pPrevious;}
197223
uint8_t *currentBuffer(void) { return _state.pCurrent;}

0 commit comments

Comments
 (0)