Skip to content

Commit 37708bb

Browse files
author
DIBJT
committed
initial entry, move code over from test library
0 parents  commit 37708bb

File tree

24 files changed

+120726
-0
lines changed

24 files changed

+120726
-0
lines changed

LICENSE

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, SparkFun Electronics
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SparkFun PicoDVI Arduino Library
2+
3+
SparkFun Wrapper for the AdaFruit PicoDVI Library

examples/16bit_hello/16bit_hello.ino

+650
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Note - this example is from the AdaFruit Pico DVI library, but
2+
// modified to work with the SparkFun RedBoard IoT - RP2350. All
3+
// that is changed is the hardware configuration.
4+
5+
// Double-buffered 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
6+
// Animates without redraw flicker. Requires Adafruit_GFX >= 1.11.5
7+
8+
#include <SparkFun_PicoDVI.h>
9+
10+
// Here's how a 640x480 1-bit (black, white) framebuffer is declared.
11+
// Second argument ('true' here) enables double-buffering for flicker-free
12+
// animation. Third argument is a hardware configuration -- examples are
13+
// written for Adafruit Feather RP2040 DVI, but that's easily switched out
14+
// for boards like the Pimoroni Pico DV (use 'pimoroni_demo_hdmi_cfg') or
15+
// the SparkFun RedBoard IoT - RP2350 - which this example is using.
16+
17+
DVIGFX1 display(DVI_RES_640x480p60, true, sparkfun_iot_redboard_rp2350_dvi_cfg);
18+
19+
// An 800x480 mode is possible but pushes overclocking even higher than
20+
// 640x480 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
21+
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
22+
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
23+
// DVIGFX1 display(DVI_RES_800x480p60, true, sparkfun_iot_redboard_rp2350_dvi_cfg);
24+
25+
#define N_BALLS 100 // Number of bouncy balls to draw
26+
struct
27+
{
28+
int16_t pos[2]; // Ball position (X,Y)
29+
int8_t vel[2]; // Ball velocity (X,Y)
30+
} ball[N_BALLS];
31+
32+
void setup()
33+
{ // Runs once on startup
34+
if (!display.begin())
35+
{ // Blink LED if insufficient RAM
36+
pinMode(LED_BUILTIN, OUTPUT);
37+
for (;;)
38+
digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
39+
}
40+
41+
// Randomize initial ball positions and velocities
42+
for (int i = 0; i < N_BALLS; i++)
43+
{
44+
ball[i].pos[0] = 10 + random(display.width() - 20);
45+
ball[i].pos[1] = 10 + random(display.height() - 20);
46+
do
47+
{
48+
ball[i].vel[0] = 4 - random(9);
49+
ball[i].vel[1] = 4 - random(9);
50+
} while ((ball[i].vel[0] == 0) && (ball[i].vel[1] == 0));
51+
}
52+
}
53+
54+
void loop()
55+
{
56+
display.fillScreen(0); // Clear back framebuffer...
57+
// And draw bouncy balls (circles) there
58+
for (int i = 0; i < N_BALLS; i++)
59+
{
60+
display.drawCircle(ball[i].pos[0], ball[i].pos[1], 40, 1);
61+
// After drawing each one, update positions, bounce off edges.
62+
ball[i].pos[0] += ball[i].vel[0];
63+
if ((ball[i].pos[0] <= 0) || (ball[i].pos[0] >= display.width()))
64+
ball[i].vel[0] *= -1;
65+
ball[i].pos[1] += ball[i].vel[1];
66+
if ((ball[i].pos[1] <= 0) || (ball[i].pos[1] >= display.height()))
67+
ball[i].vel[1] *= -1;
68+
}
69+
70+
// Swap front/back buffers, do not duplicate current screen state to next frame,
71+
// we'll draw it new from scratch each time.
72+
display.swap();
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Note - this example is from the AdaFruit Pico DVI library, but
2+
// modified to work with the SparkFun RedBoard IoT - RP2350. All
3+
// that is changed is the hardware configuration.
4+
5+
// Simple 1-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
6+
7+
#include <SparkFun_PicoDVI.h>
8+
9+
// Here's how a 640x480 1-bit (black, white) framebuffer is declared.
10+
// Second argument ('false' here) means NO double-buffering; all drawing
11+
// operations are shown as they occur. Third argument is a hardware
12+
// configuration -- examples are written for Adafruit Feather RP2040 DVI,
13+
// but that's easily switched out for boards like the Pimoroni Pico DV
14+
// (use 'pimoroni_demo_hdmi_cfg') or the SparkFun RedBoard IoT - RP2350 - which this example is using.
15+
16+
DVIGFX1 display(DVI_RES_640x480p60, false, sparkfun_iot_redboard_rp2350_dvi_cfg);
17+
18+
// An 800x480 mode is possible but pushes overclocking even higher than
19+
// 640x480 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
20+
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
21+
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
22+
// DVIGFX1 display(DVI_RES_800x480p60, false, sparkfun_iot_redboard_rp2350_dvi_cfg);
23+
24+
void setup()
25+
{ // Runs once on startup
26+
if (!display.begin())
27+
{ // Blink LED if insufficient RAM
28+
pinMode(LED_BUILTIN, OUTPUT);
29+
for (;;)
30+
digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
31+
}
32+
}
33+
34+
void loop()
35+
{
36+
// Draw random lines
37+
display.drawLine(random(display.width()), random(display.height()), // Start X,Y
38+
random(display.width()), random(display.height()), // End X,Y
39+
random(2)); // Color (0 or 1)
40+
}

examples/1bit_text/1bit_text.ino

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Note - this example is from the AdaFruit Pico DVI library, but
2+
// modified to work with the SparkFun RedBoard IoT - RP2350. All
3+
// that is changed is the hardware configuration.
4+
5+
// 1-bit (black, white) text mode for PicoDVI.
6+
7+
#include <SparkFun_PicoDVI.h>
8+
9+
// Here's how an 80x30 character display is declared. First argument,
10+
// resolution, is full display pixel count...character cells are 8x8 pixels,
11+
// yielding the 80x30 result. 640x240 uses "tall" pixels, the result of all
12+
// this is very reminiscent of IBM VGA mode. Second argument is a hardware
13+
// configuration -- examples are written for Adafruit Feather RP2040 DVI,
14+
// but that's easily switched out for boards like the Pimoroni Pico DV
15+
// (use 'pimoroni_demo_hdmi_cfg') or the SparkFun RedBoard IoT - RP2350 -
16+
// which this example is using.
17+
18+
DVItext1 display(DVI_RES_640x240p60, sparkfun_iot_redboard_rp2350_dvi_cfg);
19+
20+
// Wider and taller modes are possible. Wider pushes overclocking even
21+
// higher than 640x480 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE
22+
// WITH THIS. May require selecting QSPI div4 clock (Tools menu) to slow
23+
// down flash accesses, may require over-volting the CPU to 1.25 or 1.3 V.
24+
// Here's how a 100x60 char display might be declared:
25+
// DVItext1 display(DVI_RES_800x480p60, sparkfun_iot_redboard_rp2350_dvi_cfg);
26+
27+
// A reduced refresh rate display doesn't as aggressive an over-clock
28+
// This timing is verified to work on https://www.adafruit.com/product/2232
29+
// DVItext1 display(DVI_RES_800x240p30, sparkfun_iot_redboard_rp2350_dvi_cfg);
30+
31+
void setup()
32+
{ // Runs once on startup
33+
if (!display.begin())
34+
{ // Blink LED if insufficient RAM
35+
pinMode(LED_BUILTIN, OUTPUT);
36+
for (;;)
37+
digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
38+
}
39+
}
40+
41+
void loop()
42+
{
43+
display.print("Hello World! ");
44+
delay(50);
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Note - this example is from the AdaFruit Pico DVI library, but
2+
// modified to work with the SparkFun RedBoard IoT - RP2350. All
3+
// that is changed is the hardware configuration.
4+
5+
// Double-buffered 8-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
6+
// Animates without redraw flicker. Requires Adafruit_GFX >= 1.11.4
7+
8+
#include <SparkFun_PicoDVI.h>
9+
10+
// Here's how a 320x240 8-bit (color-paletted) framebuffer is declared.
11+
// Second argument ('true' here) enables double-buffering for flicker-free
12+
// animation. Third argument is a hardware configuration -- examples are
13+
// written for Adafruit Feather RP2040 DVI, but that's easily switched out
14+
// for boards like the Pimoroni Pico DV (use 'pimoroni_demo_hdmi_cfg') or
15+
// the SparkFun RedBoard IoT - RP2350 - which this example is using.
16+
17+
DVIGFX8 display(DVI_RES_320x240p60, true, sparkfun_iot_redboard_rp2350_dvi_cfg);
18+
19+
// A 400x240 mode is possible but pushes overclocking even higher than
20+
// 320x240 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
21+
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
22+
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
23+
// DVIGFX8 display(DVI_RES_400x240p60, true, sparkfun_iot_redboard_rp2350_dvi_cfg);
24+
25+
#define N_BALLS 100 // Number of bouncy balls to draw, 1-254 (not 255)
26+
struct
27+
{
28+
int16_t pos[2]; // Ball position (X,Y)
29+
int8_t vel[2]; // Ball velocity (X,Y)
30+
} ball[N_BALLS];
31+
32+
void setup()
33+
{ // Runs once on startup
34+
if (!display.begin())
35+
{ // Blink LED if insufficient RAM
36+
pinMode(LED_BUILTIN, OUTPUT);
37+
for (;;)
38+
digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
39+
}
40+
41+
// Randomize initial ball positions, velocities and colors
42+
for (int i = 0; i < N_BALLS; i++)
43+
{
44+
display.setColor(i + 1, 64 + random(192), 64 + random(192), 64 + random(192));
45+
ball[i].pos[0] = 10 + random(display.width() - 20);
46+
ball[i].pos[1] = 10 + random(display.height() - 20);
47+
do
48+
{
49+
ball[i].vel[0] = 2 - random(5);
50+
ball[i].vel[1] = 2 - random(5);
51+
} while ((ball[i].vel[0] == 0) && (ball[i].vel[1] == 0));
52+
}
53+
display.setColor(255, 0xFFFF); // Last palette entry = white
54+
display.swap(false, true); // Duplicate same palette into front & back buffers
55+
}
56+
57+
void loop()
58+
{
59+
// Clear back framebuffer and draw balls (circles) there.
60+
display.fillScreen(0);
61+
for (int i = 0; i < N_BALLS; i++)
62+
{
63+
display.fillCircle(ball[i].pos[0], ball[i].pos[1], 20, i + 1);
64+
// After drawing each one, update positions, bounce off edges.
65+
ball[i].pos[0] += ball[i].vel[0];
66+
if ((ball[i].pos[0] <= 0) || (ball[i].pos[0] >= display.width()))
67+
ball[i].vel[0] *= -1;
68+
ball[i].pos[1] += ball[i].vel[1];
69+
if ((ball[i].pos[1] <= 0) || (ball[i].pos[1] >= display.height()))
70+
ball[i].vel[1] *= -1;
71+
}
72+
// Swap front/back buffers, do not duplicate current screen state to next frame,
73+
// we'll draw it new from scratch each time.
74+
display.swap();
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Note - this example is from the AdaFruit Pico DVI library, but
2+
// modified to work with the SparkFun RedBoard IoT - RP2350. All
3+
// that is changed is the hardware configuration.
4+
5+
// 8-bit Adafruit_GFX-compatible framebuffer for PicoDVI.
6+
7+
#include <SparkFun_PicoDVI.h>
8+
9+
// Here's how a 320x240 8-bit (color-paletted) framebuffer is declared.
10+
// Second argument ('false' here) means NO double-buffering; all drawing
11+
// operations are shown as they occur. Third argument is a hardware
12+
// configuration -- examples are written for Adafruit Feather RP2040 DVI,
13+
// but that's easily switched out for boards like the Pimoroni Pico DV
14+
// (use 'pimoroni_demo_hdmi_cfg') or the SparkFun RedBoard IoT - RP2350 -
15+
// which this example is using.
16+
17+
DVIGFX8 display(DVI_RES_320x240p60, false, sparkfun_iot_redboard_rp2350_dvi_cfg);
18+
19+
// A 400x240 mode is possible but pushes overclocking even higher than
20+
// 320x240 mode. SOME BOARDS MIGHT SIMPLY NOT BE COMPATIBLE WITH THIS.
21+
// May require selecting QSPI div4 clock (Tools menu) to slow down flash
22+
// accesses, may require further over-volting the CPU to 1.25 or 1.3 V.
23+
// DVIGFX8 display(DVI_RES_400x240p60, false, sparkfun_iot_redboard_rp2350_dvi_cfg);
24+
25+
void setup()
26+
{ // Runs once on startup
27+
if (!display.begin())
28+
{ // Blink LED if insufficient RAM
29+
pinMode(LED_BUILTIN, OUTPUT);
30+
for (;;)
31+
digitalWrite(LED_BUILTIN, (millis() / 500) & 1);
32+
}
33+
34+
// Randomize color palette. First entry is left black, last is set white.
35+
for (int i = 1; i < 255; i++)
36+
display.setColor(i, random(65536));
37+
display.setColor(255, 0xFFFF);
38+
}
39+
40+
void loop()
41+
{
42+
// Draw random lines
43+
display.drawLine(random(display.width()), random(display.height()), random(display.width()),
44+
random(display.height()), random(256));
45+
}

examples/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Arduino Examples for PicoDVI Library
2+
3+
This directory does not exist in the original PicoDVI repository.
4+
It contains examples compatible with the Arduino IDE.
5+
6+
## Note
7+
8+
The examples in this directory are ported over from the Adafruit fork of the Pico DVI library. The only changes made were to use the SparkFun IoT RedBoard - RP2350 configuration structure in setup.

0 commit comments

Comments
 (0)