~ruther/uni-mam-arm

85b15c7e9f353a97b0ab7b77701b8b7efc520091 — Rutherther 3 months ago 54e9f8d
feat(arm07): add led indication of auto toggle
1 files changed, 13 insertions(+), 0 deletions(-)

M arm07/src/main.c
M arm07/src/main.c => arm07/src/main.c +13 -0
@@ 77,6 77,7 @@ void SystemCoreClockSetHSI(void) {
pin_t user_button;
timer_t button_timer;
exti_t button_exti;
pin_t led;

// Display
matrix_t matrix;


@@ 131,6 132,7 @@ void handle_command(char* cmd, uint16_t len) {
  case 'N':
    // auto toggle
    if (len == 1) {
      handled = true;
      auto_toggle = !auto_toggle;

      if (auto_toggle) {


@@ 220,6 222,13 @@ void next_image()
void app_loop()
{
  while (1) {

    if (auto_toggle) {
      pin_set(&led);
    } else {
      pin_reset(&led);
    }

    if (auto_toggle && cycle >= AUTO_TOGGLE_CYCLES) {
      next_image();
      cycle = 0;


@@ 363,6 372,9 @@ void main()
    pin_init(&user_button, GPIOC, 13);
    pin_into_input(&user_button);

    pin_init(&led, GPIOA, 5);
    pin_into_output(&led);

    exti_init(&button_exti, 13, EXTI, SYSCFG);
    exti_external_interrupt(&button_exti, 2);
    exti_falling_interrupt(&button_exti);


@@ 419,6 431,7 @@ void TIM2_handler(void) {
    if (count > 10) { // at least 50 ms
      if (count > 400) { // at least 2 s
        auto_toggle = !auto_toggle;
        cycle = 0;
      } else { // less than 2 s
        if (auto_toggle) {
          auto_toggle = false;

Do not follow this link