direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
demoThread.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs 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. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #include "demoThread.h"
22 
24 {
25  stopped = false;
26  demoMode = false;
27 
28  // start random number generator
29  srand(time(NULL));
30 }
31 
32 
34 {
35 }
36 
37 
39 {
40  stopped = true;
41 }
42 
43 
45 {
46  int number1 = 1;
47  int number2 = 1;
48  int number3 = 1;
49  // static bool toggle = false;
50 
51  //
52  // start "threading"...
53  //
54  while (!stopped)
55  {
56 // toggle = !toggle;
57 
58  if (0)
59  {
60  emit setRGBLEDBrightness(RGBLED1, rand() % 99 +1);
61  emit setRGBLEDBrightness(RGBLED2, rand() % 99 +1);
62  emit setRGBLEDBrightness(RGBLED3, rand() % 99 +1);
63  emit setRGBLEDBrightness(RGBLED4, rand() % 99 +1);
64  emit setRGBLEDBrightness(RGBLED5, rand() % 99 +1);
65  emit setRGBLEDBrightness(RGBLED6, rand() % 99 +1);
66  }
67  else
68  {
69  number1 = rand() % 99 +1;
70  number2 = rand() % 99 +1;
71  number3 = rand() % 99 +1;
72 
73  emit setRGBLEDBrightness(RGBLED1, number1);
74  emit setRGBLEDBrightness(RGBLED2, number2);
75  emit setRGBLEDBrightness(RGBLED3, number3);
76 
77  emit setRGBLEDBrightness(RGBLED4, number1);
78  emit setRGBLEDBrightness(RGBLED5, number2);
79  emit setRGBLEDBrightness(RGBLED6, number3);
80  }
81 
82  // let the thread sleep some time - kind of timer...
83  msleep(THREADSLEEPTIME);
84  }
85  stopped = false;
86 }
87 
88 
90 {
91  return true;
92 }