From d53cef82685822b09fbf06fec346cbe74a2af5b5 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 9 Jun 2020 21:17:16 +1200 Subject: [PATCH] Trial of fixing github action --- .github/workflows/rust.yml | 90 ++++++++++++++++++++++++++------ rog-client/src/animatrix_dbus.rs | 37 +------------ rog-client/src/anime_matrix.rs | 9 ++-- rog-client/src/lib.rs | 6 +-- 4 files changed, 82 insertions(+), 60 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3c13d1be..8d703a80 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,22 +1,78 @@ +on: [push, pull_request] + name: Rust -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -env: - CARGO_TERM_COLOR: always - jobs: - build: - + check: + name: Check runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - name: Install deps + run: sudo apt-get install libusb-1.0-0-dev libdbus-1-dev llvm libclang-dev + + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - name: Install deps + run: sudo apt-get install libusb-1.0-0-dev libdbus-1-dev llvm libclang-dev + + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Install deps + run: sudo apt-get install libusb-1.0-0-dev libdbus-1-dev llvm libclang-dev + + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings \ No newline at end of file diff --git a/rog-client/src/animatrix_dbus.rs b/rog-client/src/animatrix_dbus.rs index 7a7b4ad5..15d324ff 100644 --- a/rog-client/src/animatrix_dbus.rs +++ b/rog-client/src/animatrix_dbus.rs @@ -16,42 +16,7 @@ pub const ANIME_PANE2_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x0 /// The resolution is 34x56 (1904) but only 1,215 LEDs in the top-left are used. /// The display is available only on select GA401 models. /// -/// Amory crate assumes first row is 33 pixels/bytes, this means the actual structure -/// likely follows this format with every second line offset physically by half. -/// Even rows (mod 1) are aligned right, odd are offset left by half (`..=` is inclusive) -/// -/// - 0..=32, row 0, 33 pixels // len starts at 37 if using formula -/// - 33..=66, row 1, 33 pixels -/// - 68..=101, row 2, 33 pixels -/// - 101..=134, row 3, 33 pixels -/// - 135..=168, row 4, 33 pixels -/// - 169..=202, row 5, 33 pixels // Should be last offset line? -/// - 203..=236, row 6, 33 pixels -/// - 237..=268, row 7, 31 pixels -2 px from last -/// - 269..=301, row 8, 32 pixels +1 px from last -/// - 302..=332, row 9, 30 pixels -2 -/// - 333..=364, row 10, 31 pixels +1 -/// - 365..=394, row 11, 29 pixels -2 -/// - 395..=425, row 12, 30 pixels +1 -/// - 426..=454, row 13, 28 pixels -2 -/// - 455..=484, row 14, 29 pixels +1 -/// - 485..=512, row 15, 27 pixels -2 -/// - 513..=541, row 16, 28 pixels +1 -/// - 542..=568, row 17, 26 pixels -2 -/// - 569..=596, row 18, 27 pixels +1 -/// - 597..=622, row 19, 25 pixels -2 -/// - BEGIN NEXT BLOCK AT IDX627 (when writing out the one dimensional array) -/// - 623..=649, row 20, 26 pixels +1 -/// - .. 57 rows (from 0) -/// -/// Image is 33x56, and -/// -/// The formula below starts at row 7 -/// ``` -/// if current_row_idx != 0 && current_row_idx.mod(1) == 0 -/// then current_row_len = last_row_len + 1 -/// else current_row_len = last_row_len - 2, // offset left by half -/// ``` +/// Actual image ration when displayed is stretched width. /// /// Data structure should be nested array of [[u8; 33]; 56] pub struct AniMeDbusWriter { diff --git a/rog-client/src/anime_matrix.rs b/rog-client/src/anime_matrix.rs index 775eea5e..35d10193 100644 --- a/rog-client/src/anime_matrix.rs +++ b/rog-client/src/anime_matrix.rs @@ -6,6 +6,9 @@ const BLOCK_START: usize = 7; const BLOCK_END: usize = 634; use yansi_term::Colour::RGB; +/// Helper structure for writing images. +/// +/// See the examples for ways to write an image to `AniMeMatrix` format. pub struct AniMeMatrix(AniMeBufferType); impl AniMeMatrix { @@ -38,8 +41,6 @@ impl AniMeMatrix { if count < 6 { if count % 2 != 0 { print!(" "); - } else if count == 0 { - print!(" "); } else { print!(" "); } @@ -52,7 +53,7 @@ impl AniMeMatrix { print!(" {}", RGB(*x, *x, *x).paint(&format!("{:#04X}", x))); } - print!("\n"); + println!(); } else { // Switch to next block (looks like ) if count % 2 != 0 { @@ -78,7 +79,7 @@ impl AniMeMatrix { print!(" "); } } - print!("\n"); + println!(); } } } diff --git a/rog-client/src/lib.rs b/rog-client/src/lib.rs index 31fea603..c6c3c96f 100644 --- a/rog-client/src/lib.rs +++ b/rog-client/src/lib.rs @@ -28,7 +28,7 @@ use crate::cli_options::*; /// /// The HID descriptor looks like: /// -/// ``` +/// ```ignore /// 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined 0xFF31) /// 0x09, 0x76, // Usage (0x76) /// 0xA1, 0x01, // Collection (Application) @@ -60,7 +60,7 @@ pub fn aura_brightness_bytes(brightness: u8) -> [u8; 17] { /// /// Byte structure: /// -/// ``` +/// ```ignore /// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| /// |---|---|---|---|---|---|---|---|---|---|---|---|---| /// |5d |b3 |00 |03 |ff |00 |00 |00 |00 |00 |00 |ff |00 | @@ -103,7 +103,7 @@ pub fn aura_brightness_bytes(brightness: u8) -> [u8; 17] { /// Bytes 10, 11, 12 are Red, Green, Blue for second colour if mode supports it /// /// The HID descriptor looks like: -/// ``` +/// ```ignore /// 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined 0xFF31) /// 0x09, 0x79, // Usage (0x79) /// 0xA1, 0x01, // Collection (Application)