diff options
author | ThomasintAnker <thomasintanker1@gmail.com> | 2024-06-18 16:23:51 +0200 |
---|---|---|
committer | ThomasintAnker <thomasintanker1@gmail.com> | 2024-06-18 16:23:51 +0200 |
commit | a55d0bed6240c54f6173b1e38e80212c02c302de (patch) | |
tree | 07c15eebc8cd84e1071a3f72d3c74475017372f3 /puzzle | |
parent | b45b5d04daa29fcdd456233a931dcbb5b287769f (diff) | |
parent | 245fde65808ce902064ab438296f04f691d007e7 (diff) |
Merge branch 'master' into wip/handover
Diffstat (limited to 'puzzle')
-rw-r--r-- | puzzle/dummy/CMakeLists.txt | 37 | ||||
l--------- | puzzle/dummy/lib | 1 | ||||
-rw-r--r-- | puzzle/dummy/main.cpp | 36 | ||||
-rw-r--r-- | puzzle/dummy/makefile | 20 | ||||
-rw-r--r-- | puzzle/readme.md | 31 |
5 files changed, 125 insertions, 0 deletions
diff --git a/puzzle/dummy/CMakeLists.txt b/puzzle/dummy/CMakeLists.txt new file mode 100644 index 0000000..c485e74 --- /dev/null +++ b/puzzle/dummy/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.29) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) + +# enable debug features +set(CMAKE_BUILD_TYPE Debug) +add_compile_definitions(DEBUG) + +# arduino +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/lib/Arduino-CMake-Toolchain/Arduino-toolchain.cmake) +set(ARDUINO_BOARD "Arduino Uno [avr.uno]") + +# used for testing +# set(ARDUINO_BOARD "Raspberry Pi Pico W [rp2040.rpipicow]") +# add_compile_definitions(USE_TINYUSB) +# include_directories(/home/loek/.arduino15/packages/rp2040/hardware/rp2040/3.9.2/libraries/Adafruit_TinyUSB_Arduino/src/arduino) + +project(pb_mod_dummy C CXX) + +add_subdirectory(lib/pbdrv) + +add_executable(main + main.cpp + ) + +target_link_libraries(main + pbdrv-mod + ) +target_link_arduino_libraries(main + core + Wire + ) + +target_enable_arduino_upload(main) + diff --git a/puzzle/dummy/lib b/puzzle/dummy/lib new file mode 120000 index 0000000..58677dd --- /dev/null +++ b/puzzle/dummy/lib @@ -0,0 +1 @@ +../../lib
\ No newline at end of file diff --git a/puzzle/dummy/main.cpp b/puzzle/dummy/main.cpp new file mode 100644 index 0000000..3d84679 --- /dev/null +++ b/puzzle/dummy/main.cpp @@ -0,0 +1,36 @@ +#include <Arduino.h> +#include <Wire.h> + +#include "drv/arduino/mod.h" +#include "pb-mod.h" + +#ifdef TEST_A +#define ADDR_RX 0x69 +#define ADDR_TX 0x20 +#define MSG "aa" +#define MSG_SIZE 3 +#define MSG_DELAY 10 +#endif + +#ifdef TEST_B +#define ADDR_TX 0x69 +#define ADDR_RX 0x20 +#define MSG "bbbbbbbb" +#define MSG_SIZE 9 +#define MSG_DELAY 10 +#endif + +const char * PBDRV_MOD_NAME = "dummy"; +const i2c_addr_t PBDRV_MOD_ADDR = ADDR_RX; + +void setup() { + pbdrv_setup(); +} + +void loop() { + pbdrv_i2c_send(ADDR_TX, (uint8_t *) MSG, MSG_SIZE); + delay(MSG_DELAY); +} + +void pbdrv_i2c_recv(const uint8_t * data, size_t size) { } + diff --git a/puzzle/dummy/makefile b/puzzle/dummy/makefile new file mode 100644 index 0000000..509d8e3 --- /dev/null +++ b/puzzle/dummy/makefile @@ -0,0 +1,20 @@ +TARGET = $(BUILD_DIR)/main.elf + +include ../../lazy.mk + +export SERIAL_PORT ?= /dev/ttyACM0 +flash: upload-main; +upload-main: $(TARGET) + +test: test_a test_b; + +test_a: + $(MAKE) -C . clean + $(MAKE) -E CMFLAGS+=-D\ CMAKE_CXX_FLAGS=-DTEST_A -C . + $(MAKE) -E SERIAL_PORT=/dev/ttyACM0 -C . flash + +test_b: + $(MAKE) -C . clean + $(MAKE) -E CMFLAGS+=-D\ CMAKE_CXX_FLAGS=-DTEST_B -C . + $(MAKE) -E SERIAL_PORT=/dev/ttyACM1 -C . flash + diff --git a/puzzle/readme.md b/puzzle/readme.md new file mode 100644 index 0000000..59c10b1 --- /dev/null +++ b/puzzle/readme.md @@ -0,0 +1,31 @@ +# puzzles + +This folder contains the source code for all puzzle modules. + +## Arduino-based puzzle modules + +Because of the poorly designed hardware (21-22) used during development +(23-24), some puzzle modules ended up being developed using Arduino boards. All +libraries in this repository use CMake for building (for consistency), which +also means the Arduino based puzzle modules use CMake. The CMakeLists.txt of +some puzzles uses the [Arduino-CMake-Toolchain][arduino-cmake]. To build any of +these subfolders, make sure you have done the following: + +- Install the official Arduino IDE +- Open "Tools" > "Board" > "Board manager" +- Install the "Arduino AVR Boards" package (1.8.6 works at the time of writing) + +[arduino-cmake]: https://github.com/a9183756-gh/Arduino-CMake-Toolchain + +## ESP-based puzzle modules + +### ESP-IDF SDK Setup instructions + +1. Install ESP-IDF extension in Visual Studio Code +2. Install using 'express' option +3. Install ESP-IDF v5.2.1 (release version) + + Additional help: + - [For windows](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/windows-setup.html#get-started-windows-first-steps) + - [For Linux](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/linux-macos-setup.html#get-started-linux-macos-first-steps) + |