avr-something

Something something AVR side…
git clone git://henryandlizzy.uk/avr-something
Log | Files | Refs | README

commit 1a5f7494e149d8aa11b7c0e2520019bc641e2dbb
parent 7d9a2ccf464158c27e1f250c24a96041cda2674f
Author: Henry Wilson <m3henry@googlemail.com>
Date:   Tue,  6 Feb 2018 22:08:09 +0000

Added centre button detection

NOTE: Resoldered the diode for the centre button the correct way round

Diffstat:
Mmain.cpp | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/main.cpp b/main.cpp @@ -27,7 +27,7 @@ C2 U-B~ | W-A C3 D-B~ | W-B - C4 R-B~ | C-B~ + C4 R-B~ | C-B C5 L-B~ D0 BUTTON COM B @@ -42,6 +42,7 @@ constexpr auto wheelCOM = bit(1); constexpr auto wheelA = bit(2); constexpr auto wheelB = bit(3); +constexpr auto buttonC = bit(4); constexpr auto ledRED = bit(7); constexpr auto ledYEL = bit(4); @@ -51,7 +52,9 @@ int main(void) { ctrl::disableJTAG(); - io::out::C() = wheelA | wheelB; + io::direction::B() = ledRED; + + io::out::C() = wheelA | wheelB | buttonC; io::direction::C() = 0; io::out::D() = 0; @@ -59,10 +62,12 @@ int main(void) for (;;) { - auto val = io::pin::C(); - auto a = (val & wheelA) << 2; - auto b = (val & wheelB) << 3; + auto val = ~io::pin::C(); + auto r = (val << 3) & ledRED; + auto a = (val << 2) & ledYEL; + auto b = (val << 3) & ledGRN; + io::out::B() = r; io::out::D() = a | b; }