Skip to content

Refactor EPaperDisplay args into struct #10565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 18 additions & 36 deletions ports/atmel-samd/boards/openbook_m4/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,24 @@ void board_init(void) {

epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
display->base.type = &epaperdisplay_epaperdisplay_type;
common_hal_epaperdisplay_epaperdisplay_construct(display,
bus,
start_sequence,
sizeof(start_sequence),
0, // start up time
stop_sequence,
sizeof(stop_sequence),
300, // width
400, // height
300, // RAM width
400, // RAM height
0, // colstart
0, // rowstart
270, // rotation
NO_COMMAND, // set_column_window_command
NO_COMMAND, // set_row_window_command
NO_COMMAND, // set_current_column_command
NO_COMMAND, // set_current_row_command
0x13, // write_black_ram_command
false, // black_bits_inverted
NO_COMMAND, // write_color_ram_command (can add this for grayscale eventually)
false, // color_bits_inverted
0x000000, // highlight_color
0x000000, // highlight_color2
refresh_sequence, // refresh_display_sequence
sizeof(refresh_sequence),
40, // refresh_time
&pin_PA01, // busy_pin
false, // busy_state
5, // seconds_per_frame
false, // chip_select (don't always toggle chip select)
false, // grayscale
false, // acep
false, // spectra6
false, // two_byte_sequence_length
false); // address_little_endian
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
args.bus = bus;
args.start_sequence = start_sequence;
args.start_sequence_len = sizeof(start_sequence);
args.stop_sequence = stop_sequence;
args.stop_sequence_len = sizeof(stop_sequence);
args.width = 300;
args.height = 400;
args.ram_width = 300;
args.ram_height = 400;
args.rotation = 270;
args.write_black_ram_command = 0x13;
args.refresh_sequence = refresh_sequence;
args.refresh_sequence_len = sizeof(refresh_sequence);
args.refresh_time = 40.0;
args.busy_pin = &pin_PA01;
args.seconds_per_frame = 5.0;
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
}

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
115 changes: 47 additions & 68 deletions ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,75 +217,54 @@ void board_init(void) {
display->base.type = &epaperdisplay_epaperdisplay_type;

if (is_ssd1680) {
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
ssd1680_display_start_sequence, sizeof(ssd1680_display_start_sequence),
0, // start up time
ssd1680_display_stop_sequence, sizeof(ssd1680_display_stop_sequence),
296, // width
128, // height
250, // ram_width
296, // ram_height
0, // colstart
0, // rowstart
270, // rotation
0x44, // set_column_window_command
0x45, // set_row_window_command
0x4e, // set_current_column_command
0x4f, // set_current_row_command
0x24, // write_black_ram_command
false, // black_bits_inverted
0x26, // write_color_ram_command
false, // color_bits_inverted
0x000000, // highlight_color
0x000000, // highlight_color2
ssd1680_display_refresh_sequence, sizeof(ssd1680_display_refresh_sequence),
1.0, // refresh_time
&pin_GPIO5, // busy_pin
true, // busy_state
5.0, // seconds_per_frame
false, // always_toggle_chip_select
true, // grayscale
false, // acep
false, // spectra6
true, // two_byte_sequence_length
true); // address_little_endian
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
args.bus = bus;
args.start_sequence = ssd1680_display_start_sequence;
args.start_sequence_len = sizeof(ssd1680_display_start_sequence);
args.stop_sequence = ssd1680_display_stop_sequence;
args.stop_sequence_len = sizeof(ssd1680_display_stop_sequence);
args.width = 296;
args.height = 128;
args.ram_width = 250;
args.ram_height = 296;
args.rotation = 270;
args.set_column_window_command = 0x44;
args.set_row_window_command = 0x45;
args.set_current_column_command = 0x4e;
args.set_current_row_command = 0x4f;
args.write_black_ram_command = 0x24;
args.write_color_ram_command = 0x26;
args.refresh_sequence = ssd1680_display_refresh_sequence;
args.refresh_sequence_len = sizeof(ssd1680_display_refresh_sequence);
args.refresh_time = 1.0;
args.busy_pin = &pin_GPIO5;
args.busy_state = true;
args.seconds_per_frame = 5.0;
args.grayscale = true;
args.two_byte_sequence_length = true;
args.address_little_endian = true;
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
} else {
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
il0373_display_start_sequence, sizeof(il0373_display_start_sequence),
0, // start up time
il0373_display_stop_sequence, sizeof(il0373_display_stop_sequence),
296, // width
128, // height
160, // ram_width
296, // ram_height
0, // colstart
0, // rowstart
270, // rotation
NO_COMMAND, // set_column_window_command
NO_COMMAND, // set_row_window_command
NO_COMMAND, // set_current_column_command
NO_COMMAND, // set_current_row_command
0x10, // write_black_ram_command
false, // black_bits_inverted
0x13, // write_color_ram_command
false, // color_bits_inverted
0x000000, // highlight_color
0x000000, // highlight_color2
il0373_display_refresh_sequence, sizeof(il0373_display_refresh_sequence),
1.0, // refresh_time
&pin_GPIO5, // busy_pin
false, // busy_state
5.0, // seconds_per_frame
false, // always_toggle_chip_select
true, // grayscale
false, // acep
false, // spectra6
false, // two_byte_sequence_length
false); // address_little_endian
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
args.bus = bus;
args.start_sequence = il0373_display_start_sequence;
args.start_sequence_len = sizeof(il0373_display_start_sequence);
args.stop_sequence = il0373_display_stop_sequence;
args.stop_sequence_len = sizeof(il0373_display_stop_sequence);
args.width = 296;
args.height = 128;
args.ram_width = 160;
args.ram_height = 296;
args.rotation = 270;
args.write_black_ram_command = 0x10;
args.write_color_ram_command = 0x13;
args.refresh_sequence = il0373_display_refresh_sequence;
args.refresh_sequence_len = sizeof(il0373_display_refresh_sequence);
args.refresh_time = 1.0;
args.busy_pin = &pin_GPIO5;
args.seconds_per_frame = 5.0;
args.grayscale = true;
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
}
}

Expand Down
57 changes: 22 additions & 35 deletions ports/espressif/boards/elecrow_crowpanel_4_2_epaper/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,30 @@ void board_init(void) {
0, // Polarity
0); // Phase

// Set up the DisplayIO epaper object
// Set up the DisplayIO epaper object
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
display->base.type = &epaperdisplay_epaperdisplay_type;
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
display_start_sequence, sizeof(display_start_sequence),
1, // start up time
display_stop_sequence, sizeof(display_stop_sequence),
400, // width
300, // height
400, // ram_width
300, // ram_height
0, // colstart
0, // rowstart
0, // rotation
NO_COMMAND, // set_column_window_command
NO_COMMAND, // set_row_window_command
NO_COMMAND, // set_current_column_command
NO_COMMAND, // set_current_row_command
0x24, // write_black_ram_command
false, // black_bits_inverted
0x26, // write_color_ram_command
false, // color_bits_inverted
0x000000, // highlight_color
0x000000, // highlight_color2
refresh_sequence, sizeof(refresh_sequence), // refresh_display_command
1.0, // refresh_time
&pin_GPIO48, // busy_pin
true, // busy_state
2.0, // seconds_per_frame
false, // always_toggle_chip_select
false, // grayscale
false, // acep
false, // spectra6
false, // two_byte_sequence_length
false); // address_little_endian

epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
args.bus = bus;
args.start_sequence = display_start_sequence;
args.start_sequence_len = sizeof(display_start_sequence);
args.start_up_time = 1.0;
args.stop_sequence = display_stop_sequence;
args.stop_sequence_len = sizeof(display_stop_sequence);
args.width = 400;
args.height = 300;
args.ram_width = 400;
args.ram_height = 300;
args.write_black_ram_command = 0x24;
args.write_color_ram_command = 0x26;
args.refresh_sequence = refresh_sequence;
args.refresh_sequence_len = sizeof(refresh_sequence);
args.refresh_time = 1.0;
args.busy_pin = &pin_GPIO48;
args.busy_state = true;
args.seconds_per_frame = 2.0;
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
}

void board_deinit(void) {
Expand Down
64 changes: 29 additions & 35 deletions ports/espressif/boards/heltec_vision_master_e290/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,43 +61,37 @@ void board_init(void) {
0, // Polarity
0); // Phase

// Set up the DisplayIO epaper object
// Set up the DisplayIO epaper object
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
display->base.type = &epaperdisplay_epaperdisplay_type;
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
display_start_sequence, sizeof(display_start_sequence),
0, // start up time
display_stop_sequence, sizeof(display_stop_sequence),
296, // width
128, // height
250, // ram_width
296, // ram_height
8, // colstart
0, // rowstart
90, // rotation
0x44, // set_column_window_command
0x45, // set_row_window_command
0x4E, // set_current_column_command
0x4F, // set_current_row_command
0x24, // write_black_ram_command
false, // black_bits_inverted
0x26, // write_color_ram_command
false, // color_bits_inverted
0xFF0000, // highlight_color
0x000000, // highlight_color2
refresh_sequence, sizeof(refresh_sequence), // refresh_display_command
1.0, // refresh_time
&pin_GPIO6, // busy_pin
true, // busy_state
2.0, // seconds_per_frame
false, // always_toggle_chip_select
false, // grayscale
false, // acep
false, // spectra6
false, // two_byte_sequence_length
true); // address_little_endian

epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
args.bus = bus;
args.start_sequence = display_start_sequence;
args.start_sequence_len = sizeof(display_start_sequence);
args.stop_sequence = display_stop_sequence;
args.stop_sequence_len = sizeof(display_stop_sequence);
args.width = 296;
args.height = 128;
args.ram_width = 250;
args.ram_height = 296;
args.colstart = 8;
args.rotation = 90;
args.set_column_window_command = 0x44;
args.set_row_window_command = 0x45;
args.set_current_column_command = 0x4E;
args.set_current_row_command = 0x4F;
args.write_black_ram_command = 0x24;
args.write_color_ram_command = 0x26;
args.highlight_color = 0xFF0000;
args.refresh_sequence = refresh_sequence;
args.refresh_sequence_len = sizeof(refresh_sequence);
args.refresh_time = 1.0;
args.busy_pin = &pin_GPIO6;
args.busy_state = true;
args.seconds_per_frame = 2.0;
args.address_little_endian = true;
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
}

void board_deinit(void) {
Expand Down
56 changes: 21 additions & 35 deletions ports/espressif/boards/heltec_wireless_paper/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,29 @@ void board_init(void) {
0, // Polarity
0); // Phase

// Set up the DisplayIO epaper object
// Set up the DisplayIO epaper object
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
display->base.type = &epaperdisplay_epaperdisplay_type;
common_hal_epaperdisplay_epaperdisplay_construct(
display,
bus,
display_start_sequence, sizeof(display_start_sequence),
0, // start up time
display_stop_sequence, sizeof(display_stop_sequence),
250, // width
122, // height
128, // ram_width
296, // ram_height
0, // colstart
0, // rowstart
270, // rotation
NO_COMMAND, // set_column_window_command
NO_COMMAND, // set_row_window_command
NO_COMMAND, // set_current_column_command
NO_COMMAND, // set_current_row_command
0x13, // write_black_ram_command
false, // black_bits_inverted
0x10, // write_color_ram_command
false, // color_bits_inverted
0x000000, // highlight_color
0x000000, // highlight_color2
refresh_sequence, sizeof(refresh_sequence), // refresh_display_command
1.0, // refresh_time
&pin_GPIO7, // busy_pin
false, // busy_state
2.0, // seconds_per_frame
false, // always_toggle_chip_select
false, // grayscale
false, // acep
false, // spectra6
false, // two_byte_sequence_length
false); // address_little_endian

epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
args.bus = bus;
args.start_sequence = display_start_sequence;
args.start_sequence_len = sizeof(display_start_sequence);
args.stop_sequence = display_stop_sequence;
args.stop_sequence_len = sizeof(display_stop_sequence);
args.width = 250;
args.height = 122;
args.ram_width = 128;
args.ram_height = 296;
args.rotation = 270;
args.write_black_ram_command = 0x13;
args.write_color_ram_command = 0x10;
args.refresh_sequence = refresh_sequence;
args.refresh_sequence_len = sizeof(refresh_sequence);
args.refresh_time = 1.0;
args.busy_pin = &pin_GPIO7;
args.seconds_per_frame = 2.0;
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
}

void board_deinit(void) {
Expand Down
Loading