Rev 1252 | Rev 1335 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1252 | Rev 1256 | ||
|---|---|---|---|
| Line 39... | Line 39... | ||
| 39 | Display.prototype.exchangeCalendarFirstMenuItem = null; |
39 | Display.prototype.exchangeCalendarFirstMenuItem = null; |
| 40 | Display.prototype.exchangeCalendarLastMenuItem = null; |
40 | Display.prototype.exchangeCalendarLastMenuItem = null; |
| 41 | Display.prototype.statusMenuItem = null; |
41 | Display.prototype.statusMenuItem = null; |
| 42 | Display.prototype.bookMenuItem = null; |
42 | Display.prototype.bookMenuItem = null; |
| 43 | Display.prototype.bookResultMenuItem = null; |
43 | Display.prototype.bookResultMenuItem = null; |
| - | 44 | Display.prototype.screenSaverMenuItem = null; |
|
| 44 | 45 | ||
| 45 | 46 | ||
| 46 | /* The currently displayed menuitem */ |
47 | /* The currently displayed menuitem */ |
| 47 | Display.prototype.currentMenuItem = null; |
48 | Display.prototype.currentMenuItem = null; |
| 48 | 49 | ||
| Line 150... | Line 151... | ||
| 150 | /* create the first menu item */ |
151 | /* create the first menu item */ |
| 151 | this.statusMenuItem = new MenuItem(this); |
152 | this.statusMenuItem = new MenuItem(this); |
| 152 | this.statusMenuItem.displayData[0] = this.lcdCenterText(this.niceName); |
153 | this.statusMenuItem.displayData[0] = this.lcdCenterText(this.niceName); |
| 153 | this.statusMenuItem.doUpdate = function(args) { self.updateStatusMenuItem(); }; |
154 | this.statusMenuItem.doUpdate = function(args) { self.updateStatusMenuItem(); }; |
| 154 | this.currentMenuItem = this.statusMenuItem; |
155 | this.currentMenuItem = this.statusMenuItem; |
| - | 156 | ||
| - | 157 | /* create the screensaver menu item */ |
|
| - | 158 | this.screenSaverMenuItem = new MenuItem(this); |
|
| - | 159 | this.screenSaverMenuItem.displayData[0] = this.lcdCenterText(""); |
|
| - | 160 | this.screenSaverMenuItem.displayData[1] = this.lcdCenterText(""); |
|
| - | 161 | this.screenSaverMenuItem.doRight = function(args) { self.changeToNext(); }; |
|
| - | 162 | this.screenSaverMenuItem.doLeft = function(args) { self.changeToPrev(); }; |
|
| - | 163 | this.screenSaverMenuItem.setNextItem(this.statusMenuItem); |
|
| - | 164 | this.screenSaverMenuItem.setPrevItem(this.statusMenuItem); |
|
| 155 | 165 | ||
| 156 | /* create the menuitem where you can choose to enter the booking sub-menu */ |
166 | /* create the menuitem where you can choose to enter the booking sub-menu */ |
| 157 | this.bookMenuItem = new MenuItem(this); |
167 | this.bookMenuItem = new MenuItem(this); |
| 158 | this.bookMenuItem.displayData[0] = this.lcdCenterText("Book room"); |
168 | this.bookMenuItem.displayData[0] = this.lcdCenterText("Book room"); |
| 159 | this.bookMenuItem.displayData[1] = this.lcdCenterText("(Push button)"); |
169 | this.bookMenuItem.displayData[1] = this.lcdCenterText("(Push button)"); |
| Line 365... | Line 375... | ||
| 365 | //FIXME: constraints? |
375 | //FIXME: constraints? |
| 366 | var now = new Date(); |
376 | var now = new Date(); |
| 367 | if (this.bookToTime.getHours() >= now.getHours()) |
377 | if (this.bookToTime.getHours() >= now.getHours()) |
| 368 | { |
378 | { |
| 369 | this.bookToTime.setMinutes(this.bookToTime.getMinutes() - bookingIncrease); |
379 | this.bookToTime.setMinutes(this.bookToTime.getMinutes() - bookingIncrease); |
| 370 | } |
380 | } |
| 371 | } |
381 | } |
| 372 | 382 | ||
| 373 | Display.prototype.incBookTimeFrom = function() |
383 | Display.prototype.incBookTimeFrom = function() |
| 374 | { |
384 | { |
| 375 | //FIXME: constraints? |
385 | //FIXME: constraints? |
| 376 | if (this.bookFromTime.getHours() < 23) |
386 | if (this.bookFromTime.getHours() < 23) |
| 377 | { |
387 | { |
| 378 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() + bookingIncrease); |
388 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() + bookingIncrease); |
| 379 | } |
389 | } |
| 380 | } |
390 | } |
| 381 | 391 | ||
| 382 | Display.prototype.decBookTimeFrom = function() |
392 | Display.prototype.decBookTimeFrom = function() |
| 383 | { |
393 | { |
| 384 | //FIXME: constraints? |
394 | //FIXME: constraints? |
| 385 | var now = new Date(); |
395 | var now = new Date(); |
| 386 | if (this.bookFromTime.getHours() >= now.getHours()) |
396 | if (this.bookFromTime.getHours() >= now.getHours()) |
| 387 | { |
397 | { |
| 388 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() - bookingIncrease); |
398 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() - bookingIncrease); |
| 389 | } |
399 | } |
| 390 | } |
400 | } |
| 391 | 401 | ||
| 392 | Display.prototype.setBookTimeFrom = function() |
402 | Display.prototype.setBookTimeFrom = function() |
| 393 | { |
403 | { |
| 394 | this.currentMenuItem.displayData[1] = " <"+this.bookFromTime.getTimeShortFormated()+"> "; |
404 | this.currentMenuItem.displayData[1] = " <"+this.bookFromTime.getTimeShortFormated()+"> "; |
| 395 | } |
405 | } |
| Line 420... | Line 430... | ||
| 420 | Display.prototype.updateStatusMenuItem = function() |
430 | Display.prototype.updateStatusMenuItem = function() |
| 421 | { |
431 | { |
| 422 | var date = new Date(); |
432 | var date = new Date(); |
| 423 | var dateAndTime = "" + date.getTimeShortFormated(); |
433 | var dateAndTime = "" + date.getTimeShortFormated(); |
| 424 | this.statusMenuItem.displayData[1] = this.lcdCenterText(dateAndTime); |
434 | this.statusMenuItem.displayData[1] = this.lcdCenterText(dateAndTime); |
| 425 | } |
435 | } |
| 426 | 436 | ||
| 427 | Display.prototype.updateBookMenuItem = function() |
437 | Display.prototype.updateBookMenuItem = function() |
| 428 | { |
438 | { |
| 429 | if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem) |
439 | if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem) |
| 430 | { |
440 | { |
| 431 | this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem); |
441 | this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem); |
| Line 437... | Line 447... | ||
| 437 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
447 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
| 438 | } |
448 | } |
| 439 | } |
449 | } |
| 440 | 450 | ||
| 441 | Display.prototype.exchangeCalendarLookupCallback = function(shortname, data) |
451 | Display.prototype.exchangeCalendarLookupCallback = function(shortname, data) |
| 442 | { |
452 | { |
| 443 | if (shortname == this.shortName) |
453 | if (shortname == this.shortName) |
| 444 | { |
454 | { |
| 445 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
455 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
| 446 | if (data.error) |
456 | if (data.error) |
| 447 | { |
457 | { |
| 448 | log("Display:"+this.myId+"> got this error from exchange.php: " + data.error + "\n"); |
458 | log("Display:"+this.myId+"> got this error from exchange.php: " + data.error + "\n"); |
| 449 | } |
459 | } |
| Line 466... | Line 476... | ||
| 466 | 476 | ||
| 467 | if (this.exchangeData) |
477 | if (this.exchangeData) |
| 468 | { |
478 | { |
| 469 | var lastMenuItem; |
479 | var lastMenuItem; |
| 470 | for (var i = 0; i < this.exchangeData.meetings.length; i++) |
480 | for (var i = 0; i < this.exchangeData.meetings.length; i++) |
| 471 | { |
481 | { |
| 472 | /* create the menuitem for a calendar meeting */ |
482 | /* create the menuitem for a calendar meeting */ |
| 473 | var menu = new MenuItem(this); |
483 | var menu = new MenuItem(this); |
| 474 | menu.displayData[0] = this.lcdCenterText(this.replaceAumlauts(this.exchangeData.meetings[i].subject)); |
484 | menu.displayData[0] = this.lcdCenterText(this.replaceAumlauts(this.exchangeData.meetings[i].subject)); |
| 475 | menu.displayData[1] = this.lcdCenterText(this.exchangeData.meetings[i].start + " - " |
485 | menu.displayData[1] = this.lcdCenterText(this.exchangeData.meetings[i].start + " - " |
| 476 | + this.exchangeData.meetings[i].end); |
486 | + this.exchangeData.meetings[i].end); |
| Line 483... | Line 493... | ||
| 483 | } |
493 | } |
| 484 | else |
494 | else |
| 485 | { |
495 | { |
| 486 | menu.setPrevItem(lastMenuItem); |
496 | menu.setPrevItem(lastMenuItem); |
| 487 | lastMenuItem.setNextItem(menu); |
497 | lastMenuItem.setNextItem(menu); |
| 488 | } |
498 | } |
| 489 | 499 | ||
| 490 | lastMenuItem = menu; |
500 | lastMenuItem = menu; |
| 491 | } |
501 | } |
| 492 | if (lastMenuItem) |
502 | if (lastMenuItem) |
| 493 | { |
503 | { |
| 494 | this.exchangeCalendarLastMenuItem = lastMenuItem; |
504 | this.exchangeCalendarLastMenuItem = lastMenuItem; |
| 495 | this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem); |
505 | this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem); |
| 496 | this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem); |
506 | this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem); |
| 497 | 507 | ||
| 498 | } |
508 | } |
| 499 | /* to link in the newly created menuitems with exchangeinformation the display must be showing |
509 | /* to link in the newly created menuitems with exchangeinformation the display must be showing |
| 500 | either the statusmenu or the bookingmenu */ |
510 | either the statusmenu or the bookingmenu */ |
| 501 | if (this.currentMenuItem == this.statusMenuItem || this.currentMenuItem == this.bookMenuItem || this.currentMenuItem == this.bookResultMenuItem) |
511 | if (this.currentMenuItem == this.statusMenuItem || this.currentMenuItem == this.bookMenuItem || this.currentMenuItem == this.bookResultMenuItem) |
| 502 | { |
512 | { |
| 503 | /* if there is one or more exchangemenuitems */ |
513 | /* if there is one or more exchangemenuitems */ |
| Line 510... | Line 520... | ||
| 510 | else |
520 | else |
| 511 | { |
521 | { |
| 512 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
522 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
| 513 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
523 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
| 514 | } |
524 | } |
| 515 | } |
525 | } |
| 516 | } |
526 | } |
| 517 | } |
527 | } |
| 518 | 528 | ||
| 519 | Display.prototype.replaceAumlauts = function(intext) |
529 | Display.prototype.replaceAumlauts = function(intext) |
| 520 | { |
530 | { |
| 521 | intext = intext.replace(/Ã…/, String.fromCharCode(1)); |
531 | intext = intext.replace(/Ã…/, String.fromCharCode(1)); |
| 522 | intext = intext.replace(/Ã¥/, String.fromCharCode(0)); |
532 | intext = intext.replace(/Ã¥/, String.fromCharCode(0)); |
| Line 528... | Line 538... | ||
| 528 | //intext = intext.replace(/,/, "."); |
538 | //intext = intext.replace(/,/, "."); |
| 529 | return intext; |
539 | return intext; |
| 530 | } |
540 | } |
| 531 | 541 | ||
| 532 | Display.prototype.softPwmOnline = function() |
542 | Display.prototype.softPwmOnline = function() |
| 533 | { |
543 | { |
| - | 544 | this.LEDstatus = "none"; |
|
| 534 | } |
545 | } |
| 535 | 546 | ||
| 536 | Display.prototype.rotaryOnline = function() |
547 | Display.prototype.rotaryOnline = function() |
| 537 | { |
548 | { |
| 538 | } |
549 | } |
| 539 | 550 | ||
| 540 | Display.prototype.rotaryPosUpdate = function(SwitchId) |
551 | Display.prototype.rotaryPosUpdate = function(SwitchId) |
| Line 554... | Line 565... | ||
| 554 | { |
565 | { |
| 555 | if (this.currentMenuItem.doLeft) |
566 | if (this.currentMenuItem.doLeft) |
| 556 | { |
567 | { |
| 557 | this.currentMenuItem.doLeft(); |
568 | this.currentMenuItem.doLeft(); |
| 558 | } |
569 | } |
| 559 | } |
570 | } |
| 560 | } |
571 | } |
| 561 | 572 | ||
| 562 | this.updateDisplay(); |
573 | this.updateDisplay(); |
| 563 | } |
574 | } |
| 564 | 575 | ||
| 565 | Display.prototype.rotaryBtnUpdate = function(SwitchId) |
576 | Display.prototype.rotaryBtnUpdate = function(SwitchId) |
| 566 | { |
577 | { |
| 567 | this.screenSaverCnt = 0; |
578 | this.screenSaverCnt = 0; |
| 568 | this.mainScreenCnt = 0; |
579 | this.mainScreenCnt = 0; |
| Line 575... | Line 586... | ||
| 575 | this.updateDisplay(); |
586 | this.updateDisplay(); |
| 576 | } |
587 | } |
| 577 | } |
588 | } |
| 578 | 589 | ||
| 579 | Display.prototype.updateDisplay = function() |
590 | Display.prototype.updateDisplay = function() |
| 580 | { |
591 | { |
| 581 | /* see if the current menuitem wants to update itself */ |
592 | /* see if the current menuitem wants to update itself */ |
| 582 | if (this.currentMenuItem.doUpdate) |
593 | if (this.currentMenuItem.doUpdate) |
| 583 | { |
594 | { |
| 584 | this.currentMenuItem.doUpdate(); |
595 | this.currentMenuItem.doUpdate(); |
| 585 | } |
596 | } |
| 586 | 597 | ||
| 587 | /* Clear the LCD screen */ |
598 | /* Clear the LCD screen */ |
| 588 | //this.myLCDService.clearScreen(); |
599 | //this.myLCDService.clearScreen(); |
| 589 | 600 | ||
| 590 | /* send the data for the current menuitem to display */ |
601 | /* send the data for the current menuitem to display */ |
| 591 | for (var i = 0; i < this.currentMenuItem.displayData.length; i++) |
602 | for (var i = 0; i < this.currentMenuItem.displayData.length; i++) |
| 592 | { |
603 | { |
| 593 | this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]); |
604 | this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]); |
| 594 | } |
605 | } |
| 595 | 606 | ||
| 596 | } |
607 | } |
| 597 | 608 | ||
| 598 | Display.prototype.lcdCenterText = function(text) |
609 | Display.prototype.lcdCenterText = function(text) |
| 599 | { |
610 | { |
| 600 | returnText = text; |
611 | returnText = text; |
| 601 | var displayWidth = 20; //this.myLCDService.getWidth(); |
612 | var displayWidth = 20; //this.myLCDService.getWidth(); |
| 602 | /* pad on both sides with spaces to displayWidth */ |
613 | /* pad on both sides with spaces to displayWidth */ |
| 603 | returnText = text.pad(displayWidth, " ", 2); |
614 | returnText = text.pad(displayWidth, " ", 2); |
| 604 | 615 | ||
| 605 | return returnText; |
616 | return returnText; |
| 606 | } |
617 | } |
| 607 | 618 | ||
| 608 | Display.prototype.lcdOffline = function() |
619 | Display.prototype.lcdOffline = function() |
| 609 | { |
620 | { |
| 610 | /* If we have no interval timer running do nothing */ |
621 | /* If we have no interval timer running do nothing */ |
| 611 | if (this.myInterval != null) |
622 | if (this.myInterval != null) |
| 612 | { |
623 | { |
| 613 | /* Stop the interval */ |
624 | /* Stop the interval */ |
| 614 | this.myInterval.stop(); |
625 | this.myInterval.stop(); |
| 615 | } |
626 | } |
| 616 | } |
627 | } |
| 617 | 628 | ||
| 618 | Display.prototype.lcdOnline = function() |
629 | Display.prototype.lcdOnline = function() |
| 619 | { |
630 | { |
| 620 | /* If service is not online do nothing */ |
631 | /* If service is not online do nothing */ |
| 621 | if (this.myLCDService.isOnline()) |
632 | if (this.myLCDService.isOnline()) |
| Line 653... | Line 664... | ||
| 653 | var startTimeSplit = this.exchangeData.meetings[0].start.split(":"); |
664 | var startTimeSplit = this.exchangeData.meetings[0].start.split(":"); |
| 654 | var endTimeSplit = this.exchangeData.meetings[0].end.split(":"); |
665 | var endTimeSplit = this.exchangeData.meetings[0].end.split(":"); |
| 655 | if (now.getHours() < startTimeSplit[0] || |
666 | if (now.getHours() < startTimeSplit[0] || |
| 656 | now.getHours() > endTimeSplit[0] || |
667 | now.getHours() > endTimeSplit[0] || |
| 657 | now.getHours() == startTimeSplit[0] && now.getMinutes() < startTimeSplit[1]) |
668 | now.getHours() == startTimeSplit[0] && now.getMinutes() < startTimeSplit[1]) |
| 658 | { |
669 | { |
| 659 | if (this.LEDstatus != "green") |
670 | if (this.LEDstatus != "green") |
| 660 | { |
671 | { |
| 661 | this.LEDstatus = "green"; |
672 | this.LEDstatus = "green"; |
| 662 | this.setLEDgreen(); |
673 | this.setLEDgreen(); |
| 663 | } |
674 | } |
| 664 | } |
675 | } |
| 665 | else |
676 | else |
| Line 691... | Line 702... | ||
| 691 | { |
702 | { |
| 692 | this.setLED(0, 255, 0); |
703 | this.setLED(0, 255, 0); |
| 693 | } |
704 | } |
| 694 | 705 | ||
| 695 | Display.prototype.setLED = function(red, green, blue) |
706 | Display.prototype.setLED = function(red, green, blue) |
| 696 | { |
707 | { |
| 697 | log("Display:"+this.myId+"> Trying to set leds to red " +red+" green "+green+" blue "+blue+"\n"); |
708 | log("Display:"+this.myId+"> Trying to set leds to red " +red+" green "+green+" blue "+blue+"\n"); |
| 698 | if (this.mySoftPwmService.isOnline()) |
709 | if (this.mySoftPwmService.isOnline()) |
| 699 | { |
710 | { |
| 700 | this.mySoftPwmService.setPWMValue(255-(red&0xff), 1); |
711 | this.mySoftPwmService.setPWMValue(255-(red&0xff), 1); |
| 701 | this.mySoftPwmService.setPWMValue(255-(green&0xff), 2); |
712 | this.mySoftPwmService.setPWMValue(255-(green&0xff), 2); |
| 702 | this.mySoftPwmService.setPWMValue(255-(blue&0xff), 0); |
713 | this.mySoftPwmService.setPWMValue(255-(blue&0xff), 0); |
| 703 | } |
714 | } |
| 704 | } |
715 | } |
| 705 | 716 | ||
| 706 | Display.prototype.sendTimeStamp = function() |
717 | Display.prototype.sendTimeStamp = function() |
| 707 | { |
718 | { |
| 708 | var canMessage = new CanNMTMessage("nmt", "Time"); |
719 | var canMessage = new CanNMTMessage("nmt", "Time"); |
| 709 | canMessage.send(); |
720 | canMessage.send(); |
| 710 | } |
721 | } |
| Line 716... | Line 727... | ||
| 716 | { |
727 | { |
| 717 | this.screenSaverCnt++; |
728 | this.screenSaverCnt++; |
| 718 | this.mainScreenCnt++; |
729 | this.mainScreenCnt++; |
| 719 | this.exchangeUpdateCnt++; |
730 | this.exchangeUpdateCnt++; |
| 720 | 731 | ||
| 721 | if (this.mainScreenCnt > mainScreenTimeout/5) |
732 | if (this.mainScreenCnt > mainScreenTimeout/5 && this.currentMenuItem != this.screenSaverMenuItem) |
| 722 | { |
733 | { |
| 723 | /* Go to main screen (time) */ |
734 | /* Go to main screen (time) */ |
| 724 | this.currentMenuItem = this.statusMenuItem; |
735 | this.currentMenuItem = this.statusMenuItem; |
| 725 | 736 | ||
| 726 | /* update the info on display */ |
737 | /* update the info on display */ |
| Line 729... | Line 740... | ||
| 729 | this.mainScreenCnt = 0; |
740 | this.mainScreenCnt = 0; |
| 730 | } |
741 | } |
| 731 | 742 | ||
| 732 | if (this.screenSaverCnt > screenSaverTimeout/5) |
743 | if (this.screenSaverCnt > screenSaverTimeout/5) |
| 733 | { |
744 | { |
| - | 745 | /* Go to screensaver menu */ |
|
| - | 746 | this.currentMenuItem = this.screenSaverMenuItem; |
|
| - | 747 | ||
| - | 748 | /* update the info on display */ |
|
| - | 749 | this.updateDisplay(); |
|
| 734 | 750 | ||
| 735 | this.screenSaverCnt = 0; |
751 | this.screenSaverCnt = 0; |
| 736 | } |
752 | } |
| 737 | 753 | ||
| 738 | if (this.exchangeUpdateCnt > exchangeUpdateTimeout/5) |
754 | if (this.exchangeUpdateCnt > exchangeUpdateTimeout/5) |