~ruther/avr-guess-the-number

81a90bdb03966d8ab4874d854ed6c268e060fe13 — František Boháček 2 years ago 0f40a4c
feat: add inline tags to compact binary size
M src/animation.rs => src/animation.rs +2 -0
@@ 111,6 111,7 @@ impl Animation for WinAnimation {
        seven_segment.show_all_digits();
    }

    #[inline]
    fn running(&self) -> bool {
        self.led_step < WIN_ANIMATION_MAX_LED_OUTER_STEP
    }


@@ 166,6 167,7 @@ impl Animation for HelloAnimation {
        seven_segment.show_all_digits();
    }

    #[inline]
    fn running(&self) -> bool {
        self.outer_step < HELO_ANIMATION_MAX_OUTER_STEP
    }

M src/filled_seven_segment.rs => src/filled_seven_segment.rs +7 -0
@@ 29,18 29,22 @@ impl FilledSevenSegment {
        return (digit % 10).try_into().unwrap();
    }

    #[inline]
    pub fn hide_digit(&mut self, digit_index: usize) {
        self.hide |= 1 << digit_index;
    }

    #[inline]
    pub fn show_digit(&mut self, digit_index: usize) {
        self.hide &= !(1 << digit_index);
    }

    #[inline]
    pub fn hide_all_digits(&mut self) {
        self.hide = 0xFF;
    }

    #[inline]
    pub fn show_all_digits(&mut self) {
        self.hide = 0;
    }


@@ 58,6 62,7 @@ impl FilledSevenSegment {
        }
    }

    #[inline]
    pub fn show_number_block(&mut self) {
        while !self.step() {}
    }


@@ 101,10 106,12 @@ impl FilledSevenSegment {
        return false;
    }

    #[inline]
    pub fn reset(&mut self) {
        self.update_step = 0;
    }

    #[inline]
    pub fn clear(&mut self) {
        self.digits = [None, None, None, None];
    }

M src/filled_sipo.rs => src/filled_sipo.rs +2 -0
@@ 20,6 20,7 @@ impl FilledSipo {
        self.reset();
    }

    #[inline]
    pub fn push_block(&mut self) {
        while !self.step() {
        }


@@ 38,6 39,7 @@ impl FilledSipo {
        return false;
    }

    #[inline]
    pub fn reset(&mut self) {
        self.update_step = 0;
    }

M src/led_matrix.rs => src/led_matrix.rs +6 -0
@@ 25,14 25,17 @@ impl LEDMatrix {
        }
    }

    #[inline]
    fn get_position(width: u8, x: u8, y: u8) -> u8 {
        return width*y + x;
    }

    #[inline]
    pub fn data(&self) -> u8 {
        self.data
    }

    #[inline]
    pub fn set_data(&mut self, data: u8) {
        self.data = data;
    }


@@ 50,11 53,13 @@ impl LEDMatrix {
        }
    }

    #[inline]
    pub fn add_anode(&mut self, anode: Pin<mode::Output>) {
        self.anodes[self.anodes_count] = Some(anode);
        self.anodes_count += 1;
    }

    #[inline]
    pub fn add_cathode(&mut self, cathode: Pin<mode::Output>) {
        self.cathodes[self.cathodes_count] = Some(cathode);
        self.cathodes_count += 1;


@@ 96,6 101,7 @@ impl LEDMatrix {
        return false;
    }

    #[inline]
    pub fn clear(&mut self) {
        self.data = 0;
    }

M src/rng.rs => src/rng.rs +1 -0
@@ 31,6 31,7 @@ impl Rng {
        self.c
    }

    #[inline]
    pub fn take_u8(&mut self) -> u8 {
        self.randomize()
    }

M src/seven_segment.rs => src/seven_segment.rs +4 -0
@@ 56,18 56,22 @@ impl SevenSegment {
        }
    }

    #[inline]
    pub fn digits(&self) -> u8 {
        return self.digits;
    }

    #[inline]
    pub fn dp(&self) -> bool {
        return self.dp;
    }

    #[inline]
    pub fn common_cathode(&self) -> bool {
        return self.common_cathode;
    }

    #[inline]
    fn get_digit_selector(digit_count: u8, digit_index: usize) -> u8 {
        let digit_count: usize = digit_count.into();
        return 1 << (digit_count - 1 - digit_index);

M src/sipo.rs => src/sipo.rs +1 -0
@@ 20,6 20,7 @@ impl Sipo {
        return sipo;
    }

    #[inline]
    pub fn setup(&mut self) {
        self.clear();
        self.show();

Do not follow this link