Inputs logic added

This commit is contained in:
Andrew Shkolik 2019-12-24 23:41:04 -06:00
parent e2bbe8a422
commit 6906f1652e
3 changed files with 42 additions and 11 deletions

View File

@ -667,7 +667,22 @@ bool Update_All()
{ {
uint32_t chan_or=chan_order; uint32_t chan_or=chan_order;
uint8_t ch; uint8_t ch;
for(uint8_t i=0;i<PPM_chan_max;i++) uint8_t channels_count = PPM_chan_max;
#ifdef ENABLE_DIRECT_INPUTS
#ifdef DI_CH1_read
PPM_data[channels_count++] = DI_CH1_read
#endif
#ifdef DI_CH2_read
PPM_data[channels_count++] = DI_CH2_read
#endif
#ifdef DI_CH3_read
PPM_data[channels_count++] = DI_CH3_read
#endif
#ifdef DI_CH4_read
PPM_data[channels_count++] = DI_CH4_read
#endif
#endif
for(uint8_t i=0;i<channels_count;i++)
{ // update servo data without interrupts to prevent bad read { // update servo data without interrupts to prevent bad read
uint16_t val; uint16_t val;
cli(); // disable global int cli(); // disable global int

View File

@ -23,7 +23,7 @@
//If you know parameters you want for sure to be enabled or disabled which survives in future, you can use a file named "_MyConfig.h". //If you know parameters you want for sure to be enabled or disabled which survives in future, you can use a file named "_MyConfig.h".
//An example is given within the file named "_MyConfig.h.example" which needs to be renamed if you want to use it. //An example is given within the file named "_MyConfig.h.example" which needs to be renamed if you want to use it.
//To enable this config file remove the // from the line below. //To enable this config file remove the // from the line below.
//#define USE_MY_CONFIG #define USE_MY_CONFIG
/*************************/ /*************************/
@ -498,15 +498,31 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
//Direct inputs works only in ppm mode and only for stm_32 boards //Direct inputs works only in ppm mode and only for stm_32 boards
#if defined(ENABLE_PPM) && defined (STM32_BOARD) && not defined (ENABLE_SERIAL) #if defined(ENABLE_PPM) && defined (STM32_BOARD) && not defined (ENABLE_SERIAL)
//If plan to use direct input mode please uncomment lines below //If plan to use direct input mode please uncomment lines below
//#define ENABLE_DIRECT_INPUTS #define ENABLE_DIRECT_INPUTS
// //
//Direct inputs start channel
//Uncomment and change from what channel direct inputs starts #define DI1_PIN PC13
//#define DIRECT_INPUTS_START 7 #define DI1_SET_INPUT pinMode(DI1_PIN,INPUT)
// #define DI1_SET_PULLUP digitalWrite(DI1_PIN,HIGH)
#define IS_DI1_on (digitalRead(DI1_PIN)==LOW)
#define DI2_PIN PC14
#define DI2_SET_INPUT pinMode(DI2_PIN,INPUT)
#define DI2_SET_PULLUP digitalWrite(DI2_PIN,HIGH)
#define IS_DI2_on (digitalRead(DI2_PIN)==LOW)
#define DI3_PIN PC15
#define DI3_SET_INPUT pinMode(DI3_PIN,INPUT)
#define DI3_SET_PULLUP digitalWrite(DI3_PIN,HIGH)
#define IS_DI3_on (digitalRead(DI3_PIN)==LOW)
//CHANNEL1 - 2pos switch
#define DI_CH1_read IS_DI1_on ? PPM_MAX_100*2 : PPM_MIN_100*2
//CHANNEL2 - 3pos switch
#define DI_CH2_read IS_DI2_on ? PPM_MAX_100*2 : (IS_DI2_on ? PPM_MAX_100 + PPM_MIN_100 : PPM_MIN_100*2)
#endif
#endif #endif
/* Available protocols and associated sub protocols to pick and choose from (Listed in alphabetical order) /* Available protocols and associated sub protocols to pick and choose from (Listed in alphabetical order)
PROTO_AFHDS2A PROTO_AFHDS2A