Update examples for Feather DVI pinout, fix comments

This commit is contained in:
Phillip Burgess 2023-03-09 14:18:33 -08:00
parent 8fb694adaf
commit 506fca674a
7 changed files with 122 additions and 47 deletions

View file

@ -1,16 +1,24 @@
// Basic PicoDVI test. Provides a 16-bit color video framebuffer to which
// Adafruit_GFX calls can be made. It's based on the EYESPI_Test.ino sketch.
// Basic full-color PicoDVI test. Provides a 16-bit color video framebuffer to
// which Adafruit_GFX calls can be made. It's based on the EYESPI_Test.ino sketch.
#include <PicoDVI.h> // Core display & graphics library
#include <Fonts/FreeSansBold18pt7b.h> // A custom font
// Your basic 320x240 16-bit color display:
DVIGFX16 display(DVI_RES_320x240p60, pimoroni_demo_hdmi_cfg);
// 16-bit currently supports 320x240 and 400x240 resolutions only.
// Here's how a 320x240 16-bit color framebuffer is declared. Double-buffering
// is not an option in 16-bit color mode, just not enough RAM; all drawing
// operations are shown as they occur. Second argument is a hardware
// configuration -- examples are written for Adafruit Feather RP2040 DVI, but
// that's easily switched out for boards like the Pimoroni Pico DV (use
// 'pimoroni_demo_hdmi_cfg') or Pico DVI Sock ('pico_sock_cfg').
DVIGFX16 display(DVI_RES_320x240p60, adafruit_feather_dvi_cfg);
void setup() {
Serial.begin(115200);
//while(!Serial);
// A 400x240 mode is possible but pushes overclocking even higher than
// 320x240 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
//DVIGFX16 display(DVI_RES_320x240p60, adafruit_feather_dvi_cfg);
void setup() { // Runs once on startup
if (!display.begin()) { // Blink LED if insufficient RAM
pinMode(LED_BUILTIN, OUTPUT);
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);

View file

@ -1,23 +1,29 @@
// Double-buffered 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
// Allows animation without redraw flicker. Requires Adafruit_GFX >= 1.11.5
// Animates without redraw flicker. Requires Adafruit_GFX >= 1.11.5
#include <PicoDVI.h>
// Double-buffered 1-bit and 8-bit are declared a little differently...
// 1-bit accepts a boolean after the the resolution to enable/disable
// double-buffering, whereas 8-bit double-buffered uses a distinct class.
// 1-bit currently supports 640x480 and 800x480 resolutions only.
DVIGFX1 display(DVI_RES_800x480p60, true, pimoroni_demo_hdmi_cfg);
// Here's how a 640x480 1-bit (black, white) framebuffer is declared.
// Second argument ('true' here) enables double-buffering for flicker-free
// animation. Third argument is a hardware configuration -- examples are
// written for Adafruit Feather RP2040 DVI, but that's easily switched out
// for boards like the Pimoroni Pico DV (use 'pimoroni_demo_hdmi_cfg') or
// Pico DVI Sock ('pico_sock_cfg').
DVIGFX1 display(DVI_RES_640x480p60, true, adafruit_feather_dvi_cfg);
#define N_BALLS 100
// An 800x480 mode is possible but pushes overclocking even higher than
// 640x480 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
//DVIGFX1 display(DVI_RES_800x480p60, true, adafruit_feather_dvi_cfg);
#define N_BALLS 100 // Number of bouncy balls to draw
struct {
int16_t pos[2];
int8_t vel[2];
int16_t pos[2]; // Ball position (X,Y)
int8_t vel[2]; // Ball velocity (X,Y)
} ball[N_BALLS];
void setup() {
Serial.begin(115200);
//while(!Serial);
void setup() { // Runs once on startup
if (!display.begin()) { // Blink LED if insufficient RAM
pinMode(LED_BUILTIN, OUTPUT);
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
@ -35,9 +41,8 @@ void setup() {
}
void loop() {
// Clear back framebuffer and draw balls (circles) there.
display.fillScreen(0);
display.fillScreen(0); // Clear back framebuffer...
// And draw bouncy balls (circles) there
for (int i=0; i<N_BALLS; i++) {
display.drawCircle(ball[i].pos[0], ball[i].pos[1], 40, 1);
// After drawing each one, update positions, bounce off edges.
@ -46,6 +51,7 @@ void loop() {
ball[i].pos[1] += ball[i].vel[1];
if ((ball[i].pos[1] <= 0) || (ball[i].pos[1] >= display.height())) ball[i].vel[1] *= -1;
}
// Swap front/back buffers, do not duplicate current screen state to next frame,
// we'll draw it new from scratch each time.
display.swap();

View file

@ -1,13 +1,22 @@
// 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
// Simple 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
#include <PicoDVI.h>
// 1-bit currently supports 640x480 and 800x480 resolutions only.
DVIGFX1 display(DVI_RES_800x480p60, false, pimoroni_demo_hdmi_cfg);
// Here's how a 640x480 1-bit (black, white) framebuffer is declared.
// Second argument ('false' here) means NO double-buffering; all drawing
// operations are shown as they occur. Third argument is a hardware
// configuration -- examples are written for Adafruit Feather RP2040 DVI,
// but that's easily switched out for boards like the Pimoroni Pico DV
// (use 'pimoroni_demo_hdmi_cfg') or Pico DVI Sock ('pico_sock_cfg').
DVIGFX1 display(DVI_RES_640x480p60, false, adafruit_feather_dvi_cfg);
void setup() {
Serial.begin(115200);
//while(!Serial);
// An 800x480 mode is possible but pushes overclocking even higher than
// 640x480 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
//DVIGFX1 display(DVI_RES_800x480p60, false, adafruit_feather_dvi_cfg);
void setup() { // Runs once on startup
if (!display.begin()) { // Blink LED if insufficient RAM
pinMode(LED_BUILTIN, OUTPUT);
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
@ -16,5 +25,7 @@ void setup() {
void loop() {
// Draw random lines
display.drawLine(random(display.width()), random(display.height()), random(display.width()), random(display.height()), random(2));
display.drawLine(random(display.width()), random(display.height()), // Start X,Y
random(display.width()), random(display.height()), // End X,Y
random(2)); // Color (0 or 1)
}

View file

@ -0,0 +1,31 @@
// 1-bit (black, white) text mode for PicoDVI.
#include <PicoDVI.h>
// Here's how an 80x30 character display is declared. First argument,
// resolution, is full display pixel count...character cells are 8x8 pixels,
// yielding the 80x30 result. 640x240 uses "tall" pixels, the result of all
// this is very reminiscent of IBM VGA mode. Second argument is a hardware
// configuration -- examples are written for Adafruit Feather RP2040 DVI,
// but that's easily switched out for boards like the Pimoroni Pico DV
// (use 'pimoroni_demo_hdmi_cfg') or Pico DVI Sock ('pico_sock_cfg').
DVItext1 display(DVI_RES_640x240p60, adafruit_feather_dvi_cfg);
// Wider and taller modes are possible. Wider pushes overclocking even
// higher than 640x480 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE
// WITH THIS. May require selecting QSPI div4 clock (Tools menu) to slow
// down flash accesses, may require over-volting the CPU to 1.25 or 1.3 V.
// Here's how a 100x60 char display might be declared:
//DVItext1 display(DVI_RES_800x480p60, adafruit_feather_dvi_cfg);
void setup() { // Runs once on startup
if (!display.begin()) { // Blink LED if insufficient RAM
pinMode(LED_BUILTIN, OUTPUT);
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
}
}
void loop() {
display.print("Hello World! ");
delay(50);
}

View file

@ -1,20 +1,30 @@
// Double-buffered 8-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
// Allows animation without redraw flicker. Requires Adafruit_GFX >= 1.11.4
// Animates without redraw flicker. Requires Adafruit_GFX >= 1.11.4
#include <PicoDVI.h>
// 8-bit currently supports 320x240 and 400x240 resolutions only.
DVIGFX8 display(DVI_RES_400x240p60, true, pimoroni_demo_hdmi_cfg);
// Here's how a 320x240 8-bit (color-paletted) framebuffer is declared.
// Second argument ('true' here) enables double-buffering for flicker-free
// animation. Third argument is a hardware configuration -- examples are
// written for Adafruit Feather RP2040 DVI, but that's easily switched out
// for boards like the Pimoroni Pico DV (use 'pimoroni_demo_hdmi_cfg') or
// Pico DVI Sock ('pico_sock_cfg').
DVIGFX8 display(DVI_RES_320x240p60, true, adafruit_feather_dvi_cfg);
#define N_BALLS 100 // 1-254 (not 255)
// A 400x240 mode is possible but pushes overclocking even higher than
// 320x240 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
//DVIGFX8 display(DVI_RES_400x240p60, true, adafruit_feather_dvi_cfg);
#define N_BALLS 100 // Number of bouncy balls to draw, 1-254 (not 255)
struct {
int16_t pos[2];
int8_t vel[2];
int16_t pos[2]; // Ball position (X,Y)
int8_t vel[2]; // Ball velocity (X,Y)
} ball[N_BALLS];
void setup() {
Serial.begin(115200);
//while(!Serial);
void setup() { // Runs once on startup
if (!display.begin()) { // Blink LED if insufficient RAM
pinMode(LED_BUILTIN, OUTPUT);
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);

View file

@ -2,12 +2,21 @@
#include <PicoDVI.h>
// 8-bit currently supports 320x240 and 400x240 resolutions only.
DVIGFX8 display(DVI_RES_400x240p60, false, pimoroni_demo_hdmi_cfg);
// Here's how a 320x240 8-bit (color-paletted) framebuffer is declared.
// Second argument ('false' here) means NO double-buffering; all drawing
// operations are shown as they occur. Third argument is a hardware
// configuration -- examples are written for Adafruit Feather RP2040 DVI,
// but that's easily switched out for boards like the Pimoroni Pico DV
// (use 'pimoroni_demo_hdmi_cfg') or Pico DVI Sock ('pico_sock_cfg').
DVIGFX8 display(DVI_RES_320x240p60, false, adafruit_feather_dvi_cfg);
void setup() {
Serial.begin(115200);
//while(!Serial);
// A 400x240 mode is possible but pushes overclocking even higher than
// 320x240 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
//DVIGFX8 display(DVI_RES_400x240p60, false, adafruit_feather_dvi_cfg);
void setup() { // Runs once on startup
if (!display.begin()) { // Blink LED if insufficient RAM
pinMode(LED_BUILTIN, OUTPUT);
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1);

View file

@ -8,11 +8,11 @@
// GPIO connected to (or shared with) TFT control.
// Careful not to overlap the DVI pins.
#define PIN_DATA 18 // 3 contiguous pins start here: data, DC, clk
#define PIN_CS 21 // Chip-select need not be contiguous
#define PIN_DATA 9 // 3 contiguous pins start here: data, DC, clk
#define PIN_CS 6 // Chip-select need not be contiguous
// 320x240 16-bit color display (to match common TFT display resolution):
DVIGFX16 display(DVI_RES_320x240p60, pimoroni_demo_hdmi_cfg);
DVIGFX16 display(DVI_RES_320x240p60, adafruit_feather_dvi_cfg);
// Output of pioasm ----