--- /dev/null
+/*
+ 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);
+}
--- /dev/null
+/*
+ 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
+
#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[] = {
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,
};