Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Fruit Jam #10114

Merged
merged 4 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@
url = https://github.com/adafruit/Adafruit_CircuitPython_Wave.git
[submodule "ports/raspberrypi/lib/Pico-PIO-USB"]
path = ports/raspberrypi/lib/Pico-PIO-USB
url = https://github.com/adafruit/Pico-PIO-USB.git
url = https://github.com/tannewt/Pico-PIO-USB.git
branch = better_timeouts
[submodule "lib/micropython-lib"]
path = lib/micropython-lib
url = https://github.com/micropython/micropython-lib.git
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,30 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(BASEOPTS)
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(BASEOPTS)

TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/analog ports/cxd56 ports/espressif ports/mimxrt10xx ports/nordic ports/raspberrypi ports/renode ports/stm py shared-bindings shared-module supervisor
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/analog ports/cxd56 ports/espressif ports/mimxrt10xx ports/nordic ports/raspberrypi ports/renode ports/stm ports/zephyr-cp py shared-bindings shared-module supervisor
# Paths to exclude from TRANSLATE_SOURCES
# Each must be preceded by "-path"; if any wildcards, enclose in quotes.
# Separate by "-o" (Find's "or" operand)
TRANSLATE_SOURCES_EXC = -path "ports/*/build-*" \
-o -path "ports/*/build" \
-o -path ports/analog/msdk \
-o -path ports/atmel-samd/asf4 \
-o -path ports/cxd56/spresense-exported-sdk \
-o -path ports/espressif/esp-camera \
-o -path ports/espressif/esp-idf \
-o -path ports/espressif/esp-protocols \
-o -path ports/mimxrt10xx/sdk \
-o -path ports/nordic/bluetooth \
-o -path ports/nordic/nrfx \
-o -path ports/raspberrypi/lib \
-o -path ports/raspberrypi/sdk \
-o -path ports/stm/peripherals \
-o -path ports/stm/st_driver \
-o -path lib/tinyusb \
-o -path lib/lwip \
-o -path ports/zephyr-cp/bootloader \
-o -path ports/zephyr-cp/modules \
-o -path ports/zephyr-cp/tools \
-o -path ports/zephyr-cp/zephyr \
-o -path lib \
-o -path extmod/ulab/circuitpython \
-o -path extmod/ulab/micropython \

Expand Down
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 105 files
39 changes: 18 additions & 21 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ msgstr ""
msgid "%q failure: %d"
msgstr ""

#: py/argcheck.c
#: py/argcheck.c shared-module/audiofilters/Filter.c
msgid "%q in %q must be of type %q, not %q"
msgstr ""

Expand Down Expand Up @@ -187,10 +187,6 @@ msgstr ""
msgid "%q must be >= %d"
msgstr ""

#: shared-module/audiofilters/Filter.c
msgid "%q must be a %q object, %q, or %q"
msgstr ""

#: shared-bindings/analogbufio/BufferedIn.c
msgid "%q must be a bytearray or array of type 'H' or 'B'"
msgstr ""
Expand Down Expand Up @@ -218,6 +214,7 @@ msgstr ""
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
#: shared-bindings/bitmapfilter/__init__.c shared-bindings/canio/CAN.c
#: shared-bindings/digitalio/Pull.c shared-bindings/supervisor/__init__.c
#: shared-module/audiofilters/Filter.c shared-module/displayio/__init__.c
#: shared-module/synthio/Biquad.c shared-module/synthio/Synthesizer.c
msgid "%q must be of type %q or %q, not %q"
msgstr ""
Expand Down Expand Up @@ -542,7 +539,6 @@ msgstr ""
#: ports/nordic/common-hal/pulseio/PulseIn.c
#: ports/nordic/peripherals/nrf/timers.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
#: ports/stm/peripherals/timers.c
msgid "All timers in use"
msgstr ""

Expand All @@ -568,6 +564,7 @@ msgstr ""

#: ports/espressif/common-hal/wifi/Radio.c
#: ports/raspberrypi/common-hal/wifi/Radio.c
#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "Already scanning for wifi networks"
msgstr ""

Expand Down Expand Up @@ -875,10 +872,6 @@ msgstr ""
msgid "Data 0 pin must be byte aligned"
msgstr ""

#: shared-module/audiocore/WaveFile.c
msgid "Data chunk must follow fmt chunk"
msgstr ""

#: shared-module/jpegio/JpegDecoder.c
msgid "Data format error (may be broken data)"
msgstr ""
Expand Down Expand Up @@ -1042,6 +1035,10 @@ msgstr ""
msgid "Failed to release mutex, err 0x%04x"
msgstr ""

#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "Failed to set hostname"
msgstr ""

#: ports/espressif/common-hal/audioio/AudioOut.c
msgid "Failed to start async audio"
msgstr ""
Expand Down Expand Up @@ -1193,6 +1190,7 @@ msgid "Insufficient stream input buffer"
msgstr ""

#: ports/espressif/common-hal/wifi/Radio.c
#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "Interface must be started"
msgstr ""

Expand Down Expand Up @@ -1312,6 +1310,7 @@ msgid "Invalid hex password"
msgstr ""

#: ports/espressif/common-hal/wifi/Radio.c
#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "Invalid multicast MAC address"
msgstr ""

Expand Down Expand Up @@ -1414,7 +1413,8 @@ msgstr ""
msgid "Mount point directory missing"
msgstr ""

#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c
#: ports/zephyr-cp/bindings/zephyr_serial/UART.c shared-bindings/busio/UART.c
#: shared-bindings/displayio/Group.c
msgid "Must be a %q subclass."
msgstr ""

Expand Down Expand Up @@ -1653,13 +1653,6 @@ msgstr ""
msgid "Only int or string supported for ip"
msgstr ""

#: shared-module/displayio/OnDiskBitmap.c
#, c-format
msgid ""
"Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: "
"%d bpp given"
msgstr ""

#: ports/espressif/common-hal/alarm/touch/TouchAlarm.c
msgid "Only one %q can be set in deep sleep."
msgstr ""
Expand Down Expand Up @@ -1710,6 +1703,7 @@ msgstr ""

#: ports/espressif/common-hal/socketpool/Socket.c
#: ports/raspberrypi/common-hal/socketpool/Socket.c
#: ports/zephyr-cp/common-hal/socketpool/Socket.c
msgid "Out of sockets"
msgstr ""

Expand Down Expand Up @@ -1986,6 +1980,7 @@ msgstr ""

#: ports/espressif/common-hal/socketpool/SocketPool.c
#: ports/raspberrypi/common-hal/socketpool/SocketPool.c
#: ports/zephyr-cp/common-hal/socketpool/SocketPool.c
msgid "SocketPool can only be used with wifi.radio"
msgstr ""

Expand Down Expand Up @@ -2025,8 +2020,7 @@ msgstr ""
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
msgstr ""

#: shared-module/audiodelays/Echo.c shared-module/audiofilters/Distortion.c
#: shared-module/audiofilters/Filter.c shared-module/audiomixer/MixerVoice.c
#: shared-module/audiocore/__init__.c
msgid "The sample's %q does not match"
msgstr ""

Expand Down Expand Up @@ -2291,6 +2285,7 @@ msgid "Unsupported hash algorithm"
msgstr ""

#: ports/espressif/common-hal/socketpool/Socket.c
#: ports/zephyr-cp/common-hal/socketpool/Socket.c
msgid "Unsupported socket type"
msgstr ""

Expand Down Expand Up @@ -2578,7 +2573,8 @@ msgstr ""
msgid "bits must be 32 or less"
msgstr ""

#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Distortion.c
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiodelays/PitchShift.c
#: shared-bindings/audiofilters/Distortion.c
#: shared-bindings/audiofilters/Filter.c shared-bindings/audiomixer/Mixer.c
msgid "bits_per_sample must be 8 or 16"
msgstr ""
Expand Down Expand Up @@ -4361,6 +4357,7 @@ msgstr ""

#: ports/espressif/common-hal/wifi/Radio.c
#: ports/raspberrypi/common-hal/wifi/Radio.c
#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "wifi is not enabled"
msgstr ""

Expand Down
25 changes: 23 additions & 2 deletions ports/raspberrypi/boards/adafruit_fruit_jam/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

#include "common-hal/microcontroller/Pin.h"
#include "hardware/gpio.h"
#include "py/mphal.h"
#include "shared-bindings/usb_host/Port.h"
#include "supervisor/board.h"

#include "common-hal/picodvi/__init__.h"

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

#define I2S_RESET_PIN_NUMBER 22

#if defined(DEFAULT_USB_HOST_5V_POWER)
bool board_reset_pin_number(uint8_t pin_number) {
Expand All @@ -25,12 +29,29 @@ bool board_reset_pin_number(uint8_t pin_number) {

return true;
}
// Set I2S out of reset.
if (pin_number == I2S_RESET_PIN_NUMBER) {
gpio_put(pin_number, 1);
gpio_set_dir(pin_number, GPIO_OUT);
gpio_set_function(pin_number, GPIO_FUNC_SIO);

return true;
}
return false;
}
#endif

#if defined(DEFAULT_USB_HOST_DATA_PLUS)
void board_init(void) {
// Reset the DAC to put it in a known state.
gpio_put(I2S_RESET_PIN_NUMBER, 0);
gpio_set_dir(I2S_RESET_PIN_NUMBER, GPIO_OUT);
gpio_set_function(I2S_RESET_PIN_NUMBER, GPIO_FUNC_SIO);
mp_hal_delay_us(1);
board_reset_pin_number(I2S_RESET_PIN_NUMBER);

#if defined(DEFAULT_USB_HOST_DATA_PLUS)
common_hal_usb_host_port_construct(DEFAULT_USB_HOST_DATA_PLUS, DEFAULT_USB_HOST_DATA_MINUS);
#endif

picodvi_autoconstruct();
}
#endif
14 changes: 14 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@
#define DEFAULT_USB_HOST_DATA_MINUS (&pin_GPIO2)
#define DEFAULT_USB_HOST_5V_POWER (&pin_GPIO11)

#define DEFAULT_DVI_BUS_CLK_DN (&pin_GPIO12)
#define DEFAULT_DVI_BUS_CLK_DP (&pin_GPIO13)
#define DEFAULT_DVI_BUS_RED_DN (&pin_GPIO14)
#define DEFAULT_DVI_BUS_RED_DP (&pin_GPIO15)
#define DEFAULT_DVI_BUS_GREEN_DN (&pin_GPIO16)
#define DEFAULT_DVI_BUS_GREEN_DP (&pin_GPIO17)
#define DEFAULT_DVI_BUS_BLUE_DN (&pin_GPIO18)
#define DEFAULT_DVI_BUS_BLUE_DP (&pin_GPIO19)

#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO47)

// #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO44)
// #define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO45)

// #define CIRCUITPY_DEBUG_TINYUSB 0
3 changes: 3 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ CHIP_PACKAGE = B
CHIP_FAMILY = rp2

EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"

# CIRCUITPY_DISPLAY_FONT = $(TOP)/tools/fonts/unifont-16.0.02-all.bdf
# CIRCUITPY_FONT_EXTRA_CHARACTERS = "🖮🖱️"
2 changes: 0 additions & 2 deletions ports/raspberrypi/boards/adafruit_fruit_jam/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO44) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO45) },

// On-board switch reverses D0 and D1 connections to RX and TX.

{ MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
Expand Down
5 changes: 5 additions & 0 deletions ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
// streaming support.
self->framebuffer = (uint32_t *)port_malloc(framebuffer_size * sizeof(uint32_t), true);
if (self->framebuffer == NULL || ((size_t)self->framebuffer & 0xf0000000) == 0x10000000) {
if (self->framebuffer != NULL) {
// Return the memory in PSRAM.
port_free(self->framebuffer);
self->framebuffer = NULL;
}
m_malloc_fail(framebuffer_size * sizeof(uint32_t));
return;
}
Expand Down
57 changes: 52 additions & 5 deletions ports/raspberrypi/common-hal/picodvi/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "supervisor/port_heap.h"

#if defined(DEFAULT_DVI_BUS_CLK_DP)
static bool picodvi_autoconstruct_enabled(void) {
static bool picodvi_autoconstruct_enabled(mp_int_t *default_width, mp_int_t *default_height) {
char buf[sizeof("detect")];
buf[0] = 0;

Expand All @@ -42,6 +42,48 @@ static bool picodvi_autoconstruct_enabled(void) {
return false;
}
bool probed = common_hal_busio_i2c_probe(i2c, 0x50);
if (probed) {
uint8_t edid[128];
uint8_t out[1] = {0};
common_hal_busio_i2c_write_read(i2c, 0x50, out, 1, edid, sizeof(edid));
bool edid_ok = true;
if (edid[0] != 0x00 || edid[1] != 0xFF || edid[2] != 0xFF || edid[3] != 0xFF || edid[4] != 0xFF || edid[5] != 0xFF || edid[6] != 0xFF || edid[7] != 0x00) {
edid_ok = false;
}
uint8_t checksum = 0;
for (size_t i = 0; i < sizeof(edid); i++) {
checksum += edid[i];
}
if (checksum != 0) {
edid_ok = false;
}

if (edid_ok) {
uint8_t established_timings = edid[35];
if ((established_timings & 0xa0) == 0) {
// Check that 720x400@70Hz or 640x480@60Hz is supported. If not
// and we read EDID ok, then don't autostart.
probed = false;
} else {
size_t offset = 54;
uint16_t preferred_pixel_clock = edid[offset] | (edid[offset + 1] << 8);
if (preferred_pixel_clock != 0) {
size_t preferred_width = ((edid[offset + 4] & 0xf0) << 4) | edid[offset + 2];
size_t preferred_height = ((edid[offset + 7] & 0xf0) << 4) | edid[offset + 5];
// Use 720x400 on 1080p, 4k and 8k displays.
if ((established_timings & 0x80) != 0 &&
preferred_width % 1920 == 0 &&
preferred_height % 1080 == 0) {
*default_width = 720 / 2;
*default_height = 400 / 2;
} else {
*default_width = 640 / 2;
*default_height = 480 / 2;
}
}
}
}
}
common_hal_busio_i2c_unlock(i2c);
return probed;
}
Expand All @@ -53,11 +95,13 @@ void picodvi_autoconstruct(void) {
return;
}

if (!picodvi_autoconstruct_enabled()) {
mp_int_t default_width = 320;
mp_int_t default_height = 240;
if (!picodvi_autoconstruct_enabled(&default_width, &default_height)) {
return;
}

mp_int_t width = 320;
mp_int_t width = default_width;
mp_int_t height = 0;
mp_int_t color_depth = 16;
mp_int_t rotation = 0;
Expand All @@ -75,6 +119,9 @@ void picodvi_autoconstruct(void) {
case 320:
height = 240;
break;
case 360:
height = 200;
break;
}
}

Expand All @@ -85,8 +132,8 @@ void picodvi_autoconstruct(void) {

if (!common_hal_picodvi_framebuffer_preflight(width, height, color_depth)) {
// invalid configuration, set back to default
width = 320;
height = 240;
width = default_width;
height = default_height;
color_depth = 16;
}

Expand Down
Loading