Skip to content

Commit 9def829

Browse files
author
Clang Robot
committed
Committing clang-format changes
1 parent 8411bbc commit 9def829

32 files changed

+345
-352
lines changed

src/Inkplate-LVGL.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ void display_flush_callback(lv_display_t *disp, const lv_area_t *area, uint8_t *
3939
class Inkplate : public InkplateBoardClass, public NetworkController
4040
{
4141
public:
42-
#ifndef USE_COLOR_IMAGE
42+
#ifndef USE_COLOR_IMAGE
4343
Inkplate(uint8_t mode);
44-
#else
44+
#else
4545
Inkplate();
46-
#endif
47-
void begin(lv_display_render_mode_t renderMode=LV_DISP_RENDER_MODE_FULL);
46+
#endif
47+
void begin(lv_display_render_mode_t renderMode = LV_DISP_RENDER_MODE_FULL);
4848
void drawPixel(int16_t x, int16_t y, uint16_t color);
4949
void setRotation(uint8_t r);
5050
void enableDithering(bool state);

src/Inkplate.cpp

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#include "Inkplate-LVGL.h"
2121

2222
#ifndef USE_COLOR_IMAGE
23-
Inkplate::Inkplate(uint8_t mode)
23+
Inkplate::Inkplate(uint8_t mode)
2424
{
2525
_mode = mode;
2626
}
2727
#else
28-
Inkplate::Inkplate()
28+
Inkplate::Inkplate()
2929
{
3030
}
3131
#endif
@@ -56,10 +56,10 @@ void Inkplate::begin(lv_display_render_mode_t renderMode)
5656
// Init low level driver for EPD.
5757
initDriver(this);
5858

59-
// Forward the display mode to the EPD driver
60-
#ifndef USE_COLOR_IMAGE
59+
// Forward the display mode to the EPD driver
60+
#ifndef USE_COLOR_IMAGE
6161
selectDisplayMode(_mode);
62-
#endif
62+
#endif
6363

6464
// Clean frame buffers.
6565
clearDisplay();
@@ -116,74 +116,69 @@ uint8_t Inkplate::getRotation()
116116
void Inkplate::initLVGL(lv_display_render_mode_t renderMode)
117117
{
118118
Serial.println("Initializing LVGL...");
119-
119+
120120
// Init the lvgl library itself
121121
lv_init();
122122

123-
// Define display resolution
124-
#ifndef ARDUINO_INKPLATE2
123+
// Define display resolution
124+
#ifndef ARDUINO_INKPLATE2
125125
uint32_t screen_width = E_INK_WIDTH;
126126
uint32_t screen_height = E_INK_HEIGHT;
127-
#else
127+
#else
128128
uint32_t screen_width = E_INK_HEIGHT;
129129
uint32_t screen_height = E_INK_WIDTH;
130-
#endif
130+
#endif
131131
uint32_t buffer_size;
132-
lv_color_t* buf_1;
133-
lv_color_t* buf_2;
134-
135-
if(renderMode == LV_DISPLAY_RENDER_MODE_PARTIAL){
136-
#define PARTIAL_ROWS 16
137-
buf_1=(lv_color_t*)heap_caps_malloc( screen_width * PARTIAL_ROWS * (LV_COLOR_DEPTH / 8) , MALLOC_CAP_8BIT );
138-
buf_2= (lv_color_t*)heap_caps_malloc( screen_width * PARTIAL_ROWS * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT );
139-
buffer_size = screen_width*PARTIAL_ROWS*(LV_COLOR_DEPTH / 8);
132+
lv_color_t *buf_1;
133+
lv_color_t *buf_2;
134+
135+
if (renderMode == LV_DISPLAY_RENDER_MODE_PARTIAL)
136+
{
137+
#define PARTIAL_ROWS 16
138+
buf_1 = (lv_color_t *)heap_caps_malloc(screen_width * PARTIAL_ROWS * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT);
139+
buf_2 = (lv_color_t *)heap_caps_malloc(screen_width * PARTIAL_ROWS * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT);
140+
buffer_size = screen_width * PARTIAL_ROWS * (LV_COLOR_DEPTH / 8);
140141
}
141142
else
142143
{
143-
buf_1=(lv_color_t*)heap_caps_malloc( screen_width * screen_height * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT );
144-
buf_2= (lv_color_t*)heap_caps_malloc( screen_width * screen_height * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT );
145-
buffer_size = screen_width*screen_height*(LV_COLOR_DEPTH / 8);
144+
buf_1 = (lv_color_t *)heap_caps_malloc(screen_width * screen_height * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT);
145+
buf_2 = (lv_color_t *)heap_caps_malloc(screen_width * screen_height * (LV_COLOR_DEPTH / 8), MALLOC_CAP_8BIT);
146+
buffer_size = screen_width * screen_height * (LV_COLOR_DEPTH / 8);
146147
}
147148

148149
// Create a display driver instance
149150
disp = lv_display_create(screen_width, screen_height);
150-
if(disp == NULL) {
151+
if (disp == NULL)
152+
{
151153
Serial.println("ERROR: Failed to create LVGL display!");
152154
return;
153155
}
154156

155157
lv_display_set_default(disp);
156158

157-
// Use 8-bit grayscale
158-
#ifdef USE_COLOR_IMAGE
159+
// Use 8-bit grayscale
160+
#ifdef USE_COLOR_IMAGE
159161
lv_display_set_color_format(disp, LV_COLOR_FORMAT_RGB565);
160-
#else
162+
#else
161163
lv_display_set_color_format(disp, LV_COLOR_FORMAT_L8);
162-
#endif
164+
#endif
163165

164166

165167
// Attach the buffer
166-
lv_display_set_buffers(
167-
disp,
168-
buf_1,
169-
buf_2,
170-
buffer_size,
171-
renderMode
172-
);
168+
lv_display_set_buffers(disp, buf_1, buf_2, buffer_size, renderMode);
173169

174170
// Store this Inkplate instance
175171
lv_display_set_user_data(disp, this);
176172

177173
// Set flush callback
178174
lv_display_set_flush_cb(disp, display_flush_callback);
179175

180-
// Inkplate 2 doesn't have an SD Card reader
181-
#ifndef ARDUINO_INKPLATE2
176+
// Inkplate 2 doesn't have an SD Card reader
177+
#ifndef ARDUINO_INKPLATE2
182178
lv_fs_init_sd();
183-
#endif
179+
#endif
184180

185181
Serial.println("LVGL initialization complete");
186-
187182
}
188183

189184
void Inkplate::enableDithering(bool state)

src/boards/Inkplate10/Inkplate10BoardFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class InkplateBoardClass : public EPDDriver
2525
{
2626
public:
27-
InkplateBoardClass(){};
27+
InkplateBoardClass() {};
2828
};
2929

3030
#endif

src/boards/Inkplate10/Inkplate10Driver.cpp

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,19 @@ void EPDDriver::writePixelInternal(int16_t x, int16_t y, uint16_t color)
8181
}
8282

8383
/**
84-
* @brief display_flush_callback function is called whenever there is a change made on the current
84+
* @brief display_flush_callback function is called whenever there is a change made on the current
8585
* LVGL screen. The data is downscaled to 3 bit or 1 bit grayscale depending on the current display mode
8686
* and stored in the EPD buffer for rendering
8787
*
8888
* @param lv_display_t *disp
8989
* A pointer to the created LVGL display instance
90-
*
90+
*
9191
* @param lv_area_t *area
9292
* A pointer to the area of the display which has changed
93-
*
93+
*
9494
* @param uint8_t px_map
9595
* An array of pixel values in L8 format
96-
*
96+
*
9797
*/
9898
void IRAM_ATTR display_flush_callback(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)
9999
{
@@ -102,17 +102,16 @@ void IRAM_ATTR display_flush_callback(lv_display_t *disp, const lv_area_t *area,
102102
int32_t w = lv_area_get_width(area);
103103
int32_t h = lv_area_get_height(area);
104104

105-
if (w <= 0 || h <= 0 || px_map == nullptr ||
106-
area->x1 < 0 || area->y1 < 0 ||
107-
area->x2 >= E_INK_WIDTH || area->y2 >= E_INK_HEIGHT)
105+
if (w <= 0 || h <= 0 || px_map == nullptr || area->x1 < 0 || area->y1 < 0 || area->x2 >= E_INK_WIDTH ||
106+
area->y2 >= E_INK_HEIGHT)
108107
{
109108
lv_display_flush_ready(disp);
110109
return;
111110
}
112111

113112
bool is3bit = (self->getDisplayMode() == INKPLATE_3BIT);
114113

115-
if(self->ditherEnabled)
114+
if (self->ditherEnabled)
116115
{
117116
self->dither.ditherFramebuffer(px_map, E_INK_WIDTH, E_INK_HEIGHT, is3bit);
118117
}
@@ -125,7 +124,7 @@ void IRAM_ATTR display_flush_callback(lv_display_t *disp, const lv_area_t *area,
125124
const int width_bytes_3b = E_INK_WIDTH / 2;
126125

127126
// Preload LUTs to local for faster access
128-
const uint8_t *maskLUT = pixelMaskLUT;
127+
const uint8_t *maskLUT = pixelMaskLUT;
129128
const uint8_t *maskGLUT = pixelMaskGLUT;
130129

131130
for (int32_t y = 0; y < h; y++)
@@ -140,15 +139,15 @@ void IRAM_ATTR display_flush_callback(lv_display_t *disp, const lv_area_t *area,
140139
for (int32_t x = 0; x < w; x++)
141140
{
142141
int32_t screen_x = area->x1 + x;
143-
if (screen_x >= E_INK_WIDTH) break;
142+
if (screen_x >= E_INK_WIDTH)
143+
break;
144144

145145
uint8_t gray3 = src_row[x] >> 5;
146146
int x_byte = screen_x / 2;
147-
int x_sub = screen_x % 2;
147+
int x_sub = screen_x % 2;
148148

149149
uint8_t temp = dst_row[x_byte];
150-
uint8_t newv = (maskGLUT[x_sub] & temp) |
151-
(x_sub ? gray3 : (gray3 << 4));
150+
uint8_t newv = (maskGLUT[x_sub] & temp) | (x_sub ? gray3 : (gray3 << 4));
152151

153152
dst_row[x_byte] = newv;
154153
}
@@ -160,30 +159,28 @@ void IRAM_ATTR display_flush_callback(lv_display_t *disp, const lv_area_t *area,
160159
for (int32_t x = 0; x < w; x++)
161160
{
162161
int32_t screen_x = area->x1 + x;
163-
if (screen_x >= E_INK_WIDTH) break;
162+
if (screen_x >= E_INK_WIDTH)
163+
break;
164164

165165
uint8_t gray = src_row[x];
166166
uint8_t bit = (gray < 128) ? 1 : 0;
167167

168168
int x_byte = screen_x / 8;
169-
int x_sub = screen_x % 8;
169+
int x_sub = screen_x % 8;
170170

171171
uint8_t temp = dst_row[x_byte];
172172
// Preserve other bits using original mask logic
173-
dst_row[x_byte] = (~maskLUT[x_sub] & temp) |
174-
(bit ? maskLUT[x_sub] : 0);
173+
dst_row[x_byte] = (~maskLUT[x_sub] & temp) | (bit ? maskLUT[x_sub] : 0);
175174
}
176175
}
177176
}
178-
179177
}
180178

181-
179+
182180
lv_display_flush_ready(disp);
183181
}
184182

185183

186-
187184
/**
188185
* @brief begin function initialize Inkplate object with predefined
189186
* settings
@@ -248,7 +245,6 @@ void EPDDriver::calculateLUTs()
248245
}
249246

250247

251-
252248
/**
253249
* @brief vscan_start starts writing new frame and skips first two lines
254250
* that are invisible on screen
@@ -316,7 +312,7 @@ void EPDDriver::clearDisplay()
316312
}
317313
// Clear 3 bit per pixel display buffer
318314
else if (_inkplate->getDisplayMode() == 1)
319-
memset(DMemory4Bit, 0xFF, E_INK_WIDTH * E_INK_HEIGHT / 2);
315+
memset(DMemory4Bit, 0xFF, E_INK_WIDTH * E_INK_HEIGHT / 2);
320316
}
321317

322318
/**
@@ -351,14 +347,14 @@ void IRAM_ATTR EPDDriver::display3b(bool leaveOn)
351347
{
352348
if (!einkOn())
353349
return;
354-
clean(1, 1);
355-
clean(0, 10);
356-
clean(2, 1);
357-
clean(1, 10);
358-
clean(2, 1);
359-
clean(0, 10);
360-
clean(2, 1);
361-
clean(1, 10);
350+
clean(1, 1);
351+
clean(0, 10);
352+
clean(2, 1);
353+
clean(1, 10);
354+
clean(2, 1);
355+
clean(0, 10);
356+
clean(2, 1);
357+
clean(1, 10);
362358

363359
for (int k = 0; k < 9; k++)
364360
{
@@ -960,7 +956,7 @@ uint8_t EPDDriver::initializeFramebuffers()
960956
if (DMemoryNew == NULL || _partial == NULL || _pBuffer == NULL || DMemory4Bit == NULL || GLUT == NULL ||
961957
GLUT2 == NULL)
962958
{
963-
return 0;
959+
return 0;
964960
}
965961
// Set all the framebuffers to White at start
966962
memset(DMemoryNew, 0, E_INK_WIDTH * E_INK_HEIGHT / 8);
@@ -1187,6 +1183,5 @@ void EPDDriver::checkWaveformID()
11871183
{
11881184
memcpy(waveform3Bit, waveformEEPROM.waveform, sizeof(waveform3Bit));
11891185
}
1190-
11911186
}
11921187
#endif

src/boards/Inkplate2/Inkplate2BoardFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class InkplateBoardClass : public EPDDriver
2525
{
2626
public:
27-
InkplateBoardClass(){};
27+
InkplateBoardClass() {};
2828
};
2929

3030
#endif

0 commit comments

Comments
 (0)