72 lines
3.4 KiB
C
72 lines
3.4 KiB
C
|
|
||
|
#ifndef Remote_Control_transceiver_H
|
||
|
#define Remote_Control_transceiver_H
|
||
|
|
||
|
//-------------- defines fpr the radio devices NRF24 ---------------------------------------------------------
|
||
|
|
||
|
#define STATION_SEL 4 // this 4 for Nano
|
||
|
typedef enum {BASESTATION = 0, TOPSTATION} radio_type_e;
|
||
|
#define RF24_CNS 7 // this is 7 for the Nano, D4 for the ESP
|
||
|
#define RF24_CE 8 // this is 8 for the Nano, D3 for the ESP
|
||
|
|
||
|
//--------------- define the structure and type of data that sender and receiver will exchange ----------------
|
||
|
|
||
|
typedef struct transcv_struct{
|
||
|
unsigned long topstationtime; // the top station sends its time (millis()) continously to the base station
|
||
|
unsigned long topbuttonpressedtime; // the top station sends the time in millis() when the button was pressed - this is already the calculated time
|
||
|
}transcv_s;
|
||
|
|
||
|
|
||
|
#define STOPBUTTON_IN D2 // this is the input for the button
|
||
|
#define STOPBUTTON_PRESSED HIGH // this the signal level the top button will be at as soon as pressed
|
||
|
#define MIN_DELAY_BETWEEN_PRESSED_MS 1000 // this defines the time in milliseconds before the button is expected to be pressed again. We do this to avaoid keybouncing
|
||
|
#define MIN_DELAY_BETWEEN_SEND_MS 1000 // this defines the time in milliseconds before the next set of data will be send to the base station - except the button was pressed.
|
||
|
|
||
|
#define STARTBUTTON_IN D4 // start button
|
||
|
#define STARTBUTTON_PRESSED LOW
|
||
|
#define CHANCELBUTTON_IN D2 // chancle button
|
||
|
#define CHANCELBUTTON_PRESSED LOW
|
||
|
#define FAILSTARTBUTTON_IN D3 // fail start button
|
||
|
#define FAILSTARTBUTTON_PRESSED LOW
|
||
|
|
||
|
#define WARN_LED A1 // yellow warn LED
|
||
|
#define WARN_LED_ON HIGH
|
||
|
#define WARN_LED_OFF LOW
|
||
|
#define FAIL_LED A3 // red fail LED
|
||
|
#define FAIL_LED_ON HIGH
|
||
|
#define FAIL_LED_OFF LOW
|
||
|
#define READY_LED A2 // green ready LED
|
||
|
#define READY_LED_ON HIGH
|
||
|
#define READY_LED_OFF LOW
|
||
|
#define RUN_LED A0 // blue run LED
|
||
|
#define RUN_LED_ON HIGH
|
||
|
#define RUN_LED_OFF LOW
|
||
|
|
||
|
|
||
|
typedef enum {TIMER_INIT = 0, TIMER_READY, TIMER_STARTED, TIMER_RUNNING , TIMER_CHANCELED, TIMER_STOPPED, TIMER_TIMEDOUT, TIMER_FAIL, TIMER_WAIT} timer_state_e;
|
||
|
|
||
|
// READY_LED, WARN_LED, RUN_LED, FAIL_LED
|
||
|
const float LEDStates[][3] =
|
||
|
{
|
||
|
TIMER_INIT = {READY_LED_OFF, RUN_LED_OFF, FAIL_LED_OFF},
|
||
|
TIMER_READY = {READY_LED_ON, RUN_LED_OFF, FAIL_LED_OFF},
|
||
|
TIMER_STARTED = {READY_LED_ON, RUN_LED_ON, FAIL_LED_OFF},
|
||
|
TIMER_RUNNING = {READY_LED_OFF, RUN_LED_ON, FAIL_LED_OFF},
|
||
|
TIMER_CHANCELED = {READY_LED_OFF, RUN_LED_OFF, FAIL_LED_ON},
|
||
|
TIMER_STOPPED = {READY_LED_ON, RUN_LED_ON, FAIL_LED_OFF},
|
||
|
TIMER_TIMEDOUT = {READY_LED_OFF, RUN_LED_ON, FAIL_LED_ON},
|
||
|
TIMER_FAIL = {READY_LED_OFF, RUN_LED_OFF, FAIL_LED_ON}
|
||
|
}
|
||
|
|
||
|
#define MAX_DIFFERENCE_OFFSET_MS 10 // 0,001sec is the maximum offset we allow between the current offset and the mean offset. if it is more - restart offset calculation
|
||
|
#define REQUIRED_NUMBER_MEANVALS 100 // we need at least this number of meanvalues to be ready to start a run
|
||
|
|
||
|
#define STARTSEQ_LENGTH_MS = 3100 // the length of the start sequence from the time the button was pressed ... includes the 3 tones
|
||
|
#define STARTSEQ_STARTPAUSE_MS = 1000
|
||
|
#define STARTSEQ_TONEPAUSE_MS = 800
|
||
|
#define STARTSEQ_TON_1_2_LENGTH_MS = 200
|
||
|
#define STARTSEQ_TON_3_LENGTH_MS = 100
|
||
|
#endif
|
||
|
|
||
|
|