Skip to content

Commit a4818e5

Browse files
committed
Add defines for Inkplate13
1 parent 7f87df0 commit a4818e5

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

src/boardSelect.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#define __BOARD_SELECT_H__
1515

1616
#include <Arduino.h>
17-
18-
#ifdef ARDUINO_INKPLATE10V2
17+
#if defined(ARDUINO_ESP32S3_DEV)
18+
#define USE_COLOR_IMAGE
19+
#include "boards/Inkplate13/Inkplate13BoardFile.h"
20+
#elif defined(ARDUINO_INKPLATE10V2)
1921
#define MULTIPLE_DISPLAY_MODES
2022
#include "boards/Inkplate10/Inkplate10BoardFile.h"
2123
#elif defined(ARDUINO_INKPLATE6V2)

src/features/featureSelect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#ifdef ARDUINO_INKPLATE10V2
55
#include "SdFat/SdFat.h"
66
#include "rtc/rtc.h"
7-
#elif defined(ARDUINO_INKPLATE6V2) || defined(ARDUINO_INKPLATE5V2) || defined(ARDUINO_INKPLATECOLOR)
7+
#elif defined(ARDUINO_INKPLATE6V2) || defined(ARDUINO_INKPLATE5V2) || defined(ARDUINO_INKPLATECOLOR) || defined(ARDUINO_ESP32S3_DEV)
88
#include "SdFat/SdFat.h"
99
#include "rtc/rtc.h"
1010
#elif defined(ARDUINO_INKPLATE6FLICK)

src/graphics/ImageColor/ImageColor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ImageColor
113113

114114

115115
private:
116-
#ifdef ARDUINO_INKPLATE2
116+
#if defined(ARDUINO_INKPLATE2) || defined(ARDUINO_ESP32S3_DEV)
117117
uint8_t pixelBuffer[E_INK_HEIGHT * 4 + 5];
118118
#else
119119
uint8_t pixelBuffer[E_INK_WIDTH * 4 + 5];

src/graphics/ImageColor/ImageDitherColor.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222

2323
extern ImageColor *_imagePtrJpeg;
2424

25-
/*
26-
static uint32_t pallete[] = {
27-
0x000000ll, 0xFFFFFFll, 0x008000ll, 0x0000FFll, 0xFF0000ll, 0xFFFF00ll,
28-
0xFFAA00ll,
29-
};
30-
*/
3125

3226
#if defined(ARDUINO_INKPLATECOLOR)
3327

@@ -44,6 +38,11 @@ static unsigned int width = E_INK_HEIGHT, height = E_INK_WIDTH;
4438
static uint32_t pallete[] = {0xFFFFFF, 0x0000000, 0xFF0000};
4539
static unsigned int width = E_INK_WIDTH, height = E_INK_HEIGHT;
4640

41+
#elif defined(ARDUINO_ESP32S3_DEV)
42+
static uint32_t pallete[] = { 0x424852, 0xA1A8A8, 0xB0AB44, 0x7D4749, 0x4B689A, 0x516A64};
43+
//static uint32_t pallete[] = { 0x000000, 0xFFFFFF, 0xFFFF00, 0xFF0000, 0x0000FF, 0x00FF00};
44+
static unsigned int width = E_INK_WIDTH, height = E_INK_HEIGHT;
45+
4746
#endif
4847

4948
/**
@@ -56,7 +55,7 @@ static unsigned int width = E_INK_WIDTH, height = E_INK_HEIGHT;
5655
*/
5756
uint8_t ImageColor::findClosestPalette(int16_t r, int16_t g, int16_t b)
5857
{
59-
int64_t minDistance = 0x7fffffffffffffff;
58+
int64_t minDistance = INT64_MAX;
6059
uint8_t contenderCount = 0;
6160
uint8_t contenderList[sizeof pallete / sizeof pallete[0]];
6261

@@ -65,7 +64,17 @@ uint8_t ImageColor::findClosestPalette(int16_t r, int16_t g, int16_t b)
6564
int16_t pr = RED8(pallete[i]);
6665
int16_t pg = GREEN8(pallete[i]);
6766
int16_t pb = BLUE8(pallete[i]);
68-
int32_t currentDistance = SQR(r - pr) + SQR(g - pg) + SQR(b - pb);
67+
68+
int32_t dr = r - pr;
69+
int32_t dg = g - pg;
70+
int32_t db = b - pb;
71+
72+
// Perceptual weighted RGB distance (Rec.601)
73+
int32_t currentDistance =
74+
30 * dr * dr
75+
+ 59 * dg * dg
76+
+ 11 * db * db;
77+
6978
if (currentDistance < minDistance)
7079
{
7180
minDistance = currentDistance;
@@ -74,19 +83,15 @@ uint8_t ImageColor::findClosestPalette(int16_t r, int16_t g, int16_t b)
7483
}
7584
else if (currentDistance == minDistance)
7685
{
77-
contenderList[contenderCount] = i;
78-
contenderCount++;
86+
if (contenderCount < sizeof pallete / sizeof pallete[0])
87+
contenderList[contenderCount++] = i;
7988
}
8089
}
8190

82-
// If your project has a good way to seed rand(),
83-
// you can use rand() here to improve dithering quality
84-
// when using shades that are exactly between palette colors.
85-
// return contenderList[contenderCount <= 1 ? 0 : rand() % contenderCount];
86-
8791
return contenderList[0];
8892
}
8993

94+
9095
/**
9196
* @brief ditherGetPixelBmp finds dithered value for given pixel
9297
*

src/system/InkplateBoards.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#define __INKPLATE_BOARDS_H__
1616

1717
// Board selector. It only includes files for selected board.
18-
#ifdef ARDUINO_INKPLATE10V2
18+
#if defined(ARDUINO_ESP32S3_DEV)
19+
#include "../boards/Inkplate13/Inkplate13Driver.h"
20+
#elif defined(ARDUINO_INKPLATE10V2)
1921
#include "../boards/Inkplate10/Inkplate10Driver.h"
2022
#elif defined(ARDUINO_INKPLATE6V2)
2123
#include "../boards/Inkplate6/Inkplate6Driver.h"

src/system/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define INKPLATE10_WAVEFORM5 24
3232
#define INKPLATE6PLUS_WAVEFORM1 40
3333

34-
#if !defined(ARDUINO_INKPLATECOLOR) && !defined(ARDUINO_INKPLATE2)
34+
#if !defined(ARDUINO_INKPLATECOLOR) && !defined(ARDUINO_INKPLATE2) && !defined(ARDUINO_ESP32S3_DEV)
3535
#define BLACK 1
3636
#define WHITE 0
3737
#else

0 commit comments

Comments
 (0)