From 31dec770d7562aced48038d07d5aba6df9d44cb4 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Tue, 1 Sep 2015 17:41:24 +0200 Subject: [PATCH 01/13] use interrupts for the buttons --- status/status.ino | 67 +++++++++-------------------------------------- 1 file changed, 13 insertions(+), 54 deletions(-) diff --git a/status/status.ino b/status/status.ino index 90bd397..7ffa80b 100644 --- a/status/status.ino +++ b/status/status.ino @@ -22,33 +22,18 @@ // Ein-/Ausgänge Bezeichnen const int BTN_ON = 2; // Einschalter +#define INTERRUPT_NAME_BTN_ON 0 const int BTN_OFF = 3; // Ausschalter +#define INTERRUPT_NAME_BTN_OFF 1 const int LED_G = 9; // grüne LED const int LED_Y = 8; // gelbe LED const int LED_R = 7; // rote LED // hier wird der aktuelle Zustand gespeichert -byte state = STATE_OFF; +volatile byte state = STATE_OFF; // hier wird der Beginn des aktuellen Zustand gespeichert in Millisekunden nach Uptime. -unsigned long stateBegan; - -// Debouncer -class Debounce -{ - public: - Debounce(int pin); - boolean update(); - int read(); - private: - int _pin; - int _state; - int _time; - int _delay; -}; - -Debounce debounceBtnOn(BTN_ON); -Debounce debounceBtnOff(BTN_OFF); +volatile unsigned long stateBegan; // wird einmalig beim Start des Arduinos ausgeführt void setup() { @@ -57,6 +42,8 @@ void setup() { pinMode(LED_R, OUTPUT); Serial.begin(9600); setStateOnLeds(); + attachInterrupt(INTERRUPT_NAME_BTN_ON, buttonOnPressed, RISING); + attachInterrupt(INTERRUPT_NAME_BTN_OFF, buttonOffPressed, RISING); } // bildet den aktuellen Zustand auf die LEDs ab @@ -77,18 +64,7 @@ unsigned long calcStateTime() { // wird nach dem Starten dauerhaft ausgeführt void loop() { - // Einschalter auslesen - if (debounceBtnOn.update() && debounceBtnOn.read()) { - state = STATE_ON; - stateBegan = millis(); - setStateOnLeds(); - } - // Ausschalter auslesen - if (debounceBtnOff.update() && debounceBtnOff.read()) { - state = STATE_OFF; - setStateOnLeds(); - } - + setStateOnLeds(); // Auswertung des aktuellen Zustandes // ggf Zustand wechseln if (state == STATE_ON) { @@ -110,28 +86,11 @@ void loop() { delay(10); } -// Debouncer Klasse -Debounce::Debounce(int pin) -{ - pinMode(pin, INPUT); - this->_pin = pin; - this->_time = 0; - this->_state = LOW; - this->_delay = 50; +void buttonOnPressed() { + state = STATE_OM; + stateBegan = millis(); } -boolean Debounce::update() -{ - if (millis() - this->_time >= this->_delay) { - int reading = digitalRead(this->_pin); - if (reading != this->_state) { - this->_time = millis(); - this->_state = reading; - return true; - } - } - return false; -} -int Debounce::read() -{ - return this->_state; + +void buttonOffPressed() { + state = STATE_OFF; } From 59ea61af0ff3d0a9be6c97a41ddec5a1eec12781 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Thu, 24 Sep 2015 13:49:22 +0200 Subject: [PATCH 02/13] typo FIX --- status/status.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/status/status.ino b/status/status.ino index 7ffa80b..3efb24b 100644 --- a/status/status.ino +++ b/status/status.ino @@ -87,7 +87,7 @@ void loop() { } void buttonOnPressed() { - state = STATE_OM; + state = STATE_ON; stateBegan = millis(); } From 096155c6cdf9f4b509cc9699dcf610f176821cc3 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Thu, 24 Sep 2015 13:49:55 +0200 Subject: [PATCH 03/13] cleanup --- status/status.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/status/status.ino b/status/status.ino index 3efb24b..a1b55ad 100644 --- a/status/status.ino +++ b/status/status.ino @@ -41,7 +41,6 @@ void setup() { pinMode(LED_Y, OUTPUT); pinMode(LED_R, OUTPUT); Serial.begin(9600); - setStateOnLeds(); attachInterrupt(INTERRUPT_NAME_BTN_ON, buttonOnPressed, RISING); attachInterrupt(INTERRUPT_NAME_BTN_OFF, buttonOffPressed, RISING); } From 5de12c41bbfd4d1f7697292695ee7c1d8853a0d8 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Thu, 24 Sep 2015 13:58:16 +0200 Subject: [PATCH 04/13] LED test runtime --- status/status.ino | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/status/status.ino b/status/status.ino index 90bd397..3fbc8c6 100644 --- a/status/status.ino +++ b/status/status.ino @@ -56,9 +56,20 @@ void setup() { pinMode(LED_Y, OUTPUT); pinMode(LED_R, OUTPUT); Serial.begin(9600); + testLeds(); setStateOnLeds(); } +// Schaltet alle LEDs nacheinander an +void testLeds() { + digitalWrite(LED_R, HIGH); + delay(1000); + digitalWrite(LED_Y, HIGH); + delay(1000); + digitalWrite(LED_G, HIGH); + delay(1000); +} + // bildet den aktuellen Zustand auf die LEDs ab void setStateOnLeds() { digitalWrite(LED_R, (state == STATE_OFF)); From e28463d0d92af40825985558b93a9314754d7185 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Thu, 24 Sep 2015 14:50:44 +0200 Subject: [PATCH 05/13] =?UTF-8?q?verwende=20Funktionen=20f=C3=BCr=20Zustan?= =?UTF-8?q?ds=C3=A4nderung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- status/status.ino | 87 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 25 deletions(-) diff --git a/status/status.ino b/status/status.ino index 3fbc8c6..779798e 100644 --- a/status/status.ino +++ b/status/status.ino @@ -27,8 +27,9 @@ const int LED_G = 9; // grüne LED const int LED_Y = 8; // gelbe LED const int LED_R = 7; // rote LED -// hier wird der aktuelle Zustand gespeichert -byte state = STATE_OFF; +// hier wird der aktuelle und vorherige Zustand gespeichert +byte state_current = NULL; +byte state_previous = NULL; // hier wird der Beginn des aktuellen Zustand gespeichert in Millisekunden nach Uptime. unsigned long stateBegan; @@ -57,7 +58,7 @@ void setup() { pinMode(LED_R, OUTPUT); Serial.begin(9600); testLeds(); - setStateOnLeds(); + changeStateTo(STATE_OFF); } // Schaltet alle LEDs nacheinander an @@ -70,11 +71,56 @@ void testLeds() { delay(1000); } -// bildet den aktuellen Zustand auf die LEDs ab -void setStateOnLeds() { - digitalWrite(LED_R, (state == STATE_OFF)); - digitalWrite(LED_Y, (state == STATE_HALF)); - digitalWrite(LED_G, (state == STATE_ON)); +// wechselt zu neuen Zustand +void changeStateTo(byte state_new) { + state_previous = state_current; + state_current = state_new; + transition(); +} + +// behandelt die Zustandübergänge +boolean transition() { + if (state_previous == STATE_OFF && state_current == STATE_ON) { + digitalWrite(LED_R, LOW); + digitalWrite(LED_G, HIGH); + stateBegan = millis(); + return true; + } + if (state_previous == STATE_ON && state_current == STATE_ON) { // STATE_ON ist reflexiv + stateBegan = millis(); + return true; + } + if (state_previous == STATE_ON && state_current == STATE_HALF) { + digitalWrite(LED_G, LOW); + digitalWrite(LED_Y, HIGH); + return true; + } + if (state_previous == STATE_ON && state_current == STATE_OFF) { + digitalWrite(LED_G, LOW); + digitalWrite(LED_R, HIGH); + return true; + } + if (state_previous == STATE_HALF && state_current == STATE_OFF) { + digitalWrite(LED_Y, LOW); + digitalWrite(LED_R, HIGH); + return true; + } + if (state_previous == NULL && state_current == STATE_OFF) { + digitalWrite(LED_G, LOW); + digitalWrite(LED_Y, LOW); + digitalWrite(LED_R, HIGH); + return true; + } + return false; +} + +// information über aktuellen Zustand auf die Serielle Verbindung schreiben +void sendState() { + if (state_current == STATE_ON || state_current == STATE_HALF) { + Serial.print("1"); + } else { + Serial.print("0"); + } } unsigned long calcStateTime() { @@ -90,34 +136,25 @@ unsigned long calcStateTime() { void loop() { // Einschalter auslesen if (debounceBtnOn.update() && debounceBtnOn.read()) { - state = STATE_ON; - stateBegan = millis(); - setStateOnLeds(); + changeStateTo(STATE_ON); } // Ausschalter auslesen if (debounceBtnOff.update() && debounceBtnOff.read()) { - state = STATE_OFF; - setStateOnLeds(); + changeStateTo(STATE_OFF); } // Auswertung des aktuellen Zustandes // ggf Zustand wechseln - if (state == STATE_ON) { + if (state_current == STATE_ON) { if (calcStateTime() >= TIME_HALF) { - state = STATE_HALF; - setStateOnLeds(); + changeStateTo(STATE_HALF); } - } else if (state == STATE_HALF && calcStateTime() >= TIME_OFF) { - state = STATE_OFF; - setStateOnLeds(); + } else if (state_current == STATE_HALF && calcStateTime() >= TIME_OFF) { + changeStateTo(STATE_OFF); } - // aktuellen Zustand auf die Serielle Verbindung schreiben - if (state == STATE_ON || state == STATE_HALF) { - Serial.print("1"); - } else { - Serial.print("0"); - } + // kommunizieren + sendState(); delay(10); } From e1f983a03fd8ca1e391aab3a3147e3ed3f90c183 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Thu, 24 Sep 2015 15:12:14 +0200 Subject: [PATCH 06/13] FIX STATE_OFF == NULL --- status/status.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/status/status.ino b/status/status.ino index 779798e..041eb58 100644 --- a/status/status.ino +++ b/status/status.ino @@ -4,7 +4,7 @@ * 1 - An, aber auf dem weg zu aus * 2 - An */ -#define STATE_OFF 0 +#define STATE_OFF 3 #define STATE_HALF 1 #define STATE_ON 2 From 6d3ee6202a92be384cfdf7a435943026c2a60426 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Mon, 28 Sep 2015 22:37:19 +0200 Subject: [PATCH 07/13] =?UTF-8?q?FIX=20zustands=C3=BCberf=C3=BChrung=20ver?= =?UTF-8?q?gessen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- status/status.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/status/status.ino b/status/status.ino index 041eb58..0c902eb 100644 --- a/status/status.ino +++ b/status/status.ino @@ -105,6 +105,12 @@ boolean transition() { digitalWrite(LED_R, HIGH); return true; } + if (state_previous == STATE_HALF && state_current == STATE_ON) { + digitalWrite(LED_Y, LOW); + digitalWrite(LED_G, HIGH); + stateBegan = millis(); + return true; + } if (state_previous == NULL && state_current == STATE_OFF) { digitalWrite(LED_G, LOW); digitalWrite(LED_Y, LOW); From 22f8aca3ca67c349f8d402716660c7d45a536dc0 Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Mon, 26 Oct 2015 21:40:51 +0100 Subject: [PATCH 08/13] Debounce for button interrupts --- status/status.ino | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/status/status.ino b/status/status.ino index a1b55ad..68f36f5 100644 --- a/status/status.ino +++ b/status/status.ino @@ -35,14 +35,18 @@ volatile byte state = STATE_OFF; // hier wird der Beginn des aktuellen Zustand gespeichert in Millisekunden nach Uptime. volatile unsigned long stateBegan; +const long debouncing_time = 50; //Debouncing Time in Milliseconds +volatile unsigned long last_buttonOnPressed; +volatile unsigned long last_buttonOffPressed; + // wird einmalig beim Start des Arduinos ausgeführt void setup() { pinMode(LED_G, OUTPUT); pinMode(LED_Y, OUTPUT); pinMode(LED_R, OUTPUT); Serial.begin(9600); - attachInterrupt(INTERRUPT_NAME_BTN_ON, buttonOnPressed, RISING); - attachInterrupt(INTERRUPT_NAME_BTN_OFF, buttonOffPressed, RISING); + attachInterrupt(INTERRUPT_NAME_BTN_ON, buttonOnPressedDebounce, RISING); + attachInterrupt(INTERRUPT_NAME_BTN_OFF, buttonOffPressedDebounce, RISING); } // bildet den aktuellen Zustand auf die LEDs ab @@ -85,11 +89,25 @@ void loop() { delay(10); } +void buttonOnPressedDebounce() { + if (millis() - last_buttonOnPressed >= debouncing_time) { + buttonOnPressed(); + last_buttonOnPressed = millis(); + } +} + void buttonOnPressed() { state = STATE_ON; stateBegan = millis(); } +void buttonOffPressedDebounce() { + if (millis() - last_buttonOffPressed >= debouncing_time) { + buttonOffPressed(); + last_buttonOffPressed = millis(); + } +} + void buttonOffPressed() { state = STATE_OFF; } From babb27e5ea50c37f97e8fe318d0f38a57980f6db Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Tue, 10 May 2016 20:42:49 +0200 Subject: [PATCH 09/13] use limits.h --- status/status.ino | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/status/status.ino b/status/status.ino index 0c902eb..f1d8ef3 100644 --- a/status/status.ino +++ b/status/status.ino @@ -1,3 +1,4 @@ +#include /* * es gibt folgende Zustände: * 0 - Aus @@ -17,9 +18,6 @@ #define TIME_HALF 5400000 // 1,5h #define TIME_OFF 7200000 // 2h -// für Variablen Überlauf in calcStateTime -#define MAX_LONG 4294967295 - // Ein-/Ausgänge Bezeichnen const int BTN_ON = 2; // Einschalter const int BTN_OFF = 3; // Ausschalter @@ -134,7 +132,7 @@ unsigned long calcStateTime() { if (millis() - stateBegan >= 0) { return millis() - stateBegan; } else { - return millis() + (MAX_LONG - stateBegan); + return millis() + (ULONG_MAX - stateBegan); } } From 643778a27c85f3e69ba4b670c6862163164fcfae Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Tue, 10 May 2016 21:02:35 +0200 Subject: [PATCH 10/13] =?UTF-8?q?=C3=9Cberlaufbehandlung=20=C3=BCberarbeit?= =?UTF-8?q?et?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- status/status.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/status/status.ino b/status/status.ino index f1d8ef3..66ffc78 100644 --- a/status/status.ino +++ b/status/status.ino @@ -129,11 +129,12 @@ void sendState() { unsigned long calcStateTime() { // Variablen überlauf von millis erkennen - if (millis() - stateBegan >= 0) { - return millis() - stateBegan; - } else { - return millis() + (ULONG_MAX - stateBegan); + unsigned long current_uptime = millis(); + // kein überlauf + if (current_uptime > stateBegan) { + return current_uptime - stateBegan; } + return current_uptime + (ULONG_MAX - stateBegan); } // wird nach dem Starten dauerhaft ausgeführt From a495c47591577c889843b2afefb040ac0ee88a84 Mon Sep 17 00:00:00 2001 From: Lowl3v3l Date: Tue, 10 May 2016 22:30:32 +0200 Subject: [PATCH 11/13] added a Makefile that lacks a solid avrdude-command, added dependency files to gitignore --- Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..43f7f4f --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +SRC:=$(shell find src -regex '.*\.c') +OBJ:=$(patsubst %,%.o,$(SRC)) +DEP:=$(patsubst %,%.d,$(SRC)) + +CC?=avr-gcc + +CFLAGS?= -O2 -ggdb -std=gnu11 -fomit-frame-pointer -fmerge-all-constants\ +-faggressive-loop-optimizations -finline-functions -funsafe-loop-optimizations\ +-ffreestanding -Wlogical-op -Wdouble-promotion -Wformat -Winit-self -Wnormalized\ +-Wmissing-include-dirs -Wswitch-default -Wpadded -Wswitch-enum -Wall\ +-Wunused -Winline -Wuninitialized -Wstrict-overflow -Wpointer-sign\ +-Wfloat-equal -Wstack-protector -Wtraditional-conversion -Wundef -Wvla\ +-Wdeclaration-after-statement -Wshadow -Wcast-align -Wpedantic -Wextra\ +-Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wtrampolines -Wpacked\ +-Wconversion -Wdate-time -Waggregate-return -Wstrict-prototypes\ +-Wold-style-definition -Wmissing-prototypes -Wvector-operation-performance\ +-Wredundant-decls -Wnested-externs -Wlong-long -Wvariadic-macros\ +-Wdisabled-optimization -Wmissing-declarations -Wunsafe-loop-optimizations\ +-Wunsuffixed-float-constants -pipe -Werror + +ARDUINO?= +PROGRAMMER?= + +.PHONY: all clean check install build + +all: build + +# TODO : find a install commandline +#install: build +# avrdude + +clean: + rm $(OBJ) $(DEP) + +check: + $(CC) $(CFLAGS) -fsyntax-only $(SRC) + +build: $(SRC) + $(CC) $(CFLAGS) $(SRC) -MMD -MP -o hackspace-status.sys + +-include $(sort $(DEP)) \ No newline at end of file From 33bce81a421fffa232b147b07cef3ec8422d7a5e Mon Sep 17 00:00:00 2001 From: Martin Ness Date: Wed, 11 May 2016 00:03:35 +0200 Subject: [PATCH 12/13] =?UTF-8?q?anpassungen=20f=C3=BCr=20nutzung=20von=20?= =?UTF-8?q?Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 26 ++++++++++-------- status/{status.ino => status.cpp} | 44 +++++++++++++++++++------------ 2 files changed, 42 insertions(+), 28 deletions(-) rename status/{status.ino => status.cpp} (84%) diff --git a/Makefile b/Makefile index 43f7f4f..d74b3d5 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,26 @@ -SRC:=$(shell find src -regex '.*\.c') +SRC:=$(shell find status -regex '.*\.cpp') OBJ:=$(patsubst %,%.o,$(SRC)) DEP:=$(patsubst %,%.d,$(SRC)) CC?=avr-gcc -CFLAGS?= -O2 -ggdb -std=gnu11 -fomit-frame-pointer -fmerge-all-constants\ +CFLAGS?= -O2 -ggdb -std=gnu++11 -fomit-frame-pointer -fmerge-all-constants\ -faggressive-loop-optimizations -finline-functions -funsafe-loop-optimizations\ --ffreestanding -Wlogical-op -Wdouble-promotion -Wformat -Winit-self -Wnormalized\ +-ffreestanding -Wlogical-op -Wdouble-promotion -Wformat -Winit-self\ -Wmissing-include-dirs -Wswitch-default -Wpadded -Wswitch-enum -Wall\ --Wunused -Winline -Wuninitialized -Wstrict-overflow -Wpointer-sign\ --Wfloat-equal -Wstack-protector -Wtraditional-conversion -Wundef -Wvla\ --Wdeclaration-after-statement -Wshadow -Wcast-align -Wpedantic -Wextra\ --Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wtrampolines -Wpacked\ --Wconversion -Wdate-time -Waggregate-return -Wstrict-prototypes\ --Wold-style-definition -Wmissing-prototypes -Wvector-operation-performance\ --Wredundant-decls -Wnested-externs -Wlong-long -Wvariadic-macros\ +-Wunused -Winline -Wuninitialized -Wstrict-overflow\ +-Wfloat-equal -Wstack-protector -Wundef -Wvla\ +-Wshadow -Wcast-align -Wpedantic -Wextra\ +-Wpointer-arith -Wwrite-strings -Wtrampolines -Wpacked\ +-Wconversion -Wdate-time -Waggregate-return\ +-Wvector-operation-performance\ +-Wredundant-decls -Wlong-long -Wvariadic-macros\ -Wdisabled-optimization -Wmissing-declarations -Wunsafe-loop-optimizations\ --Wunsuffixed-float-constants -pipe -Werror +-pipe -Werror -fno-exceptions -fno-rtti\ +-I/usr/share/arduino/hardware/arduino/cores/arduino\ +-I/usr/share/arduino/hardware/arduino/variants/micro\ +-I/usr/lib/avr/include/\ +-DF_CPU=16000000L -MMD -DUSB_VID=0x2341 -DUSB_PID=0x8037 -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -mmcu=atmega32u4 ARDUINO?= PROGRAMMER?= diff --git a/status/status.ino b/status/status.cpp similarity index 84% rename from status/status.ino rename to status/status.cpp index 66ffc78..5ef8e79 100644 --- a/status/status.ino +++ b/status/status.cpp @@ -1,13 +1,23 @@ -#include +#include +#include +#include "Arduino.h" + +void setup(); +void testLeds(); +void loop(); +void changeStateTo(char state_new); +bool transition(); +void sendState(); +unsigned long calcStateTime(); /* * es gibt folgende Zustände: * 0 - Aus * 1 - An, aber auf dem weg zu aus * 2 - An */ -#define STATE_OFF 3 -#define STATE_HALF 1 -#define STATE_ON 2 +constexpr char STATE_OFF = 3; +constexpr char STATE_HALF = 1; +constexpr char STATE_ON = 2; /* * Zeit wie lange in einem Zustände verharrt werden soll @@ -15,19 +25,19 @@ * TIME_HALF - Zeitspanne von Zustand 2 bis Wechsel zu Zustand 1 * TIME_OFF - Zeitspanne von Zustand 2 bis Wechsel zu Zustand 0 */ -#define TIME_HALF 5400000 // 1,5h -#define TIME_OFF 7200000 // 2h +constexpr int TIME_HALF = 5400000; // 1,5h +constexpr int TIME_OFF = 7200000; // 2h // Ein-/Ausgänge Bezeichnen -const int BTN_ON = 2; // Einschalter -const int BTN_OFF = 3; // Ausschalter -const int LED_G = 9; // grüne LED -const int LED_Y = 8; // gelbe LED -const int LED_R = 7; // rote LED +constexpr int BTN_ON = 2; // Einschalter +constexpr int BTN_OFF = 3; // Ausschalter +constexpr int LED_G = 9; // grüne LED +constexpr int LED_Y = 8; // gelbe LED +constexpr int LED_R = 7; // rote LED // hier wird der aktuelle und vorherige Zustand gespeichert -byte state_current = NULL; -byte state_previous = NULL; +char state_current = STATE_OFF; +char state_previous = STATE_OFF; // hier wird der Beginn des aktuellen Zustand gespeichert in Millisekunden nach Uptime. unsigned long stateBegan; @@ -37,7 +47,7 @@ class Debounce { public: Debounce(int pin); - boolean update(); + bool update(); int read(); private: int _pin; @@ -70,14 +80,14 @@ void testLeds() { } // wechselt zu neuen Zustand -void changeStateTo(byte state_new) { +void changeStateTo(char state_new) { state_previous = state_current; state_current = state_new; transition(); } // behandelt die Zustandübergänge -boolean transition() { +bool transition() { if (state_previous == STATE_OFF && state_current == STATE_ON) { digitalWrite(LED_R, LOW); digitalWrite(LED_G, HIGH); @@ -172,7 +182,7 @@ Debounce::Debounce(int pin) this->_state = LOW; this->_delay = 50; } -boolean Debounce::update() +bool Debounce::update() { if (millis() - this->_time >= this->_delay) { int reading = digitalRead(this->_pin); From 5848da7f24662e4cd3420baf2880329194dd27fe Mon Sep 17 00:00:00 2001 From: chuckthegecko <32848614+chuckthegecko@users.noreply.github.com> Date: Mon, 4 Jun 2018 18:54:20 +0200 Subject: [PATCH 13/13] Fixed link in readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6293943..8f87533 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ hackerspace-status-arduino ========================== -see https://www.krautspace.de/hswiki:projekte:elektronikrunde:status_anzeige +see https://kraut.space/hswiki:projekte:2014:raumstatus_anzeige