Run the test code again with each OK button press.
David Blume

David Blume commited on 2020-03-07 22:37:16
Showing 8 changed files, with 51 additions and 24 deletions.

... ...
@@ -1,6 +1,6 @@
1 1
 The MIT License (MIT)
2 2
 
3
-Copyright (c) 2016 David Blume
3
+Copyright (c) 2020 David Blume
4 4
 
5 5
 Permission is hereby granted, free of charge, to any person obtaining a copy 
6 6
 of this software and associated documentation files (the "Software"), to deal 
... ...
@@ -24,11 +24,17 @@ If you're me, and you want to contribute to the repo, then you can clone it like
24 24
 
25 25
     git clone ssh://USERNAME@dlma.com/~/git/dxb_channel.git
26 26
 
27
-# Building it
27
+## Building it
28 28
 
29 29
 [Ensure you can sideload a dev channel](https://sdkdocs.roku.com/display/sdkdoc/Loading+and+Running+Your+Application).
30 30
 Then see the "build\_systems" command in dxb\_channel.sublime-project to see how the channel is zipped and deployed.
31 31
 
32
+## Experimenting
33
+
34
+The code in [`components/testtask.brs`](http://git.dlma.com/dxb_channel.git/blob/master/components/testtask.brs)
35
+is run every time the OK button is pressed (while the "Test Output" pane has focus).
36
+That's a good place to experiment with new code.
37
+
32 38
 # Is it any good?
33 39
 
34 40
 [Yes](https://news.ycombinator.com/item?id=3067434).
... ...
@@ -55,16 +55,20 @@ function init()
55 55
   m.myTask = CreateObject("roSGNode", "MyTask")
56 56
   m.myTask.ObserveField("updateText", "onUpdateText")
57 57
   m.myTask.ObserveField("updateTextLower", "onUpdateTextLower")
58
-  m.myTask.ObserveField("updateTextRight", "onUpdateTextRight")
59 58
   m.myTask.control = "RUN"
60 59
 
60
+  m.testTask = CreateObject("roSGNode", "TestTask")
61
+  m.testTask.ObserveField("updateText", "onUpdateTextRight")
62
+  m.testTask.control = "RUN"
63
+
61 64
   texttimer = m.top.findNode("textTimer")
62 65
   texttimer.observeField("fire", "timerUpdate")
63 66
   texttimer.control = "start"
64 67
 
65 68
   m.updates_lower_array = CreateObject("roArray", 10, true)
69
+  m.updates_right_array = CreateObject("roArray", 21, true)
66 70
 
67
-  m.focus_rect = 3
71
+  m.focus_rect = 1
68 72
   doUpdateFocus()
69 73
 
70 74
   m.top.setFocus(true)
... ...
@@ -93,22 +97,24 @@ function updateTextLower(s as String) as void
93 97
 end function
94 98
 
95 99
 function onUpdateTextRight() as void
96
-   if m.updates_right.text.Len() = 0
97
-       m.updates_right.text = m.myTask.updateTextRight
98
-   else
99
-       m.updates_right.text = m.updates_right.text + chr(10) + m.myTask.updateTextRight
100
-   end if
101
-   print m.myTask.updateTextRight
100
+   while m.updates_right_array.Count() > 20
101
+       m.updates_right_array.Shift()
102
+   end while
103
+   m.updates_right_array.Push(m.testTask.updateText)
104
+   m.updates_right.text = m.updates_right_array.Join(chr(10))
105
+   print m.testTask.updateText
102 106
 end function
103 107
 
104 108
 function onKeyEvent(key as String, press as Boolean) as Boolean
105 109
     handled = false
106 110
     if press then
107
-        if (key = "back") then
111
+        if key = "back" then
108 112
             handled = false
109 113
         else
110 114
             update_ui = false
111
-            if key = "up"
115
+            if key = "OK" and (m.focus_rect = 1 or m.focus_rect = 2)
116
+                m.testTask.control = "RUN"
117
+            elseif key = "up"
112 118
                 if m.focus_rect = 2:
113 119
                     m.focus_rect = 1
114 120
                 elseif m.focus_rect = 3
... ...
@@ -46,16 +46,6 @@ function executeTask() as void
46 46
     success = deviceInfo.EnableCodecCapChangedEvent(true)
47 47
     if not success then m.top.updateTextLower = "EnableCodecCapChangedEvent failure"
48 48
 
49
-    '
50
-    ' This is a good place to experiment.
51
-    ' Here, we print the GetConnectionInfo AssociativeArray.
52
-    '
53
-    aaConnectionInfo = deviceInfo.GetConnectionInfo()
54
-    for each key in aaConnectionInfo
55
-        val = aaConnectionInfo[key]
56
-        m.top.updateTextRight = key + " = " + val.ToStr()
57
-    end for
58
-
59 49
     while(true)
60 50
         msg = wait(0, port)
61 51
         msgType = type(msg)
... ...
@@ -4,7 +4,6 @@
4 4
 
5 5
 <interface>
6 6
   <field id="updateText" type="string" value=""/>
7
-  <field id="updateTextRight" type="string" value=""/>
8 7
   <field id="updateTextLower" type="string" value=""/>
9 8
 </interface>
10 9
 
... ...
@@ -0,0 +1,16 @@
1
+sub init()
2
+    m.top.functionName = "executeTest"
3
+end sub
4
+
5
+function executeTest() as void
6
+    ' This task gets run one at the start, and then
7
+    ' again every time the OK button is pressed.
8
+
9
+    deviceInfo = CreateObject("roDeviceInfo")
10
+    aaConnectionInfo = deviceInfo.GetConnectionInfo()
11
+    for each key in aaConnectionInfo
12
+        val = aaConnectionInfo[key]
13
+        m.top.updateText = key + " = " + val.ToStr()
14
+    end for
15
+
16
+end function
... ...
@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+
3
+<component name="TestTask" extends="Task">
4
+
5
+<interface>
6
+  <field id="updateText" type="string" value=""/>
7
+</interface>
8
+
9
+<script type="text/brightscript" uri="pkg:/components/testtask.brs"/>
10
+</component>
... ...
@@ -1,7 +1,7 @@
1 1
 title=dxb
2 2
 major_version=0
3 3
 minor_version=0
4
-build_version=3
4
+build_version=4
5 5
 ui_resolutions=fhd
6 6
 mm_icon_focus_hd=pkg:/images/mm_icon_focus_hd.png
7 7
 mm_icon_focus_sd=pkg:/images/mm_icon_focus_sd.png
8 8