No rocket science... I just added another control mode to readout 2 analog sticks from a PSP2 gamepad via ADC2-5 to ch0-ch3
change config
- Code: Select all
#if (TX_BOARD_TYPE == 0)
#define PPM_IN A5
// #define RF_OUT_INDICATOR A4
#define RF_OUT_INDICATOR 8 //ADC4 needed for poti
add
- Code: Select all
unsigned int adc_temp;
to the mains var section
paste in the main function under the #if (CONTROL_TYPE==1) section,
- Code: Select all
#if (CONTROL_TYPE==2) //read ADC inputs A2-A5
adc_temp = analogRead(A3);
adc_temp = adc_temp + 2500;
if ((adc_temp>1500) && (adc_temp<4500)) // check the signal time and update the channel if it is between 750us-2250us
{SetServoPos(0,adc_temp);}
adc_temp = analogRead(A4);
adc_temp = 3500 - adc_temp; //reversed
if ((adc_temp>1500) && (adc_temp<4500)) // check the signal time and update the channel if it is between 750us-2250us
{SetServoPos(1,adc_temp);}
adc_temp = analogRead(A5);
adc_temp = adc_temp + 2500;
if ((adc_temp>1500) && (adc_temp<4500)) // check the signal time and update the channel if it is between 750us-2250us
{SetServoPos(2,adc_temp);}
adc_temp = analogRead(A2);
adc_temp = 3500 - adc_temp; //reversed
if ((adc_temp>1500) && (adc_temp<4500)) // check the signal time and update the channel if it is between 750us-2250us
{SetServoPos(3,adc_temp);}
#endif
This is the first qnd approach. I thought about a looped version but with this solution it´s easier to change channel assignments/reverse channels for testing. The signal check can be also dropped as the ADC outputs shoud be consistent between 0 and 1023.
I´ll start to refine code for travel adjustment etc. when all is fitted insight the gamepad, atm the basic function is sufficient for an 1:18 mini inferno.
On the genuine modules from Melih you have access to ADC4/5 only via the futuba pins. I use a basic setup with a pro mini, so I can use ADC2-5. Maybe nice for future versions to change SW to I2C ADCs and also use eg PCF8574 to check all the buttons for setup purpose/funktions/have at running as an I2C addon module to Melihs RX/TX.
Regards,
gompf










