Skip to content

Commit

Permalink
adapt spade to work w/ HAL (depends on #2450) (#2451)
Browse files Browse the repository at this point in the history
* adapt spade to work w/ HAL (depends on #2450)

* Update CMakeLists.txt

* consolidate gardenshed & make work w/ all firmwares (#2467)
  • Loading branch information
recursiveforte authored Oct 27, 2024
1 parent a6b0f0b commit 4821090
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 382 deletions.
15 changes: 15 additions & 0 deletions firmware/c_scaffold/docker/buildScript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh

cd ~/sprig/firmware/c_scaffold

mkdir -p build
cd build

cmake ..
cmake --build .

cd ..

cp build/c_scaffold.uf2 ~/firmware.uf2
cp ~/firmware.uf2 firmware.uf2
cp build/c_scaffold.elf ~/firmware.elf
15 changes: 15 additions & 0 deletions firmware/c_scaffold/docker/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.19

RUN apk add git python3 clang make cmake entr uglify-js gcc-arm-none-eabi g++-arm-none-eabi gdb-multiarch gcc

COPY ./importBuildRepos.sh /opt/importBuildRepos.sh

RUN chmod +x /opt/importBuildRepos.sh

RUN /opt/importBuildRepos.sh

COPY ./buildScript.sh /opt/buildScript.sh

RUN chmod +x /opt/buildScript.sh

CMD /opt/buildScript.sh
10 changes: 10 additions & 0 deletions firmware/c_scaffold/docker/importBuildRepos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mkdir ~/raspberrypi
cd ~/raspberrypi
git clone -b 1.3.1 https://github.com/raspberrypi/pico-sdk.git
git clone https://github.com/raspberrypi/pico-extras.git
cd pico-sdk
git checkout 7070d230c0cdf1add83fa86b6832b47b2da47788
git submodule update --init
cd ../pico-extras
git checkout 09c64d509f1d7a49ceabde699ed6c74c77e195a1
git submodule update --init
1 change: 1 addition & 0 deletions firmware/c_scaffold/gardenshed.py
12 changes: 8 additions & 4 deletions firmware/spade/docker/buildScript.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cd ~/spade
#!/usr/bin/env sh

cd ~/sprig/firmware/spade
./src/pc/jerry/refresh.sh

cd ~/spade
cd ~/sprig/firmware/spade
./src/rpi/jerry/refresh.sh

touch game.js
Expand All @@ -13,5 +15,7 @@ mkdir -p src/shared/sprig_engine/build
cmake --preset=rpi
cmake --build --preset=rpi

cp rpi_build/src/spade.uf2 ~/spade
cp rpi_build/src/spade.elf ~/spade
cp rpi_build/src/spade.uf2 ~/firmware.uf2
cp ~/firmware.uf2 firmware.uf2
cp rpi_build/src/spade.elf ~/firmware.elf
cp ~/firmware.elf firmware.elf
1 change: 1 addition & 0 deletions firmware/spade/gardenshed.py
3 changes: 0 additions & 3 deletions firmware/spade/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ target_link_libraries(spade
include_directories(${SPADE_TARGET}/jerry/include)
include_directories(./)

pico_enable_stdio_usb(${PROJECT_NAME} 1)
pico_enable_stdio_uart(${PROJECT_NAME} 1)

file(READ version.json VERSION_JSON)

string(JSON VERSION GET ${VERSION_JSON} version)
Expand Down
2 changes: 1 addition & 1 deletion firmware/spade/src/pc/jerry/refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python3 jerryscript/tools/build.py \
--jerry-cmdline=OFF
make -C $(pwd)/example_build install\

cd ~/spade/src/pc/jerry
cd ~/sprig/firmware/spade/src/pc/jerry
cp -r ~/jerryscript_build/example_build/lib ./
rm -rf include
cp -r ~/jerryscript_build/example_install/include ./
16 changes: 8 additions & 8 deletions firmware/spade/src/pc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ static void keyboard(struct mfb_window *window, mfb_key key, mfb_key_mod mod, bo
mfb_close(window);
}

if (key == KB_KEY_W) spade_call_press( 5); // map_move(map_get_first('p'), 0, -1);
if (key == KB_KEY_S) spade_call_press( 7); // map_move(map_get_first('p'), 0, 1);
if (key == KB_KEY_A) spade_call_press( 6); // map_move(map_get_first('p'), 1, 0);
if (key == KB_KEY_D) spade_call_press( 8); // map_move(map_get_first('p'), -1, 0);
if (key == KB_KEY_I) spade_call_press(12); // map_move(map_get_first('p'), 0, -1);
if (key == KB_KEY_K) spade_call_press(14); // map_move(map_get_first('p'), 0, 1);
if (key == KB_KEY_J) spade_call_press(13); // map_move(map_get_first('p'), 1, 0);
if (key == KB_KEY_L) spade_call_press(15); // map_move(map_get_first('p'), -1, 0);
if (key == KB_KEY_W) spade_call_press(0); // map_move(map_get_first('p'), 0, -1);
if (key == KB_KEY_S) spade_call_press(1); // map_move(map_get_first('p'), 0, 1);
if (key == KB_KEY_A) spade_call_press(2); // map_move(map_get_first('p'), 1, 0);
if (key == KB_KEY_D) spade_call_press(3); // map_move(map_get_first('p'), -1, 0);
if (key == KB_KEY_I) spade_call_press(4); // map_move(map_get_first('p'), 0, -1);
if (key == KB_KEY_K) spade_call_press(5); // map_move(map_get_first('p'), 0, 1);
if (key == KB_KEY_J) spade_call_press(6); // map_move(map_get_first('p'), 1, 0);
if (key == KB_KEY_L) spade_call_press(7); // map_move(map_get_first('p'), -1, 0);
}
#endif

Expand Down
40 changes: 24 additions & 16 deletions firmware/spade/src/rpi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
pico_sdk_init()
add_definitions(-DSPADE_EMBEDDED -DSPADE_AUDIO -DPICO_NO_BI_PROGRAM_BUILD_DATE)
add_definitions(-DSPADE_EMBEDDED -DSPADE_AUDIO)
set(DCMAKE_BUILD_TYPE Release)
target_compile_definitions(spade PRIVATE
# compile time configuration of I2S
PICO_AUDIO_I2S_MONO_INPUT=1
USE_AUDIO_I2S=1
PICO_AUDIO_I2S_DATA_PIN=9
PICO_AUDIO_I2S_CLOCK_PIN_BASE=10
# PICO_DEFAULT_UART=0
# PICO_DEFAULT_UART_TX_PIN=28
# PICO_DEFAULT_UART_RX_PIN=29
# compile time configuration of I2S
PICO_AUDIO_I2S_MONO_INPUT=1
USE_AUDIO_I2S=1
PICO_AUDIO_I2S_DATA_PIN=9
PICO_AUDIO_I2S_CLOCK_PIN_BASE=10
# PICO_DEFAULT_UART=0
# PICO_DEFAULT_UART_TX_PIN=28
# PICO_DEFAULT_UART_RX_PIN=29
)

pico_enable_stdio_usb(${PROJECT_NAME} 1)
pico_enable_stdio_uart(${PROJECT_NAME} 1)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../sprig_hal sprig_hal)

target_link_libraries(spade PRIVATE
pico_stdlib
pico_audio_i2s
pico_multicore
hardware_spi
hardware_timer
hardware_pwm
hardware_adc
pico_stdlib
pico_audio_i2s
pico_multicore
hardware_spi
hardware_timer
hardware_pwm
hardware_adc
sprig_hal
)

add_compile_definitions(PICO_HEAP_SIZE=16384)

pico_enable_stdio_usb(spade 1)
pico_enable_stdio_uart(spade 0)

Expand Down
65 changes: 0 additions & 65 deletions firmware/spade/src/rpi/audio.c

This file was deleted.

2 changes: 1 addition & 1 deletion firmware/spade/src/rpi/jerry/refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python3 jerryscript/tools/build.py \
--jerry-cmdline=OFF
make -C $(pwd)/example_build install\

cd ~/spade/src/rpi/jerry
cd ~/sprig/firmware/spade/src/rpi/jerry
cp -r ~/jerryscript_build/example_build/lib/ lib/
# cp ~/jerryscript_build/example_install/include
rm -rf include
Expand Down
Loading

0 comments on commit 4821090

Please sign in to comment.