diff --git a/Makefile b/Makefile index 408a122..0923e9f 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,13 @@ all: clean build clean: rm -rf bin/ +# The following settings are very important! +# -c arduino for flashing to an AVR device with arduino bootloader. +# -p atmega328p is for the specific microcontroller. +# -b 57600 is the baudrate for transmission. Nano boards ONLY accept 57600, uno boards might accept 115200. +# -P specifies the port. flash: build - avrdude -c arduino -p atmega328p -P /dev/ttyUSB0 -b115200 -U flash:w:bin/gympal.hex:i + avrdude -c arduino -p atmega328p -P /dev/ttyUSB0 -b 57600 -U flash:w:bin/gympal.hex:i build: gympal.hex diff --git a/src/control.h b/src/control.h index 1d5463a..1c72128 100644 --- a/src/control.h +++ b/src/control.h @@ -40,6 +40,16 @@ void ctl_init(); * @brief Determines if button A has been pressed. * @return uint8_t 1 if pressed, 0 otherwise. */ -uint8_t ctl_isButtonAPressed(); +inline uint8_t ctl_isButtonAPressed() { + return (CTL_INPUT_FLAGS & (1 << CTL_BUTTON_A_FLAG)) >> CTL_BUTTON_A_FLAG; +} + +inline uint8_t ctl_isButtonBPressed() { + return (CTL_INPUT_FLAGS & (1 << CTL_BUTTON_B_FLAG)) >> CTL_BUTTON_B_FLAG; +} + +inline uint8_t ctl_isButtonCPressed() { + return (CTL_INPUT_FLAGS & (1 << CTL_BUTTON_C_FLAG)) >> CTL_BUTTON_C_FLAG; +} #endif \ No newline at end of file diff --git a/src/gympal.c b/src/gympal.c index dd25570..1cf8cd3 100644 --- a/src/gympal.c +++ b/src/gympal.c @@ -10,7 +10,7 @@ int main() { PORTB &= ~(1 << PORTB4); uint8_t led = 0; while(1) { - uint8_t v = (CTL_INPUT_FLAGS & (1 << CTL_BUTTON_B_FLAG)) >> CTL_BUTTON_A_FLAG; + uint8_t v = ctl_isButtonAPressed(); if (led != v) { led = v; if (led) {