[uart_drop] rename for uniformity: module name='switch' type='uart'

This commit is contained in:
Christophe De Wagter
2016-10-20 11:39:19 +02:00
parent e97dd798f5
commit a7e3bccdfe
9 changed files with 52 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<!DOCTYPE module SYSTEM "module.dtd"> <!DOCTYPE module SYSTEM "module.dtd">
<module name="servo_switch"> <module name="auto1_cmd" dir="switching">
<doc> <doc>
<description>AUTO1 FLAPS/HATCH COMMANDS. <description>AUTO1 FLAPS/HATCH COMMANDS.
Enable RC controlled HATCH and BRAKE/FLAPS in both MANUAL and AUTO1, while automatic in AUTO2. Enable RC controlled HATCH and BRAKE/FLAPS in both MANUAL and AUTO1, while automatic in AUTO2.
+2 -2
View File
@@ -1,6 +1,6 @@
<!DOCTYPE module SYSTEM "module.dtd"> <!DOCTYPE module SYSTEM "module.dtd">
<module name="servo_switch"> <module name="servo_switch" dir="switching">
<doc> <doc>
<description>Servo switch</description> <description>Servo switch</description>
<define name="SERVO_SWITCH_ON_VALUE" value="pwm" description="servo value in usec"/> <define name="SERVO_SWITCH_ON_VALUE" value="pwm" description="servo value in usec"/>
@@ -10,7 +10,7 @@
<settings> <settings>
<dl_settings NAME="Servo switch control"> <dl_settings NAME="Servo switch control">
<dl_settings NAME="SWITCH"> <dl_settings NAME="SWITCH">
<dl_setting var="servo_switch_on" min="0" step="1" max="1" module="servo_switch/servo_switch" values="Off|On"> <dl_setting var="servo_switch_on" min="0" step="1" max="1" module="switching/servo_switch" values="Off|On">
<strip_button name="ON" value="1" group="servo_switch"/> <strip_button name="ON" value="1" group="servo_switch"/>
<strip_button name="OFF" value="0" group="servo_switch"/> <strip_button name="OFF" value="0" group="servo_switch"/>
</dl_setting> </dl_setting>
+33
View File
@@ -0,0 +1,33 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="switch_uart" dir="switching">
<doc>
<description>Active swithes via UART commands.
Module typically used in competitions to drop items like paint-balls. An arduino is a typical target.
</description>
</doc>
<settings>
<dl_settings NAME="Switch control">
<dl_settings NAME="SWITCH">
<dl_setting var="switch_uart_channel" min="0" step="1" max="4" module="switching/switch_uart" handler="SwitchUartChannel">
<strip_button name="1" value="1" group="servo_switch"/>
<strip_button name="2" value="2" group="servo_switch"/>
<strip_button name="3" value="3" group="servo_switch"/>
<strip_button name="4" value="4" group="servo_switch"/>
</dl_setting>
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="switch_uart.h"/>
</header>
<makefile>
<file name="switch_uart.c"/>
<configure name="SWITCH_UART_PORT" default="uart1" case="upper|lower"/>
<configure name="SWITCH_UART_BAUD" default="B115200"/>
<define name="SWITCH_UART_PORT" value="$(SWITCH_UART_PORT_LOWER)"/>
<define name="USE_$(SWITCH_UART_PORT_UPPER)"/>
<define name="$(SWITCH_UART_PORT_UPPER)_BAUD" value="$(SWITCH_UART_BAUD)"/>
</makefile>
</module>
@@ -19,7 +19,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include "servo_switch/servo_switch.h" #include "switching/servo_switch.h"
#include "generated/airframe.h" #include "generated/airframe.h"
#include "subsystems/actuators.h" #include "subsystems/actuators.h"
@@ -23,17 +23,22 @@
* Module for dropping balls using UART * Module for dropping balls using UART
*/ */
#include "modules/com/uart_drop.h" #include "modules/switching/switch_uart.h"
#include "mcu_periph/uart.h" #include "mcu_periph/uart.h"
uint8_t switch_uart_channel = 0;
static uint8_t drop_string[] = "<Drop_Paintball_Now"; static uint8_t drop_string[] = "<Drop_Paintball_Now";
#define DROP_STRINGLEN 19 #define DROP_STRINGLEN 19
void drop_ball(uint8_t number) { void drop_ball(uint8_t number) {
for(uint8_t i = 0; i < DROP_STRINGLEN; i++) for(uint8_t i = 0; i < DROP_STRINGLEN; i++)
uart_put_byte(&UART_DROP_PORT, 0, drop_string[i]); uart_put_byte(&SWITCH_UART_PORT, 0, drop_string[i]);
// Drop next ball
uint8_t last = '>'; uint8_t last = '>';
// Or Drop a specific ball
if(number == 1) { if(number == 1) {
last = '1'; last = '1';
} else if(number == 2) { } else if(number == 2) {
@@ -43,5 +48,5 @@ void drop_ball(uint8_t number) {
} else if(number == 4) { } else if(number == 4) {
last = '4'; last = '4';
} }
uart_put_byte(&UART_DROP_PORT, 0, last); uart_put_byte(&SWITCH_UART_PORT, 0, last);
} }
@@ -18,15 +18,19 @@
* <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
*/ */
/** /**
* @file "modules/com/uart_drop.h" * @file "modules/switching/switch_uart.h"
* @author Freek van Tienen * @author Freek van Tienen
* Module for dropping balls using UART * Module for dropping balls using UART
*/ */
#ifndef SWITCH_UART_H
#define SWITCH_UART_H
#include "std.h" #include "std.h"
#ifndef UART_DROP_H #define switch_uart_SwitchUartChannel(X) ({switch_uart_channel=X;drop_ball(switch_uart_channel); false;})
#define UART_DROP_H
extern uint8_t switch_uart_channel;
extern void drop_ball(uint8_t number); extern void drop_ball(uint8_t number);