Main Page · Modules · All Classes · Class Hierarchy
MASwitchVolumeControl.cpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #include "MASwitchVolumeControl.hpp"
23 
24 #include "types/MAAudio.hpp"
25 #include "types/MABodyMotion.hpp"
26 #include "types/MAHead.hpp"
27 #include "types/MALeg.hpp"
28 #include "types/MARobotState.hpp"
29 #include "types/MATorso.hpp"
30 #include "controllers/MALedsController.hpp"
31 #include "controllers/MASpeakerController.hpp"
32 #include "MALookForAbyss.hpp"
33 
34 MASwitchVolumeControl::MASwitchVolumeControl() : MABehavior(MCGetClassName(this), false)
35 {
37 }
38 
39 
41 {
42  if (MA::RobotState->Torso->BackFButtonPressed > 80 &&
43  MA::RobotState->Torso->BackMButtonPressed == 0 &&
44  MA::RobotState->Torso->BackRButtonPressed == 0 &&
45  MA::RobotState->Torso->BackStroked < 40 &&
46  !MA::RobotState->LegLF->Moving && !MA::RobotState->LegLH->Moving &&
47  !MA::RobotState->LegRF->Moving && !MA::RobotState->LegRH->Moving &&
48  !MA::RobotState->Head->MouthMoving &&
49  MA::RobotState->Audio->RemainingPlaybackTime == 0 &&
50  MA::RobotState->BodyMotion->Flying == 0 &&
52  {
54  }
56 }
57 
58 
60 {
61  MA::RobotState->Audio->FullVolume = !MA::RobotState->Audio->FullVolume;
62  if (MA::RobotState->Audio->FullVolume == 1)
63  {
64  MA::Speaker->SetVolume(MA::HighVolume);
65  PlaySound("switchnormalvolume");
66  StartTransition(*MA::Leds, MA::Leds->NormalVolumeControlStr);
67  } else {
68  PlaySound("switchadaptivevolume");
69  StartTransition(*MA::Leds, MA::Leds->AdaptiveVolumeControlStr);
70  }
71  MA::Speaker->SaveVolumeControl();
72 }
virtual void ActivatingActions() override
Perform actions when the behavior is being activated.
#define MABEHAVIOR_EXISTS(_behavior)
Check if a behavior exists.
Definition: MABehavior.hpp:74
Behavior base class.
Definition: MABehavior.hpp:157
int PlaySound(const std::string &name)
Play a sound and register the playback.
Definition: MABehavior.cpp:823
virtual MABehavior::StimulusLevelType GetCurrentStimulus() override
Get the current behavior stimulus.
void SetSelfActivationDuration(const int new_duration)
Set the self-activation duration.
Definition: MABehavior.cpp:530
std::string MCGetClassName(T *instance=nullptr, const std::string &name_suffix="")
Get a class name.
Definition: MCDefs.hpp:627
void StartTransition(MAController &controller, const std::string &transition_name)
Start a transition.
Definition: MABehavior.cpp:793
Look for abyss before the dog.