Added improvement to AUX command processing
Improved the speed of the processing of aux commands from the rc that handles various bolean flags in the system. Also added some more commenting to the failsafe and toggles fiels. Also updated the motor 7 and 8s information in the REVO.h
This commit is contained in:
parent
d72e7e099b
commit
dfac730893
@ -105,62 +105,76 @@ extern boolFlags_t systemFlags;
|
||||
extern flags_Configuration_t flagConfigArr[FLAG_CONFIGURATION_COUNT];
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Could be used to set start values for some values
|
||||
* INFORMATION: Possible to set the values for any of the failsafes
|
||||
***********************************************************************/
|
||||
void initFlags();
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Process RC channels that should operate on some flags
|
||||
* INFORMATION: Reads the value of the RC channels that and checks if
|
||||
* any of the channels should handle some flag value in the
|
||||
* system. If it should it will update its state.
|
||||
***********************************************************************/
|
||||
void flags_ProcessRcChannel(int rcChannel_ID, int value);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Process RC channels that should operate on some flags
|
||||
* INFORMATION: Reads the value of the RC channels that and checks if
|
||||
* any of the channels should handle some flag value in the
|
||||
* system. If it should it will update its state.
|
||||
***********************************************************************/
|
||||
void flags_ProcessRcChannel_Improved(uint8_t minChannel, uint8_t maxChannel);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF: Set flag to true(1)
|
||||
* INFORMATION: Given an id set that value to true
|
||||
***********************************************************************/
|
||||
void flags_Set_ID(int id);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Set flag to false(0)
|
||||
* INFORMATION: Given an id set that value to false
|
||||
***********************************************************************/
|
||||
void flags_Clear_ID(int id);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Toggle a flag
|
||||
* INFORMATION: Given an id changes the current value of a flag to its
|
||||
* opposite.
|
||||
***********************************************************************/
|
||||
void flags_Toggle_ID(int id);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Checks if a flag is set
|
||||
* INFORMATION: Given an id value, check if that is set to true in the
|
||||
* bitfield
|
||||
***********************************************************************/
|
||||
bool flags_IsSet_ID(int id);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Set flag to true(1)
|
||||
* INFORMATION: Given a mask set that value to true
|
||||
***********************************************************************/
|
||||
void flags_Set_MASK(int mask);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Set flag to false(0)
|
||||
* INFORMATION: Given a mask set that value to false
|
||||
***********************************************************************/
|
||||
void flags_Clear_MASK(int mask);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Toggle a flag
|
||||
* INFORMATION: Given a mask changes the current value of a flag to its
|
||||
* opposite.
|
||||
***********************************************************************/
|
||||
void flags_Toggle_MASK(int mask);
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Checks if a flag is set
|
||||
* INFORMATION: Given a mask value, check if that is set to true in the
|
||||
* bitfield
|
||||
***********************************************************************/
|
||||
bool flags_IsSet_MASK(int mask);
|
||||
|
||||
|
@ -196,15 +196,15 @@
|
||||
#define MOTOR_6_CHANNEL TIM_CHANNEL_1
|
||||
|
||||
#define MOTOR_7 7
|
||||
#define MOTOR_7_PIN GPIO_PIN_6
|
||||
#define MOTOR_7_PORT GPIOC
|
||||
#define MOTOR_7_TIM TIM8
|
||||
#define MOTOR_7_PIN GPIO_PIN_14
|
||||
#define MOTOR_7_PORT GPIOB
|
||||
#define MOTOR_7_TIM TIM12
|
||||
#define MOTOR_7_CHANNEL TIM_CHANNEL_1
|
||||
|
||||
#define MOTOR_8 8
|
||||
#define MOTOR_8_PIN GPIO_PIN_7
|
||||
#define MOTOR_8_PORT GPIOC
|
||||
#define MOTOR_8_TIM TIM8
|
||||
#define MOTOR_8_PIN GPIO_PIN_15
|
||||
#define MOTOR_8_PORT GPIOB
|
||||
#define MOTOR_8_TIM TIM12
|
||||
#define MOTOR_8_CHANNEL TIM_CHANNEL_2
|
||||
|
||||
#define MOTOR_9 9
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "drivers/failsafe_toggles.h"
|
||||
#include "drivers/sbus.h"
|
||||
|
||||
/* Stuct containing values for all the flags and failsafe booleans sin the system */
|
||||
boolFlags_t systemFlags = {{0}};
|
||||
@ -63,17 +64,19 @@ flags_Configuration_t flagConfigArr[FLAG_CONFIGURATION_COUNT] = {
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Could be used to set start values for some values
|
||||
* INFORMATION: Possible to set the values for any of the failsafes
|
||||
***********************************************************************/
|
||||
void initFlags()
|
||||
{
|
||||
systemFlags.intRepresentation = 0;
|
||||
//Could be used to set start values for failsafes.
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Process RC channels that should operate on some flags
|
||||
* INFORMATION: Reads the value of the RC channels that and checks if
|
||||
* any of the channels should handle some flag value in the
|
||||
* system. If it should it will update its state.
|
||||
***********************************************************************/
|
||||
void flags_ProcessRcChannel(int rcChannel_ID, int value)
|
||||
{
|
||||
@ -94,8 +97,42 @@ void flags_ProcessRcChannel(int rcChannel_ID, int value)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Process RC channels that should operate on some flags
|
||||
* INFORMATION: Reads the value of the RC channels that and checks if
|
||||
* any of the channels should handle some flag value in the
|
||||
* system. If it should it will update its state.
|
||||
***********************************************************************/
|
||||
void flags_ProcessRcChannel_Improved(uint8_t minChannel, uint8_t maxChannel)
|
||||
{
|
||||
//Loop through all the active flag configuration values
|
||||
for (int i = 0; i < FLAG_CONFIGURATION_COUNT; i++)
|
||||
{
|
||||
int currentChannelNumb = flagConfigArr[i].channelNumber;
|
||||
//Check if the current Flag channel is within the set bounds
|
||||
if(currentChannelNumb >= 5 && currentChannelNumb <= maxChannel)
|
||||
{
|
||||
//Get the value for the channel that the current flag is linked to
|
||||
int value = getChannelValue(sbusChannelData, currentChannelNumb);
|
||||
|
||||
if(value >= flagConfigArr[i].minRange && value <= flagConfigArr[i].maxRange)
|
||||
{
|
||||
flags_Set_ID(flagConfigArr[i].flagId);
|
||||
}
|
||||
else
|
||||
{
|
||||
flags_Clear_ID(flagConfigArr[i].flagId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF: Set flag to true(1)
|
||||
* INFORMATION: Given a mask set that value to true
|
||||
***********************************************************************/
|
||||
void flags_Set_MASK(int mask)
|
||||
{
|
||||
@ -103,8 +140,8 @@ void flags_Set_MASK(int mask)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Set flag to false(0)
|
||||
* INFORMATION: Given a mask set that value to false
|
||||
***********************************************************************/
|
||||
void flags_Clear_MASK(int mask)
|
||||
{
|
||||
@ -112,8 +149,9 @@ void flags_Clear_MASK(int mask)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Toggle a flag
|
||||
* INFORMATION: Given a mask changes the current value of a flag to its
|
||||
* opposite.
|
||||
***********************************************************************/
|
||||
void flags_Toggle_MASK(int mask)
|
||||
{
|
||||
@ -121,8 +159,9 @@ void flags_Toggle_MASK(int mask)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Checks if a flag is set
|
||||
* INFORMATION: Given a mask value, check if that is set to true in the
|
||||
* bitfield
|
||||
***********************************************************************/
|
||||
bool flags_IsSet_MASK(int mask)
|
||||
{
|
||||
@ -130,8 +169,8 @@ bool flags_IsSet_MASK(int mask)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Set flag to true(1)
|
||||
* INFORMATION: Given an id set that value to true
|
||||
***********************************************************************/
|
||||
void flags_Set_ID(int id)
|
||||
{
|
||||
@ -139,8 +178,8 @@ void flags_Set_ID(int id)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Set flag to false(0)
|
||||
* INFORMATION: Given an id set that value to false
|
||||
***********************************************************************/
|
||||
void flags_Clear_ID(int id)
|
||||
{
|
||||
@ -148,8 +187,9 @@ void flags_Clear_ID(int id)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Toggle a flag
|
||||
* INFORMATION: Given an id changes the current value of a flag to its
|
||||
* opposite.
|
||||
***********************************************************************/
|
||||
void flags_Toggle_ID(int id)
|
||||
{
|
||||
@ -157,8 +197,9 @@ void flags_Toggle_ID(int id)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF:
|
||||
* INFORMATION:
|
||||
* BRIEF: Checks if a flag is set
|
||||
* INFORMATION: Given an id value, check if that is set to true in the
|
||||
* bitfield
|
||||
***********************************************************************/
|
||||
bool flags_IsSet_ID(int id)
|
||||
{
|
||||
|
@ -298,6 +298,9 @@ int getChannelValue(sbusFrame_s frame, int id)
|
||||
toReturn = frame.flag_DChannel_18;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
toReturn = 0;
|
||||
break;
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void init_system()
|
||||
|
||||
|
||||
//initialize the CLI NOTE: Cant use the same usart as anything else or there will be some big trouble
|
||||
cliInit(USART3);
|
||||
cliInit(USART6);
|
||||
|
||||
//init sbus, using USART1
|
||||
sbus_init();
|
||||
|
@ -72,10 +72,13 @@ void systemTaskRx(void)
|
||||
sbusFrame_s frame = sbusChannelData;
|
||||
|
||||
/* Process channel data for switches and toggles on the controller, starts after "stick" channels */
|
||||
for (int i = STICK_CHANNEL_COUNT; i < STICK_CHANNEL_COUNT + AUX_CHANNEL_COUNT; i++) //ToDo: add define for the number of channels to process, /if not work change i to start at numb of stick channels
|
||||
{
|
||||
flags_ProcessRcChannel(i+1, getChannelValue(frame, i+1));
|
||||
}
|
||||
// for (int i = STICK_CHANNEL_COUNT; i < STICK_CHANNEL_COUNT + AUX_CHANNEL_COUNT; i++) //ToDo: add define for the number of channels to process, /if not work change i to start at numb of stick channels
|
||||
// {
|
||||
// flags_ProcessRcChannel(i+1, getChannelValue(frame, i+1));
|
||||
// }
|
||||
|
||||
/*Updated flag processRcChannel function, not yet tested. Should work as the entire loop above*/
|
||||
flags_ProcessRcChannel_Improved(STICK_CHANNEL_COUNT+1, STICK_CHANNEL_COUNT + AUX_CHANNEL_COUNT);
|
||||
|
||||
//temporary send data from the RC directly form the RC
|
||||
PID_Out[0] = frame.chan1 - 1500;
|
||||
|
Reference in New Issue
Block a user