Rev 1194 | Rev 1198 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1194 | Rev 1195 | ||
|---|---|---|---|
| Line 121... | Line 121... | ||
| 121 | this.statusMenuItem.doUpdate = this.updateStatusMenuItem; |
121 | this.statusMenuItem.doUpdate = this.updateStatusMenuItem; |
| 122 | this.currentMenuItem = this.statusMenuItem; |
122 | this.currentMenuItem = this.statusMenuItem; |
| 123 | 123 | ||
| 124 | /* create the menuitem where you can choose to enter the booking sub-menu */ |
124 | /* create the menuitem where you can choose to enter the booking sub-menu */ |
| 125 | this.bookMenuItem = new MenuItem(this); |
125 | this.bookMenuItem = new MenuItem(this); |
| 126 | this.bookMenuItem.displayData[0] = this.lcdCenterText("Book room"; |
126 | this.bookMenuItem.displayData[0] = this.lcdCenterText("Book room"); |
| 127 | this.bookMenuItem.displayData[1] = this.lcdCenterText(""); |
127 | this.bookMenuItem.displayData[1] = this.lcdCenterText(""); |
| 128 | this.bookMenuItem.doUpdate = this.updateBookMenuItem; |
128 | this.bookMenuItem.doUpdate = this.updateBookMenuItem; |
| 129 | 129 | ||
| 130 | /* connect the items as a linked list */ |
130 | /* connect the items as a linked list */ |
| 131 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
131 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
| Line 264... | Line 264... | ||
| 264 | } |
264 | } |
| 265 | 265 | ||
| 266 | Display.prototype.incBookTimeTo = function() |
266 | Display.prototype.incBookTimeTo = function() |
| 267 | { |
267 | { |
| 268 | //FIXME: constraints? |
268 | //FIXME: constraints? |
| 269 | if (this.parentDisplay. |
269 | if (this.parentDisplay.bookToTime.getHours() < 23) |
| 270 | { |
270 | { |
| 271 | this.parentDisplay.bookToTime.setMinutes(this.parentDisplay.bookToTime.getMinutes() + 30); |
271 | this.parentDisplay.bookToTime.setMinutes(this.parentDisplay.bookToTime.getMinutes() + 30); |
| 272 | } |
272 | } |
| 273 | } |
273 | } |
| 274 | 274 | ||
| 275 | Display.prototype.decBookTimeTo = function() |
275 | Display.prototype.decBookTimeTo = function() |
| 276 | { |
276 | { |
| 277 | //FIXME: constraints? |
277 | //FIXME: constraints? |
| 278 | var now = new Date(); |
278 | var now = new Date(); |
| 279 | if (this.parentDisplay.bookToTime.getHours() >= now.getHours()) |
279 | if (this.parentDisplay.bookToTime.getHours() >= now.getHours()) |
| 280 | { |
280 | { |
| 281 | this.parentDisplay.bookToTime.setMinutes(this.parentDisplay.bookToTime.getMinutes() - 30); |
281 | this.parentDisplay.bookToTime.setMinutes(this.parentDisplay.bookToTime.getMinutes() - 30); |
| 282 | } |
282 | } |
| 283 | } |
283 | } |
| 284 | 284 | ||
| 285 | Display.prototype.incBookTimeFrom = function() |
285 | Display.prototype.incBookTimeFrom = function() |
| 286 | { |
286 | { |
| 287 | //FIXME: constraints? |
287 | //FIXME: constraints? |
| 288 | if (this.parentDisplay.bookFromTime.getHours() < 23) |
288 | if (this.parentDisplay.bookFromTime.getHours() < 23) |
| 289 | { |
289 | { |
| 290 | this.parentDisplay.bookFromTime.setMinutes(this.parentDisplay.bookFromTime.getMinutes() + 30); |
290 | this.parentDisplay.bookFromTime.setMinutes(this.parentDisplay.bookFromTime.getMinutes() + 30); |
| 291 | } |
291 | } |
| 292 | } |
292 | } |
| 293 | 293 | ||
| 294 | Display.prototype.decBookTimeFrom = function() |
294 | Display.prototype.decBookTimeFrom = function() |
| 295 | { |
295 | { |
| 296 | //FIXME: constraints? |
296 | //FIXME: constraints? |
| 297 | var now = new Date(); |
297 | var now = new Date(); |
| 298 | if (this.parentDisplay.bookFromTime.getHours() >= now.getHours()) |
298 | if (this.parentDisplay.bookFromTime.getHours() >= now.getHours()) |
| 299 | { |
299 | { |
| 300 | this.parentDisplay.bookFromTime.setMinutes(this.parentDisplay.bookFromTime.getMinutes() - 30); |
300 | this.parentDisplay.bookFromTime.setMinutes(this.parentDisplay.bookFromTime.getMinutes() - 30); |
| 301 | } |
301 | } |
| 302 | } |
302 | } |
| 303 | 303 | ||
| 304 | Display.prototype.setBookTimeFrom = function() |
304 | Display.prototype.setBookTimeFrom = function() |
| 305 | { |
305 | { |
| 306 | this.displayData[1] = " <"+this.parentDisplay.bookFromTime.getTimeShortFormated()+"> "; |
306 | this.displayData[1] = " <"+this.parentDisplay.bookFromTime.getTimeShortFormated()+"> "; |
| 307 | } |
307 | } |
| 308 | 308 | ||
| 309 | Display.prototype.setBookTimeTo = function() |
309 | Display.prototype.setBookTimeTo = function() |
| 310 | { |
310 | { |
| 311 | this.displayData[1] = " <"+this.parentDisplay.bookToTime.getTimeShortFormated()+"> "; |
311 | this.displayData[1] = " <"+this.parentDisplay.bookToTime.getTimeShortFormated()+"> "; |
| 312 | } |
312 | } |
| 313 | 313 | ||
| 314 | Display.prototype.chooseBookTimeTo = function() |
314 | Display.prototype.chooseBookTimeTo = function() |
| 315 | { |
315 | { |
| 316 | this.displayData[0] = " "+this.parentDisplay.bookFromTime.getTimeShortFormated()+" - <" |
316 | this.displayData[0] = " "+this.parentDisplay.bookFromTime.getTimeShortFormated()+" - <" |
| 317 | +this.parentDisplay.bookToTime.getTimeShortFormated()+"> "; |
317 | +this.parentDisplay.bookToTime.getTimeShortFormated()+"> "; |
| 318 | } |
318 | } |
| 319 | 319 | ||
| 320 | Display.prototype.chooseBookTimeFrom = function() |
320 | Display.prototype.chooseBookTimeFrom = function() |
| 321 | { |
321 | { |
| 322 | this.displayData[0] = " <"+this.parentDisplay.bookFromTime.getTimeShortFormated()+"> - " |
322 | this.displayData[0] = " <"+this.parentDisplay.bookFromTime.getTimeShortFormated()+"> - " |
| 323 | +this.parentDisplay.bookToTime.getTimeShortFormated()+" "; |
323 | +this.parentDisplay.bookToTime.getTimeShortFormated()+" "; |
| 324 | } |
324 | } |
| 325 | 325 | ||
| 326 | Display.prototype.setBookTime = function() |
326 | Display.prototype.setBookTime = function() |
| 327 | { |
327 | { |
| 328 | this.displayData[0] = " "+this.parentDisplay.bookFromTime.getTimeShortFormated()+" - " |
328 | this.displayData[0] = " "+this.parentDisplay.bookFromTime.getTimeShortFormated()+" - " |
| 329 | +this.parentDisplay.bookToTime.getTimeShortFormated()+" "; |
329 | +this.parentDisplay.bookToTime.getTimeShortFormated()+" "; |
| 330 | } |
330 | } |
| 331 | 331 | ||
| 332 | Display.prototype.updateStatusMenuItem = function() |
332 | Display.prototype.updateStatusMenuItem = function() |
| 333 | { |
333 | { |
| 334 | var date = new Date(); |
334 | var date = new Date(); |
| 335 | var dateAndTime = "" + date.getTimeShortFormated(); |
335 | var dateAndTime = "" + date.getTimeShortFormated(); |
| Line 338... | Line 338... | ||
| 338 | if (this.parentDisplay.exchangeCalendarFirstMenuItem && this.parentDisplay.exchangeCalendarLastMenuItem) |
338 | if (this.parentDisplay.exchangeCalendarFirstMenuItem && this.parentDisplay.exchangeCalendarLastMenuItem) |
| 339 | { |
339 | { |
| 340 | this.parentDisplay.statusMenuItem.setNextItem(this.parentDisplay.exchangeCalendarFirstMenuItem); |
340 | this.parentDisplay.statusMenuItem.setNextItem(this.parentDisplay.exchangeCalendarFirstMenuItem); |
| 341 | this.parentDisplay.bookMenuItem.setPrevItem(this.parentDisplay.exchangeCalendarLastMenuItem); |
341 | this.parentDisplay.bookMenuItem.setPrevItem(this.parentDisplay.exchangeCalendarLastMenuItem); |
| 342 | } |
342 | } |
| 343 | } |
343 | } |
| - | 344 | ||
| - | 345 | Display.prototype.updateBookMenuItem = function() |
|
| - | 346 | { |
|
| - | 347 | if (this.parentDisplay.exchangeCalendarFirstMenuItem && this.parentDisplay.exchangeCalendarLastMenuItem) |
|
| - | 348 | { |
|
| - | 349 | this.parentDisplay.statusMenuItem.setNextItem(this.parentDisplay.exchangeCalendarFirstMenuItem); |
|
| - | 350 | this.parentDisplay.bookMenuItem.setPrevItem(this.parentDisplay.exchangeCalendarLastMenuItem); |
|
| - | 351 | } |
|
| - | 352 | } |
|
| 344 | 353 | ||
| 345 | Display.prototype. |
354 | Display.prototype.exchangeCalendarLookupCallback = function(shortname, data) |
| 346 | { |
355 | { |
| - | 356 | //log("callback: "+shortname+" \n"); |
|
| 347 | if ( |
357 | if (shortname == this.shortName) |
| 348 | { |
358 | { |
| 349 |
|
359 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
| 350 |
|
360 | if (data.error) |
| 351 | |
361 | { |
| - | 362 | log("Display: got this error from exchange.php: " + data.error + "\n"); |
|
| 352 | } |
363 | } |
| 353 | - | ||
| 354 | Display.prototype.exchangeCalendarLookupCallback = function(shortname, data) |
- | |
| 355 |
|
364 | else |
| 356 | log("callback: "+shortname+" \n"); |
- | |
| 357 | if (shortname == this.shortName) |
- | |
| 358 | { |
365 | { |
| 359 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
- | |
| 360 | this.exchangeData = data; |
366 | this.exchangeData = data; |
| 361 | - | ||
| 362 | this.createCalendarMenu(); |
367 | this.createCalendarMenu(); |
| - | 368 | } |
|
| 363 | } |
369 | } |
| 364 | } |
370 | } |
| 365 | 371 | ||
| 366 | /* this function parses calendar data from exchange-script and creates a menu */ |
372 | /* this function parses calendar data from exchange-script and creates a menu */ |
| 367 | Display.prototype.createCalendarMenu = function() |
373 | Display.prototype.createCalendarMenu = function() |
| 368 | { |
374 | { |
| 369 | log |
375 | //log("createCalendar \n"); |
| 370 | if (this.exchangeData) |
376 | if (this.exchangeData) |
| 371 | { |
377 | { |
| 372 | log |
378 | //log("have data \n"); |
| 373 | var lastMenuItem; |
379 | var lastMenuItem; |
| 374 | for (var i = 0; i < this.exchangeData.meetings.length; i++) |
380 | for (var i = 0; i < this.exchangeData.meetings.length; i++) |
| 375 | { |
381 | { |
| 376 | log |
382 | //log("looping \n"); |
| 377 | /* create the menuitem for a calendar meeting */ |
383 | /* create the menuitem for a calendar meeting */ |
| 378 | var menu = new MenuItem(this); |
384 | var menu = new MenuItem(this); |
| 379 | menu.displayData[0] = this.lcdCenterText(this.exchangeData.meetings[i].organizer); |
385 | menu.displayData[0] = this.lcdCenterText(this.exchangeData.meetings[i].organizer); |
| 380 | menu.displayData[1] = this.lcdCenterText(this.exchangeData.meetings[i].start.replace(":",".") + " - " |
386 | menu.displayData[1] = this.lcdCenterText(this.exchangeData.meetings[i].start.replace(":",".") + " - " |
| 381 | + this.exchangeData.meetings[i].end.replace(":",".")); |
387 | + this.exchangeData.meetings[i].end.replace(":",".")); |
| 382 | menu.doRight = this.changeToNext; |
388 | menu.doRight = this.changeToNext; |
| 383 | menu.doLeft = this.changeToPrev; |
389 | menu.doLeft = this.changeToPrev; |
| 384 | 390 | ||
| 385 | if (i == 0) |
391 | if (i == 0) |
| 386 | { |
392 | { |
| 387 | this.exchangeCalendarFirstMenuItem = menu; |
393 | this.exchangeCalendarFirstMenuItem = menu; |
| 388 | } |
394 | } |
| 389 | else |
395 | else |
| 390 | { |
396 | { |
| 391 | menu.setPrevItem(lastMenuItem); |
397 | menu.setPrevItem(lastMenuItem); |
| 392 | lastMenuItem.setNextItem(menu); |
398 | lastMenuItem.setNextItem(menu); |
| 393 | } |
399 | } |
| 394 | 400 | ||
| 395 | lastMenuItem = menu; |
401 | lastMenuItem = menu; |
| 396 | } |
402 | } |
| 397 | this.exchangeCalendarLastMenuItem = lastMenuItem; |
403 | this.exchangeCalendarLastMenuItem = lastMenuItem; |
| 398 | this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem); |
404 | this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem); |
| 399 | this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem); |
405 | this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem); |
| 400 | } |
406 | } |
| 401 | } |
407 | } |
| 402 | 408 | ||
| 403 | Display.prototype.softPwmOnline = function() |
409 | Display.prototype.softPwmOnline = function() |
| 404 | { |
410 | { |
| 405 | } |
411 | } |
| 406 | 412 | ||
| 407 | Display.prototype.rotaryOnline = function() |
413 | Display.prototype.rotaryOnline = function() |
| 408 | { |
414 | { |
| 409 | } |
415 | } |
| 410 | 416 | ||
| 411 | Display.prototype.rotaryPosUpdate = function(SwitchId) |
417 | Display.prototype.rotaryPosUpdate = function(SwitchId) |
| 412 | { |
418 | { |
| 413 | for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++) |
419 | for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++) |
| 414 | { |
420 | { |
| 415 | if (this.myRotaryService.getDirection(SwitchId) == "Clockwise") |
421 | if (this.myRotaryService.getDirection(SwitchId) == "Clockwise") |
| 416 | { |
422 | { |
| 417 | if (this.currentMenuItem.doRight) |
423 | if (this.currentMenuItem.doRight) |
| 418 | { |
424 | { |
| 419 | this.currentMenuItem.doRight(); |
425 | this.currentMenuItem.doRight(); |
| 420 | } |
426 | } |
| 421 | } |
427 | } |
| 422 | else |
428 | else |
| 423 | { |
429 | { |
| 424 | if (this.currentMenuItem.doLeft) |
430 | if (this.currentMenuItem.doLeft) |
| 425 | { |
431 | { |
| 426 | this.currentMenuItem.doLeft(); |
432 | this.currentMenuItem.doLeft(); |
| 427 | } |
433 | } |
| 428 | } |
434 | } |
| 429 | } |
435 | } |
| 430 | 436 | ||
| 431 | this.updateDisplay(); |
437 | this.updateDisplay(); |
| 432 | } |
438 | } |
| 433 | 439 | ||
| 434 | Display.prototype.rotaryBtnUpdate = function(SwitchId) |
440 | Display.prototype.rotaryBtnUpdate = function(SwitchId) |
| Line 463... | Line 469... | ||
| 463 | } |
469 | } |
| 464 | 470 | ||
| 465 | Display.prototype.lcdCenterText = function(text) |
471 | Display.prototype.lcdCenterText = function(text) |
| 466 | { |
472 | { |
| 467 | returnText = text; |
473 | returnText = text; |
| 468 | var displayWidth = |
474 | var displayWidth = 20; //this.myLCDService.getWidth(); |
| 469 | /* pad on both sides with spaces to displayWidth */ |
475 | /* pad on both sides with spaces to displayWidth */ |
| 470 | returnText = text.pad(displayWidth, " ", 2); |
476 | returnText = text.pad(displayWidth, " ", 2); |
| 471 | - | ||
| 472 | /*if (displayWidth > text.length) |
- | |
| 473 | { |
- | |
| 474 | paddingLen = displayWidth - text.length; |
- | |
| 475 | paddingLen = Math.round((paddingLen/2-0.5)); |
- | |
| 476 | returnText = text |
- | |
| 477 | }*/ |
- | |
| 478 | 477 | ||
| 479 | return returnText; |
478 | return returnText; |
| 480 | } |
479 | } |
| 481 | 480 | ||
| 482 | Display.prototype.lcdOffline = function() |
481 | Display.prototype.lcdOffline = function() |
| Line 512... | Line 511... | ||
| 512 | 511 | ||
| 513 | this.timerUpdate(); |
512 | this.timerUpdate(); |
| 514 | } |
513 | } |
| 515 | } |
514 | } |
| 516 | 515 | ||
| - | 516 | Display.prototype.setLED = function(red, green, blue) |
|
| - | 517 | { |
|
| - | 518 | ||
| - | 519 | } |
|
| - | 520 | ||
| 517 | Display.prototype.timerUpdate = function() |
521 | Display.prototype.timerUpdate = function() |
| 518 | { |
522 | { |
| 519 | /* If LCD service is not online do nothing */ |
523 | /* If LCD service is not online do nothing */ |
| 520 | if (this.myLCDService.isOnline()) |
524 | if (this.myLCDService.isOnline()) |
| 521 | { |
525 | { |
| 522 |
|
526 | //this.exchangeCalendar.lookup(this.shortName); |
| 523 | 527 | ||
| 524 | /* update the info on display */ |
528 | /* update the info on display */ |
| 525 | this.updateDisplay(); |
529 | this.updateDisplay(); |
| 526 | } |
530 | } |
| - | 531 | ||
| - | 532 | /*if (this.mySoftPwmService.isOnline()) |
|
| - | 533 | { |
|
| - | 534 | this.mySoftPwmService.setPWMValue(0, 0); |
|
| - | 535 | this.mySoftPwmService.setPWMValue(11, 1); |
|
| - | 536 | this.mySoftPwmService.setPWMValue(11, 2); |
|
| - | 537 | }*/ |
|
| 527 | } |
538 | } |
| 528 | 539 | ||