8000 Merge pull request #10316 from bablokb/spectra6 · adafruit/circuitpython@5eee7a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5eee7a2

Browse files
authored
Merge pull request #10316 from bablokb/spectra6
implement spectra6 support
2 parents 31a1266 + f54b0d7 commit 5eee7a2

File tree

18 files changed

+63
-8
lines changed

18 files changed

+63
-8
lines changed

ports/atmel-samd/boards/openbook_m4/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void board_init(void) {
8585
false, // chip_select (don't always toggle chip select)
8686
false, // grayscale
8787
false, // acep
88+
false, // spectra6
8889
false, // two_byte_sequence_length
8990
false); // address_little_endian
9091
}

ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void board_init(void) {
141141
false, // always_toggle_chip_select
142142
true, // grayscale
143143
false, // acep
144+
false, // spectra6
144145
false, // two_byte_sequence_length
145146
false); // address_little_endian
146147
}

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void board_init(void) {
9696
false, // always_toggle_chip_select
9797
false, // grayscale
9898
false, // acep
99+
false, // spectra6
99100
false, // two_byte_sequence_length
100101
false); // address_little_endian
101102
}

ports/espressif/boards/heltec_vision_master_e290/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void board_init(void) {
9494
false, // always_toggle_chip_select
9595
false, // grayscale
9696
false, // acep
97+
false, // spectra6
9798
false, // two_byte_sequence_length
9899
true); // address_little_endian
99100
}

ports/espressif/boards/heltec_wireless_paper/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ void board_init(void) {
134134
false, // always_toggle_chip_select
135135
false, // grayscale
136136
false, // acep
137+
false, // spectra6
137138
false, // two_byte_sequence_length
138139
false); // address_little_endian
139140
}

ports/espressif/boards/m5stack_m5paper/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void board_init(void) {
7474
// false, // always_toggle_chip_select
7575
// false, // grayscale
7676
// true, // acep
77+
// false, // spectra6
7778
// false, // two_byte_sequence_length
7879
// false // address_little_endian
7980
// );

ports/espressif/boards/sqfmi_watchy/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void board_init(void) {
190190
false, // always_toggle_chip_select
191191
false, // grayscale
192192
false, // acep
193+
false, // spectra6
193194
false, // two_byte_sequence_length
194195
true // address_little_endian
195196
);

ports/raspberrypi/boards/bradanlanestudio_explorer_rp2040/board.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ void board_init(void) {
281281
true, // always_toggle_chip_select
282282
false, // not grayscale
283283
false, // not acep
284+
false, // not spectra6
284285
false, // not two_byte_sequence_length
285286
true); // address_little_endian
286287
} else if (vid_setting == 2) { // Explorer SSD1608 BW
@@ -314,6 +315,7 @@ void board_init(void) {
314315
true, // always_toggle_chip_select
315316
false, // not grayscale
316317
false, // not acep
318+
false, // not spectra6
317319
false, // not two_byte_sequence_length
318320
true); // address_little_endian
319321
} else {

ports/raspberrypi/boards/pimoroni_badger2040/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ void board_init(void) {
303303
false, // always_toggle_chip_select
304304
false, // grayscale
305305
false, // acep
306+
false, // spectra6
306307
false, // two_byte_sequence_length
307308
false); // address_little_endian
308309
}

ports/raspberrypi/boards/pimoroni_badger2040w/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ void board_init(void) {
303303
false, // always_toggle_chip_select
304304
false, // grayscale
305305
false, // acep
306+
false, // spectra6
306307
false, // two_byte_sequence_length
307308
false); // address_little_endian
308309
}

ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void board_init(void) {
9797
false, // always_toggle_chip_select
9898
false, // grayscale
9999
true, // acep
100+
false, // spectra6
100101
false, // two_byte_sequence_length
101102
false); // address_little_endian
102103
}

ports/raspberrypi/boards/pimoroni_inky_frame_7_3/board.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ void board_init(void) {
156156
false, // always_toggle_chip_select
157157
false, // grayscale
158158
true, // acep
159+
false, // spectra6
159160
false, // two_byte_sequence_length
160161
false); // address_little_endian
161162
}

shared-bindings/epaperdisplay/EPaperDisplay.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
//| always_toggle_chip_select: bool = False,
6363
//| grayscale: bool = False,
6464
//| advanced_color_epaper: bool = False,
65+
//| spectra6: bool = False,
6566
//| two_byte_sequence_length: bool = False,
6667
//| start_up_time: float = 0,
6768
//| address_little_endian: bool = False,
@@ -104,6 +105,7 @@
104105
//| :param bool always_toggle_chip_select: When True, chip select is toggled every byte
105106
//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale
106107
//| :param bool advanced_color_epaper: When true, the display is a 7-color advanced color epaper (ACeP)
108+
//| :param bool spectra6: When true, the display is a 6-color spectra6 epaper
107109
//| :param bool two_byte_sequence_length: When true, use two bytes to define sequence length
108110
//| :param float start_up_time: Time to wait after reset before sending commands
109111
//| :param bool address_little_endian: Send the least significant byte (not bit) of multi-byte addresses first. Ignored when ram is addressed with one byte
@@ -117,7 +119,7 @@ static mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type,
117119
ARG_set_current_row_command, ARG_write_black_ram_command, ARG_black_bits_inverted,
118120
ARG_write_color_ram_command, ARG_color_bits_inverted, ARG_highlight_color,
119121
ARG_refresh_display_command, ARG_refresh_time, ARG_busy_pin, ARG_busy_state,
120-
ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale, ARG_advanced_color_epaper,
122+
ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale, ARG_advanced_color_epaper, ARG_spectra6,
121123
ARG_two_byte_sequence_length, ARG_start_up_time, ARG_address_little_endian };
122124
static const mp_arg_t allowed_args[] = {
123125
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
@@ -147,6 +149,7 @@ static mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type,
147149
{ MP_QSTR_always_toggle_chip_select, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
148150
{ MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
149151
{ MP_QSTR_advanced_color_epaper, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
152+
{ MP_QSTR_spectra6, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
150153
{ MP_QSTR_two_byte_sequence_length, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
151154
{ MP_QSTR_start_up_time, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(0)} },
152155
{ MP_QSTR_address_little_endian, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
@@ -215,7 +218,7 @@ static mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type,
215218
args[ARG_write_black_ram_command].u_int, args[ARG_black_bits_inverted].u_bool, write_color_ram_command,
216219
args[ARG_color_bits_inverted].u_bool, highlight_color, refresh_buf, refresh_buf_len, refresh_time,
217220
busy_pin, args[ARG_busy_state].u_bool, seconds_per_frame,
218-
args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool, args[ARG_advanced_color_epaper].u_bool,
221+
args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool, args[ARG_advanced_color_epaper].u_bool, args[ARG_spectra6].u_bool,
219222
two_byte_sequence_length, args[ARG_address_little_endian].u_bool
220223
);
221224

shared-bindings/epaperdisplay/EPaperDisplay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void common_hal_epaperdisplay_epaperdisplay_construct(epaperdisplay_epaperdispla
2626
uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color,
2727
const uint8_t *refresh_sequence, uint16_t refresh_sequence_len, mp_float_t refresh_time,
2828
const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame,
29-
bool always_toggle_chip_select, bool grayscale, bool acep, bool two_byte_sequence_length,
29+
bool always_toggle_chip_select, bool grayscale, bool acep, bool spectra6, bool two_byte_sequence_length,
3030
bool address_little_endian);
3131

3232
bool common_hal_epaperdisplay_epaperdisplay_refresh(epaperdisplay_epaperdisplay_obj_t *self);

shared-module/displayio/ColorConverter.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,40 @@ uint8_t displayio_colorconverter_compute_hue(uint32_t color_rgb888) {
9191
return hue;
9292
}
9393

94+
uint8_t displayio_colorconverter_compute_sixcolor(uint32_t color_rgb888) {
95+
// This is DDX=1, the default for the displays.
96+
uint8_t chroma = displayio_colorconverter_compute_chroma(color_rgb888);
97+
if (chroma >= 64) {
98+
uint8_t hue = displayio_colorconverter_compute_hue(color_rgb888);
99+
// Red 0
100+
if (hue < 10) {
101+
return 0x3;
102+
}
103+
// Yellow 42
104+
if (hue < 42 + 21) {
105+
return 0x2;
106+
}
107+
// Green 85
108+
if (hue < 85 + 42) {
109+
return 0x6;
110+
}
111+
// Blue 170
112+
if (hue < 170 + 42) {
113+
return 0x5;
114+
}
115+
116+
// The rest is red to 255
117+
return 0x3;
118+
} else {
119+
uint8_t luma = displayio_colorconverter_compute_luma(color_rgb888);
120+
if (luma >= 128) {
121+
return 0x1; // White
122+
} else {
123+
return 0x0; // Black
124+
}
125+
}
126+
}
127+
94128
uint8_t displayio_colorconverter_compute_sevencolor(uint32_t color_rgb888) {
95129
// This is DDX=1, the default for the displays.
96130
uint8_t chroma = displayio_colorconverter_compute_chroma(color_rgb888);
@@ -309,7 +343,9 @@ void displayio_convert_color(const _displayio_colorspace_t *colorspace, bool dit
309343
return;
310344
} else if (colorspace->depth == 4) {
311345
uint8_t packed;
312-
if (colorspace->sevencolor) {
346+
if (colorspace->sixcolor) {
347+
packed = displayio_colorconverter_compute_sixcolor(pixel);
348+
} else if (colorspace->sevencolor) {
313349
packed = displayio_colorconverter_compute_sevencolor(pixel);
314350
} else {
315351
packed = displayio_colorconverter_compute_rgbd(pixel);

shared-module/displayio/ColorConverter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ uint8_t displayio_colorconverter_compute_rgbd(uint32_t color_rgb888);
4141
uint8_t displayio_colorconverter_compute_luma(uint32_t color_rgb888);
4242
uint8_t displayio_colorconverter_compute_chroma(uint32_t color_rgb888);
4343
uint8_t displayio_colorconverter_compute_hue(uint32_t color_rgb888);
44+
uint8_t displayio_colorconverter_compute_sixcolor(uint32_t color_rgb888);
4445
uint8_t displayio_colorconverter_compute_sevencolor(uint32_t color_rgb888);
4546
void displayio_colorconverter_compute_tricolor(const _displayio_colorspace_t *colorspace, uint8_t pixel_hue, uint32_t *color);

shared-module/displayio/Palette.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ typedef struct {
1919
uint8_t grayscale_bit; // The lowest grayscale bit. Normally 8 - depth.
2020
bool grayscale;
2121
bool tricolor;
22+
bool sixcolor; // Spectra6 e-ink screens.
2223
bool sevencolor; // Acep e-ink screens.
2324
bool pixels_in_byte_share_row;
2425
bool reverse_pixels_in_byte;

shared-module/epaperdisplay/EPaperDisplay.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void common_hal_epaperdisplay_epaperdisplay_construct(epaperdisplay_epaperdispla
3636
uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color,
3737
const uint8_t *refresh_sequence, uint16_t refresh_sequence_len, mp_float_t refresh_time,
3838
const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame,
39-
bool chip_select, bool grayscale, bool acep, bool two_byte_sequence_length, bool address_little_endian) {
39+
bool chip_select, bool grayscale, bool acep, bool spectra6, bool two_byte_sequence_length, bool address_little_endian) {
4040
uint16_t color_depth = 1;
4141
bool core_grayscale = true;
4242
if (highlight_color != 0x000000) {
@@ -46,9 +46,10 @@ void common_hal_epaperdisplay_epaperdisplay_construct(epaperdisplay_epaperdispla
4646
} else {
4747
self->core.colorspace.tricolor = false;
4848
}
49-
self->acep = acep;
49+
self->acep = acep || spectra6;
50+
self->core.colorspace.sixcolor = spectra6;
5051
self->core.colorspace.sevencolor = acep;
51-
if (acep) {
52+
if (self->acep) {
5253
color_depth = 4; // bits. 7 colors + clean
5354
grayscale = false;
5455
core_grayscale = false;
@@ -338,7 +339,7 @@ static bool epaperdisplay_epaperdisplay_refresh_area(epaperdisplay_epaperdisplay
338339
} else if (self->core.colorspace.tricolor) {
339340
self->core.colorspace.grayscale = false;
340341
displayio_display_core_fill_area(&self->core, &subrectangle, mask, buffer);
341-
} else if (self->core.colorspace.sevencolor) {
342+
} else if (self->core.colorspace.sixcolor || self->core.colorspace.sevencolor) {
342343
displayio_display_core_fill_area(&self->core, &subrectangle, mask, buffer);
343344
}
344345
} else {

0 commit comments

Comments
 (0)
0