DV Display: Allow scrolling by single pixel in x coordinate

dv_stick
Mike Bell 2023-06-30 00:19:36 +01:00 zatwierdzone przez Phil Howard
rodzic 1a54f7b77d
commit b9cd998709
5 zmienionych plików z 2141 dodań i 2084 usunięć

Wyświetl plik

@ -20,10 +20,10 @@ namespace pimoroni {
display_height = display_height_;
mode = mode_;
if (frame_width == 0) frame_width = display_width_;
if (frame_width_ == 0) frame_width = display_width_;
else frame_width = frame_width_;
if (frame_height == 0) frame_height = display_height_;
if (frame_height_ == 0) frame_height = display_height_;
else frame_height = frame_height_;
bank = 0;
@ -130,9 +130,6 @@ namespace pimoroni {
void DVDisplay::set_display_offset(const Point& p) {
int32_t offset = (int32_t)point_to_address(p) - (int32_t)point_to_address({0,0});
while (offset & 3) {
offset -= pixel_size();
}
i2c->write_bytes(I2C_ADDR, I2C_REG_SCROLL, (uint8_t*)&offset, 4);
}

Wyświetl plik

@ -148,8 +148,6 @@ namespace pimoroni {
// Set the top left corner of the display within the frame, if a larger
// frame is specified than the display.
// Note that the supplied x coordinate is rounded down to the previous multiple of 2 in RGB555 mode
// or multiple of 4 in palette or RGB888 modes
void set_display_offset(const Point& p);
uint8_t get_gpio();

Wyświetl plik

@ -9,18 +9,18 @@
using namespace pimoroni;
#define DISPLAY_WIDTH 720
#define DISPLAY_WIDTH 360
#define DISPLAY_HEIGHT 480
#define FRAME_WIDTH 720
#define FRAME_HEIGHT 720
#define FRAME_WIDTH 1000
#define FRAME_HEIGHT 480
#define READ_EDID 0
#if READ_EDID
extern "C" { int decode_edid(unsigned char* edid); }
#endif
#define USE_PALETTE 1
#define USE_PALETTE 0
void on_uart_rx() {
while (uart_is_readable(uart1)) {
@ -205,11 +205,19 @@ int main() {
//printf("%02x %02x\n", display.get_gpio(), display.get_gpio_hi());
display.set_display_offset(scroll);
#if 1
scroll.x += scroll_dir;
if (scroll.x + DISPLAY_WIDTH > FRAME_WIDTH || scroll.x < 0) {
scroll_dir = -scroll_dir;
scroll.x += scroll_dir;
}
#else
scroll.y += scroll_dir;
if (scroll.y + DISPLAY_HEIGHT > FRAME_HEIGHT || scroll.y < 0) {
scroll_dir = -scroll_dir;
scroll.y += scroll_dir;
}
#endif
++frames;
display.set_gpio_hi_pull_up_all(frames & 0x3F);