Rev 2017 | Rev 2020 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2017 | Rev 2019 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | 1 | ||
| 2 |
|
2 | G_Display_ModuleNames = [ "KS0108" ]; |
| 3 |
|
3 | G_Display_Height = function() { return [ 0, 1, 2, 3 ]; }; |
| 4 |
|
4 | G_Display_Radius = function() { return [ 2, 5, 10, 20, 30, 50, 100 ]; }; |
| 5 |
|
5 | G_Display_Inverted = function() { return [ "Standard", "Inverted" ]; }; |
| 6 |
|
6 | G_Display_Fill = function() { return [ "NoFill", "Fill" ]; }; |
| 7 |
|
7 | G_Dsplay_Transparent = function() { return [ "Standard", "Transparent" ]; }; |
| 8 |
|
8 | G_Display_Width = function() { return [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]; }; |
| 9 |
|
9 | G_Display_Backlight = function() { return [ 0, 50, 100, 150, 200, 255 ]; }; |
| 10 |
|
10 | G_Display_Aliases = function() { return Module_GetAliasNames(G_Display_ModuleNames); }; |
| 11 |
|
11 | G_Display_AvailableIds = function() { return Module_GetAvailableIds(G_Display_ModuleNames); }; |
| 12 | 12 | ||
| 13 | function |
13 | function G_Display_Clear(alias_name, inverted) |
| 14 | { |
14 | { |
| 15 | if (arguments.length < 2) |
15 | if (arguments.length < 2) |
| 16 | { |
16 | { |
| 17 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
17 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 18 | return false; |
18 | return false; |
| 19 | } |
19 | } |
| 20 | 20 | ||
| 21 | var aliases_data = Module_ResolveAlias(alias_name, |
21 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 22 | var found = false; |
22 | var found = false; |
| 23 | 23 | ||
| 24 | for (var name in aliases_data) |
24 | for (var name in aliases_data) |
| 25 | { |
25 | { |
| 26 | var variables = { |
26 | var variables = { |
| Line 40... | Line 40... | ||
| 40 | return false; |
40 | return false; |
| 41 | } |
41 | } |
| 42 | 42 | ||
| 43 | return true; |
43 | return true; |
| 44 | } |
44 | } |
| 45 | Console_RegisterCommand( |
45 | Console_RegisterCommand(G_Display_Clear, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Inverted()); }); |
| 46 | 46 | ||
| 47 | function |
47 | function G_Display_SetBacklight(alias_name, strength) |
| 48 | { |
48 | { |
| 49 | if (arguments.length < 2) |
49 | if (arguments.length < 2) |
| 50 | { |
50 | { |
| 51 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
51 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 52 | return false; |
52 | return false; |
| 53 | } |
53 | } |
| 54 | 54 | ||
| 55 | var aliases_data = Module_ResolveAlias(alias_name, |
55 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 56 | var found = false; |
56 | var found = false; |
| 57 | 57 | ||
| 58 | for (var name in aliases_data) |
58 | for (var name in aliases_data) |
| 59 | { |
59 | { |
| 60 | var variables = { |
60 | var variables = { |
| Line 80... | Line 80... | ||
| 80 | return false; |
80 | return false; |
| 81 | } |
81 | } |
| 82 | 82 | ||
| 83 | return true; |
83 | return true; |
| 84 | } |
84 | } |
| 85 | Console_RegisterCommand( |
85 | Console_RegisterCommand(G_Display_SetBacklight, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Backlight()); }); |
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | function |
88 | function G_Display_Print(alias_name, x, y, inverted, transparent, text) |
| 89 | { |
89 | { |
| 90 | if (arguments.length < 6) |
90 | if (arguments.length < 6) |
| 91 | { |
91 | { |
| 92 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
92 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 93 | return false; |
93 | return false; |
| Line 107... | Line 107... | ||
| 107 | for (var n = 6; n < arguments.length; n++) |
107 | for (var n = 6; n < arguments.length; n++) |
| 108 | { |
108 | { |
| 109 | text += " " + arguments[n]; |
109 | text += " " + arguments[n]; |
| 110 | } |
110 | } |
| 111 | 111 | ||
| 112 | var aliases_data = Module_ResolveAlias(alias_name, |
112 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 113 | var found = false; |
113 | var found = false; |
| 114 | 114 | ||
| 115 | for (var name in aliases_data) |
115 | for (var name in aliases_data) |
| 116 | { |
116 | { |
| 117 | var org_text = text; |
117 | var org_text = text; |
| Line 151... | Line 151... | ||
| 151 | return false; |
151 | return false; |
| 152 | } |
152 | } |
| 153 | 153 | ||
| 154 | return true; |
154 | return true; |
| 155 | } |
155 | } |
| 156 | Console_RegisterCommand( |
156 | Console_RegisterCommand(G_Display_Print, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Width(), G_Display_Height(), G_Display_Inverted(), G_Display_Transparent()); }); |
| 157 | 157 | ||
| 158 | function |
158 | function G_Display_DrawCircle(alias_name, xCentre, yCentre, radius, inverted) |
| 159 | { |
159 | { |
| 160 | if (arguments.length < 5) |
160 | if (arguments.length < 5) |
| 161 | { |
161 | { |
| 162 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
162 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 163 | return false; |
163 | return false; |
| 164 | } |
164 | } |
| 165 | xCentre = parseInt(xCentre); |
165 | xCentre = parseInt(xCentre); |
| 166 | yCentre = parseInt(yCentre); |
166 | yCentre = parseInt(yCentre); |
| 167 | radius = parseInt(radius); |
167 | radius = parseInt(radius); |
| 168 | var aliases_data = Module_ResolveAlias(alias_name, |
168 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 169 | var found = false; |
169 | var found = false; |
| 170 | for (var name in aliases_data) |
170 | for (var name in aliases_data) |
| 171 | { |
171 | { |
| 172 | var variables = { |
172 | var variables = { |
| 173 | "Xcentre" : xCentre, |
173 | "Xcentre" : xCentre, |
| Line 186... | Line 186... | ||
| 186 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
186 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 187 | return false; |
187 | return false; |
| 188 | } |
188 | } |
| 189 | return true; |
189 | return true; |
| 190 | } |
190 | } |
| 191 | Console_RegisterCommand( |
191 | Console_RegisterCommand(G_Display_DrawCircle, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Width(), G_Display_Height(), G_Display_Radius(), G_Display_Inverted()); }); |
| 192 | 192 | ||
| 193 | function |
193 | function G_Display_DrawLine(alias_name, xStart, yStart, xEnd, yEnd, inverted) |
| 194 | { |
194 | { |
| 195 | if (arguments.length < 6) |
195 | if (arguments.length < 6) |
| 196 | { |
196 | { |
| 197 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
197 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 198 | return false; |
198 | return false; |
| 199 | } |
199 | } |
| 200 | xStart = parseInt(xStart); |
200 | xStart = parseInt(xStart); |
| 201 | yStart = parseInt(yStart); |
201 | yStart = parseInt(yStart); |
| 202 | xEnd = parseInt(xEnd); |
202 | xEnd = parseInt(xEnd); |
| 203 | yEnd = parseInt(yEnd); |
203 | yEnd = parseInt(yEnd); |
| 204 | var aliases_data = Module_ResolveAlias(alias_name, |
204 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 205 | var found = false; |
205 | var found = false; |
| 206 | for (var name in aliases_data) |
206 | for (var name in aliases_data) |
| 207 | { |
207 | { |
| 208 | var variables = { |
208 | var variables = { |
| 209 | "X1" : xStart, |
209 | "X1" : xStart, |
| Line 223... | Line 223... | ||
| 223 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
223 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 224 | return false; |
224 | return false; |
| 225 | } |
225 | } |
| 226 | return true; |
226 | return true; |
| 227 | } |
227 | } |
| 228 | Console_RegisterCommand( |
228 | Console_RegisterCommand(G_Display_DrawLine, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Width(), G_Display_Height(),G_Display_Width(), G_Display_Height(), G_Display_Inverted()); }); |
| 229 | 229 | ||
| 230 | function |
230 | function G_Display_invertRect(alias_name, xStart, yStart, width, height) |
| 231 | { |
231 | { |
| 232 | if (arguments.length < 5) |
232 | if (arguments.length < 5) |
| 233 | { |
233 | { |
| 234 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
234 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 235 | return false; |
235 | return false; |
| 236 | } |
236 | } |
| 237 | xStart = parseInt(xStart); |
237 | xStart = parseInt(xStart); |
| 238 | yStart = parseInt(yStart); |
238 | yStart = parseInt(yStart); |
| 239 | width = parseInt(width); |
239 | width = parseInt(width); |
| 240 | height = parseInt(height); |
240 | height = parseInt(height); |
| 241 | var aliases_data = Module_ResolveAlias(alias_name, |
241 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 242 | var found = false; |
242 | var found = false; |
| 243 | for (var name in aliases_data) |
243 | for (var name in aliases_data) |
| 244 | { |
244 | { |
| 245 | var variables = { |
245 | var variables = { |
| 246 | "X" : xStart, |
246 | "X" : xStart, |
| Line 259... | Line 259... | ||
| 259 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
259 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 260 | return false; |
260 | return false; |
| 261 | } |
261 | } |
| 262 | return true; |
262 | return true; |
| 263 | } |
263 | } |
| 264 | Console_RegisterCommand( |
264 | Console_RegisterCommand(G_Display_invertRect, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Width(), G_Display_Height(),G_Display_Width(), G_Display_Height()); }); |
| 265 | 265 | ||
| 266 | function |
266 | function G_Display_DrawRect(alias_name, xStart, yStart, width, height, inverted, fill, radius) |
| 267 | { |
267 | { |
| 268 | if (arguments.length < 8) |
268 | if (arguments.length < 8) |
| 269 | { |
269 | { |
| 270 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
270 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 271 | return false; |
271 | return false; |
| Line 273... | Line 273... | ||
| 273 | xStart = parseInt(xStart); |
273 | xStart = parseInt(xStart); |
| 274 | yStart = parseInt(yStart); |
274 | yStart = parseInt(yStart); |
| 275 | width = parseInt(width); |
275 | width = parseInt(width); |
| 276 | height = parseInt(height); |
276 | height = parseInt(height); |
| 277 | radius = parseInt(radius); |
277 | radius = parseInt(radius); |
| 278 | var aliases_data = Module_ResolveAlias(alias_name, |
278 | var aliases_data = Module_ResolveAlias(alias_name, G_Display_ModuleNames); |
| 279 | var found = false; |
279 | var found = false; |
| 280 | for (var name in aliases_data) |
280 | for (var name in aliases_data) |
| 281 | { |
281 | { |
| 282 | var variables = { |
282 | var variables = { |
| 283 | "X" : xStart, |
283 | "X" : xStart, |
| Line 299... | Line 299... | ||
| 299 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
299 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 300 | return false; |
300 | return false; |
| 301 | } |
301 | } |
| 302 | return true; |
302 | return true; |
| 303 | } |
303 | } |
| 304 | Console_RegisterCommand( |
304 | Console_RegisterCommand(G_Display_DrawRect, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, G_Display_Aliases(), G_Display_Width(), G_Display_Height(),G_Display_Width(), G_Display_Height(), G_Display_Inverted(), G_Display_Fill(), G_Display_Radius()); }); |
| 305 | 305 | ||
| 306 | function |
306 | function G_Display_OnMessage(module_name, module_id, command, variables) |
| 307 | { |
307 | { |
| 308 | if (in_array( |
308 | if (in_array(G_Display_ModuleNames, module_name)) |
| 309 | { |
309 | { |
| 310 | var aliases_data = Module_LookupAliases({ |
310 | var aliases_data = Module_LookupAliases({ |
| 311 | "module_name" : module_name, |
311 | "module_name" : module_name, |
| 312 | "module_id" : module_id, |
312 | "module_id" : module_id, |
| 313 | "group" : false |
313 | "group" : false |
| Line 336... | Line 336... | ||
| 336 | break; |
336 | break; |
| 337 | } |
337 | } |
| 338 | } |
338 | } |
| 339 | } |
339 | } |
| 340 | } |
340 | } |
| 341 | Module_RegisterToOnMessage("all", |
341 | Module_RegisterToOnMessage("all", G_Display_OnMessage); |
| 342 | 342 | ||
| 343 | function |
343 | function G_Display_OnChange(module_name, module_id, available) |
| 344 | { |
344 | { |
| 345 | if (in_array( |
345 | if (in_array(G_Display_ModuleNames, module_name) && available) |
| 346 | { |
346 | { |
| 347 | var aliases_data = Module_LookupAliases({ |
347 | var aliases_data = Module_LookupAliases({ |
| 348 | "module_name" : module_name, |
348 | "module_name" : module_name, |
| 349 | "module_id" : module_id, |
349 | "module_id" : module_id, |
| 350 | "group" : false |
350 | "group" : false |
| Line 356... | Line 356... | ||
| 356 | 356 | ||
| 357 | Module_SendMessage(aliases_data[alias_name]["module_name"], aliases_data[alias_name]["module_id"], "LCD_Backlight", variables); |
357 | Module_SendMessage(aliases_data[alias_name]["module_name"], aliases_data[alias_name]["module_id"], "LCD_Backlight", variables); |
| 358 | } |
358 | } |
| 359 | } |
359 | } |
| 360 | } |
360 | } |
| 361 | Module_RegisterToOnChange("all", |
361 | Module_RegisterToOnChange("all", G_Display_OnChange); |