#include "uMuxOutputLib.h" #include "debounce.h" constexpr size_t Id1up=3; constexpr size_t Id1dn=0; constexpr size_t Id2up=2; constexpr size_t Id2dn=1; constexpr size_t incount=4; constexpr bool AN=true; constexpr bool AUS=false; constexpr bool ACTIVE_MUX=true; int pins[8] = {6, 7, 8, 9, 10, 11, 12, 13}; int muxes[4] = {3, 2, 4, 5}; const int inpins[incount] = {A0, A1, A2, A3}; const bool cg[11][7] = { /* 0 */ { /* a */ AN, /* b */ AN, /* c */ AN, /* d */ AN, /* e */ AN, /* f */ AN, /* g */ AUS }, /* 1 */ { /* a */ AUS, /* b */ AN, /* c */ AN, /* d */ AUS, /* e */ AUS, /* f */ AUS, /* g */ AUS }, /* 2 */ { /* a */ AN, /* b */ AN, /* c */ AUS, /* d */ AN, /* e */ AN, /* f */ AUS, /* g */ AN }, /* 3 */ { /* a */ AN, /* b */ AN, /* c */ AN, /* d */ AN, /* e */ AUS, /* f */ AUS, /* g */ AN }, /* 4 */ { /* a */ AUS, /* b */ AN, /* c */ AN, /* d */ AUS, /* e */ AUS, /* f */ AN, /* g */ AN }, /* 5 */ { /* a */ AN, /* b */ AUS, /* c */ AN, /* d */ AN, /* e */ AUS, /* f */ AN, /* g */ AN }, /* 6 */ { /* a */ AN, /* b */ AUS, /* c */ AN, /* d */ AN, /* e */ AN, /* f */ AN, /* g */ AN }, /* 7 */ { /* a */ AN, /* b */ AN, /* c */ AN, /* d */ AUS, /* e */ AUS, /* f */ AUS, /* g */ AUS }, /* 8 */ { /* a */ AN, /* b */ AN, /* c */ AN, /* d */ AN, /* e */ AN, /* f */ AN, /* g */ AN }, /* 9 */ { /* a */ AN, /* b */ AN, /* c */ AN, /* d */ AN, /* e */ AUS, /* f */ AN, /* g */ AN }, /* . */ { /* a */ AUS, /* b */ AUS, /* c */ AUS, /* d */ AUS, /* e */ AUS, /* f */ AUS, /* g */ AUS }, }; bool pressed[incount]={false, false, false, false}; uint8_t punkte1 = 0U; uint8_t punkte2 = 0U; void buttonHandler(uint8_t btnId, uint8_t btnState); uMuxOutputLib muxer(8U, 4U, pins, muxes, 200U); Button Button1up(Id1up, buttonHandler); Button Button1dn(Id1dn, buttonHandler); Button Button2up(Id2up, buttonHandler); Button Button2dn(Id2dn, buttonHandler); void yield(void) { Button1up.update(digitalRead(inpins[Id1up])); Button1dn.update(digitalRead(inpins[Id1dn])); Button2up.update(digitalRead(inpins[Id2up])); Button2dn.update(digitalRead(inpins[Id2dn])); } void buttonHandler(uint8_t btnId, uint8_t btnState) { if (btnState == BTN_PRESSED) { pressed[btnId] = true; } } void setup() { size_t i; for (i=0U; i 0U) { punkte1--; } } if (pressed[Id2up]) { pressed[Id2up] = false; if (punkte2 < 99U) { punkte2++; } } if (pressed[Id2dn]) { pressed[Id2dn] = false; if (punkte2 > 0U) { punkte2--; } } digit[0] = punkte1 / 10U; if (0U == digit[0]) { digit[0] = 10U; } digit[1] = punkte1 % 10U; digit[2] = punkte2 / 10U; if (0U == digit[2]) { digit[2] = 10U; } digit[3] = punkte2 % 10U; for (i=0U; i < 4U; i++) { for (j=0U; j<7U; j++) { yield(); muxer.setPinMuxPin(j, i, cg[digit[i]][j]); } } }