Subversion Repositories HomeAutomation

Rev

Rev 1204 | Rev 1226 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. loadScript("Logic/MenuItem.js");
  3.  
  4. function Display(type, name, id)
  5. {
  6.     /* We must always call the parent constructor, initialization
  7.        of variables could be done here, but initialize is a better place */
  8.     this.Service(type, name, id);
  9. }
  10.  
  11. /* We inherit from Service with this call, it must always be next
  12.    after the constructor */
  13. extend(Display, Service);
  14.  
  15. /* Declaration of instance variables, for static variables remove prototype */
  16.  
  17. /* format: dat objects, just use the time */
  18. Display.prototype.bookFromTime = null;
  19. Display.prototype.bookToTime = null;
  20.  
  21. /* the shortname for this exchangeobject */
  22. Display.prototype.shortName = null;
  23.  
  24. /* the name for this display (shown on first screen) */
  25. Display.prototype.niceName = null;
  26.  
  27. /* The display should regulary update and store the calendar */
  28. Display.prototype.exchangeData = null;
  29.  
  30. Display.prototype.myLCDService = null;
  31. Display.prototype.myRotaryService = null;
  32. Display.prototype.mySoftPwmService = null;
  33. Display.prototype.myInterval = null;
  34.  
  35. /*  */
  36. Display.prototype.exchangeCalendar = null;
  37. /*  */
  38. Display.prototype.exchangeCalendarFirstMenuItem = null;
  39. Display.prototype.exchangeCalendarLastMenuItem = null;
  40. Display.prototype.statusMenuItem = null;
  41. Display.prototype.bookMenuItem = null;
  42.  
  43. /* The currently displayed menuitem */
  44. Display.prototype.currentMenuItem = null;
  45.  
  46. /* counter for calling exchange update */
  47. Display.prototype.exchangeUpdateCnt = null;
  48.  
  49. /* counter for going to screensaver */
  50. Display.prototype.screenSaverCnt = null;
  51.  
  52. /* counter for going to main screen */
  53. Display.prototype.mainScreenCnt = null;
  54.  
  55. const exchangeUpdateTimeout = 50;
  56. const mainScreenTimeout = 40;
  57. const screenSaverTimeout = 120;
  58.  
  59. const bookingIncrease = 15;
  60.  
  61. /* This function must always be declared, this is where all the startup code
  62.    should be placed. Gets called with arguments like what ids to use etc. */
  63. Display.prototype.initialize = function(initialArguments)
  64. {
  65.     /* We must always call the parent initialize */
  66.     this.Service.prototype.initialize.call(this, initialArguments);
  67.  
  68.     /* This is used for function declarations like the callbacks below */
  69.     var self = this;
  70.  
  71.     if (!this.myInitialArguments["HD44789"])
  72.     {
  73.         log(this.myName + ":" + this.myId + "> Failed to initialize, HD44789-config missing from config.\n");
  74.         return;
  75.     }
  76.    
  77.     if (!this.myInitialArguments["Rotary"])
  78.     {
  79.         log(this.myName + ":" + this.myId + "> Failed to initialize, Rotary-config missing from config.\n");
  80.         return;
  81.     }
  82.    
  83.     if (!this.myInitialArguments["softPWM"])
  84.     {
  85.         log(this.myName + ":" + this.myId + "> Failed to initialize, softPWM-config missing from config.\n");
  86.         return;
  87.     }
  88.    
  89.     if (!this.myInitialArguments["Name"])
  90.     {
  91.         log(this.myName + ":" + this.myId + "> Failed to initialize, Name-config missing from config.\n");
  92.         return;
  93.     }
  94.     this.niceName = this.myInitialArguments["Name"];
  95.  
  96.     if (!this.myInitialArguments["ShortName"])
  97.     {
  98.         log(this.myName + ":" + this.myId + "> Failed to initialize, Name-config missing from config.\n");
  99.         return;
  100.     }
  101.     this.shortName = this.myInitialArguments["ShortName"];
  102.    
  103.     this.screenSaverCnt = 0;
  104.     this.mainScreenCnt = 0;
  105.     this.exchangeUpdateCnt = exchangeUpdateTimeout-10;
  106.    
  107.     /* Get the LCD service that we want from the ServiceManager, it takes type, service name, service id */
  108.     this.myLCDService = ServiceManager.getService("Can", "HD44789", this.myInitialArguments["HD44789"]["Id"]);
  109.     /* Add a callback for when the service goes online */
  110.     this.myLCDService.registerEventCallback("online", function(args) { self.lcdOnline(); });
  111.     /* If the service is already online we should call the handler here */
  112.     this.lcdOnline();
  113.     /* Add a callback for when the service goes offline */
  114.     this.myLCDService.registerEventCallback("offline", function(args) { self.lcdOffline(); });
  115.    
  116.     /* Get the Rotary service that we want from the ServiceManager, it takes type, service name, service id */
  117.     this.myRotaryService = ServiceManager.getService("Can", "Rotary", this.myInitialArguments["Rotary"]["Id"]);
  118.     /* Add a callback for when the encoder reports a new position */
  119.     this.myRotaryService.registerEventCallback("newPosition", function(args) { self.rotaryPosUpdate(args); });
  120.     /* Add a callback for when the encoder reports a new button status */
  121.     this.myRotaryService.registerEventCallback("newBtnStatus", function(args) { self.rotaryBtnUpdate(args); });
  122.     /* Add a callback for when the service goes online */
  123.     this.myRotaryService.registerEventCallback("online", function(args) { self.rotaryOnline(); });
  124.     /* If the service is already online we should call the handler here */
  125.     this.rotaryOnline();
  126.    
  127.     /* Get the softPWM service that we want from the ServiceManager, it takes type, service name, service id */
  128.     this.mySoftPwmService = ServiceManager.getService("Can", "softPWM", this.myInitialArguments["softPWM"]["Id"]);
  129.     /* Add a callback for when the service goes online */
  130.     this.mySoftPwmService.registerEventCallback("online", function(args) { self.softPwmOnline(); });
  131.     /* If the service is already online we should call the handler here */
  132.     this.softPwmOnline();
  133.    
  134.     this.exchangeCalendar = new ExchangeCalendar(function(shortname, data) { self.exchangeCalendarLookupCallback(shortname, data); });
  135.    
  136.     /* create the first menu item */
  137.     this.statusMenuItem = new MenuItem(this);
  138.     this.statusMenuItem.displayData[0] = this.lcdCenterText(this.niceName);
  139.     this.statusMenuItem.doUpdate = this.updateStatusMenuItem;
  140.     this.currentMenuItem = this.statusMenuItem;
  141.    
  142.     /* create the menuitem where you can choose to enter the booking sub-menu */
  143.     this.bookMenuItem = new MenuItem(this);
  144.     this.bookMenuItem.displayData[0] = this.lcdCenterText("Book room");
  145.     this.bookMenuItem.displayData[1] = this.lcdCenterText("(Not implemented)");
  146.     this.bookMenuItem.doUpdate = this.updateBookMenuItem;
  147.  
  148.     /* connect the items as a linked list */
  149.     this.statusMenuItem.setNextItem(this.bookMenuItem);
  150.     this.statusMenuItem.setPrevItem(this.bookMenuItem);
  151.     /* set the function that shall be executed when knob is turned */
  152.     this.statusMenuItem.doRight = this.changeToNext;
  153.     this.statusMenuItem.doLeft = this.changeToPrev;
  154.    
  155.     /* connect the items as a linked list */
  156.     this.bookMenuItem.setNextItem(this.statusMenuItem);
  157.     this.bookMenuItem.setPrevItem(this.statusMenuItem);
  158.     /* set the function that shall be executed when knob is turned */
  159.     this.bookMenuItem.doRight = this.changeToNext;
  160.     this.bookMenuItem.doLeft = this.changeToPrev;
  161.    
  162.     /* create the menuitem where you can choose the to-time */
  163.     var menuChooseTo = new MenuItem(this);
  164.     menuChooseTo.displayData[1] = this.lcdCenterText(" Ok     Cancel ");
  165.     menuChooseTo.doUpdate = this.chooseBookTimeTo;
  166.    
  167.     this.bookMenuItem.doPress = this.startBooking;
  168.     this.bookMenuItem.setDescItem(menuChooseTo);
  169.    
  170.     /* create the menuitem where you can choose to book the room with OK */
  171.     var menuChooseOk = new MenuItem(this);
  172.     menuChooseOk.displayData[1] = this.lcdCenterText("<Ok>    Cancel ");
  173.     menuChooseOk.doUpdate = this.setBookTime;
  174.  
  175.     /* create the menuitem where you can choose to cancel the booking */
  176.     var menuChooseCancel = new MenuItem(this);
  177.     menuChooseCancel.displayData[1] = this.lcdCenterText(" Ok    <Cancel>");
  178.     menuChooseCancel.doUpdate = this.setBookTime;
  179.  
  180.     /* create the menuitem where you can choose the from-time */
  181.     var menuChooseFrom = new MenuItem(this);
  182.     menuChooseFrom.displayData[1] = this.lcdCenterText(" Ok     Cancel ");
  183.     menuChooseFrom.doUpdate = this.chooseBookTimeFrom;
  184.  
  185.     /* connect the items as a linked list */
  186.     menuChooseTo.setNextItem(menuChooseOk);
  187.     menuChooseTo.setPrevItem(menuChooseFrom);
  188.     /* set the function that shall be executed when knob is turned */
  189.     menuChooseTo.doRight = this.changeToNext;
  190.     menuChooseTo.doLeft = this.changeToPrev;
  191.     menuChooseTo.doPress = this.changeToDesc;
  192.  
  193.     /* connect the items as a linked list */
  194.     menuChooseOk.setNextItem(menuChooseCancel);
  195.     menuChooseOk.setPrevItem(menuChooseTo);
  196.     /* set the function that shall be executed when knob is turned */
  197.     menuChooseOk.doRight = this.changeToNext;
  198.     menuChooseOk.doLeft = this.changeToPrev;
  199.  
  200.     /* connect the items as a linked list */
  201.     menuChooseCancel.setNextItem(menuChooseFrom);
  202.     menuChooseCancel.setPrevItem(menuChooseOk);
  203.     menuChooseCancel.setDescItem(this.bookMenuItem);
  204.     /* set the function that shall be executed when knob is turned */
  205.     menuChooseCancel.doRight = this.changeToNext;
  206.     menuChooseCancel.doLeft = this.changeToPrev;
  207.     menuChooseCancel.doPress = this.changeToDesc;
  208.  
  209.     /* connect the items as a linked list */
  210.     menuChooseFrom.setNextItem(menuChooseTo);
  211.     menuChooseFrom.setPrevItem(menuChooseCancel);
  212.     /* set the function that shall be executed when knob is turned */
  213.     menuChooseFrom.doRight = this.changeToNext;
  214.     menuChooseFrom.doLeft = this.changeToPrev;
  215.     menuChooseFrom.doPress = this.changeToDesc;
  216.  
  217.     /* create the menuitem where you can modify the to-time */
  218.     var menuSetTo = new MenuItem(this);
  219.     menuSetTo.doUpdate = this.setBookTimeTo;
  220.     menuSetTo.displayData[0] = this.lcdCenterText("Set end time");
  221.     menuSetTo.doRight = this.incBookTimeTo;
  222.     menuSetTo.doLeft = this.decBookTimeTo;
  223.     menuSetTo.doPress = this.changeToDesc;
  224.     menuSetTo.setDescItem(menuChooseTo);
  225.     menuChooseTo.setDescItem(menuSetTo);
  226.  
  227.     /* create the menuitem where you can modify the from-time */
  228.     var menuSetFrom = new MenuItem(this);
  229.     menuSetFrom.doUpdate = this.setBookTimeFrom;
  230.     menuSetFrom.displayData[0] = this.lcdCenterText("Set start time");
  231.     menuSetFrom.doRight = this.incBookTimeFrom;
  232.     menuSetFrom.doLeft = this.decBookTimeFrom;
  233.     menuSetFrom.doPress = this.changeToDesc;
  234.     menuSetFrom.setDescItem(menuChooseFrom);
  235.     menuChooseFrom.setDescItem(menuSetFrom);
  236.  
  237. }
  238.  
  239. Display.prototype.startBooking = function()
  240. {
  241.     this.parentDisplay.bookFromTime = new Date();
  242.     this.parentDisplay.bookToTime = new Date();
  243.     //this.bookFromTime.setHours(8);
  244.     //this.bookToTime.setHours(8);
  245.     if (this.parentDisplay.bookFromTime.getMinutes() < 30)
  246.     {
  247.         this.parentDisplay.bookFromTime.setMinutes(0);
  248.         this.parentDisplay.bookToTime.setMinutes(30);
  249.     }
  250.     else
  251.     {
  252.         this.parentDisplay.bookFromTime.setMinutes(30);
  253.         this.parentDisplay.bookToTime.setHours(this.parentDisplay.bookToTime.getHours()+1);
  254.         this.parentDisplay.bookToTime.setMinutes(0);
  255.     }
  256.  
  257.     this.parentDisplay.currentMenuItem = this.parentDisplay.currentMenuItem.descItem;
  258. }
  259.  
  260. Display.prototype.changeToDesc = function()
  261. {
  262.     if (this.descItem)
  263.     {
  264.         this.parentDisplay.currentMenuItem = this.descItem;
  265.     }
  266. }
  267.  
  268. Display.prototype.changeToNext = function()
  269. {
  270.     if (this.nextItem)
  271.     {
  272.         this.parentDisplay.currentMenuItem = this.nextItem;
  273.     }
  274. }
  275.  
  276. Display.prototype.changeToPrev = function()
  277. {
  278.     if (this.prevItem)
  279.     {
  280.         this.parentDisplay.currentMenuItem = this.prevItem;
  281.     }
  282. }
  283.  
  284. Display.prototype.incBookTimeTo = function()
  285. {
  286.     //FIXME: constraints?
  287.     if (this.parentDisplay.bookToTime.getHours() < 23)
  288.     {
  289.         this.parentDisplay.bookToTime.setMinutes(this.parentDisplay.bookToTime.getMinutes() + bookingIncrease);
  290.     }
  291. }
  292.  
  293. Display.prototype.decBookTimeTo = function()
  294. {
  295.     //FIXME: constraints?
  296.     var now = new Date();
  297.     if (this.parentDisplay.bookToTime.getHours() >= now.getHours())
  298.     {
  299.         this.parentDisplay.bookToTime.setMinutes(this.parentDisplay.bookToTime.getMinutes() - bookingIncrease);
  300.     }
  301. }
  302.  
  303. Display.prototype.incBookTimeFrom = function()
  304. {
  305.     //FIXME: constraints?
  306.     if (this.parentDisplay.bookFromTime.getHours() < 23)
  307.     {
  308.         this.parentDisplay.bookFromTime.setMinutes(this.parentDisplay.bookFromTime.getMinutes() + bookingIncrease);
  309.     }
  310. }
  311.  
  312. Display.prototype.decBookTimeFrom = function()
  313. {
  314.     //FIXME: constraints?
  315.     var now = new Date();
  316.     if (this.parentDisplay.bookFromTime.getHours() >= now.getHours())
  317.     {
  318.         this.parentDisplay.bookFromTime.setMinutes(this.parentDisplay.bookFromTime.getMinutes() - bookingIncrease);
  319.     }
  320. }
  321.  
  322. Display.prototype.setBookTimeFrom = function()
  323. {
  324.     this.displayData[1] = "      <"+this.parentDisplay.bookFromTime.getTimeShortFormated()+">       ";
  325. }
  326.  
  327. Display.prototype.setBookTimeTo = function()
  328. {
  329.     this.displayData[1] = "      <"+this.parentDisplay.bookToTime.getTimeShortFormated()+">       ";
  330. }
  331.  
  332. Display.prototype.chooseBookTimeTo = function()
  333. {
  334.     this.displayData[0] = "  "+this.parentDisplay.bookFromTime.getTimeShortFormated()+"  - <"
  335.                                 +this.parentDisplay.bookToTime.getTimeShortFormated()+">  ";
  336. }
  337.  
  338. Display.prototype.chooseBookTimeFrom = function()
  339. {
  340.     this.displayData[0] = " <"+this.parentDisplay.bookFromTime.getTimeShortFormated()+"> -  "
  341.                                 +this.parentDisplay.bookToTime.getTimeShortFormated()+"   ";
  342. }
  343.  
  344. Display.prototype.setBookTime = function()
  345. {
  346.     this.displayData[0] = "  "+this.parentDisplay.bookFromTime.getTimeShortFormated()+"  -  "
  347.                                 +this.parentDisplay.bookToTime.getTimeShortFormated()+"   ";
  348. }
  349.  
  350. Display.prototype.updateStatusMenuItem = function()
  351. {
  352.     var date = new Date();
  353.     var dateAndTime = "" + date.getTimeShortFormated();
  354.     this.displayData[1] = "       " + dateAndTime + "        ";
  355. }
  356.  
  357. Display.prototype.updateBookMenuItem = function()
  358. {
  359.     if (this.parentDisplay.exchangeCalendarFirstMenuItem && this.parentDisplay.exchangeCalendarLastMenuItem)
  360.     {
  361.         this.parentDisplay.statusMenuItem.setNextItem(this.parentDisplay.exchangeCalendarFirstMenuItem);
  362.         this.parentDisplay.bookMenuItem.setPrevItem(this.parentDisplay.exchangeCalendarLastMenuItem);
  363.     }
  364.     else
  365.     {
  366.         this.parentDisplay.statusMenuItem.setNextItem(this.parentDisplay.bookMenuItem);
  367.         this.parentDisplay.bookMenuItem.setPrevItem(this.parentDisplay.statusMenuItem);
  368.     }
  369. }
  370.  
  371. Display.prototype.exchangeCalendarLookupCallback = function(shortname, data)
  372. {
  373. //log("callback: "+shortname+" \n");
  374.     if (shortname == this.shortName)
  375.     {
  376.         //FIXME check if data contains error tag and error message, print to log and keep previous data?
  377.         if (data.error)
  378.         {
  379.             log("Display: got this error from exchange.php: " + data.error + "\n");
  380.         }
  381.         else
  382.         {
  383.             this.exchangeData = data;
  384.             this.createCalendarMenu();
  385.         }
  386.     }
  387. }
  388.  
  389. /* this function parses calendar data from exchange-script and creates a menu */
  390. Display.prototype.createCalendarMenu = function()
  391. {
  392.     this.exchangeCalendarLastMenuItem = null;
  393.     this.exchangeCalendarFirstMenuItem = null;
  394.    
  395. //log("createCalendar \n");
  396.     if (this.exchangeData)
  397.     {
  398. //log("have data \n");
  399.         var lastMenuItem;
  400.         for (var i = 0; i < this.exchangeData.meetings.length; i++)
  401.         {
  402. //log("looping \n");
  403.             /* create the menuitem for a calendar meeting */
  404.             var menu = new MenuItem(this);
  405.             menu.displayData[0] = this.lcdCenterText(this.replaceAumlauts(this.exchangeData.meetings[i].subject));
  406.             menu.displayData[1] = this.lcdCenterText(this.exchangeData.meetings[i].start.replace(":",".") + " - "
  407.                                         + this.exchangeData.meetings[i].end.replace(":","."));
  408.             menu.doRight = this.changeToNext;
  409.             menu.doLeft = this.changeToPrev;
  410.            
  411.             if (i == 0)
  412.             {
  413.                 this.exchangeCalendarFirstMenuItem = menu;
  414.             }
  415.             else
  416.             {
  417.                 menu.setPrevItem(lastMenuItem);
  418.                 lastMenuItem.setNextItem(menu);
  419.             }
  420.            
  421.             lastMenuItem = menu;
  422.         }
  423.         if (lastMenuItem)
  424.         {
  425.             this.exchangeCalendarLastMenuItem = lastMenuItem;
  426.             this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem);
  427.             this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem);
  428.        
  429.         }
  430.         /* to link in the newly created menuitems with exchangeinformation the display must be showing
  431.            either the statusmenu or the bookingmenu */
  432.         if (this.currentMenuItem == this.statusMenuItem || this.currentMenuItem == this.bookMenuItem)
  433.         {
  434.             /* if there is one or more exchangemenuitems */
  435.             if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem)
  436.             {
  437.                 this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem);
  438.                 this.bookMenuItem.setPrevItem(this.exchangeCalendarLastMenuItem);
  439.             }
  440.             /* if not then link statusmenu to bookingmenu */
  441.             else
  442.             {
  443.                 this.statusMenuItem.setNextItem(this.bookMenuItem);
  444.                 this.bookMenuItem.setPrevItem(this.statusMenuItem);
  445.             }
  446.         }
  447.     }
  448. }
  449.  
  450. Display.prototype.replaceAumlauts = function(intext)
  451. {
  452.     intext = intext.replace(/Å/, "A");
  453.     intext = intext.replace(/å/, "a");
  454.     intext = intext.replace(/Ä/, "A");
  455.     intext = intext.replace(/ä/, "a");
  456.     intext = intext.replace(/Ö/, "O");
  457.     intext = intext.replace(/ö/, "o");
  458.     return intext;
  459. }
  460.  
  461. Display.prototype.softPwmOnline = function()
  462. {
  463. }
  464.  
  465. Display.prototype.rotaryOnline = function()
  466. {
  467. }
  468.  
  469. Display.prototype.rotaryPosUpdate = function(SwitchId)
  470. {
  471.     this.screenSaverCnt = 0;
  472.     this.mainScreenCnt = 0;
  473.     for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++)
  474.     {
  475.         if (this.myRotaryService.getDirection(SwitchId) == "Clockwise")
  476.         {
  477.             if (this.currentMenuItem.doRight)
  478.             {
  479.                 this.currentMenuItem.doRight();
  480.             }
  481.         }
  482.         else
  483.         {
  484.             if (this.currentMenuItem.doLeft)
  485.             {
  486.                 this.currentMenuItem.doLeft();
  487.             }
  488.         }
  489.     }
  490.    
  491.     this.updateDisplay();
  492. }
  493.  
  494. Display.prototype.rotaryBtnUpdate = function(SwitchId)
  495. {
  496.     this.screenSaverCnt = 0;
  497.     this.mainScreenCnt = 0;
  498.     if (this.myRotaryService.getButtonStatus(SwitchId) == "Released")
  499.     {
  500.         if (this.currentMenuItem.doPress)
  501.         {
  502.             this.currentMenuItem.doPress();
  503.         }
  504.         this.updateDisplay();
  505.     }
  506. }
  507.  
  508. Display.prototype.updateDisplay = function()
  509. {
  510.     /* see if the current menuitem wants to update itself */
  511.     if (this.currentMenuItem.doUpdate)
  512.     {
  513.         this.currentMenuItem.doUpdate();
  514.     }
  515.  
  516.     /* Clear the LCD screen */
  517.     //this.myLCDService.clearScreen();
  518.    
  519.     /* send the data for the current menuitem to display */
  520.     for (var i = 0; i < this.currentMenuItem.displayData.length; i++)
  521.     {
  522.         this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]);
  523.     }
  524.    
  525. }
  526.  
  527. Display.prototype.lcdCenterText = function(text)
  528. {
  529.     returnText = text;
  530.     var displayWidth = 20;  //this.myLCDService.getWidth();
  531.     /* pad on both sides with spaces to displayWidth */
  532.     returnText = text.pad(displayWidth, " ", 2);
  533.    
  534.     return returnText;
  535. }
  536.  
  537. Display.prototype.lcdOffline = function()
  538. {
  539.     /* If we have no interval timer running do nothing */
  540.     if (this.myInterval != null)
  541.     {
  542.         /* Stop the interval */
  543.         this.myInterval.stop();
  544.     }
  545. }
  546.  
  547. Display.prototype.lcdOnline = function()
  548. {
  549.     /* If service is not online do nothing */
  550.     if (this.myLCDService.isOnline())
  551.     {
  552.         /* Clear the LCD screen */
  553.         this.myLCDService.clearScreen();
  554.         /* Set backlight to max */
  555.         this.myLCDService.setBacklight(255);
  556.  
  557.         /* If we have no interval timer running start it */
  558.         if (this.myInterval == null)
  559.         {
  560.             var self = this;
  561.        
  562.             /* Start interval timer for our printout. Arguments are the callback function and time in milliseconds */
  563.             this.myInterval = new Interval(function() { self.timerUpdate() }, 5000);
  564.         }
  565.        
  566.         this.myInterval.start();
  567.        
  568.         this.timerUpdate();
  569.     }
  570. }
  571.  
  572. Display.prototype.setLED = function(red, green, blue)
  573. {
  574.    
  575. }
  576.  
  577. Display.prototype.timerUpdate = function()
  578. {
  579.     /* If LCD service is not online do nothing */
  580.     if (this.myLCDService.isOnline())
  581.     {
  582.         this.screenSaverCnt++;
  583.         this.mainScreenCnt++;
  584.         this.exchangeUpdateCnt++;
  585.  
  586.         if (this.mainScreenCnt > mainScreenTimeout/5)
  587.         {
  588.             /* Go to main screen (time) */
  589.             this.currentMenuItem = this.statusMenuItem;
  590.  
  591.             /* update the info on display */
  592.             this.updateDisplay();
  593.         }
  594.        
  595.         if (this.screenSaverCnt > screenSaverTimeout/5)
  596.         {
  597.            
  598.         }
  599.  
  600.         if (this.exchangeUpdateCnt > exchangeUpdateTimeout/5)
  601.         {
  602.             /* update the info on display */
  603.             this.updateDisplay();
  604.            
  605.             /* do an exchange lookup */
  606.             this.exchangeCalendar.lookup(this.shortName);
  607.            
  608.             this.exchangeUpdateCnt = 0;
  609.         }
  610.        
  611.     }
  612.    
  613.     /*if (this.mySoftPwmService.isOnline())
  614.     {
  615.         this.mySoftPwmService.setPWMValue(0, 0);
  616.         this.mySoftPwmService.setPWMValue(11, 1);
  617.         this.mySoftPwmService.setPWMValue(11, 2);
  618.     }*/
  619. }
  620.  
  621.