Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1610 | runge | 1 | |
| 2 | function HD44789(name) |
||
| 3 | { |
||
| 4 | this.Module(name); |
||
| 5 | HD44789.instance_ = this; |
||
| 6 | } |
||
| 7 | |||
| 8 | Extend(HD44789, Module); |
||
| 9 | |||
| 10 | HD44789.instance_ = null; |
||
| 11 | |||
| 12 | HD44789.prototype.ReceiveMessage = function(id, command, variables) |
||
| 13 | { |
||
| 14 | switch (command) |
||
| 15 | { |
||
| 16 | case "LCD_Cursor": |
||
| 17 | { |
||
| 18 | break; |
||
| 19 | } |
||
| 20 | case "LCD_Text": |
||
| 21 | { |
||
| 22 | break; |
||
| 23 | } |
||
| 24 | case "LCD_TextAt": |
||
| 25 | { |
||
| 26 | break; |
||
| 27 | } |
||
| 28 | case "LCD_Size": |
||
| 29 | { |
||
| 30 | this.EventBase.prototype.Trigger.call(this, "onSize", id, variables["Width"], variables["Height"]); |
||
| 31 | break; |
||
| 32 | } |
||
| 33 | case "LCD_Backlight": |
||
| 34 | { |
||
| 35 | this.EventBase.prototype.Trigger.call(this, "onBacklight", id, variables["Strength"]); |
||
| 36 | break; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | this.Module.prototype.ReceiveMessage.call(this, id, command, variables); |
||
| 41 | } |
||
| 42 | |||
| 43 | function HD44789_complete(args) |
||
| 44 | { |
||
| 45 | var result = new Array(); |
||
| 46 | |||
| 47 | var arg_index = args.length - 1; |
||
| 48 | |||
| 49 | if (arg_index == 1) // id |
||
| 50 | { |
||
| 51 | result = HD44789.instance_.GetAvailableIds(); |
||
| 52 | } |
||
| 53 | |||
| 54 | return result; |
||
| 55 | } |
||
| 56 | |||
| 57 | function HD44789_PrintText(id, x, y, text) |
||
| 58 | { |
||
| 59 | text = text.replace(/Å/, String.fromCharCode(1)); |
||
| 60 | text = text.replace(/å/, String.fromCharCode(0)); |
||
| 61 | text = text.replace(/Ä/, String.fromCharCode(2)); |
||
| 62 | text = text.replace(/ä/, String.fromCharCode(225)); |
||
| 63 | text = text.replace(/Ö/, String.fromCharCode(3)); |
||
| 64 | text = text.replace(/ö/, String.fromCharCode(239)); |
||
| 65 | text = text.replace(/¤/, String.fromCharCode(223)); |
||
| 66 | |||
| 67 | x = parseInt(x); |
||
| 68 | y = parseInt(y); |
||
| 69 | |||
| 70 | for (var n = 4; n < arguments.length; n++) |
||
| 71 | { |
||
| 72 | text += " " + arguments[n]; |
||
| 73 | } |
||
| 74 | |||
| 75 | while (text.length > 0) |
||
| 76 | { |
||
| 77 | var length = text.length < 6 ? text.length : 6; |
||
| 78 | var text_part = text.substr(0, length); |
||
| 79 | |||
| 80 | var variables = [ |
||
| 81 | { "X" : x }, |
||
| 82 | { "Y" : y }, |
||
| 83 | { "Text" : text_part } ]; |
||
| 84 | |||
| 85 | HD44789.instance_.Module.prototype.SendMessage.call(HD44789.instance_, id, "LCD_TextAt", variables); |
||
| 86 | |||
| 87 | text = text.substr(6); |
||
| 88 | x += 6; |
||
| 89 | } |
||
| 90 | |||
| 91 | return "OK"; |
||
| 92 | } |
||
| 93 | RegisterConsoleCommand(HD44789_PrintText, HD44789_complete); |
||
| 94 | |||
| 95 | |||
| 96 | function HD44789_ClearScreen(id) |
||
| 97 | { |
||
| 98 | var variables = [ ]; |
||
| 99 | |||
| 100 | HD44789.instance_.Module.prototype.SendMessage.call(HD44789.instance_, id, "LCD_Clear", variables); |
||
| 101 | return "OK"; |
||
| 102 | } |
||
| 103 | RegisterConsoleCommand(HD44789_ClearScreen, HD44789_complete); |
||
| 104 | |||
| 105 | |||
| 106 | function HD44789_SetBacklight(id, strength) |
||
| 107 | { |
||
| 108 | var variables = [ |
||
| 109 | { "Strength" : strength } ]; |
||
| 110 | |||
| 111 | HD44789.instance_.Module.prototype.SendMessage.call(HD44789.instance_, id, "LCD_Backlight", variables); |
||
| 112 | return "OK"; |
||
| 113 | } |
||
| 114 | RegisterConsoleCommand(HD44789_SetBacklight, HD44789_complete); |
||
| 115 |