From 9d41fe830e6e32e955daef2197892bf14c3a44ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nidecki?= Date: Sun, 22 Jan 2017 16:50:09 +0100 Subject: [PATCH] Disabling device using button --- config.h | 4 +++- main.c | 14 ++++++++++++-- rtty.coproj | 8 ++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index fd54218..c102d96 100644 --- a/config.h +++ b/config.h @@ -15,6 +15,7 @@ #define APRS_FREQUENCY 432.500f //Mhz middle frequency //************rtty speed****************** si4032 #define RTTY_SPEED 300 +// SHITY -> 450Hz //************rtty bits****************** si4032 #define RTTY_7BIT 1 //************rtty stop bits****************** si4032 @@ -23,7 +24,8 @@ #define Smoc 7 // PWR 0...7 0- MIN ... 7 - MAX // 7 -> 42.95 mW@434.150 MHz na E4406A //*************************************************** - +// WARNING: do not use this in flying tracker! +#define ALLOW_DISABLE_BY_BUTTON 1 //********** frame delay in msec********** #define tx_delay 5000 diff --git a/main.c b/main.c index ea5df56..37c42e0 100644 --- a/main.c +++ b/main.c @@ -46,6 +46,7 @@ volatile unsigned int tx_on_delay; volatile unsigned char tx_enable = 0; rttyStates send_rtty_status = rttyZero; volatile char *rtty_buf; +volatile uint16_t button_pressed = 0; unsigned char cun_off = 0; void send_rtty_packet(); @@ -104,6 +105,16 @@ void TIM2_IRQHandler(void) { } cun = 200; } + if (ALLOW_DISABLE_BY_BUTTON){ + if (ADCVal[1] > 1900){ + button_pressed++; + if (button_pressed > (10 * RTTY_SPEED)){ + GPIO_SetBits(GPIOA, GPIO_Pin_12); + } + } else { + button_pressed = 0; + } + } } } @@ -149,8 +160,7 @@ int main(void) { rtty_buf = buf_rtty; tx_on = 0; tx_enable = 1; - //tx_enable =0; - //Button = ADCVal[1]; + aprs_init(); radio_enable_tx(); diff --git a/rtty.coproj b/rtty.coproj index 9aec786..dc8eb1b 100644 --- a/rtty.coproj +++ b/rtty.coproj @@ -86,8 +86,8 @@ - + @@ -100,8 +100,8 @@ - + @@ -113,14 +113,14 @@ - + - +