avr-something

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

commit 612093eb3265fd3d12a3b203c3a94d2679b84e83
parent 855cde0d1061ddf3952710da281e33fb44a0320c
Author: Henry Wilson <m3henry@googlemail.com>
Date:   Sun, 11 Feb 2018 17:26:50 +0000

Improved lcd test efficiency and added bits(...)

Diffstat:
MhidModule.cpp | 2+-
Mlcd.h | 6++++--
Mmain.cpp | 4++--
Mutils.h | 12++++++++++++
4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/hidModule.cpp b/hidModule.cpp @@ -12,7 +12,7 @@ void hid::init() uint8_t hid::sampleInput() { - constexpr uint8_t maskC = 0b00111100; + constexpr uint8_t maskC = bits(2,3,4,5); constexpr uint8_t maskD = wheelCOM | buttonCOM; const auto saveCdir = io::direction::C(); diff --git a/lcd.h b/lcd.h @@ -104,11 +104,13 @@ void test() for (;;) { - if (0 == ++p.r) if (0 == ++p.b) --p.g; + //if (0 == ++p.r) if (0 == ++p.b) --p.g; //send(p.word); //send(uint16_t(0xF800)); - send(hid::sampleInput()); + auto x = hid::sampleInput(); + send(x); + send(x); } } diff --git a/main.cpp b/main.cpp @@ -14,9 +14,9 @@ int main(void) io::direction::C() = 0xFF; - hid::test(); + //hid::test(); - //lcd::test(); + lcd::test(); /* for (;;) { diff --git a/utils.h b/utils.h @@ -13,6 +13,18 @@ inline constexpr uint8_t bit(const uint8_t shift) return uint8_t(1) << shift; } +inline constexpr uint8_t bits() +{ + return 0; +} + +template <typename...Ts> +inline constexpr uint8_t bits(const uint8_t shift, Ts... others) +{ +// static_assert(8 > shift, "must be in range (0, 7)"); + return bit(shift) | bits(others...); +} + inline constexpr uint16_t wbit(const uint8_t shift) { // static_assert(8 > shift, "must be in range (0, 7)");