From 6fcd135c6f5c50ba77677e6afabf3abbc6bfbe8e Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 18 Jul 2015 19:53:29 +0200 Subject: [PATCH] Implementierung eines... *hust* ...Radios! --- MotorControl.cpp | 28 ++++++++++++++++++++++++++++ radio | 8 ++++++++ 2 files changed, 36 insertions(+) create mode 100755 radio diff --git a/MotorControl.cpp b/MotorControl.cpp index cc81444..6459d88 100644 --- a/MotorControl.cpp +++ b/MotorControl.cpp @@ -228,6 +228,9 @@ void MotorControl::ComputeInputButtons() // Tastendrücke bis zum Beenden der Motorsteuerung verarbeiten bool kill_server = false; // Beenden-Anfrage bool horn = false; // Hupe + bool radio = false; // Radio + bool radioButtonPressed = false; // Radio-Knopf gedrückt + bool radioIsPlaying = false; // Radio aktiv? int cam_servo_direction = 0; // Richtung in den der Servo gedreht werden soll while(_running) @@ -243,6 +246,9 @@ void MotorControl::ComputeInputButtons() // Feuerknopf abfragen horn = (_joystickButtons[0] == 1); + // Radio Button + radio = (_joystickButtons[5] == 1); + // Servosteuerung nach Wert des kleinen Steuerknüppels cam_servo_direction = _joystickAxis[4] < 0 ? -1 : _joystickAxis[4] > 0 ? 1 : 0; } @@ -269,6 +275,28 @@ void MotorControl::ComputeInputButtons() _hornActive = horn; } + // Wurde der Button losgelassen? + if (radioButtonPressed && !radio) + { + // Spielt das Radio ab? + if (radioIsPlaying) + { + // Radio beenden + system("./radio stop"); + } + else + { + // Radio starten + system("./radio start"); + } + + // Radiozustand merken + radioIsPlaying = !radioIsPlaying; + } + + // Tastenzustand merken + radioButtonPressed = radio; + // Kamera-Servo drehen? if(cam_servo_direction != 0) { diff --git a/radio b/radio new file mode 100755 index 0000000..43d78a6 --- /dev/null +++ b/radio @@ -0,0 +1,8 @@ +#!/bin/bash +if [ "$1" == "start" ]; then + screen -d -m -S radio mplayer http://mp3ad.energybremen.c.nmdn.net/energybremen_mobile/livestream.mp3 +fi + +if [ "$1" == "stop" ]; then + screen -X -S radio quit +fi