diff --git a/CMakeLists.txt b/CMakeLists.txt index a8a36e9..49e142e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.12) -set(PICO_PLATFORM rp2350) +if (NOT PICO_PLATFORM) + set(PICO_PLATFORM rp2350) +endif() include(pico_sdk_import.cmake) include(pimoroni_pico_import.cmake) diff --git a/drivers/dvhstx/dvhstx.cpp b/drivers/dvhstx/dvhstx.cpp index fb14ab2..7111cdf 100644 --- a/drivers/dvhstx/dvhstx.cpp +++ b/drivers/dvhstx/dvhstx.cpp @@ -225,6 +225,28 @@ void __scratch_x("display") DVHSTX::text_dma_handler() { uint8_t* dst_ptr = (uint8_t*)&line_buffers[ch_num * line_buf_total_len + count_of(vactive_text_line_header)]; uint8_t* src_ptr = &frame_buffer_display[(y / 24) * frame_width]; uint8_t* colour_ptr = src_ptr + frame_width * frame_height; +#ifdef __riscv + for (int i = 0; i < frame_width; ++i) { + const uint8_t c = (*src_ptr++ - 0x20); + uint32_t bits = (c < 95) ? font_cache[c * 24 + char_y] : 0; + const uint8_t colour = *colour_ptr++; + + *dst_ptr++ = colour * ((bits >> 24) & 3); + *dst_ptr++ = colour * ((bits >> 22) & 3); + *dst_ptr++ = colour * ((bits >> 20) & 3); + *dst_ptr++ = colour * ((bits >> 18) & 3); + *dst_ptr++ = colour * ((bits >> 16) & 3); + *dst_ptr++ = colour * ((bits >> 14) & 3); + *dst_ptr++ = colour * ((bits >> 12) & 3); + *dst_ptr++ = colour * ((bits >> 10) & 3); + *dst_ptr++ = colour * ((bits >> 8) & 3); + *dst_ptr++ = colour * ((bits >> 6) & 3); + *dst_ptr++ = colour * ((bits >> 4) & 3); + *dst_ptr++ = colour * ((bits >> 2) & 3); + *dst_ptr++ = colour * (bits & 3); + *dst_ptr++ = 0; + } +#else int i = 0; for (; i < frame_width-1; i += 2) { uint8_t c = (*src_ptr++ - 0x20); @@ -333,6 +355,7 @@ void __scratch_x("display") DVHSTX::text_dma_handler() { *dst_ptr++ = colour * (bits & 3); *dst_ptr++ = 0; } +#endif } } diff --git a/examples/dvhstx/CMakeLists.txt b/examples/dvhstx/CMakeLists.txt index 74a0a9d..95a4011 100644 --- a/examples/dvhstx/CMakeLists.txt +++ b/examples/dvhstx/CMakeLists.txt @@ -10,3 +10,15 @@ pico_enable_stdio_usb(mandelbrot 1) # create map/bin/hex file etc. pico_add_extra_outputs(mandelbrot) + +add_executable( + textmode + textmode.cpp +) + +# Pull in pico libraries that we need +target_link_libraries(textmode pico_stdlib pico_dvhstx) +pico_enable_stdio_usb(textmode 1) + +# create map/bin/hex file etc. +pico_add_extra_outputs(textmode) diff --git a/examples/dvhstx/mandelbrot.cpp b/examples/dvhstx/mandelbrot.cpp index 4fc3de6..8b7756e 100644 --- a/examples/dvhstx/mandelbrot.cpp +++ b/examples/dvhstx/mandelbrot.cpp @@ -10,11 +10,13 @@ extern "C" { using namespace pimoroni; +#ifdef __riscv +#define FRAME_WIDTH 400 +#define FRAME_HEIGHT 300 +#else #define FRAME_WIDTH 640 #define FRAME_HEIGHT 360 - -//#define FRAME_WIDTH 400 -//#define FRAME_HEIGHT 300 +#endif //#define FRAME_WIDTH 320 //#define FRAME_HEIGHT 180 @@ -103,10 +105,11 @@ void draw_mandel() { } int main() { - stdio_init_all(); - display.init(FRAME_WIDTH, FRAME_HEIGHT, DVHSTX::MODE_PALETTE); + stdio_init_all(); + while (!stdio_usb_connected()); + init_palette(); graphics.set_pen(0); diff --git a/examples/dvhstx/textmode.cpp b/examples/dvhstx/textmode.cpp new file mode 100644 index 0000000..f9482c7 --- /dev/null +++ b/examples/dvhstx/textmode.cpp @@ -0,0 +1,49 @@ +#include +#include "hardware/uart.h" +#include "drivers/dvhstx/dvhstx.hpp" + +using namespace pimoroni; + +#define FRAME_WIDTH 91 +#define FRAME_HEIGHT 30 + +static DVHSTX display; + +using namespace pimoroni; + +void fill_text(int frame) +{ + char buf[128]; + sprintf(buf, "Hello World! Frame: %d", frame); + display.write_text({0,0}, buf); + + for (int i = 0; i < 0x7f; ++i) { + buf[i] = i; + } + buf[0x7f] = 0; + + for (int i = 1; i < FRAME_HEIGHT; ++i) { + display.write_text({0, i}, &buf[0x20 + i], (i & 1) ? (i & 2) ? DVHSTX::TEXT_WHITE : DVHSTX::TEXT_BLUE : (i & 2) ? DVHSTX::TEXT_YELLOW : DVHSTX::TEXT_RED); + } +} + +int main() +{ + stdio_init_all(); + + printf("Main\n"); + + bool rv = display.init(FRAME_WIDTH, FRAME_HEIGHT, DVHSTX::MODE_TEXT_RGB111); + + printf("Init complete: %s", rv ? "True" : "False"); + + fill_text(0); + display.flip_now(); + + int frame = 1; + while(1) { + fill_text(frame++); + display.flip_blocking(); + printf(".\n"); + } +}