Skip to content

Commit

Permalink
Update examples for Feather DVI pinout, fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PaintYourDragon committed Mar 9, 2023
1 parent 8fb694a commit 506fca6
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 48 deletions.
26 changes: 17 additions & 9 deletions examples/hello/hello.ino → examples/16bit_hello/16bit_hello.ino
Original file line number Diff line number Diff line change
@@ -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.

void setup() {
Serial.begin(115200);
//while(!Serial);
// 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);

// 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);
Expand Down
36 changes: 21 additions & 15 deletions examples/1bit_double_buffer/1bit_double_buffer.ino
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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.
Expand All @@ -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();
Expand Down
25 changes: 18 additions & 7 deletions examples/1bit_single_buffer/1bit_single_buffer.ino
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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)
}
31 changes: 31 additions & 0 deletions examples/1bit_text/1bit_text.ino
Original file line number Diff line number Diff line change
@@ -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);
}
28 changes: 19 additions & 9 deletions examples/8bit_double_buffer/8bit_double_buffer.ino
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
19 changes: 14 additions & 5 deletions examples/8bit_single_buffer/8bit_single_buffer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions examples/virtual_spitft/virtual_spitft.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----

Expand Down

0 comments on commit 506fca6

Please sign in to comment.