libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
switch3.h
Go to the documentation of this file.
1#pragma once
2#include "daisy_core.h"
3#include "per/gpio.h"
4
5namespace daisy
6{
7class Switch3
8{
9 public:
10 enum
11 {
14 POS_UP = 1,
17 };
18
19
22
28
29 int Read()
30 {
31 if(!pina_gpio_.Read())
32 return POS_UP;
33 if(!pinb_gpio_.Read())
34 return POS_DOWN;
35 return POS_CENTER;
36 }
37
38 private:
39 GPIO pina_gpio_;
40 GPIO pinb_gpio_;
41};
42
43} // namespace daisy
General Purpose I/O control.
Definition gpio.h:22
bool Read()
Reads the state of the GPIO.
void Init()
Initialize the GPIO using the internal Config struct.
Definition leddriver.h:33
Definition switch3.h:8
void Init(Pin pina, Pin pinb)
Definition switch3.h:23
int Read()
Definition switch3.h:29
Switch3()
Definition switch3.h:20
@ POS_CENTER
Definition switch3.h:12
@ POS_DOWN
Definition switch3.h:16
@ POS_UP
Definition switch3.h:14
@ POS_RIGHT
Definition switch3.h:15
@ POS_LEFT
Definition switch3.h:13
~Switch3()
Definition switch3.h:21
Hardware defines and helpers for daisy field platform.
Definition index.h:2
representation of hardware port/pin combination
Definition daisy_core.h:193