Skip to content

Commit 11c8430

Browse files
committed
2 parents e36bacf + e19c472 commit 11c8430

File tree

177 files changed

+35185
-30155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+35185
-30155
lines changed

src/boards/Inkplate6Motion/IP6MotionBoardFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Wrapper for different Inkplate boards.
2727
class InkplateBoardClass : public EPDDriver
2828
{
29-
public:
29+
public:
3030
InkplateBoardClass(){};
3131
};
3232

src/boards/Inkplate6Motion/IP6MotionDriver.h

Lines changed: 117 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
#include "../../libs/imageProcessing/ditherKernels.h"
4848

4949
// Defines for EPD GPIOs
50-
#define EPD_DRIVER_PINS_OUTPUT 0
51-
#define EPD_DRIVER_PINS_H_ZI 1
50+
#define EPD_DRIVER_PINS_OUTPUT 0
51+
#define EPD_DRIVER_PINS_H_ZI 1
5252

5353
// FMC address for sending data to the EPD.
54-
#define EPD_FMC_ADDR 0x68000000
54+
#define EPD_FMC_ADDR 0x68000000
5555

5656
// Inplate Motion base class.
5757
class Inkplate;
@@ -93,7 +93,8 @@ static inline void vScanStart()
9393
// Compiler be nice, please do not optimise this function.
9494
__attribute__((optimize("O0"))) static inline void cycleDelay(uint32_t _cycles)
9595
{
96-
while(_cycles--);
96+
while (_cycles--)
97+
;
9798
}
9899

99100
// Start writing the first line into epaper display.
@@ -125,157 +126,160 @@ __attribute__((always_inline)) static inline void vScanEnd()
125126

126127
class EPDDriver : public Helpers
127128
{
128-
public:
129-
EPDDriver();
130-
int initDriver(Inkplate *_inkplatePtr);
131-
void cleanFast(uint8_t *_clearWavefrom, uint8_t _wavefromPhases);
132-
void clearDisplay();
133-
void partialUpdate(uint8_t _leaveOn = 0);
134-
void display(uint8_t _leaveOn = 0);
135-
int epdPSU(uint8_t _state);
136-
bool loadWaveform(InkplateWaveform _customWaveform);
137-
double readBattery();
138-
void selectDisplayMode(uint8_t _mode);
139-
uint8_t getDisplayMode();
129+
public:
130+
EPDDriver();
131+
int initDriver(Inkplate *_inkplatePtr);
132+
void cleanFast(uint8_t *_clearWavefrom, uint8_t _wavefromPhases);
133+
void clearDisplay();
134+
void partialUpdate(uint8_t _leaveOn = 0);
135+
void display(uint8_t _leaveOn = 0);
136+
int epdPSU(uint8_t _state);
137+
bool loadWaveform(InkplateWaveform _customWaveform);
138+
double readBattery();
139+
void selectDisplayMode(uint8_t _mode);
140+
uint8_t getDisplayMode();
140141

141-
// Set the automatic partial update.
142-
void setFullUpdateTreshold(uint16_t _numberOfPartialUpdates);
142+
// Set the automatic partial update.
143+
void setFullUpdateTreshold(uint16_t _numberOfPartialUpdates);
143144

144-
// Should be moved into Inkplate.h or Graphics.h.
145-
void drawBitmapFast(const uint8_t *_p);
145+
// Should be moved into Inkplate.h or Graphics.h.
146+
void drawBitmapFast(const uint8_t *_p);
146147

147-
// Initializer for microSD card.
148-
bool microSDCardInit();
148+
// Initializer for microSD card.
149+
bool microSDCardInit();
149150

150-
// Enable selected peripherals.
151-
void peripheralState(uint8_t _peripheral, bool _en);
151+
// Enable selected peripherals.
152+
void peripheralState(uint8_t _peripheral, bool _en);
152153

153-
// Object for ePaper power managment IC.
154-
EpdPmic pmic;
154+
// Object for ePaper power managment IC.
155+
EpdPmic pmic;
155156

156-
// Object for GPIO expander.
157-
IOExpander internalIO;
157+
// Object for GPIO expander.
158+
IOExpander internalIO;
158159

159-
// Object for the STM32 built-in RTC.
160-
STM32H7RTC rtc;
160+
// Object for the STM32 built-in RTC.
161+
STM32H7RTC rtc;
161162

162-
// Object for the magnetic rotary encoder.
163-
AS5600 rotaryEncoder;
163+
// Object for the magnetic rotary encoder.
164+
AS5600 rotaryEncoder;
164165

165-
// Object for NeoPixel LED.
166-
Adafruit_NeoPixel led = Adafruit_NeoPixel(2, INKPLATE_WSLED_DIN, NEO_GRB + NEO_KHZ800);
166+
// Object for NeoPixel LED.
167+
Adafruit_NeoPixel led = Adafruit_NeoPixel(2, INKPLATE_WSLED_DIN, NEO_GRB + NEO_KHZ800);
167168

168-
// Object for SHTC3 temperature and humidity sensor.
169-
SHTC3 shtc3;
169+
// Object for SHTC3 temperature and humidity sensor.
170+
SHTC3 shtc3;
170171

171-
// Object for the ADPS9960 Sensor.
172-
SparkFun_APDS9960 apds9960;
172+
// Object for the ADPS9960 Sensor.
173+
SparkFun_APDS9960 apds9960;
173174

174-
// Object for LSM6DSO32 accelerometer & gyroscope.
175-
Adafruit_LSM6DSO32 lsm6dso32;
175+
// Object for LSM6DSO32 accelerometer & gyroscope.
176+
Adafruit_LSM6DSO32 lsm6dso32;
176177

177-
// Object for the Inkplate on-board micro SD card.
178-
SdFat sdFat;
178+
// Object for the Inkplate on-board micro SD card.
179+
SdFat sdFat;
179180

180-
// Inkplate Motion object, needed for drawPixel.
181-
Inkplate *_inkplate;
181+
// Inkplate Motion object, needed for drawPixel.
182+
Inkplate *_inkplate;
182183

183-
// Class for image decode in Inkplate Motion library.
184-
ImageDecoder image;
184+
// Class for image decode in Inkplate Motion library.
185+
ImageDecoder image;
185186

186-
// Class for the image processing (grayscale, color invert, dither).
187-
ImageProcessing imgProcess;
187+
// Class for the image processing (grayscale, color invert, dither).
188+
ImageProcessing imgProcess;
188189

189-
// If needed, DMA buffers used in drivers can be used for something else.
190-
volatile uint8_t *_dmaBuffer[3];
190+
// If needed, DMA buffers used in drivers can be used for something else.
191+
volatile uint8_t *_dmaBuffer[3];
191192

192-
protected:
193-
// Function initializes all GPIO pins used on Inkplate for driving EPD.
194-
void gpioInit();
193+
protected:
194+
// Function initializes all GPIO pins used on Inkplate for driving EPD.
195+
void gpioInit();
195196

196-
// External SRAM frame buffers astart addresses. Statically allocated due speed.
197-
// Frame buffer for current image on the screen. 2MB in size (2097152 bytes).
198-
volatile uint8_t *_currentScreenFB = (uint8_t *)0xD0000000;
197+
// External SRAM frame buffers astart addresses. Statically allocated due speed.
198+
// Frame buffer for current image on the screen. 2MB in size (2097152 bytes).
199+
volatile uint8_t *_currentScreenFB = (uint8_t *)0xD0000000;
199200

200-
// Frame buffer for the image that will be written to the screen on update. 2MB in size (2097152 bytes).
201-
volatile uint8_t *_pendingScreenFB = (uint8_t *)0xD0200000;
201+
// Frame buffer for the image that will be written to the screen on update. 2MB in size (2097152 bytes).
202+
volatile uint8_t *_pendingScreenFB = (uint8_t *)0xD0200000;
202203

203-
// "Scratchpad memory" used for calculations (partial update for example). 2MB in size (2097152 bytes).
204-
volatile uint8_t *_scratchpadMemory = (uint8_t *)0xD0400000;
204+
// "Scratchpad memory" used for calculations (partial update for example). 2MB in size (2097152 bytes).
205+
volatile uint8_t *_scratchpadMemory = (uint8_t *)0xD0400000;
205206

206-
// Buffer for downloading files from the web. 4MB in size (4194304 bytes).
207-
volatile uint8_t *_downloadFileMemory = (uint8_t *)0xD0800000;
207+
// Buffer for downloading files from the web. 4MB in size (4194304 bytes).
208+
volatile uint8_t *_downloadFileMemory = (uint8_t *)0xD0800000;
208209

209-
private:
210-
// Sets EPD control GPIO pins to the output or High-Z state.
211-
void epdGpioState(uint8_t _state);
210+
private:
211+
// Sets EPD control GPIO pins to the output or High-Z state.
212+
void epdGpioState(uint8_t _state);
212213

213-
// Function calculates 4 pixels at once from 4 bit per pixel buffer on the fly (before start writing new frame).
214-
// With this we can crate LUT that will take all 4 pixels from the frame buffer and convert them into waveform.
215-
void calculateGLUTOnTheFly(uint8_t *_lut, uint8_t *_waveform);
214+
// Function calculates 4 pixels at once from 4 bit per pixel buffer on the fly (before start writing new frame).
215+
// With this we can crate LUT that will take all 4 pixels from the frame buffer and convert them into waveform.
216+
void calculateGLUTOnTheFly(uint8_t *_lut, uint8_t *_waveform);
216217

217-
// Function calculates the difference between tfo framebuffers (usually between current image on the screen and pending in the MCU memory).
218-
void differenceMask(uint8_t *_currentScreenFB, uint8_t *_pendingScreenFB, uint8_t *_differenceMask);
218+
// Function calculates the difference between tfo framebuffers (usually between current image on the screen and
219+
// pending in the MCU memory).
220+
void differenceMask(uint8_t *_currentScreenFB, uint8_t *_pendingScreenFB, uint8_t *_differenceMask);
219221

220-
// Internal method for global 1 bit ePaper screen update.
221-
void display1b(uint8_t _leaveOn);
222-
223-
// Internal method for global 4 bit ePaper screen update.
224-
void display4b(uint8_t _leaveOn);
222+
// Internal method for global 1 bit ePaper screen update.
223+
void display1b(uint8_t _leaveOn);
225224

226-
// Universal method fot the ePaper screen update.
227-
void pixelsUpdate(volatile uint8_t *_frameBuffer, uint8_t *_waveformLut, void (*_pixelDecode)(void*, void*, void*), const uint8_t _prebufferedLines, uint8_t _bitsPerPx);
225+
// Internal method for global 4 bit ePaper screen update.
226+
void display4b(uint8_t _leaveOn);
228227

229-
// Mode dependant methods for conversion framebuffer data into waveforem data. Used by the pixelsUpdate.
230-
static void pixelDecode4BitEPD(void *_out, void *_lut, void *_fb);
231-
static void pixelDecode1BitEPDFull(void *_out, void *_lut, void *_fb);
232-
static void pixelDecode1BitEPDPartial(void *_out, void *_lut, void *_fb);
228+
// Universal method fot the ePaper screen update.
229+
void pixelsUpdate(volatile uint8_t *_frameBuffer, uint8_t *_waveformLut,
230+
void (*_pixelDecode)(void *, void *, void *), const uint8_t _prebufferedLines,
231+
uint8_t _bitsPerPx);
233232

234-
// Internal 4 bit partial update method.
235-
void partialUpdate4Bit(uint8_t _leaveOn);
233+
// Mode dependant methods for conversion framebuffer data into waveforem data. Used by the pixelsUpdate.
234+
static void pixelDecode4BitEPD(void *_out, void *_lut, void *_fb);
235+
static void pixelDecode1BitEPDFull(void *_out, void *_lut, void *_fb);
236+
static void pixelDecode1BitEPDPartial(void *_out, void *_lut, void *_fb);
236237

237-
// Internal 1 bit partial update method.
238-
void partialUpdate1Bit(uint8_t _leaveOn);
238+
// Internal 4 bit partial update method.
239+
void partialUpdate4Bit(uint8_t _leaveOn);
239240

240-
// Object for the SdFat SPI STM32 library.
241-
SdSpiConfig* _microSDCardSPIConf = nullptr;
241+
// Internal 1 bit partial update method.
242+
void partialUpdate1Bit(uint8_t _leaveOn);
242243

243-
// Typedef handles for Master DMA.
244-
MDMA_HandleTypeDef *_epdMdmaHandle;
245-
MDMA_HandleTypeDef *_sdramMdmaHandle;
244+
// Object for the SdFat SPI STM32 library.
245+
SdSpiConfig *_microSDCardSPIConf = nullptr;
246246

247-
// Default EPD PSU state is off.
248-
uint8_t _epdPSUState = 0;
247+
// Typedef handles for Master DMA.
248+
MDMA_HandleTypeDef *_epdMdmaHandle;
249+
MDMA_HandleTypeDef *_sdramMdmaHandle;
249250

250-
// Current display mode. By defaul, set it to 1 bit B&W mode.
251-
uint8_t _displayMode = INKPLATE_1BW;
252-
253-
// Block partial update at startup, use full update.
254-
uint8_t _blockPartial = 1;
251+
// Default EPD PSU state is off.
252+
uint8_t _epdPSUState = 0;
255253

256-
// Internal typedef for the 4 bit waveform - global update.
257-
InkplateWaveform _waveform4BitInternal = default4BitWavefrom;
254+
// Current display mode. By defaul, set it to 1 bit B&W mode.
255+
uint8_t _displayMode = INKPLATE_1BW;
258256

259-
// Internal typedef for the 1 bit mode waveform - global update.
260-
InkplateWaveform _waveform1BitInternal = default1BitWavefrom;
257+
// Block partial update at startup, use full update.
258+
uint8_t _blockPartial = 1;
261259

262-
// Internal typedef for the 4 bit waveform - partial update.
263-
InkplateWaveform _waveform4BitPartialInternal = default4BitPartialUpdate;
260+
// Internal typedef for the 4 bit waveform - global update.
261+
InkplateWaveform _waveform4BitInternal = default4BitWavefrom;
264262

265-
// Internal typedef for the 1 bit waveform - partial update.
266-
InkplateWaveform _waveform1BitPartialInternal = default1BitPartialUpdate;
263+
// Internal typedef for the 1 bit mode waveform - global update.
264+
InkplateWaveform _waveform1BitInternal = default1BitWavefrom;
267265

268-
// Variable keeps track on how many partial updates have been executed for automatic full update.
269-
uint16_t _partialUpdateCounter = 0;
266+
// Internal typedef for the 4 bit waveform - partial update.
267+
InkplateWaveform _waveform4BitPartialInternal = default4BitPartialUpdate;
270268

271-
// Variable that set the user-defined treshold for the full update. If zero, automatic full update is disabled.
272-
uint16_t _partialUpdateLimiter = 0;
269+
// Internal typedef for the 1 bit waveform - partial update.
270+
InkplateWaveform _waveform1BitPartialInternal = default1BitPartialUpdate;
273271

274-
// Variable keeps current status of the microSD card initializaton.
275-
bool _microSdInit = false;
272+
// Variable keeps track on how many partial updates have been executed for automatic full update.
273+
uint16_t _partialUpdateCounter = 0;
276274

277-
// Fast LUT table for conversion from 2 * 4 bit grayscale pixel to EPD Wavefrom.
278-
uint8_t _fastGLUT[65536];
275+
// Variable that set the user-defined treshold for the full update. If zero, automatic full update is disabled.
276+
uint16_t _partialUpdateLimiter = 0;
277+
278+
// Variable keeps current status of the microSD card initializaton.
279+
bool _microSdInit = false;
280+
281+
// Fast LUT table for conversion from 2 * 4 bit grayscale pixel to EPD Wavefrom.
282+
uint8_t _fastGLUT[65536];
279283
};
280284

281285
#endif

0 commit comments

Comments
 (0)