Skip to content

Commit

Permalink
initial upload to branch 'touchcol'. modifications for compatibility …
Browse files Browse the repository at this point in the history
…with branch touchcol from graphlcd-base; skin 'touchcol' for experimenting
  • Loading branch information
mrwastl committed May 1, 2011
1 parent 4121317 commit 091b7b1
Show file tree
Hide file tree
Showing 36 changed files with 633 additions and 39 deletions.
9 changes: 1 addition & 8 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
- add missing objects like textbox, scrollbar
- add dynamic behaviour to objects like scrolling and blinking
- add special objects for external data so that other plugins can draw text and bitmaps on an area of the display that will be defined in the skin. This could be used p.e. for a spectrum analyzer or displaying id3 tags.
- add service interface for external data objects
- make skin variables more dynamic, p.e. evaluate positions while displaying, not only during skin loading. This should make it easier to support several display sizes with one skin.
- DOCUMENTATION, DOCUMENTATION, DOCUMENTATION
- fix all the small bugs that were introduced
- all the stuff I forgot :-)
for skin-related TODOs: see TODO in graphlcd-base
133 changes: 110 additions & 23 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* to the COPYING file distributed with this package.
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
* (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
* (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
* (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de>
* (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net>
*/

#include <stdlib.h>
Expand All @@ -29,6 +29,8 @@
#include <vdr/tools.h>
#include <vdr/menu.h>

#include <vdr/remote.h>

cGraphLCDDisplay::cGraphLCDDisplay()
: cThread("glcd_display"),
mLcd(NULL),
Expand All @@ -43,6 +45,9 @@ cGraphLCDDisplay::cGraphLCDDisplay()

mState = StateNormal;
mLastState = StateNormal;

mDisplayMode = DisplayModeNormal;
LastTimeDisplayMode = 0;

mShowVolume = false;

Expand Down Expand Up @@ -119,21 +124,51 @@ void cGraphLCDDisplay::Action(void)
}

skinFileName = mSkinConfig->SkinPath() + "/" + mSkinConfig->SkinName() + ".skin";
mSkin = GLCD::XmlParse(*mSkinConfig, mSkinConfig->SkinName(), skinFileName);
std::string errorString = "";
mSkin = GLCD::XmlParse(*mSkinConfig, mSkinConfig->SkinName(), skinFileName, errorString);
if (!mSkin)
{
int skipx = mLcd->Width() >> 3;
int skipy = mLcd->Height() >> 3;

esyslog("graphlcd plugin: ERROR loading skin\n");

// draw an 'X' to inform the user that there was a problem with loading the skin
// (better than just leaving an empty screen ...)
mLcd->Clear();
// clear the screen with a filled rectangle using a defined colour to guarantee visible text or 'X'
#ifdef GRAPHLCD_CBITMAP_ARGB
mScreen->DrawRectangle(0, 0, mLcd->Width()-1, mLcd->Height()-1, GLCD::cColor::Black, true);
#else
mScreen->DrawRectangle(0, 0, mLcd->Width()-1, mLcd->Height()-1, GLCD::clrBlack, true);
mScreen->DrawLine(skipx, skipy, mLcd->Width()-1-skipx, mLcd->Height()-1-skipy, GLCD::clrWhite);
mScreen->DrawLine(mLcd->Width()-1-skipx, skipy, skipx, mLcd->Height()-1-skipy, GLCD::clrWhite);
#endif

GLCD::cFont * font = new GLCD::cFont();
if ( font->LoadFNT( mSkinConfig->FontPath() + "/" + "f8n.fnt") ) {
std::vector <std::string> lines;
font->WrapText(mLcd->Width()-10, mLcd->Height()-1, errorString, lines);
int lh = font->LineHeight();
for (size_t i = 0; i < lines.size(); i++) {
#ifdef GRAPHLCD_CBITMAP_ARGB
mScreen->DrawText(3, 1+i*lh, mLcd->Width()-1, lines[i], font, GLCD::cColor::White);
#else
mScreen->DrawText(3, 1+i*lh, mLcd->Width()-1, lines[i], font, GLCD::clrWhite);
#endif
}
} else {
// draw an 'X' to inform the user that there was a problem with loading the skin
// (better than just leaving an empty screen ...)
#ifdef GRAPHLCD_CBITMAP_ARGB
mScreen->DrawLine(skipx, skipy, mLcd->Width()-1-skipx, mLcd->Height()-1-skipy, GLCD::cColor::White);
mScreen->DrawLine(mLcd->Width()-1-skipx, skipy, skipx, mLcd->Height()-1-skipy, GLCD::cColor::White);
#else
mScreen->DrawLine(skipx, skipy, mLcd->Width()-1-skipx, mLcd->Height()-1-skipy, GLCD::clrWhite);
mScreen->DrawLine(mLcd->Width()-1-skipx, skipy, skipx, mLcd->Height()-1-skipy, GLCD::clrWhite);
#endif
}
#ifdef GRAPHLCD_CBITMAP_ARGB
mLcd->SetScreen(mScreen->Data(), mScreen->Width(), mScreen->Height());
#else
mLcd->SetScreen(mScreen->Data(), mScreen->Width(), mScreen->Height(), mScreen->LineSize());
#endif
mLcd->Refresh(true);
return;
}
Expand All @@ -143,11 +178,15 @@ void cGraphLCDDisplay::Action(void)
mLcd->Refresh(true);
mUpdate = true;

uint64_t lastEventMs = 0;
#define MIN_EVENT_DELAY 500

while (Running())
{
if (GraphLCDSetup.PluginActive)
{
uint64_t currTimeMs = cTimeMs::Now();
GLCD::cSkinDisplay * display = NULL;

if (mUpdateAt != 0)
{
Expand Down Expand Up @@ -185,27 +224,31 @@ void cGraphLCDDisplay::Action(void)
}
}

{
GLCD::cSkinDisplay * display = NULL;
/* display mode (normal or interactive): reset after 10 secs if not normal */
if ( (mDisplayMode != DisplayModeNormal) && ( (uint32_t)(currTimeMs - LastTimeDisplayMode) > (uint32_t)(10000)) ) {
mDisplayMode = DisplayModeNormal;
LastTimeDisplayMode = currTimeMs;
mUpdate = true;
}

if (mState == StateNormal)
display = mSkin->GetDisplay("normal");
else if (mState == StateReplay)
display = mSkin->GetDisplay("replay");
else if (mState == StateMenu)
display = mSkin->GetDisplay("menu");
if (display && display->NeedsUpdate(currTimeMs ) )
mUpdate = true;

if (mState == StateNormal)
display = mSkin->GetDisplay("normal");
else if (mState == StateReplay)
display = mSkin->GetDisplay("replay");
else if (mState == StateMenu)
display = mSkin->GetDisplay("menu");
if (display && display->NeedsUpdate(currTimeMs ) )
mUpdate = true;

}
// update Display every minute
if (mState == StateNormal && currTimeMs/60000 != mLastTimeMs/60000)
if (mState == StateNormal && (currTimeMs/60000 != mLastTimeMs/60000))
{
mUpdate = true;
}

// update Display every second in replay state
if (mState == StateReplay && currTimeMs/1000 != mLastTimeMs/1000)
if (mState == StateReplay && (currTimeMs/1000 != mLastTimeMs/1000))
{
mUpdate = true;
}
Expand All @@ -219,7 +262,7 @@ void cGraphLCDDisplay::Action(void)

// update display if BrightnessDelay is exceeded
if (bActive && (nCurrentBrightness == GraphLCDSetup.BrightnessActive) &&
((int)((cTimeMs::Now() - LastTimeBrightness)) > (GraphLCDSetup.BrightnessDelay*1000)))
((uint32_t)((cTimeMs::Now() - LastTimeBrightness)) > (uint32_t)(GraphLCDSetup.BrightnessDelay*1000)))
{
mUpdate = true;
}
Expand All @@ -232,14 +275,38 @@ void cGraphLCDDisplay::Action(void)
}


// check event
GLCD::cGLCDEvent * ev = mSkin->Config().GetDriver()->GetEvent();
if (ev && display && ((uint32_t)(currTimeMs-lastEventMs) > (uint32_t)(MIN_EVENT_DELAY) )) {
std::string rv = "";

if ( (rv = display->CheckAction(ev) ) != "") {
if (rv.substr(0,4) == "Key.") {
cRemote::Put(cKey::FromString(rv.substr(4).c_str()), true);
LastTimeDisplayMode = currTimeMs; /* if interactive mode: extend it */
} else if (rv.substr(0,5) == "Mode.") {
if (rv.substr(5) == "Interactive") {
mDisplayMode = DisplayModeInteractive;
LastTimeDisplayMode = currTimeMs;
} else if (rv.substr(5) == "Normal") {
mDisplayMode = DisplayModeNormal;
LastTimeDisplayMode = currTimeMs;
}
mUpdate = true;
}
lastEventMs = currTimeMs;
}
}

if (mUpdate)
{
mUpdateAt = 0;
mUpdate = false;

mGraphLCDState->Update();

mScreen->Clear();
mScreen->Clear(mSkin->GetBackgroundColor());

GLCD::cSkinDisplay * display = NULL;

if (mState == StateNormal)
Expand All @@ -262,13 +329,33 @@ void cGraphLCDDisplay::Action(void)
if (display)
display->Render(mScreen);
}
#ifdef GRAPHLCD_CBITMAP_ARGB
mLcd->SetScreen(mScreen->Data(), mScreen->Width(), mScreen->Height());
#else
mLcd->SetScreen(mScreen->Data(), mScreen->Width(), mScreen->Height(), mScreen->LineSize());
#endif
mLcd->Refresh(false);
mLastTimeMs = currTimeMs;
SetBrightness();

// flush events
mSkin->Config().GetDriver()->GetEvent();
}
else
{
#if 0
GLCD::cGLCDEvent * ev = mSkin->Config().GetDriver()->GetEvent();
if (ev && display && ((uint32_t)(currTimeMs-lastEventMs) > (uint32_t)(MIN_EVENT_DELAY) )) {
std::string rv = "";

if ( (rv = display->CheckAction(ev) ) != "") {
if (rv.substr(0,4) == "Key.") {
cRemote::Put(cKey::FromString(rv.substr(4).c_str()), true);
}
lastEventMs = currTimeMs;
}
}
#endif
cCondWait::SleepMs(100);
}
}
Expand Down Expand Up @@ -381,7 +468,7 @@ void cGraphLCDDisplay::SetBrightness()
else
{
if (GraphLCDSetup.BrightnessDelay < 1
|| ((int)(cTimeMs::Now() - LastTimeBrightness) > (GraphLCDSetup.BrightnessDelay*1000)))
|| ((unsigned int)(cTimeMs::Now() - LastTimeBrightness) > (unsigned int)(GraphLCDSetup.BrightnessDelay*1000)))
{
mLcd->SetBrightness(GraphLCDSetup.BrightnessIdle);
nCurrentBrightness = GraphLCDSetup.BrightnessIdle;
Expand Down
18 changes: 16 additions & 2 deletions display.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* to the COPYING file distributed with this package.
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
* (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
* (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
* (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de>
* (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net>
*/

#ifndef _GRAPHLCD_DISPLAY_H_
Expand Down Expand Up @@ -40,6 +40,13 @@ enum eThreadState
StateMenu
};

// state of current display mode (interesting for displays w/ touchpads)
enum eDisplayMode
{
DisplayModeNormal,
DisplayModeInteractive
};

// Display update Thread
class cGraphLCDDisplay : public cThread
{
Expand All @@ -59,6 +66,10 @@ class cGraphLCDDisplay : public cThread
void ForceUpdateBrightness();

const cGraphLCDService * GetServiceObject() const { return mService; }

GLCD::cDriver * GetDriver() const { return mLcd; }

const eDisplayMode GetDisplayMode() const { return mDisplayMode; }
protected:
virtual void Action();

Expand Down Expand Up @@ -89,6 +100,9 @@ class cGraphLCDDisplay : public cThread
bool bBrightnessActive;
/* external services */
cGraphLCDService * mService;
/* display mode (normal or interactive) */
eDisplayMode mDisplayMode;
uint64_t LastTimeDisplayMode;
};

#endif
Binary file added graphlcd/skins/touchcol/images/arrow.pbm
Binary file not shown.
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/images/arrow_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
8 7
 ��� 
Binary file added graphlcd/skins/touchcol/images/message.pbm
Binary file not shown.
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/images/mute.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
23 22
��`�0�0�`a�� �}�A����l��8��8��l����}�A �@�`a0�0�`���
Expand Down
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/dolby.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
����†‚������†ž���
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/dolby_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
�����?�?�?����
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/empty.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
�������������
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/empty_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
���?�?�?�9�7��
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/multilanguage.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
�����r�ڢ��ڜr����
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/multilanguage_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
���?�������?��
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/mute.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
v �0���0 �v
Expand Down
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/mute_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
G_)�%)�G_
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
�����f�����������f����
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording2.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
������n������~�����
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording2_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
���������?��
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording3.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
������n�������n�����
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording3_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
�����������
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording4.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
15 11
��������~�^���������
4 changes: 4 additions & 0 deletions graphlcd/skins/touchcol/symbols/recording4_small.pbm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P4
# Created by Paint Shop Pro 5
11 7
�������?���
Loading

0 comments on commit 091b7b1

Please sign in to comment.