Skip to content

Commit

Permalink
More improvements to Terminal:
Browse files Browse the repository at this point in the history
* Fix Hallowing.
* Fix builds without displayio.
* Fix y bounds that appears as untrollable row of pixels.
* Add scrolling to TileGrid.
* Remove Sprite to save space. TileGrid is a drop in replacement.
  • Loading branch information
tannewt committed Jan 31, 2019
1 parent 6145f08 commit 601a910
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 422 deletions.
7 changes: 1 addition & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "lib/utils/pyexec.h"

#include "mpconfigboard.h"
#include "shared-module/displayio/__init__.h"
#include "supervisor/cpu.h"
#include "supervisor/memory.h"
#include "supervisor/port.h"
Expand All @@ -61,10 +62,6 @@
#include "shared-module/network/__init__.h"
#endif

#ifdef CIRCUITPY_DISPLAYIO
#include "shared-module/displayio/__init__.h"
#endif

void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
if (lex == NULL) {
Expand Down Expand Up @@ -203,10 +200,8 @@ bool run_code_py(safe_mode_t safe_mode) {
serial_write_compressed(translate("WARNING: Your code filename has two extensions\n"));
}
}
#ifdef CIRCUITPY_DISPLAYIO
// Turn off the display before the heap disappears.
reset_displays();
#endif
stop_mp();
free_memory(heap);
supervisor_move_memory();
Expand Down
1 change: 0 additions & 1 deletion ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ SRC_SHARED_MODULE = \
displayio/OnDiskBitmap.c \
displayio/Palette.c \
displayio/Shape.c \
displayio/Sprite.c \
displayio/TileGrid.c \
gamepad/__init__.c \
gamepad/GamePad.c \
Expand Down
5 changes: 3 additions & 2 deletions ports/atmel-samd/boards/hallowing_m0_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ void board_init(void) {
128, // Width
128, // Height
2, // column start
0, // row start
1, // row start
16, // Color depth
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
display_init_sequence,
sizeof(display_init_sequence));
sizeof(display_init_sequence),
&pin_PA00);
}

bool board_requests_safe_mode(void) {
Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ extern const struct _mp_obj_module_t pixelbuf_module;
#define MICROPY_PY_BUILTINS_COMPLEX (0)

#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0)
#define CIRCUITPY_DISPLAYIO (0)
#define CIRCUITPY_DISPLAY_LIMIT (0)
#endif

Expand Down
195 changes: 0 additions & 195 deletions shared-bindings/displayio/Sprite.c

This file was deleted.

43 changes: 0 additions & 43 deletions shared-bindings/displayio/Sprite.h

This file was deleted.

1 change: 1 addition & 0 deletions shared-bindings/displayio/TileGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *se
void common_hal_displayio_tilegrid_set_pixel_shader(displayio_tilegrid_t *self, mp_obj_t pixel_shader);

void common_hal_displayio_textgrid_set_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y, uint8_t tile_index);
void common_hal_displayio_textgrid_set_top_left(displayio_tilegrid_t *self, uint16_t x, uint16_t y);

#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_TILEGRID_H
1 change: 0 additions & 1 deletion shared-bindings/displayio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_OnDiskBitmap), MP_ROM_PTR(&displayio_ondiskbitmap_type) },
{ MP_ROM_QSTR(MP_QSTR_Palette), MP_ROM_PTR(&displayio_palette_type) },
{ MP_ROM_QSTR(MP_QSTR_Shape), MP_ROM_PTR(&displayio_shape_type) },
{ MP_ROM_QSTR(MP_QSTR_Sprite), MP_ROM_PTR(&displayio_sprite_type) },
{ MP_ROM_QSTR(MP_QSTR_TileGrid), MP_ROM_PTR(&displayio_tilegrid_type) },

{ MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&displayio_fourwire_type) },
Expand Down
4 changes: 2 additions & 2 deletions shared-module/displayio/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void displayio_display_start_region_update(displayio_display_obj_t* self, uint16
data[1] = __builtin_bswap16(x1 - 1 + self->colstart);
self->send(self->bus, false, (uint8_t*) data, 4);
self->send(self->bus, true, &self->set_row_command, 1);
data[0] = __builtin_bswap16(y0 + 1 + self->rowstart);
data[1] = __builtin_bswap16(y1 + self->rowstart);
data[0] = __builtin_bswap16(y0 + self->rowstart);
data[1] = __builtin_bswap16(y1 - 1 + self->rowstart);
self->send(self->bus, false, (uint8_t*) data, 4);
self->send(self->bus, true, &self->write_ram_command, 1);
}
Expand Down
13 changes: 0 additions & 13 deletions shared-module/displayio/Group.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer)
mp_raise_RuntimeError(translate("Group full"));
}
mp_obj_t native_layer = mp_instance_cast_to_native_base(layer, &displayio_group_type);
if (native_layer == MP_OBJ_NULL) {
native_layer = mp_instance_cast_to_native_base(layer, &displayio_sprite_type);
}
if (native_layer == MP_OBJ_NULL) {
native_layer = mp_instance_cast_to_native_base(layer, &displayio_tilegrid_type);
}
Expand Down Expand Up @@ -85,10 +82,6 @@ bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, ui
if (displayio_tilegrid_get_pixel(layer, x, y, pixel)) {
return true;
}
} else if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) {
if (displayio_sprite_get_pixel(layer, x, y, pixel)) {
return true;
}
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
if (displayio_group_get_pixel(layer, x, y, pixel)) {
return true;
Expand All @@ -113,10 +106,6 @@ bool displayio_group_needs_refresh(displayio_group_t *self) {
if (displayio_group_needs_refresh(layer)) {
return true;
}
} else if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) {
if (displayio_sprite_needs_refresh(layer)) {
return true;
}
}
}
return false;
Expand All @@ -130,8 +119,6 @@ void displayio_group_finish_refresh(displayio_group_t *self) {
displayio_tilegrid_finish_refresh(layer);
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
displayio_group_finish_refresh(layer);
} else if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) {
displayio_sprite_finish_refresh(layer);
}
}
}
Loading

0 comments on commit 601a910

Please sign in to comment.