diff --git a/examples/hello/hello.ino b/examples/16bit_hello/16bit_hello.ino similarity index 96% rename from examples/hello/hello.ino rename to examples/16bit_hello/16bit_hello.ino index aaebefc..dca2516 100644 --- a/examples/hello/hello.ino +++ b/examples/16bit_hello/16bit_hello.ino @@ -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 // Core display & graphics library #include // 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); diff --git a/examples/1bit_double_buffer/1bit_double_buffer.ino b/examples/1bit_double_buffer/1bit_double_buffer.ino index eede2cd..d00c7ee 100644 --- a/examples/1bit_double_buffer/1bit_double_buffer.ino +++ b/examples/1bit_double_buffer/1bit_double_buffer.ino @@ -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 -// 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= 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(); diff --git a/examples/1bit_single_buffer/1bit_single_buffer.ino b/examples/1bit_single_buffer/1bit_single_buffer.ino index 9b67239..d4bf6ca 100644 --- a/examples/1bit_single_buffer/1bit_single_buffer.ino +++ b/examples/1bit_single_buffer/1bit_single_buffer.ino @@ -1,13 +1,22 @@ -// 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI. +// Simple 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI. #include -// 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) } diff --git a/examples/1bit_text/1bit_text.ino b/examples/1bit_text/1bit_text.ino new file mode 100644 index 0000000..ae2a735 --- /dev/null +++ b/examples/1bit_text/1bit_text.ino @@ -0,0 +1,31 @@ +// 1-bit (black, white) text mode for PicoDVI. + +#include + +// 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); +} diff --git a/examples/8bit_double_buffer/8bit_double_buffer.ino b/examples/8bit_double_buffer/8bit_double_buffer.ino index 8a0b418..87df0b5 100644 --- a/examples/8bit_double_buffer/8bit_double_buffer.ino +++ b/examples/8bit_double_buffer/8bit_double_buffer.ino @@ -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 -// 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); diff --git a/examples/8bit_single_buffer/8bit_single_buffer.ino b/examples/8bit_single_buffer/8bit_single_buffer.ino index fb90bba..cc98983 100644 --- a/examples/8bit_single_buffer/8bit_single_buffer.ino +++ b/examples/8bit_single_buffer/8bit_single_buffer.ino @@ -2,12 +2,21 @@ #include -// 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); diff --git a/examples/virtual_spitft/virtual_spitft.ino b/examples/virtual_spitft/virtual_spitft.ino index 0e65573..427b981 100644 --- a/examples/virtual_spitft/virtual_spitft.ino +++ b/examples/virtual_spitft/virtual_spitft.ino @@ -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 ----