Browse Source

nicer splash, more workflows

Thomas Buck 1 year ago
parent
commit
039178aca6
4 changed files with 68 additions and 18 deletions
  1. 1
    0
      python-test/.gitignore
  2. 11
    0
      python-test/copy.sh
  3. 34
    18
      python-test/states.py
  4. 22
    0
      python-test/workflows.py

+ 1
- 0
python-test/.gitignore View File

@@ -1 +1,2 @@
1 1
 venv
2
+_git.py

+ 11
- 0
python-test/copy.sh View File

@@ -1,7 +1,17 @@
1 1
 #!/bin/bash
2 2
 
3
+BRANCH=`git symbolic-ref --short HEAD`
4
+HASH=`git rev-parse --short HEAD`
5
+DATE=`date "+%Y-%m-%d %H:%M:%S"`
6
+
7
+echo "# auto generated - do not edit" > _git.py
8
+echo "git_branch=\"$BRANCH\"" >> _git.py
9
+echo "git_hash=\"$HASH\"" >> _git.py
10
+echo "build_date=\"$DATE\"" >> _git.py
11
+
3 12
 if [ $# -ne 0 ] ; then
4 13
 cat << EOF | rshell
14
+cp _git.py /pyboard
5 15
 cp poll.py /pyboard
6 16
 cp scan.py /pyboard
7 17
 cp lcd.py /pyboard
@@ -19,6 +29,7 @@ cp $1 /pyboard/main.py
19 29
 EOF
20 30
 else
21 31
 cat << EOF | rshell
32
+cp _git.py /pyboard
22 33
 cp poll.py /pyboard
23 34
 cp scan.py /pyboard
24 35
 cp lcd.py /pyboard

+ 34
- 18
python-test/states.py View File

@@ -153,26 +153,42 @@ def state_machine(lcd):
153 153
 from lcd import LCD
154 154
 lcd = LCD()
155 155
 
156
-# splash screen
157
-lcd.fill(lcd.black)
158
-lcd.textC("S&B Volcano Remote", int(lcd.width / 2), 10, lcd.green)
159
-lcd.textC("by xythobuz",        int(lcd.width / 2), 20, lcd.yellow)
160
-lcd.textC("Initializing...",    int(lcd.width / 2), 30, lcd.white)
161
-lcd.textC(os.uname()[0][ 0 : 30], int(lcd.width / 2), lcd.height - 50, lcd.green)
162
-lcd.textC(os.uname()[3][ 0 : 30], int(lcd.width / 2), lcd.height - 40, lcd.yellow)
163
-lcd.textC(os.uname()[3][30 : 60], int(lcd.width / 2), lcd.height - 30, lcd.yellow)
164
-lcd.textC(os.uname()[4][ 0 : 30], int(lcd.width / 2), lcd.height - 20, lcd.white)
165
-lcd.textC(os.uname()[4][30 : 60], int(lcd.width / 2), lcd.height - 10, lcd.white)
166
-lcd.show()
167
-lcd.brightness(1.0)
168
-
169
-# bootloader access with face buttons
170
-keys = lcd.buttons()
171
-if keys.once("a") and keys.once("b"):
172
-    machine.bootloader()
156
+def main():
157
+    # splash screen
158
+    from state_wait_temp import from_hsv
159
+    for x in range(0, lcd.width):
160
+        hue = x / (lcd.width - 1)
161
+        r, g, b = from_hsv(hue, 1.0, 1.0)
162
+        c = lcd.color(r, g, b)
163
+        lcd.rect(x, 0, 1, lcd.height, c)
164
+
165
+    lcd.textC("S&B Volcano Remote", int(lcd.width / 2), 10, lcd.green, lcd.black)
166
+    lcd.textC("by xythobuz",        int(lcd.width / 2), 20, lcd.yellow, lcd.black)
167
+    lcd.textC("Initializing...",    int(lcd.width / 2), 30, lcd.white, lcd.black)
168
+
169
+    import _git
170
+    lcd.textC(_git.git_branch, int(lcd.width / 2), int(lcd.height / 2) - 10, lcd.green, lcd.black)
171
+    lcd.textC(_git.git_hash, int(lcd.width / 2), int(lcd.height / 2), lcd.yellow, lcd.black)
172
+    lcd.textC(_git.build_date, int(lcd.width / 2), int(lcd.height / 2) + 10, lcd.white, lcd.black)
173
+
174
+    lcd.textC(os.uname()[0][ 0 : 30], int(lcd.width / 2), lcd.height - 50, lcd.green, lcd.black)
175
+    lcd.textC(os.uname()[3][ 0 : 30], int(lcd.width / 2), lcd.height - 40, lcd.yellow, lcd.black)
176
+    lcd.textC(os.uname()[3][30 : 60], int(lcd.width / 2), lcd.height - 30, lcd.yellow, lcd.black)
177
+    lcd.textC(os.uname()[4][ 0 : 30], int(lcd.width / 2), lcd.height - 20, lcd.white, lcd.black)
178
+    lcd.textC(os.uname()[4][30 : 60], int(lcd.width / 2), lcd.height - 10, lcd.white, lcd.black)
179
+
180
+    lcd.show()
181
+    lcd.brightness(1.0)
182
+
183
+    # bootloader access with face buttons
184
+    keys = lcd.buttons()
185
+    if keys.once("a") and keys.once("b"):
186
+        machine.bootloader()
173 187
 
174
-try:
175 188
     state_machine(lcd)
189
+
190
+try:
191
+    main()
176 192
 except Exception as e:
177 193
     sys.print_exception(e)
178 194
 

+ 22
- 0
python-test/workflows.py View File

@@ -2,6 +2,28 @@
2 2
 
3 3
 workflows = [
4 4
     {
5
+        "name": "Default",
6
+        "author": "xythobuz",
7
+        "steps": [
8
+            (185.0, 15.0, 5.0),
9
+            (195.0, 10.0, 20.0),
10
+            (205.0, 10.0, 20.0),
11
+        ],
12
+        "notify": (4, 1.0),
13
+        "reset_temperature": 190.0,
14
+    },
15
+    {
16
+        "name": "Relaxo",
17
+        "author": "xythobuz",
18
+        "steps": [
19
+            (175.0, 15.0, 5.0),
20
+            (185.0, 10.0, 20.0),
21
+            (195.0, 10.0, 20.0),
22
+        ],
23
+        "notify": (4, 1.0),
24
+        "reset_temperature": 190.0,
25
+    },
26
+    {
5 27
         "name": "Hardcore",
6 28
         "author": "xythobuz",
7 29
         "steps": [

Loading…
Cancel
Save