Skip to content

Commit

Permalink
[uart_drop] rename for uniformity: module name='switch' type='uart'
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter committed Oct 27, 2016
1 parent cdeceb5 commit 0a28bb3
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion conf/modules/auto1_commands.xml
@@ -1,6 +1,6 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="servo_switch">
<module name="auto1_cmd" dir="switching">
<doc>
<description>AUTO1 FLAPS/HATCH COMMANDS.
Enable RC controlled HATCH and BRAKE/FLAPS in both MANUAL and AUTO1, while automatic in AUTO2.
Expand Down
4 changes: 2 additions & 2 deletions conf/modules/servo_switch.xml
@@ -1,6 +1,6 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="servo_switch">
<module name="servo_switch" dir="switching">
<doc>
<description>Servo switch</description>
<define name="SERVO_SWITCH_ON_VALUE" value="pwm" description="servo value in usec"/>
Expand All @@ -10,7 +10,7 @@
<settings>
<dl_settings NAME="Servo switch control">
<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="OFF" value="0" group="servo_switch"/>
</dl_setting>
Expand Down
33 changes: 33 additions & 0 deletions conf/modules/switch_uart.xml
@@ -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>

Expand Up @@ -19,7 +19,7 @@
* Boston, MA 02111-1307, USA.
*/

#include "servo_switch/servo_switch.h"
#include "switching/servo_switch.h"
#include "generated/airframe.h"
#include "subsystems/actuators.h"

Expand Down
Expand Up @@ -23,17 +23,22 @@
* Module for dropping balls using UART
*/

#include "modules/com/uart_drop.h"
#include "modules/switching/switch_uart.h"
#include "mcu_periph/uart.h"

uint8_t switch_uart_channel = 0;

static uint8_t drop_string[] = "<Drop_Paintball_Now";
#define DROP_STRINGLEN 19

void drop_ball(uint8_t number) {
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 = '>';

// Or Drop a specific ball
if(number == 1) {
last = '1';
} else if(number == 2) {
Expand All @@ -43,5 +48,5 @@ void drop_ball(uint8_t number) {
} else if(number == 4) {
last = '4';
}
uart_put_byte(&UART_DROP_PORT, 0, last);
uart_put_byte(&SWITCH_UART_PORT, 0, last);
}
Expand Up @@ -18,15 +18,19 @@
* <http://www.gnu.org/licenses/>.
*/
/**
* @file "modules/com/uart_drop.h"
* @file "modules/switching/switch_uart.h"
* @author Freek van Tienen
* Module for dropping balls using UART
*/

#ifndef SWITCH_UART_H
#define SWITCH_UART_H

#include "std.h"

#ifndef UART_DROP_H
#define UART_DROP_H
#define switch_uart_SwitchUartChannel(X) ({switch_uart_channel=X;drop_ball(switch_uart_channel); false;})

extern uint8_t switch_uart_channel;

extern void drop_ball(uint8_t number);

Expand Down

0 comments on commit 0a28bb3

Please sign in to comment.