2 Copyright 2008 Thomas Steger
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
20 #include "vsleeptimer.h"
29 #include "messagequeue.h"
31 Sleeptimer* Sleeptimer::instance = NULL;
33 Sleeptimer::Sleeptimer()
39 Sleeptimer::~Sleeptimer()
44 const char* Sleeptimer::SetTime()
144 Sleeptimer* Sleeptimer::getInstance()
149 void Sleeptimer::threadMethod()
151 while (sec>-1 && active==true)
154 if (sec<31 && sec>-1)
156 VCountdown* count = new VCountdown();
158 sprintf(temp, "0:%02d", sec);
159 count->drawClock(temp);
161 Message* m1 = new Message();
162 m1->message = Message::ADD_VIEW;
163 m1->to = BoxStack::getInstance();
164 m1->parameter = reinterpret_cast<ULONG>(count);
165 MessageQueue::getInstance()->postMessage(m1);
171 Message* m2 = new Message(); // Delete self
172 m2->message = Message::UDP_BUTTON;
173 m2->to = Command::getInstance();
175 m2->parameter = 61; // FIXME use constant name when they're sorted out
176 MessageQueue::getInstance()->postMessage(m2);
182 void Sleeptimer::shutdown()
193 VSleeptimer::VSleeptimer()
197 if (Video::getInstance()->getFormat() == Video::PAL)
199 setPosition(100, 499);
203 setPosition(90, 400);
207 VSleeptimer::~VSleeptimer()
209 // Make sure the timer is deleted
210 Timers::getInstance()->cancelTimer(this, 1);
213 void VSleeptimer::draw()
215 fillColour(DrawStyle::VIEWBACKGROUND);
218 w.nextSymbol = WSymbol::CLOCK;
223 drawText(displaySleeptimer,50,2,DrawStyle::LIGHTTEXT);
224 Timers::getInstance()->setTimerD(this, 1, 2);
227 void VSleeptimer::timercall(int /* clientReference */)
230 Message* m = new Message(); // Delete self
231 m->message = Message::CLOSE_ME;
232 m->to = BoxStack::getInstance();
234 MessageQueue::getInstance()->postMessage(m);
237 int VSleeptimer::handleCommand(int command)
243 displaySleeptimer = Sleeptimer::getInstance()->SetTime();
245 BoxStack::getInstance()->update(this);
251 // allow command to drop through to other views
258 VCountdown::VCountdown()
263 if (Video::getInstance()->getFormat() == Video::PAL)
265 setPosition(100, 499);
269 setPosition(90, 400);
273 VCountdown::~VCountdown()
275 // Make sure the timer is deleted
276 Timers::getInstance()->cancelTimer(this, 1);
279 void VCountdown::drawClock(const char* sec)
281 fillColour(DrawStyle::VIEWBACKGROUND);
284 w.nextSymbol = WSymbol::CLOCK;
285 w.nextColour = DrawStyle::RED;
290 drawText(sec, 50, 2, DrawStyle::RED);
291 Timers::getInstance()->setTimerD(this, 1, 1);
294 void VCountdown::timercall(int clientReference)
297 Message* m = new Message(); // Delete self
298 m->message = Message::CLOSE_ME;
299 m->to = BoxStack::getInstance();
301 MessageQueue::getInstance()->postMessage(m);