diff options
author | anbr <vdr07@deltab.de> | 2010-10-31 10:19:39 +0100 |
---|---|---|
committer | anbr <vdr07@deltab.de> | 2010-10-31 10:19:39 +0100 |
commit | 25177cb4765a03da7fab10c500097910e13924e6 (patch) | |
tree | 488e54bdf7f851dcddf44e05bebc4cc48130b376 | |
parent | 16745cec0de781245650aa6332c97ae9a8db8644 (diff) | |
download | vdr-plugin-targavfd-25177cb4765a03da7fab10c500097910e13924e6.tar.gz vdr-plugin-targavfd-25177cb4765a03da7fab10c500097910e13924e6.tar.bz2 |
Support spectrum analyzer visualization (need span-plugin)0.0.6
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | bitmap.c | 100 | ||||
-rw-r--r-- | bitmap.h | 13 | ||||
-rw-r--r-- | targavfd.c | 52 | ||||
-rw-r--r-- | vfd.c | 36 | ||||
-rw-r--r-- | vfd.h | 3 | ||||
-rw-r--r-- | watch.c | 3 | ||||
-rw-r--r-- | watch.h | 1 |
10 files changed, 168 insertions, 51 deletions
@@ -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) @@ -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: @@ -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 @@ -14,23 +14,35 @@ #include <vdr/tools.h> #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<height && 0<bytesPerLine) + bitmap = MALLOC(uchar, bytesPerLine * height); clear(); } +/** + * Ctor - Create empty framebuffer + */ cVFDBitmap::cVFDBitmap() { height = 0; width = 0; bitmap = NULL; } +/** + * Dtor - Destroy framebuffer + */ cVFDBitmap::~cVFDBitmap() { if(bitmap) @@ -38,6 +50,9 @@ cVFDBitmap::~cVFDBitmap() { bitmap = NULL; } +/** + * Compare current framebuffer. + */ cVFDBitmap& cVFDBitmap::operator = (const cVFDBitmap& x) { if(height != x.height @@ -53,14 +68,17 @@ cVFDBitmap& cVFDBitmap::operator = (const cVFDBitmap& x) { bytesPerLine = (width + 7) / 8; - if(height && width) + if(0<height && 0<bytesPerLine) bitmap = MALLOC(uchar, bytesPerLine * height); } - if(x.bitmap) + if(bitmap && x.bitmap) memcpy(bitmap, x.bitmap, bytesPerLine * height); return *this; } +/** + * Copy current framebuffer. + */ bool cVFDBitmap::operator == (const cVFDBitmap& x) const { if(height != x.height @@ -71,12 +89,20 @@ bool cVFDBitmap::operator == (const cVFDBitmap& x) const { return ((memcmp(x.bitmap, bitmap, bytesPerLine * height)) == 0); } - +/** + * Cleanup current framebuffer. + */ void cVFDBitmap::clear() { if (bitmap) memset(bitmap, 0x00, bytesPerLine * height); } +/** + * Draw a single pixel framebuffer. + * + * \param x horizontal column. + * \param y vertical row. + */ bool cVFDBitmap::SetPixel(int x, int y) { unsigned char c; @@ -100,3 +126,67 @@ bool cVFDBitmap::SetPixel(int x, int y) return true; } + +/** + * Draw a horizontal line on framebuffer. + * + * \param x1 First horizontal column. + * \param y vertical row. + * \param x2 Second horizontal column. + */ +bool cVFDBitmap::HLine(int x1, int y, int x2) { + + sort(x1,x2); + + for (int x = x1; x <= x2; x++) { + if(!SetPixel(x, y)) + return false; + } + return true; +} + +/** + * Draw a vertical line on framebuffer. + * + * \param x horizontal column. + * \param y1 First vertical row. + * \param y2 Second vertical row. + */ +bool cVFDBitmap::VLine(int x, int y1, int y2) { + + sort(y1,y2); + + for (int y = y1; y <= y2; y++) { + if(!SetPixel(x, y)) + return false; + } + return true; +} + +/** + * Draw a rectangle on framebuffer. + * + * \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 cVFDBitmap::Rectangle(int x1, int y1, int x2, int y2, bool filled) { + + if (!filled) { + return HLine(x1, y1, x2) + && VLine(x1, y1, y2) + && HLine(x1, y2, x2) + && VLine(x2, y1, y2); + } else { + sort(y1,y2); + + for (int y = y1; y <= y2; y++) { + if(!HLine(x1, y, x2)) + return false; + } + return true; + } +} + @@ -21,8 +21,17 @@ class cVFDBitmap { uchar *bitmap; protected: cVFDBitmap(); + + inline void sort(int& x,int& y) { + if(x<y) return; + int t = x; + x = y; + y = t; + }; + bool HLine(int x1, int y, int x2); + bool VLine(int x, int y1, int y2); public: - cVFDBitmap( int w, int h ); + cVFDBitmap(int w,int h); virtual ~cVFDBitmap(); cVFDBitmap& operator = (const cVFDBitmap& x); @@ -31,7 +40,9 @@ public: void clear(); int Height() const { return height; } int Width() const { return width; } + bool SetPixel(int x, int y); + bool Rectangle(int x1, int y1, int x2, int y2, bool filled); uchar * getBitmap() const { return bitmap; }; }; @@ -15,6 +15,7 @@ #include <getopt.h> #include <string.h> +#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) { @@ -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 @@ -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); @@ -360,6 +360,9 @@ bool cVFDWatch::RenderScreen(bool bReDraw) { scRender = chName; } } else { + if(RenderSpectrumAnalyzer()) + return true; + if(Replay()) { bForce = true; } @@ -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); |