summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--ambiservice.c4
-rw-r--r--ambiservice.h2
-rw-r--r--ambithread.h2
-rw-r--r--config.h5
-rw-r--r--main_menu.c60
-rw-r--r--main_menu.h28
-rw-r--r--setup_menu.c55
-rw-r--r--setup_menu.h27
-rw-r--r--vdrboblight.c257
-rw-r--r--vdrboblight.h82
11 files changed, 298 insertions, 231 deletions
diff --git a/Makefile b/Makefile
index 5311afc..85d170a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,8 @@ PLUGIN = vdrboblight
### The version number of this plugin (taken from the main source file):
-VERSION = $(shell grep 'static const char \*VERSION *=' DVBAPI.h | awk '{ print $$6 }' | sed -e 's/[";]//g')
+#VERSION = $(shell grep 'static const char \*VERSION *=' vdrboblight.h | awk '{ print $$6 }' | sed -e 's/[";]//g')
+VERSION := $(shell git describe --abbrev=4 --dirty --always)
### The directory environment:
@@ -78,10 +79,12 @@ INCLUDES += -I$(VDRSRC)/include
endif
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
+### Define GITVERSION used in vdrboblight.c
+DEFINES += -DGITVERSION='"$(VERSION)"'
### The object files (add further files here):
-OBJS = $(PLUGIN).o ambithread.o ambiservice.o boblightservice.o common.o config.o
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
### The main target:
diff --git a/ambiservice.c b/ambiservice.c
index b3b6ba8..544095c 100644
--- a/ambiservice.c
+++ b/ambiservice.c
@@ -28,9 +28,7 @@ const char* cAmbiService::viewModes[] =
"atmo",
"fixed color",
"black",
- "detached",
-
- 0
+ "detached"
};
const char* cAmbiService::toName(ViewMode vm)
diff --git a/ambiservice.h b/ambiservice.h
index 7ca41c6..3e08c2a 100644
--- a/ambiservice.h
+++ b/ambiservice.h
@@ -47,4 +47,4 @@ class cAmbiService
static const char* viewModes[];
};
-#endif // __SEDU_SERVICE_H
+#endif // __AMBI_SERVICE_H
diff --git a/ambithread.h b/ambithread.h
index 5316a9a..3558aea 100644
--- a/ambithread.h
+++ b/ambithread.h
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#pragma once
#include <queue>
#include <vdr/thread.h>
diff --git a/config.h b/config.h
index 9978928..344a6e2 100644
--- a/config.h
+++ b/config.h
@@ -48,13 +48,14 @@ class cBobConfig : public cAmbiService
// technical
- ViewMode viewMode;
+ int viewMode;
+ int startupViewMode;
int fixedR;
int fixedG;
int fixedB;
int showMainmenu; //bool
- Cinebars detectCineBars;
+ int detectCineBars;
int loglevel;
diff --git a/main_menu.c b/main_menu.c
new file mode 100644
index 0000000..04c58ef
--- /dev/null
+++ b/main_menu.c
@@ -0,0 +1,60 @@
+
+#include <vdr/plugin.h>
+
+#include "ambiservice.h"
+#include "main_menu.h"
+#include "config.h"
+#include "common.h"
+
+cBoblightPluginMenu::cBoblightPluginMenu(const char* title, cPluginBoblight* aPlugin)
+{
+ plugin = aPlugin;
+
+ Create();
+}
+
+void cBoblightPluginMenu::Create(void) {
+ Clear();
+
+ Add(new cMenuEditStraItem(tr("View Mode"), &cfg.viewMode, cAmbiService::vmCount, cAmbiService::viewModes));
+ Add(new cMenuEditStraItem(tr("Startup View Mode"), &cfg.startupViewMode, cAmbiService::vmCount, cAmbiService::viewModes));
+
+ Add(new cMenuEditIntItem(tr("Fixed Color Red"), &cfg.fixedR, 0, 255));
+ Add(new cMenuEditIntItem(tr("Fixed Color Green"), &cfg.fixedG, 0, 255));
+ Add(new cMenuEditIntItem(tr("Fixed Color Blue"), &cfg.fixedB, 0, 255));
+
+ SetHelp(0, 0, 0, 0);
+ Display();
+}
+
+void cBoblightPluginMenu::Store() {
+ plugin->Save();
+}
+
+//***************************************************************************
+// Process Key
+//***************************************************************************
+
+eOSState cBoblightPluginMenu::ProcessKey(eKeys key)
+{
+ eOSState state = cOsdMenu::ProcessKey(key);
+
+ if (state != osUnknown)
+ return state;
+
+ if (key == kLeft || key == kRight)
+ {
+ if (cfg.viewMode == cAmbiService::vmDetached && plugin->isRunning())
+ plugin->stopAtmo();
+ else if (cfg.viewMode != cAmbiService::vmDetached && !plugin->isRunning())
+ plugin->startAtmo();
+ }
+
+ if (key == kOk)
+ {
+ plugin->Save();
+ return osEnd;
+ }
+
+ return state;
+} \ No newline at end of file
diff --git a/main_menu.h b/main_menu.h
new file mode 100644
index 0000000..db46512
--- /dev/null
+++ b/main_menu.h
@@ -0,0 +1,28 @@
+#ifndef __MAIN_MENU_H
+#define __MAIN_MENU_H
+
+#include <vdr/plugin.h>
+
+#include "vdrboblight.h"
+
+//***************************************************************************
+// Plugins Main Menu
+//***************************************************************************
+
+class cPluginBoblight;
+
+class cBoblightPluginMenu : public cMenuSetupPage
+{
+ public:
+
+ cBoblightPluginMenu(const char* title, cPluginBoblight* aPlugin);
+ virtual ~cBoblightPluginMenu() { };
+ virtual void Store();
+ virtual eOSState ProcessKey(eKeys key);
+
+ protected:
+ void Create(void);
+ cPluginBoblight* plugin;
+};
+
+#endif
diff --git a/setup_menu.c b/setup_menu.c
new file mode 100644
index 0000000..6098ca8
--- /dev/null
+++ b/setup_menu.c
@@ -0,0 +1,55 @@
+
+#include "setup_menu.h"
+#include "config.h"
+#include "common.h"
+
+//***************************************************************************
+// Object
+//***************************************************************************
+
+cAmbiSetup::cAmbiSetup(cPluginBoblight* aPlugin)
+{
+ plugin = aPlugin;
+ cineBars[0] = "Horizontal";
+ cineBars[1] = "Vertical";
+ cineBars[2] = "Both";
+
+ Setup();
+}
+
+//***************************************************************************
+// Setup
+//***************************************************************************
+
+void cAmbiSetup::Setup()
+{
+ Clear();
+
+ Add(new cMenuEditIntItem(tr("Log level"), &cfg.loglevel, 0, 3));
+ Add(new cMenuEditBoolItem(tr("Show mainmenu"), &cfg.showMainmenu));
+
+ Add(new cMenuEditIntItem(tr("Updaterate [Hz]"), &cfg.frequence, 1, 100));
+
+ Add(new cMenuEditStraItem(tr("Detect cinema bars"), &cfg.detectCineBars, 3, cineBars));
+
+ Add(new cMenuEditIntItem(tr("Threshold (0-255)"), &cfg.threshold, 0, 255));
+ Add(new cMenuEditIntItem(tr("Gamma (0-10.0)"), &cfg.gamma, 0, 100));
+ Add(new cMenuEditIntItem(tr("Value (0-20.0)"), &cfg.value, 0, 200));
+ Add(new cMenuEditIntItem(tr("Saturation (0-20.0)"), &cfg.saturation, 0, 200));
+ Add(new cMenuEditIntItem(tr("Speed (0-100)"), &cfg.speed, 0, 100));
+ Add(new cMenuEditIntItem(tr("Autospeed (0-100)"), &cfg.autospeed, 0, 100));
+ Add(new cMenuEditBoolItem(tr("Interpolation"), &cfg.interpolation));
+ Add(new cMenuEditIntItem(tr("Priority 0=Highest, 255=Lowest"), &cfg.priority, 0, 255));
+}
+
+eOSState cAmbiSetup::ProcessKey(eKeys key)
+{
+ eOSState state = cMenuSetupPage::ProcessKey(key);
+
+ return state;
+}
+
+void cAmbiSetup::Store()
+{
+ plugin->Save();
+} \ No newline at end of file
diff --git a/setup_menu.h b/setup_menu.h
new file mode 100644
index 0000000..60a8ed7
--- /dev/null
+++ b/setup_menu.h
@@ -0,0 +1,27 @@
+#ifndef __SETUP_MENU_H
+#define __SETUP_MENU_H
+
+#include <vdr/plugin.h>
+#include "ambiservice.h"
+#include "vdrboblight.h"
+
+//***************************************************************************
+// Setup
+//***************************************************************************
+class cPluginBoblight;
+class cAmbiSetup : public cMenuSetupPage, public cAmbiService
+{
+ public:
+ cAmbiSetup(cPluginBoblight* aPlugin);
+
+ protected:
+
+ virtual void Setup();
+ virtual eOSState ProcessKey(eKeys Key);
+ virtual void Store();
+
+ const char* cineBars[cbCount];
+ cPluginBoblight* plugin;
+};
+
+#endif
diff --git a/vdrboblight.c b/vdrboblight.c
index b9c0dc7..d48fe99 100644
--- a/vdrboblight.c
+++ b/vdrboblight.c
@@ -16,154 +16,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include <vdr/plugin.h>
+#include "vdrboblight.h"
-#include "config.h"
-#include "ambiservice.h"
-#include "ambithread.h"
-
-//***************************************************************************
-//
-//***************************************************************************
-
-static const char *VERSION = "0.0.2";
-static const char *DESCRIPTION = "Boblight with data from softhddevice";
-static const char *MAINMENUENTRY = "Boblight";
-
-//***************************************************************************
-// Setup
-//***************************************************************************
-
-class cAmbiSetup : public cMenuSetupPage, public cAmbiService
-{
- public:
-
- cAmbiSetup();
-
- protected:
-
- virtual void Setup();
- virtual eOSState ProcessKey(eKeys Key);
- virtual void Store();
-
- const char* cineBars[cbCount];
- const char* seduRGBOrders[6];
- int rgbOrderIndex;
-};
-
-//***************************************************************************
-// Plugin
-//***************************************************************************
-
-class cPluginBoblight : public cPlugin
-{
- public:
-
- cPluginBoblight(void);
- virtual ~cPluginBoblight();
- virtual const char* Version(void) { return VERSION; }
- virtual const char* Description(void) { return DESCRIPTION; }
- virtual const char* CommandLineHelp(void) { return 0; }
- virtual bool ProcessArgs(int argc, char* argv[]);
- virtual bool Initialize(void);
- virtual bool Start(void);
- virtual void Stop(void);
- virtual void Housekeeping(void) { };
- virtual void MainThreadHook(void) { };
- virtual cString Active(void);
- virtual time_t WakeupTime(void);
- virtual const char* MainMenuEntry(void) { return cfg.showMainmenu ? MAINMENUENTRY : 0; }
- virtual cOsdObject* MainMenuAction(void);
- virtual cMenuSetupPage* SetupMenu(void) { return new cAmbiSetup; }
- virtual bool SetupParse(const char* Name, const char* Value);
- virtual bool Service(const char* Id, void* Data = NULL);
- virtual const char** SVDRPHelpPages(void);
- virtual cString SVDRPCommand(const char* Command, const char* Option, int &ReplyCode);
-
- int startAtmo();
- int stopAtmo();
- cAmbiThread* update;
-
- int isRunning()
- {
- if (!update)
- return no;
-
- return update->isRunning();
- }
-};
-
-//***************************************************************************
-// Plugins Main Menu
-//***************************************************************************
-
-class cSeduPluginMenu : public cMenuSetupPage
-{
- public:
-
- cSeduPluginMenu(const char* title, cPluginBoblight* aPlugin);
- virtual ~cSeduPluginMenu() { };
-
- virtual eOSState ProcessKey(eKeys key);
-
- protected:
-
- void Store() { }
- cPluginBoblight* plugin;
-};
-
-cSeduPluginMenu::cSeduPluginMenu(const char* title, cPluginBoblight* aPlugin)
-{
- SetTitle(title ? title : "");
- plugin = aPlugin;
-
- Clear();
-
- cOsdMenu::Add(new cMenuEditStraItem(tr("View Mode"),
- (int*)&cfg.viewMode,
- (int)cAmbiService::vmCount,
- cAmbiService::viewModes));
-
- Add(new cMenuEditIntItem(tr("Fixed Color Red"), &cfg.fixedR, 0, 255));
- Add(new cMenuEditIntItem(tr("Fixed Color Green"), &cfg.fixedG, 0, 255));
- Add(new cMenuEditIntItem(tr("Fixed Color Blue"), &cfg.fixedB, 0, 255));
-
- SetHelp(0, 0, 0, 0);
-
- Display();
-}
-
-//***************************************************************************
-// Process Key
-//***************************************************************************
-
-eOSState cSeduPluginMenu::ProcessKey(eKeys key)
-{
- eOSState state = cOsdMenu::ProcessKey(key);
-
- if (key == kLeft || key == kRight)
- {
- if (cfg.viewMode == cAmbiService::vmDetached && plugin->isRunning())
- plugin->stopAtmo();
- else if (cfg.viewMode != cAmbiService::vmDetached && !plugin->isRunning())
- plugin->startAtmo();
- }
-
- if (state != osUnknown)
- return state;
-
- if (key == kOk)
- {
- SetupStore("FixedColorRed", cfg.fixedR);
- SetupStore("FixedColorGreen", cfg.fixedG);
- SetupStore("FixedColorBlue", cfg.fixedB);
- SetupStore("ViewMode", (int)cfg.viewMode);
-
- return osEnd;
- }
- return state;
-}
+#include "setup_menu.h"
+#include "main_menu.h"
//***************************************************************************
// Plugin
@@ -221,6 +78,29 @@ int cPluginBoblight::stopAtmo()
return done;
}
+void cPluginBoblight::Save() {
+ cfg.dirty = 1;
+ SetupStore("LogLevel", cfg.loglevel);
+ SetupStore("ShowMainmenu", cfg.showMainmenu);
+ SetupStore("StartupViewMode", cfg.startupViewMode);
+
+ SetupStore("DetectCineBars", cfg.detectCineBars);
+
+ SetupStore("Updaterate", cfg.frequence);
+ SetupStore("Threshold", cfg.threshold);
+ SetupStore("Gamma", cfg.gamma);
+ SetupStore("Value", cfg.value);
+ SetupStore("Saturation", cfg.saturation);
+ SetupStore("Speed", cfg.speed);
+ SetupStore("Autospeed", cfg.autospeed);
+ SetupStore("Interpolation", cfg.interpolation);
+ SetupStore("Priority", cfg.priority);
+
+ SetupStore("FixedColorRed", cfg.fixedR);
+ SetupStore("FixedColorGreen", cfg.fixedG);
+ SetupStore("FixedColorBlue", cfg.fixedB);
+}
+
void cPluginBoblight::Stop(void)
{
stopAtmo();
@@ -236,16 +116,23 @@ time_t cPluginBoblight::WakeupTime(void)
return 0;
}
+cMenuSetupPage* cPluginBoblight::SetupMenu(void) {
+ return new cAmbiSetup(this);
+}
+
cOsdObject* cPluginBoblight::MainMenuAction(void)
{
- return new cSeduPluginMenu(MAINMENUENTRY, this);
+ return new cBoblightPluginMenu(MAINMENUENTRY, this);
}
bool cPluginBoblight::SetupParse(const char* Name, const char* Value)
{
if (!strcasecmp(Name, "LogLevel")) cfg.loglevel = atoi(Value);
else if (!strcasecmp(Name, "ShowMainmenu")) cfg.showMainmenu = atoi(Value);
- else if (!strcasecmp(Name, "ViewMode")) cfg.viewMode = (cAmbiService::ViewMode)atoi(Value);
+ else if (!strcasecmp(Name, "StartupViewMode")) {
+ cfg.startupViewMode = atoi(Value);
+ cfg.viewMode = cfg.startupViewMode;
+ }
else if (!strcasecmp(Name, "DetectCineBars")) cfg.detectCineBars = (cAmbiService::Cinebars)atoi(Value);
@@ -276,9 +163,6 @@ bool cPluginBoblight::Service(const char* Id, void* Data)
cString cPluginBoblight::SVDRPCommand(const char* Command, const char* Option, int &ReplyCode)
{
- if (!update)
- return "Error: Plugin not initialized!";
-
if (!strcasecmp(Command, "MODE"))
{
if (Option && strcasecmp(Option, "atmo") == 0)
@@ -333,77 +217,6 @@ const char** cPluginBoblight::SVDRPHelpPages(void)
return HelpPages;
}
-//***************************************************************************
-// Class Setup Menu
-//***************************************************************************
-//***************************************************************************
-// Object
-//***************************************************************************
-
-cAmbiSetup::cAmbiSetup()
-{
- cineBars[0] = "Horizontal";
- cineBars[1] = "Vertical";
- cineBars[2] = "Both";
-
- Setup();
-}
-
-//***************************************************************************
-// Setup
-//***************************************************************************
-
-void cAmbiSetup::Setup()
-{
- Clear();
-
- Add(new cMenuEditIntItem(tr("Log level"), &cfg.loglevel, 0, 3));
- Add(new cMenuEditBoolItem(tr("Show mainmenu"), &cfg.showMainmenu));
-
- Add(new cMenuEditIntItem(tr("Updaterate [Hz]"), &cfg.frequence, 1, 100));
-
- Add(new cMenuEditStraItem(tr("Detect cinema bars"), (int*)&cfg.detectCineBars, 3, cineBars));
-
- Add(new cMenuEditIntItem(tr("Threshold (0-255)"), &cfg.threshold, 0, 255));
- Add(new cMenuEditIntItem(tr("Gamma (0-10.0)"), &cfg.gamma, 0, 100));
- Add(new cMenuEditIntItem(tr("Value (0-20.0)"), &cfg.value, 0, 200));
- Add(new cMenuEditIntItem(tr("Saturation (0-20.0)"), &cfg.saturation, 0, 200));
- Add(new cMenuEditIntItem(tr("Speed (0-100)"), &cfg.speed, 0, 100));
- Add(new cMenuEditIntItem(tr("Autospeed (0-100)"), &cfg.autospeed, 0, 100));
- Add(new cMenuEditBoolItem(tr("Interpolation"), &cfg.interpolation));
- Add(new cMenuEditIntItem(tr("Priority 0=Highest, 255=Lowest"), &cfg.priority, 0, 255));
-}
-
-eOSState cAmbiSetup::ProcessKey(eKeys key)
-{
- eOSState state = cMenuSetupPage::ProcessKey(key);
-
- return state;
-}
-
-void cAmbiSetup::Store()
-{
- cfg.dirty = 1;
- SetupStore("LogLevel", cfg.loglevel);
- SetupStore("ShowMainmenu", cfg.showMainmenu);
- SetupStore("ViewMode", (int)cfg.viewMode);
-
- SetupStore("DetectCineBars", cfg.detectCineBars);
-
- SetupStore("Updaterate", cfg.frequence);
- SetupStore("Threshold", cfg.threshold);
- SetupStore("Gamma", cfg.gamma);
- SetupStore("Value", cfg.value);
- SetupStore("Saturation", cfg.saturation);
- SetupStore("Speed", cfg.speed);
- SetupStore("Autospeed", cfg.autospeed);
- SetupStore("Interpolation", cfg.interpolation);
- SetupStore("Priority", cfg.priority);
-
- SetupStore("FixedColorRed", cfg.fixedR);
- SetupStore("FixedColorGreen", cfg.fixedG);
- SetupStore("FixedColorBlue", cfg.fixedB);
-}
//***************************************************************************
// VDR Internal
diff --git a/vdrboblight.h b/vdrboblight.h
new file mode 100644
index 0000000..0b46d11
--- /dev/null
+++ b/vdrboblight.h
@@ -0,0 +1,82 @@
+/*
+ * vdrboblight.h
+ *
+ * Copyright (C) 2013 - Christian Völlinger
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __VDRBOBLIGHT_H
+#define __VDRBOBLIGHT_H
+
+#include <vdr/plugin.h>
+
+#include "config.h"
+#include "ambiservice.h"
+#include "ambithread.h"
+#include "setup_menu.h"
+#include "main_menu.h"
+
+//***************************************************************************
+//
+//***************************************************************************
+
+static const char *VERSION = GITVERSION;
+static const char *DESCRIPTION = "Boblight with data from softhddevice";
+static const char *MAINMENUENTRY = "Boblight";
+
+
+//***************************************************************************
+// Plugin
+//***************************************************************************
+
+class cPluginBoblight : public cPlugin
+{
+ public:
+
+ cPluginBoblight(void);
+ virtual ~cPluginBoblight();
+ virtual const char* Version(void) { return VERSION; }
+ virtual const char* Description(void) { return DESCRIPTION; }
+ virtual const char* CommandLineHelp(void) { return 0; }
+ virtual bool ProcessArgs(int argc, char* argv[]);
+ virtual bool Initialize(void);
+ virtual bool Start(void);
+ virtual void Stop(void);
+ virtual void Housekeeping(void) { };
+ virtual void MainThreadHook(void) { };
+ virtual cString Active(void);
+ virtual time_t WakeupTime(void);
+ virtual const char* MainMenuEntry(void) { return cfg.showMainmenu ? MAINMENUENTRY : 0; }
+ virtual cOsdObject* MainMenuAction(void);
+ virtual cMenuSetupPage* SetupMenu(void);
+ virtual bool SetupParse(const char* Name, const char* Value);
+ virtual bool Service(const char* Id, void* Data = NULL);
+ virtual const char** SVDRPHelpPages(void);
+ virtual cString SVDRPCommand(const char* Command, const char* Option, int &ReplyCode);
+
+ int startAtmo();
+ int stopAtmo();
+ void Save();
+ cAmbiThread* update;
+
+ int isRunning()
+ {
+ if (!update)
+ return no;
+
+ return update->isRunning();
+ }
+};
+
+#endif