Skip to content

Commit

Permalink
Implementierung eines... *hust* ...Radios!
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas committed Jul 18, 2015
1 parent 7c84cf6 commit 6fcd135
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions MotorControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand All @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions radio
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6fcd135

Please sign in to comment.