|
14 | 14 |
|
15 | 15 | """ |
16 | 16 |
|
17 | | -VERSION: 0.6 |
| 17 | +VERSION: 0.7 |
18 | 18 |
|
19 | 19 | CHANGES: |
20 | | - Improved Settings app UI |
| 20 | + Adjusted battery level detection, improved launcher sort method, |
| 21 | + added apps folders to import path, |
| 22 | + added ability to jump to alphabetical location in apps list, |
| 23 | + added new fbuf-based display driver to lib |
21 | 24 |
|
22 | 25 | This program is designed to be used in conjunction with the "apploader.py" program, to select and launch MPy apps for the Cardputer. |
23 | 26 |
|
@@ -168,8 +171,8 @@ def scan_apps(sd): |
168 | 171 | app_names.append( this_name ) |
169 | 172 | app_paths[f"{this_name}"] = f"/sd/apps/{entry}" |
170 | 173 |
|
171 | | - |
172 | | - app_names.sort() |
| 174 | + #sort alphabetically without uppercase/lowercase discrimination: |
| 175 | + app_names.sort(key=lambda element: element.lower()) |
173 | 176 |
|
174 | 177 | #add an appname to refresh the app list |
175 | 178 | app_names.append("Reload Apps") |
@@ -246,19 +249,27 @@ def read_battery_level(adc): |
246 | 249 | read approx battery level on the adc and return as int range 0 (low) to 3 (high) |
247 | 250 | """ |
248 | 251 | raw_value = adc.read_uv() # vbat has a voltage divider of 1/2 |
249 | | - |
250 | | - if raw_value < 525000: # 1.05v |
| 252 | + |
| 253 | + # more real-world data is needed to dial in battery level. |
| 254 | + # the original values were low, so they will be adjusted based on feedback. |
| 255 | + |
| 256 | + #originally 525000 (1.05v) |
| 257 | + if raw_value < 1575000: #3.15v |
251 | 258 | return 0 |
252 | | - if raw_value < 1050000: # 2.1v |
| 259 | + #originally 1050000 (2.1v) |
| 260 | + if raw_value < 1750000: #3.5v |
253 | 261 | return 1 |
254 | | - if raw_value < 1575000: # 3.15v |
| 262 | + #originally 1575000 (3.15v) |
| 263 | + if raw_value < 1925000: #3.85v |
255 | 264 | return 2 |
| 265 | + # 2100000 (4.2v) |
256 | 266 | return 3 # 4.2v or higher |
257 | 267 |
|
258 | 268 |
|
259 | 269 |
|
260 | 270 |
|
261 | 271 |
|
| 272 | + |
262 | 273 | #-------------------------------------------------------------------------------------------------- |
263 | 274 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
264 | 275 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Main Loop: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
@@ -492,8 +503,27 @@ def main_loop(): |
492 | 503 | beep.play(('C4','B4','C5','C5'),100,volume) |
493 | 504 |
|
494 | 505 | launch_app(app_paths[app_names[app_selector_index]]) |
495 | | - |
496 | | - |
| 506 | + |
| 507 | + else: # keyboard shortcuts! |
| 508 | + for key in pressed_keys: |
| 509 | + # jump to letter: |
| 510 | + if key not in prev_pressed_keys and len(key) == 1: # filter special keys and repeated presses |
| 511 | + if key in 'abcdefghijklmnopqrstuvwxyz1234567890': |
| 512 | + #search for that letter in the app list |
| 513 | + for idx, name in enumerate(app_names): |
| 514 | + if name.lower().startswith(key): |
| 515 | + #animation: |
| 516 | + if app_selector_index > idx: |
| 517 | + scroll_direction = -1 |
| 518 | + elif app_selector_index < idx: |
| 519 | + scroll_direction = 1 |
| 520 | + current_vscsad = target_vscsad |
| 521 | + # go there! |
| 522 | + app_selector_index = idx |
| 523 | + if ui_sound: |
| 524 | + beep.play(("G3"), 100, volume) |
| 525 | + found_key = True |
| 526 | + break |
497 | 527 |
|
498 | 528 | # once we parse the keypresses for this loop, we need to store them for next loop |
499 | 529 | prev_pressed_keys = pressed_keys |
@@ -676,3 +706,4 @@ def main_loop(): |
676 | 706 |
|
677 | 707 |
|
678 | 708 |
|
| 709 | + |
0 commit comments