Subversion Repositories HomeAutomation

Rev

Rev 1899 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1899 Rev 2300
Line 1... Line 1...
1
 
1
 
2
 
2
 
3
function TouchPanel(aliasnameRGBLED_red,aliasnameRGBLED_green, aliasnameRGBLED_blue, aliasnameTouch, aliasnameDimmer1, aliasnameDimmer2, aliasnameDimmer3, aliasnameDimmer4, aliasnameDimmer5, aliasnameDimmer6)
3
function TouchPanel(aliasnameRGBLED_red,aliasnameRGBLED_green, aliasnameRGBLED_blue, aliasnameTouch, aliasnameDimmer1, aliasnameDimmer2, aliasnameDimmer3, aliasnameDimmer4, aliasnameDimmer5, aliasnameDimmer6,aliasnameDimmer7, aliasnameIR )
4
{
4
{
5
 
5
 
6
/* Declaration of instance variables, for static variables remove prototype */
6
/* Declaration of instance variables, for static variables remove prototype */
7
 
7
 
8
    /* We must always call the parent constructor, initialization
8
    /* We must always call the parent constructor, initialization
Line 16... Line 16...
16
    this.myDimmer2 = aliasnameDimmer2;
16
    this.myDimmer2 = aliasnameDimmer2;
17
    this.myDimmer3 = aliasnameDimmer3;
17
    this.myDimmer3 = aliasnameDimmer3;
18
    this.myDimmer4 = aliasnameDimmer4;
18
    this.myDimmer4 = aliasnameDimmer4;
19
    this.myDimmer5 = aliasnameDimmer5;
19
    this.myDimmer5 = aliasnameDimmer5;
20
    this.myDimmer6 = aliasnameDimmer6;
20
    this.myDimmer6 = aliasnameDimmer6;
-
 
21
    this.myDimmer7 = aliasnameDimmer7;
-
 
22
    this.myIR = aliasnameIR;
21
    this.myTouchMode = "Gesture";
23
    this.myTouchMode = "Gesture";
22
    this.myTouchRawX = 0;
24
    this.myTouchRawX = 0;
23
    this.myTouchRawY = 0;
25
    this.myTouchRawY = 0;
24
    this.myTouchRawYlast = 0;
26
    this.myTouchRawYlast = 0;
25
    Module_RegisterToOnMessage(aliasnameTouch, function(alias_name, command, variables) { self.touchOnMessage(alias_name, command, variables) });
27
    Module_RegisterToOnMessage(aliasnameTouch, function(alias_name, command, variables) { self.touchOnMessage(alias_name, command, variables) });
Line 36... Line 38...
36
TouchPanel.prototype.myDimmer2 = null;
38
TouchPanel.prototype.myDimmer2 = null;
37
TouchPanel.prototype.myDimmer3 = null;
39
TouchPanel.prototype.myDimmer3 = null;
38
TouchPanel.prototype.myDimmer4 = null;
40
TouchPanel.prototype.myDimmer4 = null;
39
TouchPanel.prototype.myDimmer5 = null;
41
TouchPanel.prototype.myDimmer5 = null;
40
TouchPanel.prototype.myDimmer6 = null;
42
TouchPanel.prototype.myDimmer6 = null;
-
 
43
TouchPanel.prototype.myDimmer7 = null;
41
TouchPanel.prototype.myTouch = null;
44
TouchPanel.prototype.myTouch = null;
42
TouchPanel.prototype.myRGBLED_red = null;
45
TouchPanel.prototype.myRGBLED_red = null;
43
TouchPanel.prototype.myRGBLED_green = null;
46
TouchPanel.prototype.myRGBLED_green = null;
44
TouchPanel.prototype.myRGBLED_blue = null;
47
TouchPanel.prototype.myRGBLED_blue = null;
45
//TouchPanel.prototype.outputStatus = "Low";
48
//TouchPanel.prototype.outputStatus = "Low";
Line 85... Line 88...
85
                    Dimmer_AbsoluteFade(this.myDimmer5, 132, 255);
88
                    Dimmer_AbsoluteFade(this.myDimmer5, 132, 255);
86
                    Dimmer_AbsoluteFade(this.myDimmer6, 132, 255);
89
                    Dimmer_AbsoluteFade(this.myDimmer6, 132, 255);
87
                    this.setLED(0,255,0);
90
                    this.setLED(0,255,0);
88
                    Timer_Cancel(this.myInterval);
91
                    Timer_Cancel(this.myInterval);
89
                    this.myInterval = Timer_SetTimer(function(timer) {self.timerUpdate(timer)}, 5000, true);
92
                    this.myInterval = Timer_SetTimer(function(timer) {self.timerUpdate(timer)}, 5000, true);
-
 
93
                   
-
 
94
                   
-
 
95
                    /* Check if it is time to turn on ljusstake i sovrummet */
-
 
96
                   
-
 
97
                    if (get_time() > TouchGetTsFromTime("7:00") && get_time() < TouchGetTsFromTime("9:30"))
-
 
98
                    {
-
 
99
                        TouchstartSend("rf", "NexaRemote", "Dosa_3_On", 4);
-
 
100
                    }
-
 
101
                    if (get_time() > TouchGetTsFromTime("16:00") && get_time() < TouchGetTsFromTime("22:00"))
-
 
102
                    {
-
 
103
                        TouchstartSend("rf", "NexaRemote", "Dosa_3_On", 4);
-
 
104
                    }
-
 
105
                   
-
 
106
                   
90
                }
107
                }
91
                else if (gesture == "JOIN")
108
                else if (gesture == "JOIN")
92
                {
109
                {
93
                    //getDimmerService('Badrum').absFade(2,132, 0);
110
                    //getDimmerService('Badrum').absFade(2,132, 0);
94
                    //getDimmerService('TakHall').absFade(0,132, 0);
111
                    //getDimmerService('TakHall').absFade(0,132, 0);
95
                    //getDimmerService('TakSovrum').absFade(0,132, 0);
112
                    //getDimmerService('TakSovrum').absFade(0,132, 0);
96
                    Dimmer_AbsoluteFade(this.myDimmer1, 132, 0);
113
                    Dimmer_AbsoluteFade(this.myDimmer1, 132, 0);
97
                    Dimmer_AbsoluteFade(this.myDimmer2, 132, 0);
114
                    Dimmer_AbsoluteFade(this.myDimmer2, 132, 0);
-
 
115
                    var shorttime = new Date().getTimeShortFormated();
-
 
116
                    /* Remove leading zero if any */
-
 
117
                    var data = parseInt(shorttime.substr(0,2));
-
 
118
                    //if (data < 22 && data >= 6) {
98
                    Dimmer_AbsoluteFade(this.myDimmer3, 132, 0);
119
                        Dimmer_AbsoluteFade(this.myDimmer3, 132, 0);
-
 
120
                    //}
99
                    Dimmer_AbsoluteFade(this.myDimmer4, 132, 0);
121
                    Dimmer_AbsoluteFade(this.myDimmer4, 132, 0);
100
                    Dimmer_AbsoluteFade(this.myDimmer5, 132, 0);
122
                    Dimmer_AbsoluteFade(this.myDimmer5, 132, 0);
101
                    Dimmer_AbsoluteFade(this.myDimmer6, 132, 0);
123
                    Dimmer_AbsoluteFade(this.myDimmer6, 132, 0);
-
 
124
                    Dimmer_AbsoluteFade(this.myDimmer7, 132, 0);
102
                    this.setLED(0,0,255);
125
                    this.setLED(0,0,255);
103
                    Timer_Cancel(this.myInterval);
126
                    Timer_Cancel(this.myInterval);
104
                    this.myInterval = Timer_SetTimer(function(timer) {self.timerUpdate(timer)}, 5000, true);
127
                    this.myInterval = Timer_SetTimer(function(timer) {self.timerUpdate(timer)}, 5000, true);
105
                   
128
                   
106
                }
129
                }
Line 117... Line 140...
117
                    //getDimmerService('Badrum').absFade(2,132, 0);
140
                    //getDimmerService('Badrum').absFade(2,132, 0);
118
                    //getDimmerService('TakHall').absFade(0,117, 0);
141
                    //getDimmerService('TakHall').absFade(0,117, 0);
119
                    //getDimmerService('TakSovrum').absFade(0,105, 0);
142
                    //getDimmerService('TakSovrum').absFade(0,105, 0);
120
                    Dimmer_AbsoluteFade(this.myDimmer1, 132, 0);
143
                    Dimmer_AbsoluteFade(this.myDimmer1, 132, 0);
121
                    Dimmer_AbsoluteFade(this.myDimmer2, 117, 0);
144
                    Dimmer_AbsoluteFade(this.myDimmer2, 117, 0);
122
                    Dimmer_AbsoluteFade(this.myDimmer3, 103, 0);
145
                    Dimmer_AbsoluteFade(this.myDimmer3, 132, 0);
123
                    Dimmer_AbsoluteFade(this.myDimmer4, 132, 0);
146
                    Dimmer_AbsoluteFade(this.myDimmer4, 132, 0);
124
                    Dimmer_AbsoluteFade(this.myDimmer5, 132, 0);
147
                    Dimmer_AbsoluteFade(this.myDimmer5, 132, 0);
125
                    Dimmer_AbsoluteFade(this.myDimmer6, 132, 0);
148
                    Dimmer_AbsoluteFade(this.myDimmer6, 132, 0);
-
 
149
                    Dimmer_AbsoluteFade(this.myDimmer7, 132, 0);
126
                    Timer_Cancel(this.myInterval);
150
                    Timer_Cancel(this.myInterval);
127
                    this.myInterval = Timer_SetTimer(function(timer) {self.timerUpdate(timer)}, 5000, true);
151
                    this.myInterval = Timer_SetTimer(function(timer) {self.timerUpdate(timer)}, 5000, true);
-
 
152
                } else if (gesture == "INSERT_LINE")
-
 
153
                {
-
 
154
                    Log("Starting Roomba\n");
-
 
155
                    this.setLED(255,0,0);
-
 
156
                    IROut_SendBurst(this.myIR, "Roomba", "Clean");         
128
                }
157
                }
-
 
158
 
129
            }
159
            }
130
           
160
           
131
           
161
           
132
            break;
162
            break;
133
        case "Raw":
163
        case "Raw":
134
 
164
 
135
            break;
165
            break;
136
    }
166
    }
137
 
167
 
138
}
168
}
-
 
169
 
-
 
170
function TouchGetTsFromTime(time)
-
 
171
{
-
 
172
    var date = new Date().getDateFormated();
-
 
173
    var timestamp = Date.parse(date + " " + time);
-
 
174
    return timestamp/1000;
-
 
175
}
-
 
176
 
-
 
177
/* Start sending command, could be command to start heating or stop heating */
-
 
178
/* A command is sent <count> number of times to make sure its actually sent */
-
 
179
function TouchstartSend(alias, remote, button, count)
-
 
180
{
-
 
181
    if (count > 0)
-
 
182
    {
-
 
183
//Log("carHeater: Start sending heater command, count="+count);
-
 
184
        sendCounter = count;
-
 
185
        sendTimer_id = Timer_SetTimer(function(timer) {send(alias, remote, button)}, 5000, true);
-
 
186
        send(alias, remote, button);
-
 
187
    }
-
 
188
}
-
 
189
 
-
 
190
function Touchsend(alias, remote, button)
-
 
191
{
-
 
192
    if (sendCounter > 0)
-
 
193
    {
-
 
194
//Log("carHeater: Sending heater command, count="+sendCounter);
-
 
195
        IROut_SendBurst(alias, remote, button);
-
 
196
    }
-
 
197
    sendCounter--;
-
 
198
    if (sendCounter == 0)
-
 
199
    {
-
 
200
        Timer_Cancel(sendTimer_id);
-
 
201
    }
-
 
202
}
-
 
203
 
139
 
204
 
140
TouchPanel.prototype.timerUpdate = function(timer)
205
TouchPanel.prototype.timerUpdate = function(timer)
141
{
206
{
142
    this.myTouchMode = "Gesture"
207
    this.myTouchMode = "Gesture"
143
    Log("Switching back to Gesture mode\n");
208
    Log("Switching back to Gesture mode\n");