Skip to content

Commit

Permalink
Remove unused line buffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBell committed Aug 15, 2024
1 parent c9ff4ee commit b711011
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 4 additions & 2 deletions drivers/st7701/st7701.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ void __no_inline_not_in_flash_func(ST7701::fill_next_line()) {
line_buffer(linebuffer)
{
st7701_inst = this;
if(!line_buffer) {

// Allocate line buffers only if none supplied and frame buffer is not in internal RAM.
if(!line_buffer && (intptr_t)framebuffer < 0x20000000) {
line_buffer = (uint16_t*)malloc(NUM_LINE_BUFFERS * width * sizeof(line_buffer[0]));
}
}
Expand Down Expand Up @@ -589,4 +591,4 @@ void __no_inline_not_in_flash_func(ST7701::fill_next_line()) {
waiting_for_vsync = true;
while (waiting_for_vsync) __wfe();
}
}
}
9 changes: 3 additions & 6 deletions modules/c/presto/presto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ extern "C" {

// MicroPython's GC heap will automatically resize, so we should just
// statically allocate these in C++ to avoid fragmentation.
__attribute__((section(".uninitialized_bss"))) static uint16_t presto_buffer_a[WIDTH * HEIGHT] = {0};
__attribute__((section(".uninitialized_bss"))) static uint16_t presto_buffer_b[WIDTH * HEIGHT] = {0};
__attribute__((section(".uninitialized_bss"))) static uint16_t presto_line_buffer[WIDTH * ST7701::NUM_LINE_BUFFERS];
__attribute__((section(".uninitialized_data"))) static uint16_t presto_buffer_a[WIDTH * HEIGHT] = {0};
__attribute__((section(".uninitialized_data"))) static uint16_t presto_buffer_b[WIDTH * HEIGHT] = {0};

void __printf_debug_flush() {
for(auto i = 0u; i < 10; i++) {
Expand All @@ -48,7 +47,6 @@ typedef struct _Presto_obj_t {
ST7701* presto;
uint16_t* next_fb;
uint16_t* curr_fb;
uint16_t* linebuffer;
} _Presto_obj_t;

typedef struct _ModPicoGraphics_obj_t {
Expand Down Expand Up @@ -97,12 +95,11 @@ mp_obj_t Presto_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
presto_debug("set fb pointers\n");
self->curr_fb = presto_buffer_a; //(uint16_t*)0x11000000;
self->next_fb = presto_buffer_b; //(uint16_t*)0x11080000;
self->linebuffer = presto_line_buffer;

presto_debug("m_new_class(ST7701...\n");
ST7701 *presto = m_new_class(ST7701, WIDTH, HEIGHT, ROTATE_0,
SPIPins{spi1, LCD_CS, LCD_CLK, LCD_DAT, PIN_UNUSED, LCD_DC, BACKLIGHT},
self->next_fb, self->linebuffer,
self->next_fb, nullptr,
LCD_D0);

self->presto = presto;
Expand Down

0 comments on commit b711011

Please sign in to comment.