Skip to content

Commit

Permalink
Merge pull request #9 from adafruit/640x480-mode-fixes
Browse files Browse the repository at this point in the history
640x480 mode fixes
  • Loading branch information
jepler authored Feb 27, 2025
2 parents 8a6c26e + e21bf9a commit 5675ddb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
build/*
/doxygen
/html
37 changes: 32 additions & 5 deletions examples/01palettetest/01palettetest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ DVHSTX8 display(DVHSTX_PINOUT_DEFAULT, DVHSTX_RESOLUTION_640x360);
// The order is: {CKP, D0P, D1P, D2P} DVHSTX8 display({12, 14, 16, 18},
// DVHSTX_RESOLUTION_640x360);

struct moving_point {
int x, y, dx, dy;
void step() {
x += dx;
if (x < 0) { x = 0; dx = random(3) + 1; }
if (x >= display.width()) { x = display.width() - 1; dx = -random(3) - 1; }

y += dy;
if (y < 0) { y = 0; dy = random(3) + 1; }
if (y >= display.height()) { y = display.height() - 1; dy = -random(3) - 1; }
}
};

moving_point p1, p2;

int random_with_sign(int n) {
return random(2) ? random(n-1)+1 : -random(n-1)-1;
}

void setup() {
Serial.begin(115200);
// while(!Serial);
Expand All @@ -19,12 +38,20 @@ void setup() {
digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
}
Serial.println("display initialized");
p1 = moving_point{random(display.width()), random(display.height()), random_with_sign(3), random_with_sign(3)};
p2 = moving_point{random(display.width()), random(display.height()), random_with_sign(3), random_with_sign(3)};
}

void loop() {
// Draw random lines
display.drawLine(random(display.width()), random(display.height()),
random(display.width()), random(display.height()),
random(65536));
sleep_ms(1);
static int j;
display.drawLine(p1.x, p1.y, p2.x, p2.y, 1 + (j + 254) % 255);
Serial.printf("%d %d %d %d\r\n", p1.x, p1.y, p1.dx, p1.dy);
p1.step();
p2.step();

for(int i=1; i<256; i++) {
display.setColor(i, ((i + j) % 255) * 0x010101);
}
j += 1;
delay(3);
}
8 changes: 8 additions & 0 deletions src/Adafruit_dvhstx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ int16_t dvhstx_width(DVHSTXResolution r) {
return 400;
case DVHSTX_RESOLUTION_320x240:
return 320;
case DVHSTX_RESOLUTION_640x480:
return 640;
case DVHSTX_RESOLUTION_360x240:
return 360;
case DVHSTX_RESOLUTION_360x200:
return 360;
case DVHSTX_RESOLUTION_720x400:
return 720;
case DVHSTX_RESOLUTION_360x288:
return 360;
case DVHSTX_RESOLUTION_400x300:
Expand All @@ -42,10 +46,14 @@ int16_t dvhstx_height(DVHSTXResolution r) {
return 225;
case DVHSTX_RESOLUTION_320x240:
return 240;
case DVHSTX_RESOLUTION_640x480:
return 480;
case DVHSTX_RESOLUTION_360x240:
return 240;
case DVHSTX_RESOLUTION_360x200:
return 200;
case DVHSTX_RESOLUTION_720x400:
return 400;
case DVHSTX_RESOLUTION_360x288:
return 288;
case DVHSTX_RESOLUTION_400x300:
Expand Down
8 changes: 7 additions & 1 deletion src/Adafruit_dvhstx.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ struct enum {

DVHSTX_RESOLUTION_320x240, ///< well supported, aspect ratio 4:3, actual
///< resolution 640x480@60Hz
DVHSTX_RESOLUTION_640x480, ///< well supported, aspect ratio 4:3, actual
///< resolution 640x480@60Hz
DVHSTX_RESOLUTION_360x240, ///< well supported, aspect ratio 3:2, actual
///< resolution 720x480@60Hz
DVHSTX_RESOLUTION_360x200, ///< well supported, aspect ratio 9:5, actual
///< resolution 720x400@70Hz
///< resolution 720x400@70Hz (very close to
///< 16:9)
DVHSTX_RESOLUTION_720x400, ///< well supported, aspect ratio 9:5, actual
///< resolution 720x400@70Hz (very close to
///< 16:9)
DVHSTX_RESOLUTION_360x288, ///< well supported, aspect ratio 5:4, actual
///< resolution 720x576@60Hz
DVHSTX_RESOLUTION_400x300, ///< well supported, aspect ratio 4:3, actual
Expand Down
8 changes: 6 additions & 2 deletions src/drivers/dvhstx/dvhstx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,17 @@ void __scratch_x("display") DVHSTX::gfx_dma_handler() {
*dst_ptr++ = val;
*dst_ptr++ = val;
}
}
else {
} else if (h_repeat_shift == 1) {
for (int i = 0; i < timing_mode->h_active_pixels; i += 2) {
uint32_t val = display_palette[*src_ptr++];
*dst_ptr++ = val;
*dst_ptr++ = val;
}
} else {
for (int i = 0; i < timing_mode->h_active_pixels; i += 1) {
uint32_t val = display_palette[*src_ptr++];
*dst_ptr++ = val;
}
}
}
}
Expand Down

0 comments on commit 5675ddb

Please sign in to comment.