summaryrefslogtreecommitdiff
path: root/src/input/input_volume_buttons.cpp
blob: 0413222c1075d9446aea6ad2a8b90fe1cc6e48eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright 2024 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#include "input_volume_buttons.hpp"
#include "event_queue.hpp"
#include "gpios.hpp"

namespace input {

VolumeButtons::VolumeButtons(drivers::IGpios& gpios) : gpios_(gpios) {}

auto VolumeButtons::read(lv_indev_data_t* data) -> void {
  bool vol_up = gpios_.Get(drivers::IGpios::Pin::kKeyUp);
  switch (up_.update(!vol_up)) {
    case Trigger::State::kNone:
      break;
    default:
      events::Audio().Dispatch(audio::StepUpVolume{});
      break;
  }

  bool vol_down = gpios_.Get(drivers::IGpios::Pin::kKeyDown);
  switch (down_.update(!vol_down)) {
    case Trigger::State::kNone:
      break;
    default:
      events::Audio().Dispatch(audio::StepDownVolume{});
      break;
  }
}

}  // namespace input