From 18d2ae2f3c77e0d43061a9edcb85990368ec7af3 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Wed, 21 Sep 2022 14:36:28 +0200 Subject: [PATCH] add start/stop when brake is engaged --- avrIOhelper/io-helper.h | 4 +++- spule.c | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/avrIOhelper/io-helper.h b/avrIOhelper/io-helper.h index a684bce..a3bb43b 100644 --- a/avrIOhelper/io-helper.h +++ b/avrIOhelper/io-helper.h @@ -152,6 +152,8 @@ void ioHelperEdgeDetector(void); #define BTN_KRAFT_MINUS BitPinG2 #define IN_TAENZER_HOME BitPinF0 -#define IN_SPULE_HOME BitPinF1 +#define IN_SPULE_HOME BitPinF1 + +#define IN_BREMSE_STATE BitPinF2 #endif diff --git a/spule.c b/spule.c index eafe9cf..a0ab484 100644 --- a/spule.c +++ b/spule.c @@ -80,7 +80,7 @@ void do_spule(){ } // manual forwarding if button is held - else if(!get_abzug_state()){ + else if(!get_abzug_state() || (get_abzug_state() && read_Input(IN_BREMSE_STATE, LEVEL)) ){ if(read_Input(BTN_WICKELN_EIN, LEVEL)){ set_spooling_speed(300); spule_onoff(1); @@ -122,7 +122,7 @@ void do_spule(){ ICR1 = ICR5/TRANS_ROT_FACTOR; OCR1A = ICR1/2; - if (read_Input(BTN_WICKELN_EIN, RISING)) { + if (read_Input(BTN_WICKELN_EIN, RISING) && !read_Input(IN_BREMSE_STATE, LEVEL)) { spule_onoff(1); } if (read_Input(BTN_WICKELN_AUS, RISING)) { @@ -136,6 +136,17 @@ void do_spule(){ windings = 0; windings_wakeup = 0; } + + if (read_Input(IN_BREMSE_STATE, FALLING)) { + printf("draußen\n"); + spule_onoff(1); + } + + if (read_Input(IN_BREMSE_STATE, RISING)) { + printf("drinne\n"); + spule_onoff(0); + } + //PORTH |= (1<<5); }