diff --git a/.github/Doxyfile b/.github/Doxyfile index a000c2f..f236989 100644 --- a/.github/Doxyfile +++ b/.github/Doxyfile @@ -1,5 +1,5 @@ PROJECT_NAME = "CH32V003 InspireMatrix" -INPUT = data emulator i2c-comm movingnum paint-cursor paint-exe rv rv-dis testing tic-tac-toe README.md +INPUT = data emulator ch32v003_stt eeprom i2c-comm inspire3d-demo movingnum movingcar paint paint-cursor rv-asm rv-dis save-rvasm savepaint snake-game testing tic-tac-toe README.md RECURSIVE = YES USE_MDFILE_AS_MAINPAGE = README.md BUILTIN_STL_SUPPORT = YES diff --git a/README.md b/README.md index ba1bb35..46af4ec 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,87 @@ # InspireMatrix + CH32V003 -## Description +This repository contains various projects and utilities for +working with the CH32V003 microcontroller. -Projects: +Older hardware (InspireMatrix): +![InspireMatrix](inspire_matrix.jpeg) + +## Project Structure + +* `.github`: + * `workflows`: GitHub Actions workflows. + * `Doxyfile`: Doxygen configuration. + +* `.vscode`: + * `settings.json`: VSCode settings: + + ```json + "C_Cpp.default.compilerPath": "riscv-none-elf-gcc", + ``` + + To set the default compiler to `riscv-none-elf-gcc` for IDE integration. * `ch32v003_stt` * Simple spoken digit recognition. * Originally from + * Read its [README.md](ch32v003_stt/STT-README.md) for more information. * `ch32v003fun` * `driver.h`: Contains the most frequently used functions for the CH32V003. - * `i2c_events.h`: Contains some frequently used I2C functions. - * Originally from + * `i2c_events.h`: Contains some frequently used I2C functions written manually. + * `i2c_tx.c`, `i2c_tx.h`, `oled_min.c`, `oled_min.h`: Contains some frequently used functions for the SSD1306 OLED display. Comes from + * `ws2812b_simple.h`: Contains one function for controlling the WS2812B LEDs. + You need to declare the following variables in your code: + In `funconfig.h`: + + ```c + #define FUNCONF_SYSTICK_USE_HCLK 1 + ``` + + In your code (e.g. `main.c`): + + ```c + #define WS2812BSIMPLE_IMPLEMENTATION + // ... + #include "ws2812b_simple.h" + ``` + + * Originally from the `extralibs` folder in * `data` * `buttons.h`: Button ADC calibration data. - * `colors.h`: RGB color data for WS2812B LEDs. + + Contains two sets of data, one for the first prototype + `InspireMatrix` and one for the second prototype `InspireComputer` (which uses two ADC channels for buttons). If you are using the `InspireComputer`, declare the following in `funconfig.h`: + + ```c + #define INTERNAL_INSPIRE_MATRIX + ``` + + * `colors.h`: Contains the color palette for the `InspireMatrix` or `InspireComputer`. + + One global variable `led_array[]` act as buffer to store the color data to be displayed. + Provides functions to manipulate the `led_array[]` buffer. + * `fonts.h`: Display numbers and characters in the size of 3x5 on WS2812B LEDs. + * `music.h`: Frequencies, durations and functions for playing music using a buzzer. + To play sound, use `JOY_sound()`. * `emulator` * Support development of basic embedded system software on Windows/MacOS without requiring physical hardware. * Aims to achieve function compatibility with the `ch32v003fun` library. -* `i2c-comm` (Working in progress) - * Communication between two boards using I2C. +* `i2c-comm` + * Communication between two boards using I2C protocol. The code contains a master and a slave. * `misc` * `libgcc.a` required by the `ch32v003fun` library on MacOS. See [here](misc/README.md) for more information. * `movingnum` * Animations of numbers moving from right to left, bottom to top. Uses math instead of hard coding. + Demonstrates the use of `fonts.h`. * `paint-cursor` * Draw images on `InspireMatrix` with direction buttons and matrix buttons @@ -44,7 +94,7 @@ Projects: * `rv-asm` * Coding RISC-V Compressed instructions on a board with buttons, and showing the result on the matrix. - * Originally from + * Originally from * `rv-dis` (Working in progress) * Disassemble RISC-V compressed instructions and print the result on an external OLED display (e.g. SSD1306). @@ -54,6 +104,15 @@ Projects: * This folder contains a bunch of test programs that are subject to change, and are not guaranteed to work for your specific hardware. +* `savepaint` + * Todo + +* `save-rvasm` + * Todo + +* `snake-game` + * Porting the classic snake game to `InspireMatrix`, which has `8x8`=`64` LEDs and `up / down / left / right` controls. + * `tic-tac-toe` * Play tic-tac-toe with a bot * Press button to start diff --git a/data/colors.h b/data/colors.h index 3bfcbb4..ec90869 100644 --- a/data/colors.h +++ b/data/colors.h @@ -38,7 +38,7 @@ color_t color_divide(color_t color, uint8_t divider) { #define smaller(x, y) ((x) < (y) ? (x) : (y)) void set_color(uint8_t led, color_t color) { - uint8_t divider = 8; + uint8_t divider = 1; led_array[led].r = smaller(color.r, color.r / divider); led_array[led].g = smaller(color.g, color.g / divider); led_array[led].b = smaller(color.b, color.b / divider);