Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. /* the display object who created the menu item */
  2. HDMISwitchMenuItem.prototype.parentDisplay = null;
  3.  
  4. HDMISwitchMenuItem.prototype.switch = null;
  5. HDMISwitchMenuItem.prototype.mode = 0;
  6.  
  7. HDMISwitchMenuItem.prototype.currentPosition = 0;
  8.  
  9. function HDMISwitchMenuItem(parentDisplay, hd44789Object)
  10. {
  11.     var self = this;
  12.     this.parentDisplay = parentDisplay;
  13.     this.display = hd44789Object;  
  14. }
  15.  
  16. /* the display object who created the menu item */
  17. HDMISwitchMenuItem.prototype.parentDisplay = null;
  18. /* the display that we are writing to */
  19. HDMISwitchMenuItem.prototype.display = null;
  20.  
  21. /* How often the display shall update [ms]*/
  22. HDMISwitchMenuItem.prototype.UpdateTime = 5000;
  23.  
  24. /* what HDMISwitchMenuItem is left of this item, if used */
  25. HDMISwitchMenuItem.prototype.LeftItem = null;
  26. /* what HDMISwitchMenuItem is right of this item, if used */
  27. HDMISwitchMenuItem.prototype.RightItem = null;
  28. /* what HDMISwitchMenuItem is after of this item, if used */
  29. HDMISwitchMenuItem.prototype.PressEnterItem = null;
  30.  
  31. /*
  32. Standard events can be:
  33. left, right, enter, back, up, down....
  34. */
  35. HDMISwitchMenuItem.prototype.processEvent = function (event)
  36. {
  37.     switch (event)
  38.     {
  39.     case "right":
  40.         if (this.mode == 0) {
  41.             this.parentDisplay.changeToRight();
  42.         } else if (this.mode == 1){
  43.             this.currentPosition--;
  44.             if (this.currentPosition < 0) {
  45.                 this.currentPosition= 2;
  46.             }
  47.             Output_SetSwitch("HDMI_switch", this.currentPosition+1);
  48.         }
  49.         break;
  50.  
  51.     case "left":
  52.         if (this.mode == 0) {
  53.             this.parentDisplay.changeToLeft();
  54.         } else if (this.mode == 1){
  55.             this.currentPosition++;
  56.             if (this.currentPosition >= 3) {
  57.                 this.currentPosition=0;
  58.             }
  59.             Output_SetSwitch("HDMI_switch", this.currentPosition+1);
  60.         }
  61.         break;
  62.     case "enter":
  63.         if (this.mode == 0) {
  64.             this.mode = 1;
  65.         } else {
  66.             this.mode = 0;
  67.         }
  68.         break;
  69.     }
  70. }
  71.  
  72. HDMISwitchMenuItem.prototype.onEnter = function ()
  73. {
  74.     this.mode = 0;
  75.     Display_Clear(this.display);
  76. }
  77. HDMISwitchMenuItem.prototype.update = function ()
  78. {
  79.     Display_Clear(this.display);
  80.     var last_value_string = Storage_GetParameter("LastValues", this.switch);
  81.     var last_value = eval("(" + last_value_string + ")");
  82.     if (this.mode == 0) {
  83.     Display_Print(this.display, 0, 1, " HDMI mode:          ");
  84.     } else {
  85.     Display_Print(this.display, 0, 1, ">HDMI mode:          ");
  86.      
  87.     }
  88.     switch (this.currentPosition) {
  89.       case 0:
  90.           Display_Print(this.display, 11, 1, "Dator    ");
  91.           break;
  92.       case 1:
  93.           Display_Print(this.display, 11, 1, "TV       ");
  94.           break;
  95.       case 2:
  96.           Display_Print(this.display, 11, 1, "Annat    ");
  97.           break;
  98.      
  99.     }
  100. }
  101.  
  102. HDMISwitchMenuItem.prototype.onExit = function ()
  103. {
  104.     this.mode = 0;
  105. }
  106.  
  107.  
  108.