]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Sleep timer
authorChris Tallon <chris@vomp.tv>
Sun, 14 Sep 2008 15:50:11 +0000 (15:50 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 14 Sep 2008 15:50:11 +0000 (15:50 +0000)
CREDITS
command.cc
main.cc
objects.mk
vsleeptimer.cc [new file with mode: 0644]
vsleeptimer.h [new file with mode: 0644]
wsymbol.cc
wsymbol.h

diff --git a/CREDITS b/CREDITS
index 23f9e355983135f379dac0213f4c1f49d518420a..12d5aed9819d4d0a545ea8b53016dd33ea132d5a 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -50,6 +50,9 @@ Alexander Pipelka
   Code cleaning patches
   Various bug fixes
 
+Googles
+  Sleep timer
+
 Thanks to the following people for their work with the MVP:
 
 Jon Gettler, BtB and the other MVPMC developers
index 241f5380c41747a8f03f1f32a3140a81c3bdc50c..ccf1fb44c65d3c0cc6f8d3c9c2c63f4656f31f8c 100644 (file)
@@ -49,6 +49,7 @@
 #include "boxx.h"
 #include "boxstack.h"
 #include "log.h"
+#include "vsleeptimer.h"
 
 
 Command* Command::instance = NULL;
@@ -466,6 +467,13 @@ void Command::handleCommand(int button)
       doFromTheTop(false);
       return;
     }
+    case Remote::GO:
+    {
+      VSleeptimer* sleep = new VSleeptimer();
+      boxstack->add(sleep);
+      sleep->handleCommand(button); // this will draw+show
+      return;
+    }
   }
 }
 
@@ -502,6 +510,7 @@ void Command::doStandby()
     VDR::getInstance()->disconnect();
     Led::getInstance()->off();
     isStandby = 1;
+    Sleeptimer::getInstance()->shutdown();
 #ifdef WIN32
     stop(); //different behavoiur on windows, we exit
 #endif
diff --git a/main.cc b/main.cc
index 5361f7f78303dce29e86cb50d7c09217c74c94f1..ac5a5936780fb6a959ddf4befae560ad8d841222 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -41,7 +41,7 @@
 #include "audiomvp.h"
 #include "videomvp.h"
 #include "wol.h"
-
+#include "vsleeptimer.h"
 #ifndef WIN32
 void sighandler(int signalReceived);
 #endif
@@ -66,6 +66,7 @@ VDR* vdr;
 Video* video;
 Audio* audio;
 Wol* wol;
+Sleeptimer* sleeptimer;
 
 // Linux MVP main function and sighandler
 #ifndef WIN32
@@ -117,8 +118,9 @@ int main(int argc, char** argv)
   boxstack   = new BoxStack();
   command    = new Command();
   wol        = new Wol();
-
-  if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !boxstack || !command || !wol)
+  sleeptimer = new Sleeptimer();
+  
+  if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !boxstack || !command || !wol || !sleeptimer)
   {
     printf("Could not create objects. Memory problems?\n");
     shutdown(1);
@@ -463,6 +465,12 @@ void shutdown(int code)
     logger->log("Core", Log::NOTICE, "WOL module shut down");
   }
 
+  if (sleeptimer)
+  {
+    delete sleeptimer;
+    logger->log("Core", Log::NOTICE, "Sleeptimer module shut down");
+  }
+
   if (logger)
   {
     logger->log("Core", Log::NOTICE, "Log module shutting down... bye!\n\n");
index 77681f42d5ddd4eaa888444b11be367bc46cd4b9..5fb9fcbb6f13548b518a04be5b7b71f44229c9dd 100644 (file)
@@ -17,6 +17,6 @@ OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o mutex.o     \
            vmedialist.o media.o vpicture.o vpicturebanner.o                   \
            vaudioplayer.o audioplayer.o demuxeraudio.o abstractoption.o       \
            eventdispatcher.o vdrrequestpacket.o vdrresponsepacket.o           \
-           vvideolivetv.o                                                     \
+           vvideolivetv.o vsleeptimer.o                                       \
            playerlivetv.o playerliveradio.o                                   \
            wprogressbar.o
diff --git a/vsleeptimer.cc b/vsleeptimer.cc
new file mode 100644 (file)
index 0000000..79ea1f9
--- /dev/null
@@ -0,0 +1,314 @@
+/*
+    Copyright 2008 Googles
+
+    This file is part of VOMP.
+
+    VOMP 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.
+
+    VOMP 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 VOMP; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#include "vsleeptimer.h"
+
+#include "remote.h"
+#include "wsymbol.h"
+#include "colour.h"
+#include "video.h"
+#include "timers.h"
+#include "boxstack.h"
+#include "command.h"
+
+Sleeptimer* Sleeptimer::instance = NULL;
+
+Sleeptimer::Sleeptimer()
+{
+   if (instance) return;
+   sec = -1;
+   active = false;
+   instance = this;
+   
+}
+
+Sleeptimer::~Sleeptimer()
+{
+   instance = NULL;
+}
+
+
+const char* Sleeptimer::SetTime()
+{
+   if (sec <890)
+     {
+       sec=900;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "0:15";
+     }
+   else if (sec <1790)
+     {
+       sec = 1800;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "0:30";
+     }
+   else if (sec < 2690)
+     {
+       sec = 2700;
+       if (active==false)
+       {
+          active = true;  
+          threadStart();
+       }
+       
+       return "0:45";
+     }
+   else if (sec < 3590)
+     {
+       sec = 3600;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "1:00";
+     }
+   else if (sec < 4490)
+     {
+       sec = 4500;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "1:15";
+     }
+   else if (sec < 5390)
+     {
+       sec = 5400;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "1:30";
+     }
+   else if (sec < 6290)
+     {
+       sec = 6300;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "1:45";
+     }
+   else if (sec < 7190)
+     {
+       sec = 7200;
+       if (active==false)
+       {
+          active = true;
+          threadStart();
+       }
+       
+       return "2:00";
+       
+     }
+   else
+     {
+       sec = -1;
+       if (active==true)
+       shutdown();
+       return "AUS";
+     }
+   
+}
+
+Sleeptimer* Sleeptimer::getInstance()
+{
+     return instance;
+}
+
+void Sleeptimer::threadMethod()
+{
+   
+   while (sec>-1 && active==true)
+     {
+       sec--;
+       if (sec<31 && sec>-1)
+         {
+            VCountdown* count = new VCountdown();
+             char* temp;
+            asprintf(&temp, "0:%02d", sec);
+            count->draw(temp);
+            free (temp);
+            Message* m1 = new Message();
+            m1->message = Message::ADD_VIEW;
+             m1->to = BoxStack::getInstance();
+             m1->parameter = (ULONG)count;
+            Command::getInstance()->postMessageNoLock(m1);
+         }
+        MILLISLEEP(1000);
+       
+       
+        if (sec==-1)
+         {
+            Message* m2 = new Message(); // Delete self
+            m2->message = Message::UDP_BUTTON;
+            m2->to = Command::getInstance();
+            m2->from = this;
+            m2->parameter = 61;
+            Command::getInstance()->postMessageFromOuterSpace(m2);
+            shutdown();
+         }
+       
+     }
+   
+     
+}
+
+void Sleeptimer::shutdown()
+{
+   if (active==true)
+     {
+       sec=-1; 
+       threadCancel();
+       active = false;
+     }
+   
+}
+
+
+VSleeptimer::VSleeptimer()
+{
+  setSize(100, 28);
+  createBuffer();
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    setPosition(100, 499);
+  }
+  else
+  {
+    setPosition(90, 400);
+  }
+}
+
+VSleeptimer::~VSleeptimer()
+{
+  // Make sure the timer is deleted
+  Timers::getInstance()->cancelTimer(this, 1);
+}
+
+void VSleeptimer::draw()
+{
+   fillColour(Colour::VIEWBACKGROUND);
+   WSymbol w;
+   TEMPADD(&w);
+   w.nextSymbol = WSymbol::CLOCK;
+   w.setPosition(3, 0);
+   w.draw();
+   Boxx::draw();
+   drawText(displaySleeptimer,50,2,Colour::LIGHTTEXT);
+   Timers::getInstance()->setTimerD(this, 1, 2);
+}
+
+void VSleeptimer::timercall(int clientReference)
+{
+  // delete me!
+  Message* m = new Message(); // Delete self
+  m->message = Message::CLOSE_ME;
+  m->to = BoxStack::getInstance();
+  m->from = this;
+  Command::getInstance()->postMessageFromOuterSpace(m);
+}
+
+int VSleeptimer::handleCommand(int command)
+{
+  switch(command)
+  {
+    case Remote::GO:
+    {
+      displaySleeptimer = Sleeptimer::getInstance()->SetTime();
+      draw();
+      BoxStack::getInstance()->update(this);
+      // handled
+      return 2;
+    }
+  }
+
+  // allow command to drop through to other views
+  return 0;
+}
+
+
+
+
+VCountdown::VCountdown()
+{
+
+  setSize(100, 28);
+  createBuffer();
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    setPosition(100, 499);
+  }
+  else
+  {
+    setPosition(90, 400);
+  }
+}
+
+VCountdown::~VCountdown()
+{
+  // Make sure the timer is deleted
+  Timers::getInstance()->cancelTimer(this, 1);
+}
+
+void VCountdown::draw(const char* sec)
+{
+   
+   fillColour(Colour::VIEWBACKGROUND);
+   WSymbol w;
+   TEMPADD(&w);
+   w.nextSymbol = WSymbol::CLOCK;
+   w.nextColour = Colour::RED;
+   w.setPosition(3, 0);
+   w.draw();
+   Boxx::draw();
+   drawText(sec,50,2,Colour::RED); 
+   Timers::getInstance()->setTimerD(this, 1, 1);
+}
+
+void VCountdown::timercall(int clientReference)
+{
+  // delete me!
+  Message* m = new Message(); // Delete self
+  m->message = Message::CLOSE_ME;
+  m->to = BoxStack::getInstance();
+  m->from = this;
+  Command::getInstance()->postMessageFromOuterSpace(m);
+}
diff --git a/vsleeptimer.h b/vsleeptimer.h
new file mode 100644 (file)
index 0000000..b6c04ec
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+    Copyright 2008 Googles
+
+    This file is part of VOMP.
+
+    VOMP 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.
+
+    VOMP 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 VOMP; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#ifndef VSLEEPTIMER_H
+#define VSLEEPTIMER_H
+
+#include <stdio.h>
+
+#include "boxx.h"
+#include "timerreceiver.h"
+
+#ifndef WIN32
+#include "threadp.h"
+#else
+#include "threadwin.h"
+#endif
+
+class Sleeptimer : public Thread_TYPE
+{
+ public:
+   Sleeptimer();
+   virtual ~Sleeptimer();
+   static Sleeptimer* getInstance();
+   const char* SetTime();
+   void shutdown();   
+   virtual void threadMethod();
+   virtual void threadPostStopCleanup() {};
+   
+ private:
+   int sec;
+   bool active;
+   static Sleeptimer* instance;
+   
+
+   
+};
+
+
+
+
+class VSleeptimer : public Boxx, public TimerReceiver
+{
+  public:
+    VSleeptimer();
+    ~VSleeptimer();
+    void draw();
+    int handleCommand(int command);
+    void timercall(int clientReference);
+
+  private:
+    const char*  displaySleeptimer;
+
+};
+
+class VCountdown : public Boxx, public TimerReceiver
+{
+   
+ public:
+       VCountdown();
+       ~VCountdown();
+       void draw(const char* sec);
+       void timercall(int clientReference);
+   
+}
+;
+
+
+#endif
+
index 4f693e09c2b67440372f47996b7299d1bd819414..a4d826245c4927dae8f5d779b8090d3e95ab93f8 100644 (file)
@@ -22,8 +22,8 @@
 
 #include "colour.h"
 
-UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5, 4, 4, 2, 2, 5, 5, 4, 4};
-UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18, 16, 16, 8, 8, 16, 16, 16, 16};
+UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5, 4, 4, 2, 2, 5, 5, 4, 4, 5};
+UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18, 16, 16, 8, 8, 16, 16, 16, 16, 26};
 
 UCHAR WSymbol::symbols[] = {
 
@@ -999,12 +999,61 @@ UCHAR WSymbol::symbols[] = {
 0xFF, 0x03, 0xFC, 0xFF,
 0xFF, 0x03, 0xFC, 0xFF,
 
+/*
+00000000 00011111 11111111 11111000 00000000
+00000000 00111111 11111111 11111100 00000000
+00000000 01111111 11111111 11111110 00000000
+00000000 11111111 11111111 11111111 00000000
+00000001 11111111 11111111 11111111 10000000
+00000011 11111100 00000000 00111111 11000000
+00000111 11111000 00000000 00011111 11100000
+00001111 11110000 00111100 00001111 11110000
+00011111 11100000 00111100 00000111 11111000
+00111111 11000000 00111100 00000011 11111100
+01111111 10000000 00111100 00000001 11111110
+11111111 00000000 00111111 11111100 11111111
+11111111 00000000 00111111 11111100 11111111
+11111111 00000000 00111111 11111100 11111111
+11111111 00000000 00111111 11111100 11111111
+01111111 10000000 00000000 00000001 11111110
+00111111 11000000 00000000 00000011 11111100
+00011111 11100000 00000000 00000111 11111000
+00001111 11110000 00000000 00001111 11110000
+00000111 11111000 00000000 00011111 11100000
+00000011 11111100 00000000 00111111 11000000
+00000001 11111111 11111111 11111111 10000000
+00000000 11111111 11111111 11111110 00000000
+00000000 01111111 11111111 11111100 00000000
+00000000 00111111 11111111 11111000 00000000
+00000000 00011111 11111111 11110000 00000000
+*/
 
-
-
-
-
-
+0x00, 0x1F, 0xFF, 0xF8, 0x00,
+0x00, 0x3F, 0xFF, 0xFC, 0x00,
+0x00, 0x7F, 0xFF, 0xFE, 0x00,
+0x00, 0xFF, 0xFF, 0xFF, 0x00,
+0x01, 0xFF, 0xFF, 0xFF, 0x80,
+0x03, 0xFC, 0x00, 0x3F, 0xC0,
+0x07, 0xF8, 0x00, 0x1F, 0xE0,
+0x0F, 0xF0, 0x3C, 0x0F, 0xF0,
+0x1F, 0xE0, 0x3C, 0x07, 0xF8,
+0x3F, 0xC0, 0x3C, 0x03, 0xFC,
+0x7F, 0x80, 0x3C, 0x01, 0xFE, 
+0xFF, 0x00, 0x3F, 0xFC, 0xFF,
+0xFF, 0x00, 0x3F, 0xFC, 0xFF,
+0xFF, 0x00, 0x3F, 0xFC, 0xFF, 
+0xFF, 0x00, 0x3F, 0xFC, 0xFF,
+0x7F, 0x80, 0x00, 0x01, 0xFE,
+0x3F, 0xC0, 0x00, 0x03, 0xFC,
+0x1F, 0xE0, 0x00, 0x07, 0xF8,
+0x0F, 0xF0, 0x00, 0x0F, 0xF0,
+0x07, 0xF8, 0x00, 0x1F, 0xE0,
+0x03, 0xFC, 0x00, 0x3F, 0xC0,
+0x01, 0xFF, 0xFF, 0xFF, 0x80,
+0x00, 0xFF, 0xFF, 0xFE, 0x00,
+0x00, 0x7F, 0xFF, 0xFC, 0x00,
+0x00, 0x3F, 0xFF, 0xF8, 0x00,
+0x00, 0x1F, 0xFF, 0xF0, 0x00,
 
 };
 
index 2a6c940aca55c4a635f4bada81783d5c284f8296..4cb59c9bf65c2b7d37584ba29abd3f0ba63be07b 100644 (file)
--- a/wsymbol.h
+++ b/wsymbol.h
@@ -61,7 +61,7 @@ class WSymbol : public Boxx
     const static UCHAR VIDEOASPECT169 = 23;
     const static UCHAR SINGLEAUDIO = 24;
     const static UCHAR MULTIAUDIO = 25;
-    
+    const static UCHAR CLOCK = 26;    
   private:
     static UCHAR symbols[];
     static UCHAR widths[];