-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrorhandler.py
More file actions
54 lines (44 loc) · 1.35 KB
/
errorhandler.py
File metadata and controls
54 lines (44 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# ErrorHandler by Frederik Andersen
# Class to handle all error messages from the program.
# Released under the MIT License (MIT). See LICENSE for details.
import utime
import machine
class ErrorHandler():
def __init__(self, error_message):
print(error_message)
# Used to have more functionallity, but eats up to much ram.
@staticmethod
def retry_timer():
"""
Flashes led and returns after 5 minutes.
"""
counter = 0
while True:
ErrorHandler.flash_led()
counter += 1
if counter >= 150: # After 5 min
break
@staticmethod
def flash_led():
"""
Static method for flashing the onboard led one cycle.
"""
led = machine.Pin("LED", machine.Pin.OUT)
led.on()
utime.sleep(1)
led.off()
utime.sleep(1)
@staticmethod
def turn_on_led():
"""
Static method for flashing the onboard led one cycle.
"""
led = machine.Pin("LED", machine.Pin.OUT)
led.on()
@staticmethod
def turn_off_led():
"""
Static method for flashing the onboard led one cycle.
"""
led = machine.Pin("LED", machine.Pin.OUT)
led.off()