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/>.
27 #include "messagequeue.h"
30 #include "vsleeptimer.h"
32 Sleeptimer* Sleeptimer::instance = NULL;
34 Sleeptimer::Sleeptimer()
40 Sleeptimer::~Sleeptimer()
45 const char* Sleeptimer::SetTime()
145 Sleeptimer* Sleeptimer::getInstance()
150 void Sleeptimer::threadMethod()
152 while (sec>-1 && active==true)
155 if (sec<31 && sec>-1)
157 VCountdown* count = new VCountdown();
159 sprintf(temp, "0:%02d", sec);
160 count->drawClock(temp);
162 Message* m1 = new Message();
163 m1->message = Message::ADD_VIEW;
164 m1->p_to = Message::BOXSTACK;
165 m1->data = reinterpret_cast<void*>(count);
166 MessageQueue::getInstance()->postMessage(m1);
172 Message* m2 = new Message();
173 m2->message = Message::INPUT_EVENT;
174 m2->p_to = Message::CONTROL;
176 m2->parameter = Input::POWER;
177 MessageQueue::getInstance()->postMessage(m2);
183 void Sleeptimer::shutdown()
194 VSleeptimer::VSleeptimer()
198 if (Video::getInstance()->getFormat() == Video::PAL)
200 setPosition(100, 499);
204 setPosition(90, 400);
208 VSleeptimer::~VSleeptimer()
210 // Make sure the timer is deleted
211 Timers::getInstance()->cancelTimer(this, 1);
214 void VSleeptimer::draw()
216 fillColour(DrawStyle::VIEWBACKGROUND);
219 w.nextSymbol = WSymbol::CLOCK;
224 drawText(displaySleeptimer,50,2,DrawStyle::LIGHTTEXT);
225 Timers::getInstance()->setTimerD(this, 1, 2);
228 void VSleeptimer::timercall(int /* clientReference */)
231 Message* m = new Message(); // Delete self
232 m->message = Message::CLOSE_ME;
233 m->p_to = Message::BOXSTACK;
235 MessageQueue::getInstance()->postMessage(m);
238 int VSleeptimer::handleCommand(int command)
244 displaySleeptimer = Sleeptimer::getInstance()->SetTime();
246 BoxStack::getInstance()->update(this);
252 // allow command to drop through to other views
259 VCountdown::VCountdown()
264 if (Video::getInstance()->getFormat() == Video::PAL)
266 setPosition(100, 499);
270 setPosition(90, 400);
274 VCountdown::~VCountdown()
276 // Make sure the timer is deleted
277 Timers::getInstance()->cancelTimer(this, 1);
280 void VCountdown::drawClock(const char* sec)
282 fillColour(DrawStyle::VIEWBACKGROUND);
285 w.nextSymbol = WSymbol::CLOCK;
286 w.nextColour = DrawStyle::RED;
291 drawText(sec, 50, 2, DrawStyle::RED);
292 Timers::getInstance()->setTimerD(this, 1, 1);
295 void VCountdown::timercall(int /* clientReference */)
298 Message* m = new Message(); // Delete self
299 m->message = Message::CLOSE_ME;
300 m->p_to = Message::BOXSTACK;
302 MessageQueue::getInstance()->postMessage(m);