Add a flag for removing the Blinka logo from the REPL

There may be several reasons why we might want to remove the logo form
the REPL: a fork of CircuitPython that doesn't have the right to use the
logo, an especially small display that needs all the room it has to be
useful, displays that are especially vulnerable to burn-in, maybe even
the smaller chips where we want to save as much flash memory as
possible.
This commit is contained in:
Radomir Dopieralski 2021-09-03 20:44:13 +02:00
parent 08b44eade5
commit 93ea1bd9bd
3 changed files with 40 additions and 0 deletions

View File

@ -36,3 +36,4 @@
#define IGNORE_PIN_PB11 1 #define IGNORE_PIN_PB11 1
#define SAMD5x_E5x_BOD33_LEVEL (100) #define SAMD5x_E5x_BOD33_LEVEL (100)
#define CIRCUITPY_REPL_LOGO 0

View File

@ -480,6 +480,11 @@ void supervisor_run_background_tasks_if_tick(void);
#define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (1) #define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (1)
#endif #endif
// Display the Blinka logo in the REPL on displayio displays.
#ifndef CIRCUITPY_REPL_LOGO
#define CIRCUITPY_REPL_LOGO (1)
#endif
// USB settings // USB settings
// If the port requires certain USB endpoint numbers, define these in mpconfigport.h. // If the port requires certain USB endpoint numbers, define these in mpconfigport.h.

View File

@ -45,8 +45,10 @@
#include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h"
#endif #endif
#if CIRCUITPY_REPL_LOGO
extern uint32_t blinka_bitmap_data[]; extern uint32_t blinka_bitmap_data[];
extern displayio_bitmap_t blinka_bitmap; extern displayio_bitmap_t blinka_bitmap;
#endif
extern displayio_group_t circuitpython_splash; extern displayio_group_t circuitpython_splash;
#if CIRCUITPY_TERMINALIO #if CIRCUITPY_TERMINALIO
@ -62,8 +64,13 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
displayio_tilegrid_t *grid = &supervisor_terminal_text_grid; displayio_tilegrid_t *grid = &supervisor_terminal_text_grid;
bool tall = height_px > width_px; bool tall = height_px > width_px;
bool reset_tiles = false; bool reset_tiles = false;
#if CIRCUITPY_REPL_LOGO
uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width; uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width;
uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px; uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px;
#else
uint16_t terminal_width_px = width_px;
uint16_t terminal_height_px = height_px;
#endif
uint16_t width_in_tiles = terminal_width_px / grid->tile_width; uint16_t width_in_tiles = terminal_width_px / grid->tile_width;
// determine scale based on h // determine scale based on h
if (width_in_tiles < 80) { if (width_in_tiles < 80) {
@ -106,8 +113,13 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
if (reset_tiles) { if (reset_tiles) {
uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr; uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr;
#if CIRCUITPY_REPL_LOGO
grid->y = tall ? blinka_bitmap.height : 0; grid->y = tall ? blinka_bitmap.height : 0;
grid->x = tall ? 0 : blinka_bitmap.width; grid->x = tall ? 0 : blinka_bitmap.width;
#else
grid->y = 0;
grid->x = 0;
#endif
grid->top_left_y = 0; grid->top_left_y = 0;
if (remaining_pixels > 0) { if (remaining_pixels > 0) {
grid->y -= (grid->tile_height - remaining_pixels); grid->y -= (grid->tile_height - remaining_pixels);
@ -167,6 +179,7 @@ void supervisor_display_move_memory(void) {
#endif #endif
} }
#if CIRCUITPY_REPL_LOGO
uint32_t blinka_bitmap_data[32] = { uint32_t blinka_bitmap_data[32] = {
0x00000011, 0x11000000, 0x00000011, 0x11000000,
0x00000111, 0x53100000, 0x00000111, 0x53100000,
@ -281,8 +294,10 @@ displayio_tilegrid_t blinka_sprite = {
.inline_tiles = true, .inline_tiles = true,
.in_group = true .in_group = true
}; };
#endif
#if CIRCUITPY_TERMINALIO #if CIRCUITPY_TERMINALIO
#if CIRCUITPY_REPL_LOGO
mp_obj_t members[] = { &blinka_sprite, &supervisor_terminal_text_grid, }; mp_obj_t members[] = { &blinka_sprite, &supervisor_terminal_text_grid, };
mp_obj_list_t splash_children = { mp_obj_list_t splash_children = {
.base = {.type = &mp_type_list }, .base = {.type = &mp_type_list },
@ -291,6 +306,16 @@ mp_obj_list_t splash_children = {
.items = members, .items = members,
}; };
#else #else
mp_obj_t members[] = { &supervisor_terminal_text_grid, };
mp_obj_list_t splash_children = {
.base = {.type = &mp_type_list },
.alloc = 1,
.len = 1,
.items = members,
};
#endif
#else
#if CIRCUITPY_REPL_LOGO
mp_obj_t members[] = { &blinka_sprite }; mp_obj_t members[] = { &blinka_sprite };
mp_obj_list_t splash_children = { mp_obj_list_t splash_children = {
.base = {.type = &mp_type_list }, .base = {.type = &mp_type_list },
@ -298,6 +323,15 @@ mp_obj_list_t splash_children = {
.len = 1, .len = 1,
.items = members, .items = members,
}; };
#else
mp_obj_t members[] = {};
mp_obj_list_t splash_children = {
.base = {.type = &mp_type_list },
.alloc = 0,
.len = 0,
.items = members,
};
#endif
#endif #endif
displayio_group_t circuitpython_splash = { displayio_group_t circuitpython_splash = {