Subversion Repositories HomeAutomation

Rev

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