RiscV support, textmode example
This commit is contained in:
parent
65aa8be888
commit
ec3f15cecb
5 changed files with 95 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
49
examples/dvhstx/textmode.cpp
Normal file
49
examples/dvhstx/textmode.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include <stdio.h>
|
||||
#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");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue