diff --git a/.gitmodules b/.gitmodules index 1e43329..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "firmware/pico-sdk"] - path = firmware/pico-sdk - url = https://github.com/raspberrypi/pico-sdk.git diff --git a/firmware-rs/.gitignore b/firmware-rs/.gitignore deleted file mode 100644 index 2f7896d..0000000 --- a/firmware-rs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target/ diff --git a/firmware-rs/.cargo/config.toml b/firmware/.cargo/config.toml similarity index 100% rename from firmware-rs/.cargo/config.toml rename to firmware/.cargo/config.toml diff --git a/firmware/.gitignore b/firmware/.gitignore index 567609b..2f7896d 100644 --- a/firmware/.gitignore +++ b/firmware/.gitignore @@ -1 +1 @@ -build/ +target/ diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt deleted file mode 100644 index 66eb784..0000000 --- a/firmware/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.13) - -# initialize pico-sdk from submodule -# note: this must happen before project() -include(pico-sdk/pico_sdk_init.cmake) - -enable_language( C CXX ASM ) - -# Name the project -project(jukebox_v5) - -# initialize the Raspberry Pi Pico SDK -pico_sdk_init() - -# Source files -add_executable(jukebox_firmware - "src/main.c" - - "src/keyboard.c" - "src/lcd.c" - "src/led.c" - "src/rgb.c" - "src/serial.c" - - "src/callbacks.c" - - "src/st7789_lcd.c" - - "src/usb_descriptors.c" -) - -# PIO files -pico_generate_pio_header(jukebox_firmware ${CMAKE_CURRENT_LIST_DIR}/src/st7789_lcd.pio) -pico_generate_pio_header(jukebox_firmware ${CMAKE_CURRENT_LIST_DIR}/src/ws2812_rgb.pio) - -# Header files -target_include_directories(jukebox_firmware PUBLIC - "include/" -) - -# Libraries -target_link_libraries(jukebox_firmware PUBLIC - pico_stdlib - pico_rand - pico_unique_id - pico_multicore - hardware_pio - tinyusb_device - tinyusb_board -) - -# Create map/bin/hex/uf2 file in addition to ELF. -pico_add_extra_outputs(jukebox_firmware) diff --git a/firmware-rs/Cargo.lock b/firmware/Cargo.lock similarity index 100% rename from firmware-rs/Cargo.lock rename to firmware/Cargo.lock diff --git a/firmware-rs/Cargo.toml b/firmware/Cargo.toml similarity index 100% rename from firmware-rs/Cargo.toml rename to firmware/Cargo.toml diff --git a/firmware-rs/Embed.toml b/firmware/Embed.toml similarity index 100% rename from firmware-rs/Embed.toml rename to firmware/Embed.toml diff --git a/firmware/README.md b/firmware/README.md deleted file mode 100644 index a339b8b..0000000 --- a/firmware/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# JukeBox Firmware -Designed for the RP2040 chip, by Raspberry Pi. Tested using an RPi Pico. - -### Build and Flash -Package manager dependencies, to build the firmware (on Debian/Ubuntu): -``` -sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib -``` -These are the only packages necessary for building RP2040 firmware. For more information, visit the [pico-sdk repository](https://github.com/raspberrypi/pico-sdk#quick-start-your-own-project). Equivalent packages exist for most other package managers. - -To build the firmware, run the following in the current directory: -```bash -git submodule update --init --recursive -mkdir build -cd build -cmake .. -make -j4 -``` -This updates the pico-sdk for the project, along with all of its dependencies. Then, the build is properly started by setting up the build environment, and finally running make to begin the build process with 4 processing cores. You can increase this number as necessary. The final firmware binary will be located at [`build/jukebox_firmware.uf2`](build/jukebox_firmware.uf2), move this file onto the board when it's in programming mode (held BOOTSEL) to flash the new firmware. - -TODO: update above - -### Screen Font -The default font is included as [`misc/JukeBoxFont.png`](misc/JukeBoxFont.png). It is a monospace, 12x12 pixel font, with the sheet matching IBM Code Page 437. It's ASCII compatible, but with plenty of extra symbols. To export it, run the included [`misc/mkfont.py`](misc/mkfont.py) script to generate a new `font.h` file. Then, before building the frimware, replace the existing `font.h` with your newly generated font. diff --git a/firmware-rs/build.rs b/firmware/build.rs similarity index 100% rename from firmware-rs/build.rs rename to firmware/build.rs diff --git a/firmware/include/common.h b/firmware/include/common.h deleted file mode 100644 index b80cbc7..0000000 --- a/firmware/include/common.h +++ /dev/null @@ -1,76 +0,0 @@ - -#ifndef JUKEBOX_COMMON_H -#define JUKEBOX_COMMON_H - -// Common includes -#include -#include "config.h" - - -// Common macros -#define BIT(n) (1< (Y)) ? (X) : (Y)) -#endif -#ifndef MIN - #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) -#endif - - -// Config checking -// TODO - -#if JB_HID_REFRESH_INTERVAL > 250 - #error "HID refresh interval must be greater than 250 ms." -#endif -#if JB_SERIAL_REFRESH_INTERVAL > 250 - #error "Serial refresh interval must be greater than 250 ms." -#endif - -#ifdef JB_MOD_SCREEN - #if JB_SCREEN_REFRESH_INTERVAL > 250 - #error "Screen framebuffer refresh interval must be greater than 250 ms." - #endif - - #if JB_SCREEN_PIN_DIN > 22 - #error "Screen pin DIN must be 22 or less." - #elif JB_SCREEN_PIN_CLK > 22 - #error "Screen pin CLK must be 22 or less." - #elif JB_SCREEN_PIN_CS > 22 - #error "Screen pin CS must be 22 or less." - #elif JB_SCREEN_PIN_DC > 22 - #error "Screen pin DC must be 22 or less." - #elif JB_SCREEN_PIN_RST > 22 - #error "Screen pin RST must be 22 or less." - #elif JB_SCREEN_PIN_BL > 22 - #error "Screen pin BL must be 22 or less." - #endif - - #define JB_PORTRAIT 1 - #define JB_LANDSCAPE 2 - #if JB_SCREEN_ORIENTATION != JB_PORTRAIT && JB_SCREEN_ORIENTATION != JB_LANDSCAPE - #error "Screen orientation must be either JB_PORTRAIT or JB_LANDSCAPE" - #endif -#endif - -#ifdef JB_MOD_RGBLEDS - #if JB_RGBLEDS_REFRESH_INTERVAL > 1000 - #error "Screen framebuffer refresh interval must be greater than 1000 ms." - #endif - - #if JB_RGBLEDS_PIN > 22 - #error "RGB LED pin must be 22 or less." - #endif -#endif - -#endif // JUKEBOX_COMMON_H diff --git a/firmware/include/config.h b/firmware/include/config.h deleted file mode 100644 index 94aeedc..0000000 --- a/firmware/include/config.h +++ /dev/null @@ -1,66 +0,0 @@ -// File for controlling various aspects of of the JukeBox firmware. -// If disabled in this file, certain modules will not work without reflashing the firmware. - -#ifndef JUKEBOX_CONFIG_H -#define JUKEBOX_CONFIG_H - -// ----------------------------------------------------------------------------- -// Module Switches -// ----------------------------------------------------------------------------- - -// Screen, for displaying things like PC stats. -#define JB_MOD_SCREEN -// RGB LEDs, for bright fun colors to entertain the children. -#define JB_MOD_RGBLEDS - - -// ----------------------------------------------------------------------------- -// Module Config -// ----------------------------------------------------------------------------- - -// Human Input Device -#define JB_HID_REFRESH_INTERVAL 10 -#define JB_HID_REFRESH_OFFSET 0 - -#define JB_HID_KB_COL 12 -#define JB_HID_KB_COL_NUM 4 -#define JB_HID_KB_ROW 9 -#define JB_HID_KB_ROW_NUM 3 - -// Serial (for screen) -#define JB_SERIAL_REFRESH_INTERVAL 250 -#define JB_SERIAL_REFRESH_OFFSET 0 - -// Screen -// #ifdef JB_MOD_SCREEN - #define JB_SCREEN_REFRESH_INTERVAL 100 - #define JB_SCREEN_REFRESH_OFFSET 0 - - #define JB_SCREEN_PIN_DIN 21 - #define JB_SCREEN_PIN_CLK 20 - #define JB_SCREEN_PIN_CS 19 - #define JB_SCREEN_PIN_DC 18 - #define JB_SCREEN_PIN_RST 17 - #define JB_SCREEN_PIN_BL 16 - - #define JB_SCREEN_CLK_DIV 1.f - - #define JB_SCREEN_RESOLUTION_WIDTH 240 - #define JB_SCREEN_RESOLUTION_HEIGHT 320 - - #define JB_SCREEN_ORIENTATION JB_LANDSCAPE - // #define JB_SCREEN_MIRROR_FLIP -// #endif - -// RGB LEDs -// #ifdef JB_MOD_RGBLEDS - #define JB_RGBLEDS_REFRESH_INTERVAL 100 - #define JB_RGBLEDS_REFRESH_OFFSET 0 - - #define JB_RGBLEDS_PIN 2 - #define JB_RGBLEDS_NUM 12 - #define JB_RGBLEDS_FREQ 800000.f - // #define JB_RGBLEDS_IS_RGBW -// #endif - -#endif // JUKEBOX_CONFIG_H diff --git a/firmware/include/font.h b/firmware/include/font.h deleted file mode 100644 index 4fe8e7d..0000000 --- a/firmware/include/font.h +++ /dev/null @@ -1,273 +0,0 @@ -#include - -#ifndef JUKEBOX_FONT_H -#define JUKEBOX_FONT_H - -// Based on IBM Code Page 437, and the Curses font from Dwarf Fortress - -const uint8_t kern_width = 10; -const uint8_t font_width = 12; -const uint8_t font_height = 12; - -// Binary images; 0 is off, 1 is on. Based on IBM Code Page 437 -// https://dwarffortresswiki.org/index.php/Character_table -uint16_t font[256][12] = { - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x01f8, 0x030c, 0x0204, 0x0294, 0x0204, 0x02f4, 0x0264, 0x030c, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x01f8, 0x03fc, 0x036c, 0x036c, 0x03fc, 0x0204, 0x0204, 0x030c, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0318, 0x07bc, 0x07fc, 0x07fc, 0x03f8, 0x01f0, 0x00e0, 0x0040, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0040, 0x00e0, 0x01f0, 0x03f8, 0x03f8, 0x01f0, 0x00e0, 0x0040, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x00f0, 0x00f0, 0x03fc, 0x079e, 0x079e, 0x036c, 0x0060, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x00f0, 0x01f8, 0x03fc, 0x03fc, 0x0198, 0x0060, 0x0060, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x00f0, 0x01f8, 0x01f8, 0x00f0, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0f0f, 0x0e07, 0x0e07, 0x0f0f, 0x0fff, 0x0fff, 0x0fff, 0x0fff, }, - { 0x0000, 0x0000, 0x00f0, 0x01f8, 0x039c, 0x030c, 0x030c, 0x039c, 0x01f8, 0x00f0, 0x0000, 0x0000, }, - { 0x0fff, 0x0fff, 0x0f0f, 0x0e07, 0x0c63, 0x0cf3, 0x0cf3, 0x0c63, 0x0e07, 0x0f0f, 0x0fff, 0x0fff, }, - { 0x0000, 0x00f8, 0x0038, 0x00e8, 0x01c8, 0x03e0, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0198, 0x0198, 0x00f0, 0x0060, 0x01f8, 0x0060, 0x0060, 0x0000, 0x0000, }, - { 0x0020, 0x0030, 0x0038, 0x002c, 0x002c, 0x002c, 0x0028, 0x01e0, 0x03e0, 0x01c0, 0x0000, 0x0000, }, - { 0x0000, 0x00fe, 0x00fe, 0x0082, 0x00fe, 0x0082, 0x0082, 0x008e, 0x039e, 0x078c, 0x0300, 0x0000, }, - { 0x0000, 0x0000, 0x0060, 0x036c, 0x01f8, 0x039c, 0x039c, 0x01f8, 0x036c, 0x0060, 0x0000, 0x0000, }, - { 0x0000, 0x0400, 0x0700, 0x07c0, 0x07f0, 0x07fc, 0x07f0, 0x07c0, 0x0700, 0x0400, 0x0000, 0x0000, }, - { 0x0000, 0x0004, 0x001c, 0x007c, 0x01fc, 0x07fc, 0x01fc, 0x007c, 0x001c, 0x0004, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x00f0, 0x01f8, 0x0060, 0x0060, 0x0060, 0x01f8, 0x00f0, 0x0060, 0x0000, 0x0000, }, - { 0x0000, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0000, 0x0000, 0x0198, 0x0198, 0x0000, 0x0000, }, - { 0x0000, 0x01fc, 0x036c, 0x036c, 0x036c, 0x01ec, 0x006c, 0x006c, 0x006c, 0x006c, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0188, 0x0180, 0x00f0, 0x0198, 0x0198, 0x00f0, 0x0018, 0x0118, 0x00f0, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0ffc, 0x0ffc, 0x0ffc, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x00f0, 0x01f8, 0x0060, 0x0060, 0x0060, 0x01f8, 0x00f0, 0x0060, 0x01f8, 0x0000, }, - { 0x0000, 0x0060, 0x00f0, 0x01f8, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x01f8, 0x00f0, 0x0060, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0030, 0x0018, 0x03fc, 0x0018, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x00c0, 0x0180, 0x03fc, 0x0180, 0x00c0, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0300, 0x0300, 0x03f8, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0108, 0x030c, 0x07fe, 0x030c, 0x0108, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0040, 0x0040, 0x00e0, 0x00e0, 0x01f0, 0x01f0, 0x03f8, 0x03f8, 0x07fc, 0x07fc, 0x0000, }, - { 0x0000, 0x07fc, 0x07fc, 0x03f8, 0x03f8, 0x01f0, 0x01f0, 0x00e0, 0x00e0, 0x0040, 0x0040, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x00c0, 0x01e0, 0x01e0, 0x01e0, 0x00c0, 0x00c0, 0x0000, 0x00c0, 0x00c0, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0330, 0x0120, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x01b0, 0x01b0, 0x03f8, 0x01b0, 0x01b0, 0x01b0, 0x03f8, 0x01b0, 0x01b0, 0x0000, 0x0000, }, - { 0x0060, 0x0060, 0x00f0, 0x0188, 0x0180, 0x00f0, 0x0018, 0x0118, 0x00f0, 0x0060, 0x0060, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0310, 0x0330, 0x0060, 0x00c0, 0x0180, 0x0330, 0x0230, 0x0000, 0x0000, }, - { 0x0000, 0x01c0, 0x0360, 0x0360, 0x01c0, 0x03e8, 0x0378, 0x0330, 0x0370, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0180, 0x0180, 0x0180, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0030, 0x0060, 0x00c0, 0x0180, 0x0180, 0x0180, 0x00c0, 0x0060, 0x0030, 0x0000, 0x0000, }, - { 0x0000, 0x0180, 0x00c0, 0x0060, 0x0030, 0x0030, 0x0030, 0x0060, 0x00c0, 0x0180, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0198, 0x00f0, 0x03fc, 0x00f0, 0x0198, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0060, 0x0060, 0x01f8, 0x01f8, 0x0060, 0x0060, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0180, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07fc, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0000, 0x0000, }, - { 0x0000, 0x0004, 0x000c, 0x0018, 0x0030, 0x0060, 0x00c0, 0x0180, 0x0300, 0x0200, 0x0000, 0x0000, }, - { 0x0000, 0x01f0, 0x0318, 0x0338, 0x0378, 0x0358, 0x03d8, 0x0398, 0x0318, 0x01f0, 0x0000, 0x0000, }, - { 0x0000, 0x0040, 0x00c0, 0x03c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x03f0, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0330, 0x0030, 0x0060, 0x00c0, 0x0180, 0x0330, 0x03f0, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0030, 0x0030, 0x00e0, 0x0030, 0x0030, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0030, 0x0070, 0x00f0, 0x01b0, 0x0330, 0x03f8, 0x0030, 0x0030, 0x0078, 0x0000, 0x0000, }, - { 0x0000, 0x03f0, 0x0300, 0x0300, 0x0300, 0x03e0, 0x0030, 0x0030, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x00e0, 0x0180, 0x0300, 0x0300, 0x03e0, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x03f8, 0x0318, 0x0318, 0x0018, 0x0030, 0x0060, 0x00c0, 0x00c0, 0x00c0, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0330, 0x03b0, 0x01e0, 0x0370, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x01f0, 0x0060, 0x0060, 0x00c0, 0x01c0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0060, 0x00c0, 0x0000, }, - { 0x0000, 0x0030, 0x0060, 0x00c0, 0x0180, 0x0300, 0x0180, 0x00c0, 0x0060, 0x0030, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01f8, 0x0000, 0x01f8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0180, 0x00c0, 0x0060, 0x0030, 0x0018, 0x0030, 0x0060, 0x00c0, 0x0180, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0030, 0x0060, 0x00c0, 0x00c0, 0x0000, 0x00c0, 0x00c0, 0x0000, 0x0000, }, - { 0x0000, 0x01f0, 0x0318, 0x0318, 0x0378, 0x0378, 0x0378, 0x0300, 0x0300, 0x01f0, 0x0000, 0x0000, }, - { 0x0000, 0x00c0, 0x01e0, 0x0330, 0x0330, 0x0330, 0x03f0, 0x0330, 0x0330, 0x0330, 0x0000, 0x0000, }, - { 0x0000, 0x03f0, 0x0198, 0x0198, 0x0198, 0x01f0, 0x0198, 0x0198, 0x0198, 0x03f0, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0318, 0x0300, 0x0300, 0x0300, 0x0318, 0x0198, 0x00f0, 0x0000, 0x0000, }, - { 0x0000, 0x03e0, 0x01b0, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x01b0, 0x03e0, 0x0000, 0x0000, }, - { 0x0000, 0x03f8, 0x0188, 0x0180, 0x0190, 0x01f0, 0x0190, 0x0180, 0x0188, 0x03f8, 0x0000, 0x0000, }, - { 0x0000, 0x03f8, 0x0198, 0x0188, 0x0190, 0x01f0, 0x0190, 0x0180, 0x0180, 0x03c0, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0318, 0x0300, 0x0300, 0x0338, 0x0318, 0x0198, 0x00f8, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x03f0, 0x0330, 0x0330, 0x0330, 0x0330, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0078, 0x0030, 0x0030, 0x0030, 0x0030, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0398, 0x0198, 0x01b0, 0x01b0, 0x01e0, 0x01b0, 0x01b0, 0x0198, 0x0398, 0x0000, 0x0000, }, - { 0x0000, 0x03c0, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0188, 0x0198, 0x03f8, 0x0000, 0x0000, }, - { 0x0000, 0x071c, 0x03b8, 0x03f8, 0x03f8, 0x0358, 0x0318, 0x0318, 0x0318, 0x071c, 0x0000, 0x0000, }, - { 0x0000, 0x071c, 0x0398, 0x03d8, 0x03d8, 0x0378, 0x0378, 0x0338, 0x0318, 0x071c, 0x0000, 0x0000, }, - { 0x0000, 0x00e0, 0x01b0, 0x0318, 0x0318, 0x0318, 0x0318, 0x0318, 0x01b0, 0x00e0, 0x0000, 0x0000, }, - { 0x0000, 0x03f0, 0x0198, 0x0198, 0x0198, 0x01f0, 0x0180, 0x0180, 0x0180, 0x03c0, 0x0000, 0x0000, }, - { 0x0000, 0x00e0, 0x01b0, 0x0318, 0x0318, 0x0318, 0x0358, 0x0338, 0x0198, 0x00e4, 0x0000, 0x0000, }, - { 0x0000, 0x03f0, 0x0198, 0x0198, 0x0198, 0x01f0, 0x01b0, 0x0198, 0x0198, 0x039c, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0330, 0x0300, 0x01c0, 0x0060, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x03f0, 0x02d0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e8, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0120, 0x01e0, 0x00c0, 0x0000, 0x0000, }, - { 0x0000, 0x0318, 0x0318, 0x0318, 0x0318, 0x0358, 0x0358, 0x01b0, 0x01b0, 0x01b0, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0330, 0x01e0, 0x00c0, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x00c0, 0x00c0, 0x00c0, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x03f8, 0x0318, 0x0230, 0x0060, 0x00e0, 0x00c0, 0x0188, 0x0318, 0x03f8, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00f0, 0x0000, 0x0000, }, - { 0x0000, 0x0200, 0x0300, 0x0180, 0x00c0, 0x0060, 0x0030, 0x0018, 0x000c, 0x0004, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x00f0, 0x0000, 0x0000, }, - { 0x0040, 0x00e0, 0x01b0, 0x0318, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fff, 0x0000, }, - { 0x00c0, 0x00c0, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01e0, 0x0030, 0x01f0, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0380, 0x0180, 0x0180, 0x01f0, 0x0198, 0x0198, 0x0198, 0x0198, 0x0370, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01e0, 0x0330, 0x0300, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0070, 0x0030, 0x0030, 0x01f0, 0x0330, 0x0330, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01e0, 0x0330, 0x03f0, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x00e0, 0x01b0, 0x0180, 0x0180, 0x03e0, 0x0180, 0x0180, 0x0180, 0x03c0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01d8, 0x0330, 0x0330, 0x0330, 0x01f0, 0x0030, 0x0330, 0x01e0, }, - { 0x0000, 0x0380, 0x0180, 0x0180, 0x01b0, 0x01d8, 0x0198, 0x0198, 0x0198, 0x0398, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x0060, 0x0000, 0x01e0, 0x0060, 0x0060, 0x0060, 0x0060, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0030, 0x0030, 0x0000, 0x00f0, 0x0030, 0x0030, 0x0030, 0x0030, 0x0330, 0x0330, 0x01e0, }, - { 0x0000, 0x0380, 0x0180, 0x0180, 0x0198, 0x01b0, 0x01e0, 0x01b0, 0x0198, 0x0398, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x07f0, 0x0358, 0x0358, 0x0358, 0x0358, 0x071c, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x07e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x0738, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0370, 0x0198, 0x0198, 0x0198, 0x0198, 0x01f0, 0x0180, 0x03c0, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01d8, 0x0330, 0x0330, 0x0330, 0x0330, 0x01f0, 0x0030, 0x0078, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x03b0, 0x01b8, 0x01d8, 0x0180, 0x0180, 0x03c0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01e0, 0x0330, 0x0180, 0x0060, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0080, 0x0180, 0x03f0, 0x0180, 0x0180, 0x0180, 0x01b0, 0x00e0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0330, 0x0330, 0x0330, 0x0120, 0x01e0, 0x00c0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0318, 0x0318, 0x0358, 0x0358, 0x01b0, 0x01b0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0318, 0x01b0, 0x00e0, 0x00e0, 0x01b0, 0x0318, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0060, 0x0260, 0x01c0, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x03f0, 0x0230, 0x0060, 0x0180, 0x0310, 0x03f0, 0x0000, 0x0000, }, - { 0x0000, 0x0070, 0x00c0, 0x00c0, 0x0180, 0x0380, 0x0180, 0x00c0, 0x00c0, 0x0070, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0000, }, - { 0x0000, 0x0380, 0x00c0, 0x00c0, 0x0060, 0x0070, 0x0060, 0x00c0, 0x00c0, 0x0380, 0x0000, 0x0000, }, - { 0x0000, 0x01cc, 0x036c, 0x0338, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0040, 0x00e0, 0x01f0, 0x03b8, 0x0318, 0x0318, 0x03f8, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0198, 0x0180, 0x0180, 0x0180, 0x0198, 0x0198, 0x00f0, 0x0060, 0x01e0, }, - { 0x0000, 0x0330, 0x0330, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0030, 0x0060, 0x00c0, 0x0000, 0x01e0, 0x0330, 0x03f0, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x00c0, 0x01e0, 0x0330, 0x0000, 0x01e0, 0x0030, 0x01f0, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0000, 0x01e0, 0x0030, 0x01f0, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0300, 0x0180, 0x00c0, 0x0000, 0x01e0, 0x0030, 0x01f0, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x00e0, 0x01b0, 0x01b0, 0x00e0, 0x03e0, 0x0030, 0x01f0, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x01e0, 0x0330, 0x0300, 0x0300, 0x0330, 0x01e0, 0x00c0, 0x03c0, }, - { 0x00c0, 0x01e0, 0x0330, 0x0000, 0x01e0, 0x0330, 0x03f0, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0000, 0x01e0, 0x0330, 0x03f0, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0300, 0x0180, 0x00c0, 0x0000, 0x01e0, 0x0330, 0x03f0, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0360, 0x0360, 0x0000, 0x03c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x03f0, 0x0000, 0x0000, }, - { 0x0080, 0x01c0, 0x0360, 0x0000, 0x03c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x03f0, 0x0000, 0x0000, }, - { 0x0300, 0x0180, 0x00c0, 0x0000, 0x03c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x03f0, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0000, 0x00c0, 0x01e0, 0x0330, 0x0330, 0x03f0, 0x0330, 0x0330, 0x0000, 0x0000, }, - { 0x01e0, 0x0330, 0x0330, 0x01e0, 0x01e0, 0x0330, 0x0330, 0x03f0, 0x0330, 0x0330, 0x0000, 0x0000, }, - { 0x0030, 0x0060, 0x00c0, 0x03f0, 0x0310, 0x0300, 0x03e0, 0x0300, 0x0310, 0x03f0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x03b8, 0x006c, 0x01fc, 0x0360, 0x0364, 0x01b8, 0x0000, 0x0000, }, - { 0x0000, 0x00f8, 0x01e0, 0x0360, 0x0360, 0x03f8, 0x0360, 0x0360, 0x0360, 0x0378, 0x0000, 0x0000, }, - { 0x00c0, 0x01e0, 0x0330, 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0300, 0x0180, 0x00c0, 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x00c0, 0x01e0, 0x0330, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0300, 0x0180, 0x00c0, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x0330, 0x0330, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0060, 0x0260, 0x01c0, }, - { 0x0330, 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0330, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e8, 0x0000, 0x0000, }, - { 0x0000, 0x0060, 0x0060, 0x00f0, 0x0198, 0x0300, 0x0300, 0x0198, 0x00f0, 0x0060, 0x0060, 0x0000, }, - { 0x00f0, 0x0198, 0x0180, 0x0180, 0x0180, 0x03f0, 0x0180, 0x0180, 0x0300, 0x03f8, 0x0000, 0x0000, }, - { 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x03f0, 0x00c0, 0x03f0, 0x00c0, 0x00c0, 0x0000, 0x0000, }, - { 0x03c0, 0x0220, 0x0220, 0x0220, 0x03c0, 0x0220, 0x0278, 0x0230, 0x0234, 0x0218, 0x0000, 0x0000, }, - { 0x0038, 0x006c, 0x0060, 0x0060, 0x01f8, 0x0060, 0x0060, 0x0060, 0x0360, 0x01c0, 0x0000, 0x0000, }, - { 0x0030, 0x0060, 0x00c0, 0x0000, 0x01e0, 0x0030, 0x01f0, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0060, 0x00c0, 0x0180, 0x0000, 0x03c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x03f0, 0x0000, 0x0000, }, - { 0x0030, 0x0060, 0x00c0, 0x0000, 0x01e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0030, 0x0060, 0x00c0, 0x0000, 0x0330, 0x0330, 0x0330, 0x0330, 0x0330, 0x01d8, 0x0000, 0x0000, }, - { 0x0000, 0x01d8, 0x0370, 0x0000, 0x07e0, 0x0330, 0x0330, 0x0330, 0x0330, 0x0738, 0x0000, 0x0000, }, - { 0x01d8, 0x0370, 0x0000, 0x0318, 0x0398, 0x03d8, 0x0358, 0x0378, 0x0338, 0x0318, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0330, 0x01f8, 0x0000, 0x03f8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0330, 0x0330, 0x01e0, 0x0000, 0x03f8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x00c0, 0x00c0, 0x0000, 0x00c0, 0x0180, 0x0300, 0x0300, 0x0330, 0x01e0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x03fc, 0x0300, 0x0300, 0x0300, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x03fc, 0x000c, 0x000c, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x030c, 0x0718, 0x0330, 0x0360, 0x00c0, 0x019c, 0x0326, 0x020c, 0x0018, 0x003e, 0x0000, }, - { 0x0000, 0x030c, 0x0718, 0x0330, 0x0360, 0x00c0, 0x019c, 0x032c, 0x024c, 0x007c, 0x000c, 0x0000, }, - { 0x0000, 0x0060, 0x0060, 0x0000, 0x0060, 0x0060, 0x00f0, 0x00f0, 0x00f0, 0x0060, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x00cc, 0x0198, 0x0330, 0x0330, 0x0198, 0x00cc, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0330, 0x0198, 0x00cc, 0x00cc, 0x0198, 0x0330, 0x0000, 0x0000, }, - { 0x0924, 0x0492, 0x0249, 0x0924, 0x0492, 0x0249, 0x0924, 0x0492, 0x0249, 0x0924, 0x0492, 0x0249, }, - { 0x0555, 0x0aaa, 0x0555, 0x0aaa, 0x0555, 0x0aaa, 0x0555, 0x0aaa, 0x0555, 0x0aaa, 0x0555, 0x0aaa, }, - { 0x06db, 0x0db6, 0x0b6d, 0x06db, 0x0db6, 0x0b6d, 0x06db, 0x0db6, 0x0b6d, 0x06db, 0x0db6, 0x0b6d, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0060, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0f98, 0x0f98, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0ff8, 0x0ff8, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0000, 0x0000, 0x0000, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0060, }, - { 0x0198, 0x0198, 0x0198, 0x0f98, 0x0f98, 0x0018, 0x0018, 0x0f98, 0x0f98, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0000, 0x0000, 0x0000, 0x0ff8, 0x0ff8, 0x0018, 0x0018, 0x0f98, 0x0f98, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x0f98, 0x0f98, 0x0018, 0x0018, 0x0ff8, 0x0ff8, 0x0000, 0x0000, 0x0000, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0ff8, 0x0ff8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0060, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fe0, 0x0fe0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x007f, 0x007f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x007f, 0x007f, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0fff, 0x0fff, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x007f, 0x007f, 0x0060, 0x0060, 0x007f, 0x007f, 0x0060, 0x0060, 0x0060, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x019f, 0x019f, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x019f, 0x019f, 0x0180, 0x0180, 0x01ff, 0x01ff, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x01ff, 0x01ff, 0x0180, 0x0180, 0x019f, 0x019f, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x0f9f, 0x0f9f, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0f9f, 0x0f9f, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x019f, 0x019f, 0x0180, 0x0180, 0x019f, 0x019f, 0x0198, 0x0198, 0x0198, }, - { 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, }, - { 0x0198, 0x0198, 0x0198, 0x0f9f, 0x0f9f, 0x0000, 0x0000, 0x0f9f, 0x0f9f, 0x0198, 0x0198, 0x0198, }, - { 0x0060, 0x0060, 0x0060, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0060, 0x0060, 0x0060, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0060, 0x0060, 0x0060, 0x007f, 0x007f, 0x0060, 0x0060, 0x007f, 0x007f, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x007f, 0x007f, 0x0060, 0x0060, 0x007f, 0x007f, 0x0060, 0x0060, 0x0060, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01ff, 0x01ff, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0f9f, 0x0f9f, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, }, - { 0x0060, 0x0060, 0x0060, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0fe0, 0x0fe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x007f, 0x007f, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, }, - { 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, 0x0fc0, }, - { 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, }, - { 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x01d8, 0x0378, 0x0330, 0x0330, 0x0378, 0x01d8, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0198, 0x01b0, 0x0198, 0x0198, 0x0198, 0x01f0, 0x0180, 0x00c0, 0x0000, }, - { 0x0000, 0x01f8, 0x0198, 0x0198, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, 0x0000, }, - { 0x0000, 0x03fc, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x018c, 0x0000, 0x0000, }, - { 0x0000, 0x03fc, 0x018c, 0x00c4, 0x00c0, 0x0060, 0x00c0, 0x00c4, 0x018c, 0x03fc, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x00fc, 0x0190, 0x0198, 0x0198, 0x0198, 0x00f0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x01ec, 0x0180, 0x0300, }, - { 0x0000, 0x0000, 0x0000, 0x01d8, 0x0370, 0x0060, 0x0060, 0x0060, 0x0060, 0x0038, 0x0000, 0x0000, }, - { 0x0000, 0x01f8, 0x0060, 0x00f0, 0x0198, 0x0198, 0x0198, 0x00f0, 0x0060, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0198, 0x0198, 0x01f8, 0x0198, 0x0198, 0x0198, 0x00f0, 0x0000, 0x0000, }, - { 0x0000, 0x01f0, 0x0318, 0x0318, 0x0318, 0x0318, 0x01b0, 0x01b0, 0x01b0, 0x03b8, 0x0000, 0x0000, }, - { 0x0000, 0x0078, 0x00c0, 0x0060, 0x00f0, 0x0198, 0x0198, 0x0198, 0x0198, 0x00f0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x01d8, 0x036c, 0x036c, 0x036c, 0x01b8, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0018, 0x01f0, 0x0378, 0x0358, 0x03d8, 0x01f0, 0x0300, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0078, 0x00c0, 0x0180, 0x0180, 0x01f8, 0x0180, 0x0180, 0x00c0, 0x0078, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x00f0, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0198, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x07fc, 0x0000, 0x0000, 0x07fc, 0x0000, 0x0000, 0x07fc, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0060, 0x0060, 0x01f8, 0x01f8, 0x0060, 0x0060, 0x0000, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x00c0, 0x0060, 0x0030, 0x0030, 0x0060, 0x00c0, 0x0000, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0030, 0x0060, 0x00c0, 0x00c0, 0x0060, 0x0030, 0x0000, 0x01f8, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0038, 0x006c, 0x006c, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, }, - { 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0360, 0x0360, 0x01c0, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0060, 0x0060, 0x0000, 0x03fc, 0x03fc, 0x0000, 0x0060, 0x0060, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x01cc, 0x036c, 0x0338, 0x0000, 0x01cc, 0x036c, 0x0338, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x00f0, 0x0198, 0x0198, 0x0198, 0x00f0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x00e0, 0x00e0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x007f, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0440, 0x0240, 0x0140, 0x00c0, 0x0040, 0x0000, }, - { 0x0000, 0x01b0, 0x00d8, 0x00d8, 0x00d8, 0x00d8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x01e0, 0x0030, 0x0060, 0x00c0, 0x01f0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x03fc, 0x03fc, 0x03fc, 0x03fc, 0x03fc, 0x03fc, 0x03fc, 0x03fc, 0x0000, 0x0000, }, - { 0x0000, 0x0000, 0x03fc, 0x03fc, 0x030c, 0x030c, 0x030c, 0x030c, 0x03fc, 0x03fc, 0x0000, 0x0000, }, -}; - -#endif // JUKEBOX_FONT_H diff --git a/firmware/include/keyboard.h b/firmware/include/keyboard.h deleted file mode 100644 index b2f76e8..0000000 --- a/firmware/include/keyboard.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "common.h" - -#include - -#ifndef JUKEBOX_KEYBOARD_H -#define JUKEBOX_KEYBOARD_H - -void keyboard_init(void); -void keyboard_send_hid_report(uint8_t); -void keyboard_task(void); - -#endif // JUKEBOX_KEYBOARD_H diff --git a/firmware/include/lcd.h b/firmware/include/lcd.h deleted file mode 100644 index fcc8689..0000000 --- a/firmware/include/lcd.h +++ /dev/null @@ -1,32 +0,0 @@ -#include "common.h" - -#ifndef JUKEBOX_LCD_H -#define JUKEBOX_LCD_H - -// Screen states, for what to display, when to display it, and how! -typedef enum -{ - Unknown, - WaitingConnection, - ShowStats, -} ScreenState; - -void lcd_init(void); - -void lcd_set_color(uint8_t r, uint8_t g, uint8_t b); - -void lcd_on(void); -void lcd_off(void); -void lcd_clear(void); -void lcd_present(void); - -void lcd_put(uint16_t x, uint16_t y); - -void lcd_rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h); - -void lcd_print(char * text, uint16_t x, uint16_t y, uint8_t s); -void lcd_print_raw(char * text, uint16_t x, uint16_t y, uint8_t s); - -void lcd_task(void); - -#endif // JUKEBOX_LCD_H diff --git a/firmware/include/led.h b/firmware/include/led.h deleted file mode 100644 index 09815dd..0000000 --- a/firmware/include/led.h +++ /dev/null @@ -1,13 +0,0 @@ -#include - -#ifndef JUKEBOX_LED_H -#define JUKEBOX_LED_H - -void led_init(void); -void led_blinking_task(void); - -void led_set_mounted(void); -void led_set_unmounted(void); -void led_set_suspended(void); - -#endif // JUKEBOX_LED_H diff --git a/firmware/include/rgb.h b/firmware/include/rgb.h deleted file mode 100644 index e7b6eec..0000000 --- a/firmware/include/rgb.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "common.h" -#include - -#ifndef JUKEBOX_WS2812_RGB_H -#define JUKEBOX_WS2812_RGB_H - -void rgb_init(void); - -uint32_t rgb_to_grbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w); -uint32_t hsv_to_grbw(uint16_t hue, uint8_t sat, uint8_t val); - -void rgb_put(uint8_t idx, uint32_t pixel_grb); -void rgb_clear(void); -void rgb_present(void); -void rgb_task(void); - -#endif // JUKEBOX_WS2812_RGB_H diff --git a/firmware/include/serial.h b/firmware/include/serial.h deleted file mode 100644 index 504e112..0000000 --- a/firmware/include/serial.h +++ /dev/null @@ -1,40 +0,0 @@ -#include "common.h" -#include - -#include "lcd.h" - -#ifndef JUKEBOX_SERIAL_H -#define JUKEBOX_SERIAL_H - -void serial_init(void); -void serial_task(void); - -typedef enum -{ - ErrorWait, - GreetHost, - GreetDevice, - LinkConfirmHost, - LinkConfirmDevice, - TransmitReady, -} SerialStage; - -extern char inputString[128]; -extern uint16_t inputStringLen; -extern uint8_t inputStringReady; - -extern char cpuName[48]; -extern char gpuName[48]; -extern char ramCount[10]; - -extern char cpuFreq[8]; -extern char cpuTemp[8]; -extern char cpuLoad[8]; -extern char ramUsed[8]; -extern char gpuTemp[8]; -extern char gpuCoreClock[10]; -extern char gpuCoreLoad[8]; -extern char gpuVramClock[10]; -extern char gpuVramLoad[8]; - -#endif // JUKEBOX_SERIAL_H diff --git a/firmware/include/st7789_lcd.h b/firmware/include/st7789_lcd.h deleted file mode 100644 index f615ecb..0000000 --- a/firmware/include/st7789_lcd.h +++ /dev/null @@ -1,21 +0,0 @@ -#include "common.h" -#include - -#ifndef JUKEBOX_ST7789_LCD_H -#define JUKEBOX_ST7789_LCD_H - -void lcd_set_dc_cs(bool dc, bool cs); -void lcd_write_cmd(PIO pio, uint sm, const uint8_t *cmd, size_t count); -void st7789_lcd_init(void); -void st7789_start_pixels(PIO pio, uint sm); -void st7789_fb_clear(void); -void st7789_fb_put(uint16_t color, uint16_t x, uint16_t y); -void st7789_lcd_push_fb(void); - -uint16_t st7789_get_width(void); -uint16_t st7789_get_height(void); - -void st7789_bl_on(void); -void st7789_bl_off(void); - -#endif // JUKEBOX_ST7789_LCD_H diff --git a/firmware/include/tusb_config.h b/firmware/include/tusb_config.h deleted file mode 100644 index 59d9472..0000000 --- a/firmware/include/tusb_config.h +++ /dev/null @@ -1,121 +0,0 @@ -// From: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_hid_composite/tusb_config.h - -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef _TUSB_CONFIG_H_ -#define _TUSB_CONFIG_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -//-------------------------------------------------------------------- -// COMMON CONFIGURATION -//-------------------------------------------------------------------- - -// defined by board.mk -#ifndef CFG_TUSB_MCU - // #error CFG_TUSB_MCU must be defined - #define OPT_MCU_RP2040 -#endif - -// RHPort number used for device can be defined by board.mk, default to port 0 -#ifndef BOARD_DEVICE_RHPORT_NUM - #define BOARD_DEVICE_RHPORT_NUM 0 -#endif - -// RHPort max operational speed can defined by board.mk -// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed -#ifndef BOARD_DEVICE_RHPORT_SPEED - #if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \ - CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56 || CFG_TUSB_MCU == OPT_MCU_SAMX7X) - #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED - #else - #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED - #endif -#endif - -// Device mode with rhport and speed defined by board.mk -#if BOARD_DEVICE_RHPORT_NUM == 0 - #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED) -#elif BOARD_DEVICE_RHPORT_NUM == 1 - #define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED) -#else - #error "Incorrect RHPort configuration" -#endif - -#ifndef CFG_TUSB_OS -#define CFG_TUSB_OS OPT_OS_PICO -#endif - -// CFG_TUSB_DEBUG is defined by compiler in DEBUG build -// #define CFG_TUSB_DEBUG 0 - -/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. - * Tinyusb use follows macros to declare transferring memory so that they can be put - * into those specific section. - * e.g - * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) - * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) - */ -#ifndef CFG_TUSB_MEM_SECTION -#define CFG_TUSB_MEM_SECTION -#endif - -#ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) -#endif - -//-------------------------------------------------------------------- -// DEVICE CONFIGURATION -//-------------------------------------------------------------------- - -#ifndef CFG_TUD_ENDPOINT0_SIZE -#define CFG_TUD_ENDPOINT0_SIZE 64 -#endif - -//------------- CLASS -------------// -#define CFG_TUD_HID 1 -#define CFG_TUD_CDC 1 -#define CFG_TUD_MSC 0 -#define CFG_TUD_MIDI 0 -#define CFG_TUD_VENDOR 0 - -// HID buffer size Should be sufficient to hold ID (if any) + Data -#define CFG_TUD_HID_EP_BUFSIZE 16 - -// CDC FIFO size of TX and RX -#define CFG_TUD_CDC_RX_BUFSIZE 64 -#define CFG_TUD_CDC_TX_BUFSIZE 64 - -// CDC Endpoint transfer buffer size, more is faster -#define CFG_TUD_CDC_EP_BUFSIZE 64 - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_CONFIG_H_ */ diff --git a/firmware-rs/memory.x b/firmware/memory.x similarity index 100% rename from firmware-rs/memory.x rename to firmware/memory.x diff --git a/firmware/misc/JukeBoxFont.png b/firmware/misc/JukeBoxFont.png deleted file mode 100644 index 870c16e..0000000 Binary files a/firmware/misc/JukeBoxFont.png and /dev/null differ diff --git a/firmware/misc/mkfont.py b/firmware/misc/mkfont.py deleted file mode 100644 index 945943e..0000000 --- a/firmware/misc/mkfont.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# This very primitive script takes an image input and produces a C header file. -# We make some pretty bold assumptions, like the font is 12x12, has 256 glyphs, image is 192x192, etc. -# In the future, this should be fixed, and font info standardized. - -import sys - -from PIL import Image - -atlas_width = 16 -atlas_height = 16 -glyph_width = 12 -glyph_height = 12 - -for infile in sys.argv[1:]: - try: - with Image.open(infile) as im: - #print(im.size) - - if not (im.size[0] == glyph_width * atlas_width and im.size[1] == glyph_height * atlas_height): - print(f"Image Error! Font image must be {glyph_width * atlas_height} x {glyph_height * atlas_height}!") - continue - - im = im.convert("1") - - atlas = [] - for ay in range(atlas_height): - for ax in range(atlas_width): - glyph = [] - for row in range(glyph_height): - prow = 0 - for col in range(glyph_width): - p = im.getpixel((col + ax * 12, row + ay * 12)) - if p > 0: - prow |= 1<<(glyph_width-1-col) - #print(f"{prow:0{glyph_width}b}") - glyph.append(prow) - #print() - atlas.append(glyph) - #print(atlas) - - header = "" - header += "#include \n" - header += "\n" - header += "#ifndef JUKEBOX_FONT_H\n" - header += "#define JUKEBOX_FONT_H\n" - header += "\n" - header += f"const uint8_t glyph_width = {glyph_width};\n" - header += f"const uint8_t glyph_height = {glyph_height};\n" - header += "\n" - header += f"const uint16_t font[256][{glyph_height}] = " + "{\n" - for glyph in atlas: - header += "\t{ " - for row in glyph: - header += f"0x{row:04x}, " - header += "}, \n" - header += "};\n" - header += "\n" - header += "#endif // JUKEBOX_FONT_H\n" - - print(header) - - pass # TODO: iterate over image and process bits - except OSError as e: - print("OS Error!", e, infile) diff --git a/firmware/pico-sdk b/firmware/pico-sdk deleted file mode 160000 index 6a7db34..0000000 --- a/firmware/pico-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a7db34ff63345a7badec79ebea3aaef1712f374 diff --git a/firmware/src/callbacks.c b/firmware/src/callbacks.c deleted file mode 100644 index 2f9c12f..0000000 --- a/firmware/src/callbacks.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "common.h" - -#include - -#include "led.h" - -//--------------------------------------------------------------------+ -// Device callbacks -//--------------------------------------------------------------------+ - -// Invoked when device is mounted -void tud_mount_cb(void) { - led_set_mounted(); -} - -// Invoked when device is unmounted -void tud_umount_cb(void) { - led_set_unmounted(); -} - -// Invoked when usb bus is suspended -// remote_wakeup_en : if the host allowed us to perform remote wakeup -// Within 7ms, device must draw an average of current less than 2.5 mA from bus -void tud_suspend_cb(bool remote_wakeup_en) { - (void) remote_wakeup_en; - led_set_suspended(); -} - -// Invoked when usb bus is resumed -void tud_resume_cb(void) { - led_set_mounted(); -} - - -//--------------------------------------------------------------------+ -// USB HID callbacks -//--------------------------------------------------------------------+ - -// Invoked when sent REPORT successfully to host -// Application can use this to send the next report -// Note: For composite reports, report[0] is report ID -void tud_hid_report_complete_cb( - uint8_t instance, - uint8_t const* report, - uint16_t len -) { - (void) instance; - (void) len; - - // uint8_t next_report_id = report[0] + 1; - - // if (next_report_id < REPORT_ID_COUNT) { - // keyboard_send_hid_report(next_report_id); - // } -} - -// Invoked when received GET_REPORT control request -// Application must fill buffer report's content and return its length. -// Return zero will cause the stack to STALL request -uint16_t tud_hid_get_report_cb( - uint8_t instance, - uint8_t report_id, - hid_report_type_t report_type, - uint8_t* buffer, - uint16_t reqlen -) { - (void) instance; - (void) report_id; - (void) report_type; - (void) buffer; - (void) reqlen; - - return 0; -} - -// Invoked when received SET_REPORT control request or -// received data on OUT endpoint ( Report ID = 0, Type = 0 ) -void tud_hid_set_report_cb( - uint8_t instance, - uint8_t report_id, - hid_report_type_t report_type, - uint8_t const* buffer, - uint16_t bufsize -) { - (void) instance; - - // if (report_type == HID_REPORT_TYPE_OUTPUT) { - // // Set keyboard LED e.g Capslock, Numlock etc... - // if (report_id == REPORT_ID_KEYBOARD) { - // // bufsize should be (at least) 1 - // if ( bufsize < 1 ) return; - - // uint8_t const kbd_leds = buffer[0]; - - // if (kbd_leds & KEYBOARD_LED_CAPSLOCK) { - // // Capslock On: disable blink, turn led on - // blink_interval_ms = 0; - // board_led_write(true); - // } else { - // // Caplocks Off: back to normal blink - // board_led_write(false); - // blink_interval_ms = BLINK_MOUNTED; - // } - // } - // } -} diff --git a/firmware/src/keyboard.c b/firmware/src/keyboard.c deleted file mode 100644 index fe452ca..0000000 --- a/firmware/src/keyboard.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "keyboard.h" - -enum -{ - REPORT_ID_KEYBOARD = 1, - REPORT_ID_COUNT -}; - -#define _NOP() do { __asm__ __volatile__ ("nop"); } while (0) -#define _NOPS(n) do { for(uint8_t _NOP_LOOP_I=0; _NOP_LOOP_I= 6) { - continue; - } - - if (gpio_get(COL + col)) { - keycodes[usedKeys++] = keys[k]; - } - - k++; - } - gpio_put(ROW + row, 0); - } - - if (tud_suspended() && usedKeys > 0) { - tud_remote_wakeup(); - } else if (usedKeys > 0) { - tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, keycodes); - pressedKey = true; - } else { - if (pressedKey) { - tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, NULL); - } - pressedKey = false; - } -} - -void keyboard_task(void) { - REFRESH_CHECK(JB_HID_REFRESH_INTERVAL, JB_HID_REFRESH_OFFSET); - - keyboard_send_hid_report(REPORT_ID_KEYBOARD); -} diff --git a/firmware/src/lcd.c b/firmware/src/lcd.c deleted file mode 100644 index 6c37f90..0000000 --- a/firmware/src/lcd.c +++ /dev/null @@ -1,205 +0,0 @@ -#include "lcd.h" - -#include -#include - -// #include -#include - -#include "font.h" -#include "st7789_lcd.h" -#include "serial.h" - - -ScreenState screenstate, previousstate; -extern uint32_t countermax; -extern SerialStage commstage; -extern int commstagepart; - - -inline uint16_t lcd_rgb565(uint8_t r, uint8_t g, uint8_t b) { - // https://stackoverflow.com/a/76442697/13977827 - return ((r>>3) << 11) | ((g>>2) << 5) | b >> 3; -} - -uint16_t lcd_color_full = 65535; - -inline void lcd_set_color(uint8_t r, uint8_t g, uint8_t b) { - lcd_color_full = lcd_rgb565(r, g, b); -} - -inline void lcd_on(void) { - st7789_bl_on(); -} - -inline void lcd_off(void) { - st7789_bl_off(); -} - -inline void lcd_clear(void) { - st7789_fb_clear(); -} - -inline void lcd_present(void) { - st7789_lcd_push_fb(); -} - -inline void lcd_put(uint16_t x, uint16_t y) { - st7789_fb_put(lcd_color_full, x, y); -} - -inline void lcd_rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { - for (uint16_t rh=0; rh -#include - -#include "keyboard.h" -#include "lcd.h" -#include "led.h" -#include "rgb.h" -#include "serial.h" - - -volatile uint8_t bootsel_reset_jukebox = 0; -volatile uint8_t core1_finish_jukebox = 0; - - -void task_updates(void) { - while (!bootsel_reset_jukebox) { - serial_task(); - if (bootsel_reset_jukebox) { - break; - } - - #ifdef JB_MOD_SCREEN - lcd_task(); - #endif - - #ifdef JB_MOD_RGBLEDS - rgb_task(); - #endif - } - - core1_finish_jukebox = 1; -} - - -int main(void) { - led_init(); - keyboard_init(); - - serial_init(); - - #ifdef JB_MOD_SCREEN - lcd_init(); - #endif - #ifdef JB_MOD_RGBLEDS - rgb_init(); - #endif - - tusb_init(); - bool started_tasks = false; - - while (true) { - tud_task(); - - if (tud_mounted()) { - if (!started_tasks) { - started_tasks = true; - multicore_launch_core1(task_updates); - } - keyboard_task(); - } - - if (bootsel_reset_jukebox) { - // TODO: set activity led? wait for second core to finish? - while (!core1_finish_jukebox) { /* wait until the second core exits */ } - lcd_off(); - lcd_clear(); - lcd_present(); - rgb_clear(); - rgb_present(); - reset_usb_boot(0, 0); - } - - led_blinking_task(); - } - - return 0; -} diff --git a/firmware-rs/src/main.rs b/firmware/src/main.rs similarity index 100% rename from firmware-rs/src/main.rs rename to firmware/src/main.rs diff --git a/firmware-rs/src/modules/keyboard.rs b/firmware/src/modules/keyboard.rs similarity index 100% rename from firmware-rs/src/modules/keyboard.rs rename to firmware/src/modules/keyboard.rs diff --git a/firmware-rs/src/modules/led.rs b/firmware/src/modules/led.rs similarity index 100% rename from firmware-rs/src/modules/led.rs rename to firmware/src/modules/led.rs diff --git a/firmware-rs/src/modules/rgb.rs b/firmware/src/modules/rgb.rs similarity index 100% rename from firmware-rs/src/modules/rgb.rs rename to firmware/src/modules/rgb.rs diff --git a/firmware-rs/src/modules/screen.rs b/firmware/src/modules/screen.rs similarity index 100% rename from firmware-rs/src/modules/screen.rs rename to firmware/src/modules/screen.rs diff --git a/firmware-rs/src/modules/serial.rs b/firmware/src/modules/serial.rs similarity index 100% rename from firmware-rs/src/modules/serial.rs rename to firmware/src/modules/serial.rs diff --git a/firmware-rs/src/mutex.rs b/firmware/src/mutex.rs similarity index 100% rename from firmware-rs/src/mutex.rs rename to firmware/src/mutex.rs diff --git a/firmware-rs/src/peripheral.rs b/firmware/src/peripheral.rs similarity index 100% rename from firmware-rs/src/peripheral.rs rename to firmware/src/peripheral.rs diff --git a/firmware-rs/src/pins.rs b/firmware/src/pins.rs similarity index 100% rename from firmware-rs/src/pins.rs rename to firmware/src/pins.rs diff --git a/firmware/src/rgb.c b/firmware/src/rgb.c deleted file mode 100644 index 8f2fd3a..0000000 --- a/firmware/src/rgb.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "rgb.h" - -#include - -#include "ws2812_rgb.pio.h" - -#ifdef JB_RGBLEDS_IS_RGBW - const bool is_rgbw = true; -#else - const bool is_rgbw = false; -#endif - -PIO rgb_pio = pio1; -int rgb_sm = 1; -uint rgb_offset = 0; - -uint32_t pixel_buf[JB_RGBLEDS_NUM] = {0}; - -void rgb_init(void) { - rgb_offset = pio_add_program(rgb_pio, &ws2812_program); - ws2812_program_init(rgb_pio, rgb_sm, rgb_offset, JB_RGBLEDS_PIN, JB_RGBLEDS_FREQ, is_rgbw); -} - -uint32_t rgb_to_grbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return ((uint32_t) (r) << 16) | ((uint32_t) (g) << 24) | ((uint32_t) (b) << 8)| ((uint32_t) (w)); -} - -uint32_t hsv_to_grbw(uint16_t hue, uint8_t sat, uint8_t val) { - uint8_t r, g, b; - hue = (hue * 1530L + 32768) / 65536; - if (hue < 510) { - b = 0; - if (hue < 255) { - r = 255; - g = hue; - } else { - r = 510 - hue; - g = 255; - } - } else if (hue < 1020) { - r = 0; - if (hue < 765) { - g = 255; - b = hue - 510; - } else { - g = 1020 - hue; - b = 255; - } - } else if (hue < 1530) { - g = 0; - if (hue < 1275) { - r = hue - 1020; - b = 255; - } else { - r = 255; - b = 1530 - hue; - } - } else { - r = 255; - g = b = 0; - } - - uint32_t v1 = 1 + val; - uint16_t s1 = 1 + sat; - uint8_t s2 = 255 - sat; - - return rgb_to_grbw( - ((((r * s1) >> 8) + s2) * v1) >> 8, - ((((g * s1) >> 8) + s2) * v1) >> 8, - ((((b * s1) >> 8) + s2) * v1) >> 8, - 0 - ); -} - -void rgb_put(uint8_t idx, uint32_t pixel_grbw) { - if (idx >= JB_RGBLEDS_NUM) { - return; - } - pixel_buf[idx] = pixel_grbw; -} - -void rgb_clear(void) { - for (uint8_t i = 0; i < JB_RGBLEDS_NUM; i++) { - rgb_put(i, 0); - } -} - -void rgb_present(void) { - for (uint8_t i = 0; i < JB_RGBLEDS_NUM; i++) { - pio_sm_put_blocking(rgb_pio, rgb_sm, pixel_buf[i]); - } -} - -void rgb_task(void) { - REFRESH_CHECK(JB_RGBLEDS_REFRESH_INTERVAL, JB_RGBLEDS_REFRESH_OFFSET); - - if (tud_suspended()) { - rgb_clear(); - rgb_present(); - return; - } - - rgb_clear(); - - for (uint8_t i = 0; i < JB_RGBLEDS_NUM; i++) { - rgb_put(i, hsv_to_grbw((time_us_32()>>8) - 512*i, 255, 25)); - } - - rgb_present(); -} diff --git a/firmware/src/serial.c b/firmware/src/serial.c deleted file mode 100644 index 206089a..0000000 --- a/firmware/src/serial.c +++ /dev/null @@ -1,325 +0,0 @@ -#include "serial.h" - -#include - -#include -#include - -extern volatile uint8_t bootsel_reset_jukebox; - -extern ScreenState screenstate; -SerialStage commstage = GreetHost; - -// The parts of comm stages (stage recieve and response) -int commstagepart = 0; - -// The data string we use to store received data -char inputString[128] = ""; -uint16_t inputStringLen = 0; -uint8_t inputStringReady = 0; - -// Data we store! -// Data that we receive only at the time a connection is made. -char cpuName[48] = ""; -char gpuName[48] = ""; -char ramCount[10] = ""; -// Data we constantly receive after a connection is made. -char cpuFreq[8] = ""; -char cpuTemp[8] = ""; -char cpuLoad[8] = ""; -char ramUsed[8] = ""; -char gpuTemp[8] = ""; -char gpuCoreClock[10] = ""; -char gpuCoreLoad[8] = ""; -char gpuVramClock[10] = ""; -char gpuVramLoad[8] = ""; - -uint32_t countermax = 0; - -#define clear_string(s) \ - for (uint8_t i=0; i= heartbeat_ms) { - reset_state_data(); - return; - } - } else if (commstage == GreetHost) { - if (inputStringReady && strncmp(inputString, "JB\x05", 3) == 0) { - commstage = GreetDevice; - } - reset_input_string(); - } else if (commstage == GreetDevice) { - tud_cdc_write("P001\r\n", 6); - tud_cdc_write_flush(); - commstage = LinkConfirmHost; - heartbeat_ms = time_us_64() + offset_heartbeat; - } else if (commstage == LinkConfirmHost) { - if (inputStringReady) { - if (strncmp(inputString, "P\x06", 2) == 0) { - commstage = LinkConfirmDevice; - } else if (strncmp(inputString, "P\x15", 2) == 0) { // OR WE TIME OUT - commstage = ErrorWait; - heartbeat_ms = time_us_64() + offset_heartbeat; - } - reset_input_string(); - } - if (time_us_64() >= heartbeat_ms) { - reset_input_string(); - commstage = ErrorWait; - heartbeat_ms = time_us_64() + offset_heartbeat; - } - } else if (commstage == LinkConfirmDevice) { - tud_cdc_write("L\x06\r\n", 4); - tud_cdc_write_flush(); - commstage = TransmitReady; - heartbeat_ms = time_us_64() + offset_heartbeat; - } else if (commstage == TransmitReady) { - screenstate = ShowStats; - // Check how long we've been waiting on a message - if (!inputStringReady && time_us_64() >= heartbeat_ms) { - commstage = ErrorWait; - heartbeat_ms = time_us_64() + offset_heartbeat; - return; - } - - if (!inputStringReady) { - return; - } - - // Parse any incoming messages appropriately! - if (inputString[0] == 'D') { - // Device control - if (inputString[1] == '\x11') { - // PC Stats Control - uint8_t parse_success = 0; - if (inputString[2] == '\x30') { - // "Unchanging" Info (CPU+GPU name, RAM capacity) - parse_success = parse_pc_part_info(); - } else if (inputString[2] == '\x31') { - // Stat Info (Temperature, Load%, etc.) - parse_success = parse_pc_part_stats(); - } - - if (parse_success) { - tud_cdc_write("D\x11\x06\r\n", 5); - } else { - tud_cdc_write("D\x11\x15\r\n", 5); - } - tud_cdc_write_flush(); - reset_input_string(); - } else if (inputString[1] == '\x12') { - // RGB Control - reset_input_string(); - } - } else if (inputString[0] == 'H' && inputString[1] == '\x30') { - // Heartbeat - tud_cdc_write("H\x31\r\n", 4); - tud_cdc_write_flush(); - heartbeat_ms = time_us_64() + offset_heartbeat; - reset_input_string(); - } else if (inputString[0] == 'U') { - if (inputString[1] == '\x30') { - // Disconnect - tud_cdc_write("\x04\x04\r\n", 4); - tud_cdc_write_flush(); - reset_input_string(); - commstage = ErrorWait; // TODO: better handle serial disconnects - } else if (inputString[1] == '\x31') { - // Update - tud_cdc_write("\x04\x04\r\n", 4); - tud_cdc_write_flush(); - reset_input_string(); - - lcd_off(); - lcd_clear(); - lcd_present(); - rgb_clear(); - rgb_present(); - - sleep_ms(500); // sleep to allow tinyusb to write cdc buffer (TODO: find better value) - bootsel_reset_jukebox = 1; - } else if (inputString[1] == '\x32') { - // Test Function - tud_cdc_write("U\x12\x06\r\n", 5); - tud_cdc_write_flush(); - reset_input_string(); - - static bool t = true; - t = !t; - if (t) { - lcd_on(); - } else { - lcd_off(); - } - } - } - } -} diff --git a/firmware/src/st7789_lcd.c b/firmware/src/st7789_lcd.c deleted file mode 100644 index 7c715d2..0000000 --- a/firmware/src/st7789_lcd.c +++ /dev/null @@ -1,166 +0,0 @@ -#include "st7789_lcd.h" - -#include -#include - -#include "st7789_lcd.pio.h" - - -// Tested with the parts that have the height of 240 and 320 -#define SCREEN_WIDTH JB_SCREEN_RESOLUTION_WIDTH -#define SCREEN_HEIGHT JB_SCREEN_RESOLUTION_HEIGHT - -#define PIN_DIN JB_SCREEN_PIN_DIN -#define PIN_CLK JB_SCREEN_PIN_CLK -#define PIN_CS JB_SCREEN_PIN_CS -#define PIN_DC JB_SCREEN_PIN_DC -#define PIN_RST JB_SCREEN_PIN_RST -#define PIN_BL JB_SCREEN_PIN_BL - -#define SERIAL_CLK_DIV JB_SCREEN_CLK_DIV - - -PIO pio = pio0; -uint sm = 0; -uint offset = 0; - -// Format: cmd length (including cmd byte), post delay in units of 5 ms, then cmd payload -// Note the delays have been shortened a little -static const uint8_t st7789_init_seq[] = { - 1, 20, 0x01, // Software reset - 1, 10, 0x11, // Exit sleep mode - 2, 2, 0x3A, 0x55, // Set colour mode to 16 bit - 2, 0, 0x36, 0x00, // Set MADCTL: row then column, refresh is bottom to top ???? - 5, 0, 0x2A, 0x00, 0x00, SCREEN_WIDTH >> 8, SCREEN_WIDTH & 0xFF, // CASET: column addresses - 5, 0, 0x2B, 0x00, 0x00, SCREEN_HEIGHT >> 8, SCREEN_HEIGHT & 0xFF, // RASET: row addresses - 1, 2, 0x21, // Inversion on, then 10 ms delay (supposedly a hack?) - 1, 2, 0x13, // Normal display on, then 10 ms delay - 1, 2, 0x29, // Main screen turn on, then wait 500 ms - 0 // Terminate list -}; - -static uint16_t framebuffer[SCREEN_HEIGHT][SCREEN_WIDTH]; - - -inline void lcd_set_dc_cs(bool dc, bool cs) { - sleep_us(1); - gpio_put_masked((1u << PIN_DC) | (1u << PIN_CS), !!dc << PIN_DC | !!cs << PIN_CS); - sleep_us(1); -} - - -inline void lcd_write_cmd(PIO pio, uint sm, const uint8_t *cmd, size_t count) { - st7789_lcd_wait_idle(pio, sm); - lcd_set_dc_cs(0, 0); - st7789_lcd_put(pio, sm, *cmd++); - if (count >= 2) { - st7789_lcd_wait_idle(pio, sm); - lcd_set_dc_cs(1, 0); - for (size_t i = 0; i < count - 1; ++i) - st7789_lcd_put(pio, sm, *cmd++); - } - st7789_lcd_wait_idle(pio, sm); - lcd_set_dc_cs(1, 1); -} - - -inline void st7789_lcd_init(void) { - offset = pio_add_program(pio, &st7789_lcd_program); - st7789_lcd_program_init(pio, sm, offset, PIN_DIN, PIN_CLK, SERIAL_CLK_DIV); - - gpio_init(PIN_CS); - gpio_init(PIN_DC); - gpio_init(PIN_RST); - gpio_init(PIN_BL); - gpio_set_dir(PIN_CS, GPIO_OUT); - gpio_set_dir(PIN_DC, GPIO_OUT); - gpio_set_dir(PIN_RST, GPIO_OUT); - gpio_set_dir(PIN_BL, GPIO_OUT); - - gpio_put(PIN_CS, 1); - gpio_put(PIN_RST, 1); - - const uint8_t *cmd = st7789_init_seq; - while (*cmd) { - lcd_write_cmd(pio, sm, cmd + 2, *cmd); - sleep_ms(*(cmd + 1) * 5); - cmd += *cmd + 2; - } - - gpio_put(PIN_BL, 1); - - st7789_fb_clear(); - st7789_lcd_push_fb(); -} - - -inline void st7789_start_pixels(PIO pio, uint sm) { - uint8_t cmd = 0x2c; // RAMWR - lcd_write_cmd(pio, sm, &cmd, 1); - lcd_set_dc_cs(1, 0); -} - -inline void st7789_fb_clear(void) { - for (uint16_t y=0; y= SCREEN_WIDTH || y >= SCREEN_HEIGHT) { - // if its off screen, whatever - return; - } - - // invert coords - #ifdef JB_SCREEN_MIRROR_FLIP - x = st7789_get_width() - x - 1; - y = st7789_get_height() - y - 1; - #endif - - framebuffer[y][x] = color; - #elif JB_SCREEN_ORIENTATION == JB_LANDSCAPE - if (x >= SCREEN_HEIGHT || y >= SCREEN_WIDTH) { - return; - } - - #ifdef JB_SCREEN_MIRROR_FLIP - y = st7789_get_width() - y - 1; - #else - x = st7789_get_height() - x - 1; - #endif - - framebuffer[x][y] = color; - #endif -} - -void st7789_lcd_push_fb(void) { - st7789_start_pixels(pio, sm); - uint16_t color = 0; - for (uint16_t y=0; y> 8); - st7789_lcd_put(pio, sm, color & 0xFF); - } - } -} - -inline uint16_t st7789_get_width(void) { - return SCREEN_WIDTH; -} - -inline uint16_t st7789_get_height(void) { - return SCREEN_HEIGHT; -} - -inline void st7789_bl_on(void) { - gpio_put(PIN_BL, 1); -} - -inline void st7789_bl_off(void) { - gpio_put(PIN_BL, 0); -} diff --git a/firmware/src/st7789_lcd.pio b/firmware/src/st7789_lcd.pio deleted file mode 100644 index aa35c68..0000000 --- a/firmware/src/st7789_lcd.pio +++ /dev/null @@ -1,57 +0,0 @@ -; -; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -; -; SPDX-License-Identifier: BSD-3-Clause -; - -.program st7789_lcd -.side_set 1 - -; This is just a simple clocked serial TX. At 125 MHz system clock we can -; sustain up to 62.5 Mbps. -; Data on OUT pin 0 -; Clock on side-set pin 0 - -.wrap_target - out pins, 1 side 0 ; stall here if no data (clock low) - nop side 1 -.wrap - -% c-sdk { -// For optimal use of DMA bandwidth we would use an autopull threshold of 32, -// but we are using a threshold of 8 here (consume 1 byte from each FIFO entry -// and discard the remainder) to make things easier for software on the other side - -static inline void st7789_lcd_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clk_pin, float clk_div) { - pio_gpio_init(pio, data_pin); - pio_gpio_init(pio, clk_pin); - pio_sm_set_consecutive_pindirs(pio, sm, data_pin, 1, true); - pio_sm_set_consecutive_pindirs(pio, sm, clk_pin, 1, true); - pio_sm_config c = st7789_lcd_program_get_default_config(offset); - sm_config_set_sideset_pins(&c, clk_pin); - sm_config_set_out_pins(&c, data_pin, 1); - sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); - sm_config_set_clkdiv(&c, clk_div); - sm_config_set_out_shift(&c, false, true, 8); - pio_sm_init(pio, sm, offset, &c); - pio_sm_set_enabled(pio, sm, true); -} - -// Making use of the narrow store replication behaviour on RP2040 to get the -// data left-justified (as we are using shift-to-left to get MSB-first serial) - -static inline void st7789_lcd_put(PIO pio, uint sm, uint8_t x) { - while (pio_sm_is_tx_fifo_full(pio, sm)) - ; - *(volatile uint8_t*)&pio->txf[sm] = x; -} - -// SM is done when it stalls on an empty FIFO - -static inline void st7789_lcd_wait_idle(PIO pio, uint sm) { - uint32_t sm_stall_mask = 1u << (sm + PIO_FDEBUG_TXSTALL_LSB); - pio->fdebug = sm_stall_mask; - while (!(pio->fdebug & sm_stall_mask)) - ; -} -%} diff --git a/firmware-rs/src/uid.rs b/firmware/src/uid.rs similarity index 100% rename from firmware-rs/src/uid.rs rename to firmware/src/uid.rs diff --git a/firmware/src/usb_descriptors.c b/firmware/src/usb_descriptors.c deleted file mode 100644 index fbe4301..0000000 --- a/firmware/src/usb_descriptors.c +++ /dev/null @@ -1,175 +0,0 @@ -// From: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_hid_composite/usb_descriptors.c - -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include -#include - -#define USB_PID 0xF20A -#define USB_VID 0x1209 -#define USB_BCD 0x0200 - -//--------------------------------------------------------------------+ -// Device Descriptors -//--------------------------------------------------------------------+ -tusb_desc_device_t const desc_device = { - .bLength = sizeof(tusb_desc_device_t), - .bDescriptorType = TUSB_DESC_DEVICE, - .bcdUSB = USB_BCD, - .bDeviceClass = TUSB_CLASS_MISC, - .bDeviceSubClass = MISC_SUBCLASS_COMMON, - .bDeviceProtocol = MISC_PROTOCOL_IAD, - .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE, - - .idVendor = USB_VID, - .idProduct = USB_PID, - .bcdDevice = 0x0100, - - .iManufacturer = 0x01, - .iProduct = 0x02, - .iSerialNumber = 0x03, - - .bNumConfigurations = 0x01 -}; - -// Invoked when received GET DEVICE DESCRIPTOR -// Application return pointer to descriptor -uint8_t const * tud_descriptor_device_cb(void) { - return (uint8_t const *) &desc_device; -} - -//--------------------------------------------------------------------+ -// HID Report Descriptor -//--------------------------------------------------------------------+ - -uint8_t const desc_hid_report[] = { - TUD_HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID( 1 ) ) -}; - -// Invoked when received GET HID REPORT DESCRIPTOR -// Application return pointer to descriptor -// Descriptor contents must exist long enough for transfer to complete -uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance) { - (void) instance; - return desc_hid_report; -} - -//--------------------------------------------------------------------+ -// Configuration Descriptor -//--------------------------------------------------------------------+ - -enum -{ - ITF_NUM_HID = 0, - ITF_NUM_CDC_0, - ITF_NUM_CDC_0_DATA, - ITF_NUM_TOTAL -}; - -#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN + TUD_CDC_DESC_LEN) - -#define EPNUM_HID 0x84 -#define EPNUM_CDC_0_NOTIF 0x81 -#define EPNUM_CDC_0_OUT 0x02 -#define EPNUM_CDC_0_IN 0x82 - -uint8_t const desc_configuration[] = { - // Config number, interface count, string index, total length, attribute, power in mA - TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 500), - - // Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval - TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10), - // Interface number, string index, EP notification address and size, EP data address (out, in) and size - TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 64), -}; - -// Invoked when received GET CONFIGURATION DESCRIPTOR -// Application return pointer to descriptor -// Descriptor contents must exist long enough for transfer to complete -uint8_t const * tud_descriptor_configuration_cb(uint8_t index) { - (void) index; // for multiple configurations - return desc_configuration; -} - -//--------------------------------------------------------------------+ -// String Descriptors -//--------------------------------------------------------------------+ - -// buffer to hold flash ID -char serial[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1]; - -// array of pointer to string descriptors -char const* string_desc_arr [] = { - (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) - "FriendTeamInc", // 1: Manufacturer - "JukeBox V5", // 2: Product - serial, // 3: Serials, uses the flash ID - "JukeBox V5 Serial", // 4: CDC Interface -}; - -static uint16_t _desc_str[32]; - -// Invoked when received GET STRING DESCRIPTOR request -// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete -uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) { - (void) langid; - - uint8_t chr_count; - - if ( index == 0) { - memcpy(&_desc_str[1], string_desc_arr[0], 2); - chr_count = 1; - } else { - // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. - // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors - - if (index == 3) { - pico_get_unique_board_id_string(serial, sizeof(serial)); - } - - if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) { - return NULL; - } - - const char* str = string_desc_arr[index]; - - // Cap at max char - chr_count = strlen(str); - if ( chr_count > 31 ) { - chr_count = 31; - } - - // Convert ASCII string into UTF-16 - for(uint8_t i=0; i