Subversion Repositories HomeAutomation

Rev

Rev 1222 | 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 DisplayLinus(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(DisplayLinus, Service);
  14.  
  15. /* Declaration of instance variables, for static variables remove prototype */
  16.  
  17.  
  18. /* The display should regulary update and store the calendar */
  19.  
  20. DisplayLinus.prototype.myLCDService = null;
  21. DisplayLinus.prototype.myRotaryService = null;
  22. DisplayLinus.prototype.myInterval = null;
  23.  
  24. /*  */
  25. /*  */
  26.  
  27. /* The currently displayed menuitem */
  28. DisplayLinus.prototype.currentMenuItem = null;
  29.  
  30. /* counter for going to screensaver */
  31. DisplayLinus.prototype.screenSaverCnt = null;
  32.  
  33. /* counter for going to main screen */
  34. DisplayLinus.prototype.mainScreenCnt = null;
  35.  
  36. DisplayLinus.prototype.CurrentPower = 0;
  37. DisplayLinus.prototype.CurrentEnergy = 0;
  38.  
  39. DisplayLinus.prototype.nextPhoneItem = 0;
  40. DisplayLinus.prototype.firstPhoneItem = 0;
  41.  
  42. insideTemperature = 0;
  43. outsideTemperature = 0;
  44.  
  45. const outsideTemperatureSensorId = 236;
  46. const insideTemperatureSensorId = 204;
  47.  
  48. const mainScreenTimeout = 40;
  49. const screenSaverTimeout = 15;
  50. const defaultBacklight = 255;
  51.  
  52. const numberOfItemsInPhonebook = 5;
  53.  
  54. /* This function must always be declared, this is where all the startup code
  55.    should be placed. Gets called with arguments like what ids to use etc. */
  56. DisplayLinus.prototype.initialize = function(initialArguments)
  57. {
  58.     /* We must always call the parent initialize */
  59.     this.Service.prototype.initialize.call(this, initialArguments);
  60.  
  61.     /* This is used for function declarations like the callbacks below */
  62.     var self = this;
  63.  
  64.     if (!this.myInitialArguments["HD44789"])
  65.     {
  66.         log(this.myName + ":" + this.myId + "> Failed to initialize, HD44789-config missing from config.\n");
  67.         return;
  68.     }
  69.    
  70.     if (!this.myInitialArguments["Rotary"])
  71.     {
  72.         log(this.myName + ":" + this.myId + "> Failed to initialize, Rotary-config missing from config.\n");
  73.         return;
  74.     }
  75.    
  76.     if (!this.myInitialArguments["power"])
  77.     {
  78.         log(this.myName + ":" + this.myId + "> Failed to initialize, power-config missing from config.\n");
  79.         return;
  80.     }
  81.    
  82.     if (!this.myInitialArguments["DS18x20"])
  83.     {
  84.         log(this.myName + ":" + this.myId + "> Failed to initialize, DS18x20-config missing from config.\n");
  85.         return;
  86.     }
  87.  
  88.     if (!this.myInitialArguments["SimpleDTMF"])
  89.     {
  90.         log(this.myName + ":" + this.myId + "> Failed to initialize, SimpleDTMF-config missing from config.\n");
  91.         return;
  92.     }
  93.    
  94.     this.screenSaverCnt = 0;
  95.     this.mainScreenCnt = 0;
  96.    
  97.     /* Get the LCD service that we want from the ServiceManager, it takes type, service name, service id */
  98.     this.myLCDService = ServiceManager.getService("Can", "HD44789", this.myInitialArguments["HD44789"]["Id"]);
  99.     /* Add a callback for when the service goes online */
  100.     this.myLCDService.registerEventCallback("online", function(args) { self.lcdOnline(); });
  101.     /* If the service is already online we should call the handler here */
  102.     this.lcdOnline();
  103.     /* Add a callback for when the service goes offline */
  104.     this.myLCDService.registerEventCallback("offline", function(args) { self.lcdOffline(); });
  105.    
  106.     /* Get the Rotary service that we want from the ServiceManager, it takes type, service name, service id */
  107.     this.myRotaryService = ServiceManager.getService("Can", "Rotary", this.myInitialArguments["Rotary"]["Id"]);
  108.     /* Add a callback for when the encoder reports a new position */
  109.     this.myRotaryService.registerEventCallback("newPosition", function(args) { self.rotaryPosUpdate(args); });
  110.     /* Add a callback for when the encoder reports a new button status */
  111.     this.myRotaryService.registerEventCallback("newBtnStatus", function(args) { self.rotaryBtnUpdate(args); });
  112.     /* Add a callback for when the service goes online */
  113.     this.myRotaryService.registerEventCallback("online", function(args) { self.rotaryOnline(); });
  114.     /* If the service is already online we should call the handler here */
  115.     this.rotaryOnline();
  116.  
  117.     /* Get the PWM service that we want from the ServiceManager, it takes type, service name, service id */
  118.     this.myPowerService = ServiceManager.getService("Can", "power", this.myInitialArguments["power"]["Id"]);
  119.     /* Add a callback for when the service goes online */
  120.     this.myPowerService.registerEventCallback("online", function(args) { self.PowerOnline(); });
  121.     /* Add a callback for when the sensor reports a new value */
  122.     this.myPowerService.registerEventCallback("newValue", function(args) { self.powerUpdate(); });
  123.     /* If the service is already online we should call the handler here */
  124.     this.PowerOnline();
  125.  
  126.     this.myDTMFService = ServiceManager.getService("Can", "SimpleDTMF", this.myInitialArguments["SimpleDTMF"]["Id"]);
  127.     this.myDTMFService.registerEventCallback("newPhonenumber", function(args) { self.dtmfUpdate(args); });
  128.     //this.myDTMFService.registerEventCallback("online", function(args) { self.dtmfOnline(); });
  129.     this.dtmfOnline();
  130.  
  131.     this.myOnlinePhonebook = new OnlinePhonebook(function(phonenumber, persons) { self.phonebookLookupCallback(phonenumber, persons); });
  132.  
  133.     /* Get the LCD service that we want from the ServiceManager, it takes type, service name, service id */
  134.     this.myTempService = ServiceManager.getService("Can", "DS18x20", this.myInitialArguments["DS18x20"]["Id"]);
  135.     /* Add a callback for when the sensor reports a new value */
  136.     this.myTempService.registerEventCallback("newValue", function(args) { self.temperatureUpdate(args); });
  137.  
  138.     /* create the first menu item */
  139.     this.statusMenuItem = new MenuItem(this);
  140.     this.statusMenuItem.displayData[0] = this.lcdCenterText("Meny1");
  141.     this.statusMenuItem.displayData[1] = this.lcdCenterText("");
  142.     this.statusMenuItem.displayData[2] = this.lcdCenterText("");
  143.     this.statusMenuItem.displayData[3] = this.lcdCenterText("");
  144.     this.statusMenuItem.doUpdate = this.updateStatusMenuItem;
  145.     this.currentMenuItem = this.statusMenuItem;
  146.    
  147.     /* create the menuitem where you can choose to enter the booking sub-menu */
  148.     this.dtmfMenuItem = new MenuItem(this);
  149.     this.dtmfMenuItem.displayData[0] = this.lcdCenterText("Senaste nummer");
  150.     this.dtmfMenuItem.displayData[1] = this.lcdCenterText("");
  151.     this.dtmfMenuItem.displayData[2] = this.lcdCenterText("");
  152.     this.dtmfMenuItem.displayData[3] = this.lcdCenterText("");
  153.     //this.dtmfMenuItem.doUpdate = function(args) { self.updateDtmfMenuItem(); };
  154.  
  155.     this.dtmfReturnMenuItem = new MenuItem(this);
  156.     this.dtmfReturnMenuItem.displayData[0] = this.lcdCenterText("Tryck for att ga");
  157.     this.dtmfReturnMenuItem.displayData[1] = this.lcdCenterText("till huvudmenyn");
  158.     this.dtmfReturnMenuItem.displayData[2] = this.lcdCenterText("");
  159.     this.dtmfReturnMenuItem.displayData[3] = this.lcdCenterText("");
  160.     //this.dtmfReturnMenuItem.doUpdate = function(args) { self.updateDtmfMenuItem(); };
  161.  
  162.     this.phoneItem = new Array();
  163.     for (n=0; n< numberOfItemsInPhonebook; n++)
  164.     {
  165.         this.phoneItem[n] = new MenuItem(this);
  166.         this.phoneItem[n].id = n;
  167.     }
  168.  
  169.     /* connect the items as a linked list */
  170.     this.statusMenuItem.setNextItem(this.dtmfMenuItem);
  171.     this.statusMenuItem.setPrevItem(this.dtmfMenuItem);
  172.     /* set the function that shall be executed when knob is turned */
  173.     this.statusMenuItem.doRight = function(args) { self.changeToNext(); };
  174.     this.statusMenuItem.doLeft = function(args) { self.changeToPrev(); };
  175.    
  176.     /* connect the items as a linked list */
  177.     this.dtmfMenuItem.setNextItem(this.statusMenuItem);
  178.     this.dtmfMenuItem.setPrevItem(this.statusMenuItem);
  179.     this.dtmfMenuItem.setDescItem(this.dtmfReturnMenuItem);
  180.     /* set the function that shall be executed when knob is turned */
  181.     this.dtmfMenuItem.doRight = function(args) { self.changeToNext(); };
  182.     this.dtmfMenuItem.doLeft = function(args) { self.changeToPrev(); };
  183.     this.dtmfMenuItem.doPress = function(args) { self.changeToDesc(); };
  184.  
  185.     /* connect the items as a linked list */
  186.     this.dtmfReturnMenuItem.setNextItem(this.dtmfReturnMenuItem);
  187.     this.dtmfReturnMenuItem.setPrevItem(this.dfmfReturnMenuItem);
  188.     this.dtmfReturnMenuItem.setDescItem(this.dtmfMenuItem);
  189.     this.dtmfReturnMenuItem.id = 255;
  190.     /* set the function that shall be executed when knob is turned */
  191.     this.dtmfReturnMenuItem.doRight = function(args) { self.changeToNext(); };
  192.     this.dtmfReturnMenuItem.doLeft = function(args) { self.changeToPrev(); };
  193.     this.dtmfReturnMenuItem.doPress = function(args) { self.changeToDesc(); };
  194. }
  195.  
  196. DisplayLinus.prototype.changeToDesc = function()
  197. {
  198.     if (this.currentMenuItem.descItem)
  199.     {
  200.         this.currentMenuItem = this.currentMenuItem.descItem;
  201.     }
  202. }
  203.  
  204. DisplayLinus.prototype.changeToNext = function()
  205. {
  206.     if (this.currentMenuItem.nextItem)
  207.     {
  208.         this.currentMenuItem = this.currentMenuItem.nextItem;
  209.     }
  210. }
  211.  
  212. DisplayLinus.prototype.changeToPrev = function()
  213. {
  214.     if (this.currentMenuItem.prevItem)
  215.     {
  216.         this.currentMenuItem = this.currentMenuItem.prevItem;
  217.     }
  218. }
  219.  
  220.  
  221. DisplayLinus.prototype.updateStatusMenuItem = function()
  222. {
  223.     var date = new Date();
  224.     /* Get the current date time on the format YYYY-mm-dd HH.ii.ss */
  225.     var dateAndTime = date.getDateTimeFormated();
  226.     //var date = new Date();
  227.     //var dateAndTime = "" + date.getTimeShortFormated();
  228.     this.displayData[1] = this.parentDisplay.lcdCenterText(""+dateAndTime);
  229.  
  230. this.displayData[2] = this.parentDisplay.lcdCenterText(""+insideTemperature + " C   " + outsideTemperature + " C");
  231.  
  232.     this.displayData[3] = this.parentDisplay.lcdCenterText(""+this.parentDisplay.CurrentPower.toString()+" Watt "+(this.parentDisplay.CurrentEnergy/1000).toString() + "kWh");
  233. }
  234.  
  235. DisplayLinus.prototype.temperatureUpdate = function(sensorId)
  236. {
  237.     if (sensorId == outsideTemperatureSensorId) {
  238.         outsideTemperature = this.myTempService.getValue(sensorId).toFixed(2).toString();
  239.     }
  240.     if (sensorId == insideTemperatureSensorId) {
  241.         insideTemperature = this.myTempService.getValue(sensorId).toFixed(2).toString();
  242.     }
  243. }
  244.  
  245. DisplayLinus.prototype.phonebookLookupCallback = function(phonenumber, persons)
  246. {
  247.       //log(this.myName + ":" + this.myId + "> New phonenumber\n");
  248.     // Update main dtmf menu
  249.     var date = new Date();
  250.     /* Get the current date time on the format YYYY-mm-dd HH.ii.ss */
  251.     var dateAndTime = date.getDateTimeFormated();
  252.     this.dtmfMenuItem.displayData[1] = this.lcdCenterText(""+dateAndTime);
  253.     this.dtmfMenuItem.displayData[2] = this.lcdCenterText(""+phonenumber);
  254.     this.dtmfMenuItem.displayData[3] = this.lcdCenterText(""+persons[0]);
  255.    
  256.  
  257.     if (this.dtmfReturnMenuItem.nextItem == this.dtmfReturnMenuItem) //the list is empty
  258.     {
  259.         // connect the items as a linked list
  260.         this.phoneItem[0].setNextItem(this.dtmfReturnMenuItem);
  261.         this.phoneItem[0].setPrevItem(this.dtmfReturnMenuItem);
  262.         this.phoneItem[0].setDescItem(this.statusMenuItem);
  263.         this.dtmfReturnMenuItem.setNextItem(this.phoneItem[0]);
  264.         this.dtmfReturnMenuItem.setPrevItem(this.phoneItem[0]);
  265.         this.nextPhoneItem = 1 % numberOfItemsInPhonebook;
  266.         this.lastPhoneItem = 0;
  267.         this.phoneItem[0].doRight = function(args) { self.changeToNext(); };
  268.         this.phoneItem[0].doLeft = function(args) { self.changeToPrev(); };
  269.         this.phoneItem[0].doPress = function(args) { self.changeToDesc(); };
  270.         this.phoneItem[0].displayData[0] = this.lcdCenterText(""+dateAndTime);
  271.         this.phoneItem[0].displayData[1] = this.lcdCenterText(""+phonenumber);
  272.         if (persons.length >= 1) {
  273.             this.phoneItem[0].displayData[2] = this.lcdCenterText(""+persons[0]);
  274.         } else {
  275.             this.phoneItem[0].displayData[2] = this.lcdCenterText("");
  276.         }
  277.         if (persons.length >= 2) {
  278.             this.phoneItem[0].displayData[3] = this.lcdCenterText(""+persons[1]);
  279.         } else {
  280.             this.phoneItem[0].displayData[3] = this.lcdCenterText("");
  281.         }  
  282.    
  283.     } else if (this.nextPhoneItem != this.lastPhoneItem) {      //Not full
  284.         // connect the items as a linked list
  285.         this.phoneItem[this.nextPhoneItem].setNextItem(this.phoneItem[(this.nextPhoneItem-1 + numberOfItemsInPhonebook) % numberOfItemsInPhonebook]);
  286.         this.phoneItem[this.nextPhoneItem].setPrevItem(this.dtmfReturnMenuItem);
  287.         this.phoneItem[this.nextPhoneItem].setDescItem(this.statusMenuItem);
  288.         this.dtmfReturnMenuItem.setNextItem(this.phoneItem[this.nextPhoneItem]);
  289.         this.phoneItem[(this.nextPhoneItem-1+ numberOfItemsInPhonebook) % numberOfItemsInPhonebook].setPrevItem(this.phoneItem[this.nextPhoneItem]);
  290.         this.phoneItem[this.nextPhoneItem].doRight = function(args) { self.changeToNext(); };
  291.         this.phoneItem[this.nextPhoneItem].doLeft = function(args) { self.changeToPrev(); };
  292.         this.phoneItem[this.nextPhoneItem].doPress = function(args) { self.changeToDesc(); };
  293.         this.phoneItem[this.nextPhoneItem].displayData[0] = this.lcdCenterText(""+dateAndTime);
  294.         this.phoneItem[this.nextPhoneItem].displayData[1] = this.lcdCenterText(""+phonenumber);
  295.         if (persons.length >= 1) {
  296.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText(""+persons[0]);
  297.         } else {
  298.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText("");
  299.         }
  300.         if (persons.length >= 2) {
  301.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText(""+persons[1]);
  302.         } else {
  303.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText("");
  304.         }
  305.         this.nextPhoneItem = (this.nextPhoneItem + 1) % numberOfItemsInPhonebook;
  306.     } else  {   //buffer full, start removing oldest item
  307.         // connect the items as a linked list (replace last item)
  308.         this.phoneItem[this.nextPhoneItem].setNextItem(this.phoneItem[(this.nextPhoneItem-1+ numberOfItemsInPhonebook) % numberOfItemsInPhonebook]);
  309.         this.phoneItem[this.nextPhoneItem].setPrevItem(this.dtmfReturnMenuItem);
  310.         this.phoneItem[this.nextPhoneItem].setDescItem(this.statusMenuItem);
  311.         this.dtmfReturnMenuItem.setNextItem(this.phoneItem[this.nextPhoneItem]);
  312.         this.phoneItem[(this.nextPhoneItem-1+ numberOfItemsInPhonebook) % numberOfItemsInPhonebook].setPrevItem(this.phoneItem[this.nextPhoneItem]);
  313.         this.phoneItem[this.nextPhoneItem].doRight = function(args) { self.changeToNext(); };
  314.         this.phoneItem[this.nextPhoneItem].doLeft = function(args) { self.changeToPrev(); };
  315.         this.phoneItem[this.nextPhoneItem].doPress = function(args) { self.changeToDesc(); };
  316.         this.phoneItem[this.nextPhoneItem].displayData[0] = this.lcdCenterText(""+dateAndTime);
  317.         this.phoneItem[this.nextPhoneItem].displayData[1] = this.lcdCenterText(""+phonenumber);
  318.         if (persons.length >= 1) {
  319.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText(""+persons[0]);
  320.         } else {
  321.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText("");
  322.         }
  323.         if (persons.length >= 2) {
  324.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText(""+persons[1]);
  325.         } else {
  326.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText("");
  327.         }
  328.         //this.nextPhoneItem = (this.nextPhoneItem + 1) % numberOfItemsInPhonebook;
  329.         this.lastPhoneItem = (this.lastPhoneItem + 1) % numberOfItemsInPhonebook;
  330.         this.dtmfReturnMenuItem.setPrevItem(this.phoneItem[this.lastPhoneItem]);
  331.         this.nextPhoneItem = (this.nextPhoneItem + 1) % numberOfItemsInPhonebook;
  332.     }
  333.  
  334.     /* Go to dtmf screen (time) */
  335.     this.currentMenuItem = this.dtmfMenuItem;
  336.    
  337.     this.screenSaverCnt = 0;
  338.     this.mainScreenCnt = 0;
  339.     if (this.myLCDService.getBacklight() != defaultBacklight)
  340.     {
  341.           this.myLCDService.setBacklight(defaultBacklight);
  342.     }
  343.     /* update the info on display */
  344.     this.updateDisplay();
  345.  
  346. }
  347.  
  348. DisplayLinus.prototype.replaceAumlauts = function(intext)
  349. {
  350.     intext = intext.replace(/Ã…/, "A");
  351.     intext = intext.replace(/Ã¥/, "a");
  352.     intext = intext.replace(/Ä/, "A");
  353.     intext = intext.replace(/ä/, "a");
  354.     intext = intext.replace(/Ö/, "O");
  355.     intext = intext.replace(/ö/, "o");
  356.     return intext;
  357. }
  358.  
  359.  
  360. DisplayLinus.prototype.rotaryOnline = function()
  361. {
  362. }
  363.  
  364. DisplayLinus.prototype.rotaryPosUpdate = function(SwitchId)
  365. {
  366.     this.screenSaverCnt = 0;
  367.     this.mainScreenCnt = 0;
  368.     if (this.myLCDService.getBacklight() != defaultBacklight)
  369.     {
  370.           this.myLCDService.setBacklight(defaultBacklight);
  371.     }
  372.     for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++)
  373.     {
  374.         if (this.myRotaryService.getDirection(SwitchId) == "Clockwise")
  375.         {
  376.             if (this.currentMenuItem.doRight)
  377.             {
  378.                 this.currentMenuItem.doRight();
  379.             }
  380.         }
  381.         else
  382.         {
  383.             if (this.currentMenuItem.doLeft)
  384.             {
  385.                 this.currentMenuItem.doLeft();
  386.             }
  387.         }
  388.     }
  389.    
  390.     this.updateDisplay();
  391. }
  392.  
  393. DisplayLinus.prototype.rotaryBtnUpdate = function(SwitchId)
  394. {
  395.     this.screenSaverCnt = 0;
  396.     this.mainScreenCnt = 0;
  397.     if (this.myLCDService.getBacklight() != defaultBacklight)
  398.     {
  399.           this.myLCDService.setBacklight(defaultBacklight);
  400.     }
  401.     if (this.myRotaryService.getButtonStatus(SwitchId) == "Released")
  402.     {
  403.         if (this.currentMenuItem.doPress)
  404.         {
  405.             this.currentMenuItem.doPress();
  406.         }
  407.         this.updateDisplay();
  408.     }
  409. }
  410.  
  411. DisplayLinus.prototype.updateDisplay = function()
  412. {
  413.     /* see if the current menuitem wants to update itself */
  414.     if (this.currentMenuItem.doUpdate)
  415.     {
  416.         this.currentMenuItem.doUpdate();
  417.     }
  418.  
  419.     /* Clear the LCD screen */
  420.     //this.myLCDService.clearScreen();
  421.    
  422.     /* send the data for the current menuitem to display */
  423.     for (var i = 0; i < this.currentMenuItem.displayData.length; i++)
  424.     {
  425.         this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]);
  426.     }
  427.    
  428. }
  429.  
  430.  
  431. DisplayLinus.prototype.lcdCenterText = function(text)
  432. {
  433.     returnText = text;
  434.     var displayWidth = 20;  //this.myLCDService.getWidth();
  435.     /* pad on both sides with spaces to displayWidth */
  436.     returnText = text.pad(displayWidth, " ", 2);
  437.    
  438.     return returnText;
  439. }
  440.  
  441. DisplayLinus.prototype.lcdOffline = function()
  442. {
  443.     /* If we have no interval timer running do nothing */
  444.     if (this.myInterval != null)
  445.     {
  446.         /* Stop the interval */
  447.         this.myInterval.stop();
  448.     }
  449. }
  450.  
  451. DisplayLinus.prototype.lcdOnline = function()
  452. {
  453.     /* If service is not online do nothing */
  454.     if (this.myLCDService.isOnline())
  455.     {
  456.         /* Clear the LCD screen */
  457.         this.myLCDService.clearScreen();
  458.         /* Set backlight to max */
  459.         this.myLCDService.setBacklight(defaultBacklight);
  460.  
  461.         /* If we have no interval timer running start it */
  462.         if (this.myInterval == null)
  463.         {
  464.             var self = this;
  465.        
  466.             /* Start interval timer for our printout. Arguments are the callback function and time in milliseconds */
  467.             this.myInterval = new Interval(function() { self.timerUpdate() }, 5000);
  468.         }
  469.        
  470.         this.myInterval.start();
  471.        
  472.         this.timerUpdate();
  473.  
  474.         this.updateDisplay();
  475.     }
  476. }
  477.  
  478. DisplayLinus.prototype.PowerOnline = function()
  479. {
  480.     /* If service is not online do nothing */
  481.     if (this.myPowerService.isOnline())
  482.     {
  483.         log("Power is online!\n");
  484.         /* Set report interval to 2 seconds */
  485.         this.myPowerService.setReportInterval(2);
  486.     }
  487. }
  488.  
  489. DisplayLinus.prototype.powerUpdate = function()
  490. {
  491.     this.CurrentPower = this.myPowerService.getPower();
  492.     this.CurrentEnergy = this.myPowerService.getEnergy();
  493.     if (this.currentMenuItem == this.statusMenuItem)
  494.     {
  495.         this.updateDisplay();
  496.     }
  497. }
  498.  
  499. DisplayLinus.prototype.dtmfOnline = function()
  500. {
  501. }
  502.  
  503. DisplayLinus.prototype.dtmfUpdate = function(args)
  504. {
  505.     this.myOnlinePhonebook.lookup(this.myDTMFService.getLastPhonenumber());
  506. }
  507.  
  508. DisplayLinus.prototype.timerUpdate = function()
  509. {
  510.     /* If LCD service is not online do nothing */
  511.     if (this.myLCDService.isOnline())
  512.     {
  513.         this.screenSaverCnt++;
  514.         this.mainScreenCnt++;
  515.  
  516.         if (this.mainScreenCnt > mainScreenTimeout/5)
  517.         {
  518.             /* Go to main screen (time) */
  519.             this.currentMenuItem = this.statusMenuItem;
  520.  
  521.             /* update the info on display */
  522.             this.updateDisplay();
  523.         }
  524.        
  525.         if (this.screenSaverCnt > screenSaverTimeout/5)
  526.         {
  527.             if (this.myLCDService.getBacklight() != 0)
  528.             {
  529.                   this.myLCDService.setBacklight(0);
  530.             }
  531.         }
  532.  
  533.        
  534.     }
  535.    
  536. }
  537.  
  538.