summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranbr <vdr07@deltab.de>2010-10-31 10:19:39 +0100
committeranbr <vdr07@deltab.de>2010-10-31 10:19:39 +0100
commit25177cb4765a03da7fab10c500097910e13924e6 (patch)
tree488e54bdf7f851dcddf44e05bebc4cc48130b376
parent16745cec0de781245650aa6332c97ae9a8db8644 (diff)
downloadvdr-plugin-targavfd-25177cb4765a03da7fab10c500097910e13924e6.tar.gz
vdr-plugin-targavfd-25177cb4765a03da7fab10c500097910e13924e6.tar.bz2
Support spectrum analyzer visualization (need span-plugin)0.0.6
-rw-r--r--HISTORY3
-rw-r--r--Makefile2
-rw-r--r--README6
-rw-r--r--bitmap.c100
-rw-r--r--bitmap.h13
-rw-r--r--targavfd.c52
-rw-r--r--vfd.c36
-rw-r--r--vfd.h3
-rw-r--r--watch.c3
-rw-r--r--watch.h1
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 <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;
+ }
+}
+
diff --git a/bitmap.h b/bitmap.h
index 6f4691e..e39d199 100644
--- a/bitmap.h
+++ b/bitmap.h
@@ -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; };
};
diff --git a/targavfd.c b/targavfd.c
index 9a0de26..100dfef 100644
--- a/targavfd.c
+++ b/targavfd.c
@@ -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) {
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 &current, int &total) const;
bool CurrentTime(time_t ts);