Subversion Repositories HomeAutomation

Rev

Rev 1223 | 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.     /* This is used for function declarations like the callbacks below */
  257.     var self = this;
  258.  
  259.     if (this.dtmfReturnMenuItem.nextItem == this.dtmfReturnMenuItem) //the list is empty
  260.     {
  261.         // connect the items as a linked list
  262.         this.phoneItem[0].setNextItem(this.dtmfReturnMenuItem);
  263.         this.phoneItem[0].setPrevItem(this.dtmfReturnMenuItem);
  264.         this.phoneItem[0].setDescItem(this.statusMenuItem);
  265.         this.dtmfReturnMenuItem.setNextItem(this.phoneItem[0]);
  266.         this.dtmfReturnMenuItem.setPrevItem(this.phoneItem[0]);
  267.         this.nextPhoneItem = 1 % numberOfItemsInPhonebook;
  268.         this.lastPhoneItem = 0;
  269.         this.phoneItem[0].doRight = function(args) { self.changeToNext(); };
  270.         this.phoneItem[0].doLeft = function(args) { self.changeToPrev(); };
  271.         this.phoneItem[0].doPress = function(args) { self.changeToDesc(); };
  272.         this.phoneItem[0].displayData[0] = this.lcdCenterText(""+dateAndTime);
  273.         this.phoneItem[0].displayData[1] = this.lcdCenterText(""+phonenumber);
  274.         if (persons.length >= 1) {
  275.             this.phoneItem[0].displayData[2] = this.lcdCenterText(""+persons[0]);
  276.         } else {
  277.             this.phoneItem[0].displayData[2] = this.lcdCenterText("");
  278.         }
  279.         if (persons.length >= 2) {
  280.             this.phoneItem[0].displayData[3] = this.lcdCenterText(""+persons[1]);
  281.         } else {
  282.             this.phoneItem[0].displayData[3] = this.lcdCenterText("");
  283.         }  
  284.    
  285.     } else if (this.nextPhoneItem != this.lastPhoneItem) {      //Not full
  286.         // connect the items as a linked list
  287.         this.phoneItem[this.nextPhoneItem].setNextItem(this.phoneItem[(this.nextPhoneItem-1 + numberOfItemsInPhonebook) % numberOfItemsInPhonebook]);
  288.         this.phoneItem[this.nextPhoneItem].setPrevItem(this.dtmfReturnMenuItem);
  289.         this.phoneItem[this.nextPhoneItem].setDescItem(this.statusMenuItem);
  290.         this.dtmfReturnMenuItem.setNextItem(this.phoneItem[this.nextPhoneItem]);
  291.         this.phoneItem[(this.nextPhoneItem-1+ numberOfItemsInPhonebook) % numberOfItemsInPhonebook].setPrevItem(this.phoneItem[this.nextPhoneItem]);
  292.         this.phoneItem[this.nextPhoneItem].doRight = function(args) { self.changeToNext(); };
  293.         this.phoneItem[this.nextPhoneItem].doLeft = function(args) { self.changeToPrev(); };
  294.         this.phoneItem[this.nextPhoneItem].doPress = function(args) { self.changeToDesc(); };
  295.         this.phoneItem[this.nextPhoneItem].displayData[0] = this.lcdCenterText(""+dateAndTime);
  296.         this.phoneItem[this.nextPhoneItem].displayData[1] = this.lcdCenterText(""+phonenumber);
  297.         if (persons.length >= 1) {
  298.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText(""+persons[0]);
  299.         } else {
  300.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText("");
  301.         }
  302.         if (persons.length >= 2) {
  303.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText(""+persons[1]);
  304.         } else {
  305.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText("");
  306.         }
  307.         this.nextPhoneItem = (this.nextPhoneItem + 1) % numberOfItemsInPhonebook;
  308.     } else  {   //buffer full, start removing oldest item
  309.         // connect the items as a linked list (replace last item)
  310.         this.phoneItem[this.nextPhoneItem].setNextItem(this.phoneItem[(this.nextPhoneItem-1+ numberOfItemsInPhonebook) % numberOfItemsInPhonebook]);
  311.         this.phoneItem[this.nextPhoneItem].setPrevItem(this.dtmfReturnMenuItem);
  312.         this.phoneItem[this.nextPhoneItem].setDescItem(this.statusMenuItem);
  313.         this.dtmfReturnMenuItem.setNextItem(this.phoneItem[this.nextPhoneItem]);
  314.         this.phoneItem[(this.nextPhoneItem-1+ numberOfItemsInPhonebook) % numberOfItemsInPhonebook].setPrevItem(this.phoneItem[this.nextPhoneItem]);
  315.         this.phoneItem[this.nextPhoneItem].doRight = function(args) { self.changeToNext(); };
  316.         this.phoneItem[this.nextPhoneItem].doLeft = function(args) { self.changeToPrev(); };
  317.         this.phoneItem[this.nextPhoneItem].doPress = function(args) { self.changeToDesc(); };
  318.         this.phoneItem[this.nextPhoneItem].displayData[0] = this.lcdCenterText(""+dateAndTime);
  319.         this.phoneItem[this.nextPhoneItem].displayData[1] = this.lcdCenterText(""+phonenumber);
  320.         if (persons.length >= 1) {
  321.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText(""+persons[0]);
  322.         } else {
  323.             this.phoneItem[this.nextPhoneItem].displayData[2] = this.lcdCenterText("");
  324.         }
  325.         if (persons.length >= 2) {
  326.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText(""+persons[1]);
  327.         } else {
  328.             this.phoneItem[this.nextPhoneItem].displayData[3] = this.lcdCenterText("");
  329.         }
  330.         //this.nextPhoneItem = (this.nextPhoneItem + 1) % numberOfItemsInPhonebook;
  331.         this.lastPhoneItem = (this.lastPhoneItem + 1) % numberOfItemsInPhonebook;
  332.         this.dtmfReturnMenuItem.setPrevItem(this.phoneItem[this.lastPhoneItem]);
  333.         this.nextPhoneItem = (this.nextPhoneItem + 1) % numberOfItemsInPhonebook;
  334.     }
  335.  
  336.     /* Go to dtmf screen (time) */
  337.     this.currentMenuItem = this.dtmfMenuItem;
  338.    
  339.     this.screenSaverCnt = 0;
  340.     this.mainScreenCnt = 0;
  341.     if (this.myLCDService.getBacklight() != defaultBacklight)
  342.     {
  343.           this.myLCDService.setBacklight(defaultBacklight);
  344.     }
  345.     /* update the info on display */
  346.     this.updateDisplay();
  347.  
  348. }
  349.  
  350. DisplayLinus.prototype.replaceAumlauts = function(intext)
  351. {
  352.     intext = intext.replace(/Ã…/, "A");
  353.     intext = intext.replace(/Ã¥/, "a");
  354.     intext = intext.replace(/Ä/, "A");
  355.     intext = intext.replace(/ä/, "a");
  356.     intext = intext.replace(/Ö/, "O");
  357.     intext = intext.replace(/ö/, "o");
  358.     return intext;
  359. }
  360.  
  361.  
  362. DisplayLinus.prototype.rotaryOnline = function()
  363. {
  364. }
  365.  
  366. DisplayLinus.prototype.rotaryPosUpdate = function(SwitchId)
  367. {
  368.     this.screenSaverCnt = 0;
  369.     this.mainScreenCnt = 0;
  370.     if (this.myLCDService.getBacklight() != defaultBacklight)
  371.     {
  372.           this.myLCDService.setBacklight(defaultBacklight);
  373.     }
  374.     for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++)
  375.     {
  376.         if (this.myRotaryService.getDirection(SwitchId) == "Clockwise")
  377.         {
  378.             if (this.currentMenuItem.doRight)
  379.             {
  380.                 this.currentMenuItem.doRight();
  381.             }
  382.         }
  383.         else
  384.         {
  385.             if (this.currentMenuItem.doLeft)
  386.             {
  387.                 this.currentMenuItem.doLeft();
  388.             }
  389.         }
  390.     }
  391.    
  392.     this.updateDisplay();
  393. }
  394.  
  395. DisplayLinus.prototype.rotaryBtnUpdate = function(SwitchId)
  396. {
  397.     this.screenSaverCnt = 0;
  398.     this.mainScreenCnt = 0;
  399.     if (this.myLCDService.getBacklight() != defaultBacklight)
  400.     {
  401.           this.myLCDService.setBacklight(defaultBacklight);
  402.     }
  403.     if (this.myRotaryService.getButtonStatus(SwitchId) == "Released")
  404.     {
  405.         if (this.currentMenuItem.doPress)
  406.         {
  407.             this.currentMenuItem.doPress();
  408.         }
  409.         this.updateDisplay();
  410.     }
  411. }
  412.  
  413. DisplayLinus.prototype.updateDisplay = function()
  414. {
  415.     /* see if the current menuitem wants to update itself */
  416.     if (this.currentMenuItem.doUpdate)
  417.     {
  418.         this.currentMenuItem.doUpdate();
  419.     }
  420.  
  421.     /* Clear the LCD screen */
  422.     //this.myLCDService.clearScreen();
  423.    
  424.     /* send the data for the current menuitem to display */
  425.     for (var i = 0; i < this.currentMenuItem.displayData.length; i++)
  426.     {
  427.         this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]);
  428.     }
  429.    
  430. }
  431.  
  432.  
  433. DisplayLinus.prototype.lcdCenterText = function(text)
  434. {
  435.     returnText = text;
  436.     var displayWidth = 20;  //this.myLCDService.getWidth();
  437.     /* pad on both sides with spaces to displayWidth */
  438.     returnText = text.pad(displayWidth, " ", 2);
  439.    
  440.     return returnText;
  441. }
  442.  
  443. DisplayLinus.prototype.lcdOffline = function()
  444. {
  445.     /* If we have no interval timer running do nothing */
  446.     if (this.myInterval != null)
  447.     {
  448.         /* Stop the interval */
  449.         this.myInterval.stop();
  450.     }
  451. }
  452.  
  453. DisplayLinus.prototype.lcdOnline = function()
  454. {
  455.     /* If service is not online do nothing */
  456.     if (this.myLCDService.isOnline())
  457.     {
  458.         /* Clear the LCD screen */
  459.         this.myLCDService.clearScreen();
  460.         /* Set backlight to max */
  461.         this.myLCDService.setBacklight(defaultBacklight);
  462.  
  463.         /* If we have no interval timer running start it */
  464.         if (this.myInterval == null)
  465.         {
  466.             var self = this;
  467.        
  468.             /* Start interval timer for our printout. Arguments are the callback function and time in milliseconds */
  469.             this.myInterval = new Interval(function() { self.timerUpdate() }, 5000);
  470.         }
  471.        
  472.         this.myInterval.start();
  473.        
  474.         this.timerUpdate();
  475.  
  476.         this.updateDisplay();
  477.     }
  478. }
  479.  
  480. DisplayLinus.prototype.PowerOnline = function()
  481. {
  482.     /* If service is not online do nothing */
  483.     if (this.myPowerService.isOnline())
  484.     {
  485.         log("Power is online!\n");
  486.         /* Set report interval to 2 seconds */
  487.         this.myPowerService.setReportInterval(2);
  488.     }
  489. }
  490.  
  491. DisplayLinus.prototype.powerUpdate = function()
  492. {
  493.     this.CurrentPower = this.myPowerService.getPower();
  494.     this.CurrentEnergy = this.myPowerService.getEnergy();
  495.     if (this.currentMenuItem == this.statusMenuItem)
  496.     {
  497.         this.updateDisplay();
  498.     }
  499. }
  500.  
  501. DisplayLinus.prototype.dtmfOnline = function()
  502. {
  503. }
  504.  
  505. DisplayLinus.prototype.dtmfUpdate = function(args)
  506. {
  507.     this.myOnlinePhonebook.lookup(this.myDTMFService.getLastPhonenumber());
  508. }
  509.  
  510. DisplayLinus.prototype.timerUpdate = function()
  511. {
  512.     /* If LCD service is not online do nothing */
  513.     if (this.myLCDService.isOnline())
  514.     {
  515.         this.screenSaverCnt++;
  516.         this.mainScreenCnt++;
  517.  
  518.         if (this.mainScreenCnt > mainScreenTimeout/5)
  519.         {
  520.             /* Go to main screen (time) */
  521.             this.currentMenuItem = this.statusMenuItem;
  522.  
  523.             /* update the info on display */
  524.             this.updateDisplay();
  525.         }
  526.        
  527.         if (this.screenSaverCnt > screenSaverTimeout/5)
  528.         {
  529.             if (this.myLCDService.getBacklight() != 0)
  530.             {
  531.                   this.myLCDService.setBacklight(0);
  532.             }
  533.         }
  534.  
  535.        
  536.     }
  537.    
  538. }
  539.  
  540.