Skip to content

Commit

Permalink
pico: add more PicoVision modes
Browse files Browse the repository at this point in the history
Resolution change requires a full reboot though
  • Loading branch information
Daft-Freak committed Jul 22, 2023
1 parent 5683b2a commit 1756ffd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 32blit-pico/display_picovision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ static constexpr uint32_t base_address = 0x10000;

static const blit::Size resolutions[]{
{640, 480},
{720, 480},
{720, 400},
{720, 576},
};

static pimoroni::APS6404 ram(CS, D0, pio1);
Expand Down Expand Up @@ -362,6 +365,21 @@ void update_display(uint32_t time) {
if(need_mode_change) {
auto new_res = find_resolution(cur_surf_info.bounds);

// resolution switch
if(new_res != cur_resolution) {
// if display was already enabled, we're too late so reboot
if(display_enabled) {
// seems to be the only functional way to reset
swd_load_program(section_addresses, section_data, section_data_len, std::size(section_data_len), 0x20000001, 0x15004000, true);
sleep_ms(100);
display_enabled = false;
}

uint8_t buf[2] = {I2C_REG_SET_RES, uint8_t(new_res)};
i2c_write_blocking(i2c1, I2C_ADDR, buf, 2, false);
cur_resolution = new_res;
}

auto &base_bounds = resolutions[new_res];

uint8_t h_repeat = base_bounds.w / cur_surf_info.bounds.w, v_repeat = base_bounds.h / cur_surf_info.bounds.h;
Expand Down

0 comments on commit 1756ffd

Please sign in to comment.