Subversion Repositories HomeAutomation

Rev

Rev 1344 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. function SettingsMenuItem(parentDisplay, ks0108Object)
  3. {
  4.     this.parentDisplay = parentDisplay;
  5.     this.display = ks0108Object;
  6. }
  7.  
  8. /* the display object who created the menu item */
  9. SettingsMenuItem.prototype.parentDisplay = null;
  10. /* the display that we are writing to */
  11. SettingsMenuItem.prototype.display = null;
  12.  
  13. /* what SettingsMenuItem is left of this item, if used */
  14. SettingsMenuItem.prototype.LeftItem = null;
  15. /* what SettingsMenuItem is right of this item, if used */
  16. SettingsMenuItem.prototype.RightItem = null;
  17. /* what SettingsMenuItem is after of this item, if used */
  18. SettingsMenuItem.prototype.PressEnterItem = null;
  19. /* what SettingsMenuItem is before of this item, if used */
  20. SettingsMenuItem.prototype.PressBackItem = null;
  21. /* what SettingsMenuItem is below of this item, if used */
  22. SettingsMenuItem.prototype.DownItem = null;
  23. /* what SettingsMenuItem is abowe of this item, if used */
  24. SettingsMenuItem.prototype.UpItem = null;
  25.  
  26. /*
  27. Standard events can be:
  28. left, right, enter, back, up, down....
  29. */
  30. SettingsMenuItem.prototype.processEvent = function (event)
  31. {
  32.     switch (event)
  33.     {
  34.     case "left":
  35.         this.parentDisplay.changeToLeft();
  36.         break;
  37.  
  38.     case "right":
  39.         this.parentDisplay.changeToRight();
  40.         break;
  41.    
  42.     case "up":
  43. this.parentDisplay.defaultBacklight += 10;
  44. if (this.parentDisplay.defaultBacklight > 255)
  45. this.parentDisplay.defaultBacklight = 255;
  46. this.display.setBacklight(this.parentDisplay.defaultBacklight);
  47.         //parentDisplay.changeToUp();
  48.         break;
  49.    
  50.     case "down":
  51. this.parentDisplay.defaultBacklight -= 10;
  52. if (this.parentDisplay.defaultBacklight < 0)
  53. this.parentDisplay.defaultBacklight = 0;
  54. this.display.setBacklight(this.parentDisplay.defaultBacklight);
  55.         //parentDisplay.changeToDown();
  56.         break;
  57.    
  58.     case "enter":
  59. this.display.printText(3,3,"enter ","Standard","Standard");
  60.         //parentDisplay.changeToEnter();
  61.         break;
  62.    
  63.     case "back":
  64. this.display.printText(3,3,"back ","Standard","Standard");
  65.         //parentDisplay.changeToBack();
  66.         break;
  67.     }
  68. }
  69.  
  70. SettingsMenuItem.prototype.onEnter = function ()
  71. {
  72.     this.display.clearScreen("Standard");
  73. this.display.printText(0,0,"settingsMenu","Standard","Standard");
  74. }
  75. SettingsMenuItem.prototype.update = function ()
  76. {
  77.    
  78.  
  79. this.display.printText(2,2,"Backlight: "+this.parentDisplay.defaultBacklight + "  " ,"Standard","Standard");
  80. this.display.DrawRect(120,17,25,5,"Inverted","Fill",0);
  81. this.display.DrawRect(120,17,this.parentDisplay.defaultBacklight/10,5,"Standard","Fill",0);
  82. this.display.DrawRect(120,17,25,5,"Standard","NoFill",0);
  83.  
  84. }
  85. SettingsMenuItem.prototype.onExit = function ()
  86. {
  87.    
  88. }
  89.  
  90.