diff --git a/build/kobo.mk b/build/kobo.mk old mode 100644 new mode 100755 index e329fbb..6a94197 --- a/build/kobo.mk +++ b/build/kobo.mk @@ -63,6 +63,10 @@ fi) BITSTREAM_VERA_NAMES = Vera VeraBd VeraIt VeraBI VeraMono BITSTREAM_VERA_FILES = $(patsubst %,$(BITSTREAM_VERA_DIR)/%.ttf,$(BITSTREAM_VERA_NAMES)) +KOBO_SOUND_SCRIPTS = 1.Sound_100% 2.Sound_75% 3.Sound_50% 4.Sound_25% 5.Sound_OFF +KOBO_SCRIPTS = $(patsubst %,$(topdir)/kobo/scripts/%,$(KOBO_SOUND_SCRIPTS)) +KOBO_SETTTY=$(topdir)/kobo/scripts/setTTY.sh + SYSROOT = $(shell $(CC) -print-sysroot) # install our version of the system libraries in /opt/xcsoar/lib; this @@ -95,6 +99,9 @@ $(TARGET_OUTPUT_DIR)/KoboRoot.tgz: $(XCSOAR_BIN) \ $(Q)if test -f $(KOBO_KERNEL_DIR)/uImage.otg; then install -m 0644 $(KOBO_KERNEL_DIR)/uImage.otg $(@D)/KoboRoot/opt/xcsoar/lib/kernel; fi $(Q)install -m 0644 $(topdir)/kobo/inittab $(@D)/KoboRoot/etc $(Q)install -m 0644 $(BITSTREAM_VERA_FILES) $(@D)/KoboRoot/opt/xcsoar/share/fonts + $(Q)install -m 0755 -d $(@D)/KoboRoot/mnt/onboard/XCSoarData/kobo/scripts + $(Q)install -m 0755 $(KOBO_SETTTY) $(@D)/KoboRoot/mnt/onboard/XCSoarData/kobo + $(Q)install -m 0755 $(KOBO_SCRIPTS) $(@D)/KoboRoot/mnt/onboard/XCSoarData/kobo/scripts $(Q)fakeroot tar czfC $@ $(@D)/KoboRoot . endif diff --git a/build/main.mk b/build/main.mk index 363f92b..1fd5f35 100644 --- a/build/main.mk +++ b/build/main.mk @@ -358,6 +358,7 @@ XCSOAR_SOURCES := \ $(SRC)/InfoBoxes/Content/Task.cpp \ $(SRC)/InfoBoxes/Content/Places.cpp \ $(SRC)/InfoBoxes/Content/Contest.cpp \ + $(SRC)/InfoBoxes/Content/Sound.cpp \ $(SRC)/InfoBoxes/Content/Team.cpp \ $(SRC)/InfoBoxes/Content/Terrain.cpp \ $(SRC)/InfoBoxes/Content/Thermal.cpp \ diff --git a/kobo/scripts/1.Sound_100% b/kobo/scripts/1.Sound_100% new file mode 100755 index 0000000..e719d48 --- /dev/null +++ b/kobo/scripts/1.Sound_100% @@ -0,0 +1,12 @@ +#!/bin/sh +########################################################### +# init tty +########################################################### +. /mnt/onboard/XCSoarData/kobo/setTTY.sh + +########################################################### +# init Sound +########################################################### +echo Sound 100% +printf '$BVL %s*\r\n' 1000 > $TTY_DEV +printf "%d \n" 100 >/etc/bluflySound diff --git a/kobo/scripts/2.Sound_75% b/kobo/scripts/2.Sound_75% new file mode 100755 index 0000000..b603d6f --- /dev/null +++ b/kobo/scripts/2.Sound_75% @@ -0,0 +1,12 @@ +#!/bin/sh +########################################################### +# init tty +########################################################### +. /mnt/onboard/XCSoarData/kobo/setTTY.sh + +########################################################### +# init Sound +########################################################### +echo Sound 75% +printf '$BVL %s*\r\n' 250 > $TTY_DEV +printf "%d \n" 75 >/etc/bluflySound diff --git a/kobo/scripts/3.Sound_50% b/kobo/scripts/3.Sound_50% new file mode 100755 index 0000000..68bbdf8 --- /dev/null +++ b/kobo/scripts/3.Sound_50% @@ -0,0 +1,12 @@ +#!/bin/sh +########################################################### +# init tty +########################################################### +. /mnt/onboard/XCSoarData/kobo/setTTY.sh + +########################################################### +# init Sound +########################################################### +echo Sound 50% +printf '$BVL %s*\r\n' 100 > $TTY_DEV +printf "%d \n" 50 >/etc/bluflySound diff --git a/kobo/scripts/4.Sound_25% b/kobo/scripts/4.Sound_25% new file mode 100755 index 0000000..3df62be --- /dev/null +++ b/kobo/scripts/4.Sound_25% @@ -0,0 +1,12 @@ +#!/bin/sh +########################################################### +# init tty +########################################################### +. /mnt/onboard/XCSoarData/kobo/setTTY.sh + +########################################################### +# init Sound +########################################################### +echo Sound 25% +printf '$BVL %s*\r\n' 25 > $TTY_DEV +printf "%d \n" 25 >/etc/bluflySound diff --git a/kobo/scripts/5.Sound_OFF b/kobo/scripts/5.Sound_OFF new file mode 100755 index 0000000..5f346a7 --- /dev/null +++ b/kobo/scripts/5.Sound_OFF @@ -0,0 +1,12 @@ +#!/bin/sh +########################################################### +# init tty +########################################################### +. /mnt/onboard/XCSoarData/kobo/setTTY.sh + +########################################################### +# init Sound +########################################################### +echo Sound OFF +printf '$BVL %s*\r\n' 1 > $TTY_DEV +echo 0 > /etc/bluflySound diff --git a/kobo/scripts/setTTY.sh b/kobo/scripts/setTTY.sh new file mode 100755 index 0000000..9a751bf --- /dev/null +++ b/kobo/scripts/setTTY.sh @@ -0,0 +1,12 @@ +#!/bin/sh +export BAUD_RATE=57600 +export TTY_DEV=/dev/ttymxc0 + + +########################################################### +# init tty +########################################################### + +stty -F $TTY_DEV $BAUD_RATE + + diff --git a/src/InfoBoxes/Content/Factory.cpp b/src/InfoBoxes/Content/Factory.cpp old mode 100644 new mode 100755 index e2b91d1..9d43bb5 --- a/src/InfoBoxes/Content/Factory.cpp +++ b/src/InfoBoxes/Content/Factory.cpp @@ -34,6 +34,7 @@ Copyright_License { #include "InfoBoxes/Content/Task.hpp" #include "InfoBoxes/Content/Places.hpp" #include "InfoBoxes/Content/Contest.hpp" +#include "InfoBoxes/Content/Sound.hpp" #include "InfoBoxes/Content/Team.hpp" #include "InfoBoxes/Content/Terrain.hpp" #include "InfoBoxes/Content/Thermal.hpp" @@ -897,10 +898,10 @@ static constexpr MetaData meta_data[] = { // e_Experimental { - N_("Experimental 1"), - N_("Exp1"), + N_("BlueFly Sound Level"), + N_("Sound"), NULL, - UpdateInfoBoxExperimental1, + IBFHelper::Create, //UpdateInfoBoxExperimental1, e_Experimental2, // Exp2 e_Experimental2, // Exp2 }, diff --git a/src/InfoBoxes/Content/Sound.cpp b/src/InfoBoxes/Content/Sound.cpp new file mode 100755 index 0000000..4785e8d --- /dev/null +++ b/src/InfoBoxes/Content/Sound.cpp @@ -0,0 +1,98 @@ +/* +Copyright_License { + + XCSoar Glide Computer - http://www.xcsoar.org/ + Copyright (C) 2000-2014 The XCSoar Project + A detailed list of copyright holders can be found in the file "AUTHORS". + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} +*/ + +#include "Sound.hpp" +#include "InfoBoxes/Data.hpp" +#include "InfoBoxes/Panel/Panel.hpp" +#include "Interface.hpp" +#include "Components.hpp" +#include "UIGlobals.hpp" +#include "Dialogs/dlgAnalysis.hpp" +#include "Language/Language.hpp" +#include "Widget/CallbackWidget.hpp" +#include "OS/Process.hpp" + +#include + +#ifdef KOBO +#include +#include +#include +#include +#endif + + +const InfoBoxPanel * +InfoBoxSound::GetDialogContent() +{ +#ifdef KOBO + std::ifstream in("/etc/bluflySound"); + if(in.good()){ + int value; in >> value; + switch(value){ + case 0: + Run("/mnt/onboard/XCSoarData/kobo/scripts/4.Sound_25%"); + break; + case 25: + Run("/mnt/onboard/XCSoarData/kobo/scripts/3.Sound_50%"); + break; + case 50: + Run("/mnt/onboard/XCSoarData/kobo/scripts/2.Sound_75%"); + break; + case 75: + Run("/mnt/onboard/XCSoarData/kobo/scripts/1.Sound_100%"); + break; + case 100: + Run("/mnt/onboard/XCSoarData/kobo/scripts/5.Sound_OFF"); + break; + default: + break; + } + } +#endif + return nullptr; +} + +void +InfoBoxSound::Update(InfoBoxData &data) +{ +#ifdef KOBO + static fixed blueFlySoundLevel = fixed(0); + static time_t lMtime; + struct stat my_Stata; + bool available = (stat("/etc/bluflySound", &my_Stata) >= 0); + if( available && my_Stata.st_mtime != lMtime) + { + lMtime = my_Stata.st_mtime; + std::ifstream in("/etc/bluflySound"); + int value; in >> value; + blueFlySoundLevel = fixed(value); + } + + if (available) { + data.SetValue(_T("%.0f%%"), blueFlySoundLevel); + return; + } +#endif + data.SetInvalid(); +} diff --git a/src/InfoBoxes/Content/Sound.hpp b/src/InfoBoxes/Content/Sound.hpp new file mode 100755 index 0000000..1be9ce0 --- /dev/null +++ b/src/InfoBoxes/Content/Sound.hpp @@ -0,0 +1,35 @@ +/* +Copyright_License { + + XCSoar Glide Computer - http://www.xcsoar.org/ + Copyright (C) 2000-2014 The XCSoar Project + A detailed list of copyright holders can be found in the file "AUTHORS". + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} +*/ + +#ifndef XCSOAR_INFOBOX_CONTENT_SOUND_HPP +#define XCSOAR_INFOBOX_CONTENT_SOUND_HPP + +#include "InfoBoxes/Content/Base.hpp" + +class InfoBoxSound: public InfoBoxContent +{ +public: + virtual const InfoBoxPanel *GetDialogContent() override; + virtual void Update(InfoBoxData &data) override; +}; +#endif