From 25177cb4765a03da7fab10c500097910e13924e6 Mon Sep 17 00:00:00 2001 From: anbr Date: Sun, 31 Oct 2010 10:19:39 +0100 Subject: Support spectrum analyzer visualization (need span-plugin) --- HISTORY | 3 +- Makefile | 2 +- README | 6 ++++ bitmap.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- bitmap.h | 13 +++++++- targavfd.c | 52 ++++++-------------------------- vfd.c | 36 ++++++++++++++++++++++ vfd.h | 3 ++ watch.c | 3 ++ watch.h | 1 + 10 files changed, 168 insertions(+), 51 deletions(-) diff --git a/HISTORY b/HISTORY index 8278359..cd9206d 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,8 @@ VDR Plugin 'targavfd' Revision History ------------------------------------- -2010- +2010-10-31: Version 0.0.6 +- Support spectrum analyzer visualization (need span-plugin) - Allow turn display off at night (Feature #175) - Add render mode "show channel names only" (Feature #426) - Show next timer on lines (Feature #427) diff --git a/Makefile b/Makefile index eaaa370..d9d05e2 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ DEFINES += -DHAVE_STDBOOL_H ### The object files (add further files here): -OBJS = $(PLUGIN).o bitmap.o vfd.o ffont.o setup.o status.o watch.o +OBJS = $(PLUGIN).o bitmap.o vfd.o ffont.o setup.o status.o watch.o span.o ### The main target: diff --git a/README b/README index 45912f9..838b682 100644 --- a/README +++ b/README @@ -132,4 +132,10 @@ ICON : 250 icon state 'auto' 252 icon state 'off' * 501 unknown command +Spectrum analyzer visualization +------------------------------- +This plugin can show a spectrum analyzer visualization on audio playback. +As middleware you need the 'Sp'ectrum 'An'alyzer Plugin. + +See also http://lcr.vdr-developer.org/htmls/span-plugin.html diff --git a/bitmap.c b/bitmap.c index 44ebdbd..deff15e 100644 --- a/bitmap.c +++ b/bitmap.c @@ -14,23 +14,35 @@ #include #include "bitmap.h" +/** + * Ctor - Create framebuffer + * + * \param w count of horizontal columns. + * \param h count of vertical rows. + */ cVFDBitmap::cVFDBitmap(int w, int h) { width = w; height = h; // lines are byte aligned bytesPerLine = (width + 7) / 8; - - bitmap = MALLOC(uchar, bytesPerLine * height); + if(0 #include +#include "targavfd.h" #include "vfd.h" #include "watch.h" #include "status.h" @@ -22,43 +23,6 @@ static const char *VERSION = "0.0.6"; -class cPluginTargaVFD : public cPlugin { -private: - cVFDStatusMonitor *statusMonitor; - cVFDWatch m_dev; - bool m_bSuspend; - char* m_szIconHelpPage; -protected: - bool resume(); - bool suspend(); - - const char* SVDRPCommandOn(const char *Option, int &ReplyCode); - const char* SVDRPCommandOff(const char *Option, int &ReplyCode); - const char* SVDRPCommandIcon(const char *Option, int &ReplyCode); - -public: - cPluginTargaVFD(void); - virtual ~cPluginTargaVFD(); - virtual const char *Version(void) { return VERSION; } - virtual const char *Description(void) { return tr("Control a targa vfd"); } - virtual const char *CommandLineHelp(void); - 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 NULL; } - 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); - }; - cPluginTargaVFD::cPluginTargaVFD(void) { m_bSuspend = true; @@ -80,6 +44,14 @@ cPluginTargaVFD::~cPluginTargaVFD() } } +const char* cPluginTargaVFD::Version(void) { + return VERSION; +} + +const char* cPluginTargaVFD::Description(void) { + return tr("Control a targa vfd"); +} + const char *cPluginTargaVFD::CommandLineHelp(void) { // Return a string that describes all known command line options. @@ -175,12 +147,6 @@ bool cPluginTargaVFD::SetupParse(const char *szName, const char *szValue) return theSetup.SetupParse(szName,szValue); } -bool cPluginTargaVFD::Service(const char *Id, void *Data) -{ - // Handle custom service requests from other plugins - return false; -} - const char* cPluginTargaVFD::SVDRPCommandOn(const char *Option, int &ReplyCode) { if(!m_bSuspend) { diff --git a/vfd.c b/vfd.c index c23f871..7f0162b 100644 --- a/vfd.c +++ b/vfd.c @@ -439,6 +439,42 @@ int cVFD::DrawText(int x, int y, const char* string) return -1; } +/** + * Height of framebuffer from current device. + */ +int cVFD::Height() const +{ + if(framebuf) + return framebuf->Height(); + return 0; +} + +/** + * Width of framebuffer from current device. + */ +int cVFD::Width() const +{ + if(framebuf) + return framebuf->Width(); + return 0; +} + +/** + * Draw a rectangle on framebuffer on device. + * + * \param x1 First horizontal corner (column). + * \param y1 First vertical corner (row). + * \param x2 Second horizontal corner (column). + * \param y2 Second vertical corner (row). + * \param filled drawing of rectangle should be filled. + */ +bool cVFD::Rectangle(int x1, int y1, int x2, int y2, bool filled) +{ + if(framebuf) + return framebuf->Rectangle(x1, y1, x2, y2, filled); + return false; +} + /** * Sets the "icons state" for the device. We use this to control the icons diff --git a/vfd.h b/vfd.h index c572b89..a8ce8e7 100644 --- a/vfd.h +++ b/vfd.h @@ -90,6 +90,9 @@ public: void clear (); int DrawText(int x, int y, const char* string); + int Height() const; + int Width() const; + bool Rectangle(int x1, int y1, int x2, int y2, bool filled); bool flush (bool refreshAll = true); void icons(unsigned int state); diff --git a/watch.c b/watch.c index 05fb60e..b671eb7 100644 --- a/watch.c +++ b/watch.c @@ -360,6 +360,9 @@ bool cVFDWatch::RenderScreen(bool bReDraw) { scRender = chName; } } else { + if(RenderSpectrumAnalyzer()) + return true; + if(Replay()) { bForce = true; } diff --git a/watch.h b/watch.h index cbe4021..eb233af 100644 --- a/watch.h +++ b/watch.h @@ -100,6 +100,7 @@ protected: bool Program(); bool Replay(); bool RenderScreen(bool bReDraw); + bool RenderSpectrumAnalyzer(); eReplayState ReplayMode() const; bool ReplayPosition(int ¤t, int &total) const; bool CurrentTime(time_t ts); -- cgit v1.2.3