forked from alireza787b/mavsdk_drone_show
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_led_controller.py
92 lines (70 loc) · 2.6 KB
/
test_led_controller.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import time
import logging
from src.led_controller import LEDController
# Setup logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def run_tests():
logger.info("Starting LEDController tests...")
# Initialize LEDController (this happens automatically)
led_controller = LEDController.get_instance()
# Test: Set colors
logger.info("Test: Set color to Red")
LEDController.set_color(255, 0, 0)
time.sleep(2)
logger.info("Test: Set color to Green")
LEDController.set_color(0, 255, 0)
time.sleep(2)
logger.info("Test: Set color to Blue")
LEDController.set_color(0, 0, 255)
time.sleep(2)
logger.info("Test: Set color to Yellow (Red + Green)")
LEDController.set_color(255, 255, 0)
time.sleep(2)
logger.info("Test: Set color to Cyan (Green + Blue)")
LEDController.set_color(0, 255, 255)
time.sleep(2)
logger.info("Test: Set color to Magenta (Red + Blue)")
LEDController.set_color(255, 0, 255)
time.sleep(2)
logger.info("Test: Set color to White (Red + Green + Blue)")
LEDController.set_color(255, 255, 255)
time.sleep(2)
# Test: Blinking
logger.info("Test: Blink Red 3 times")
for _ in range(3):
LEDController.set_color(255, 0, 0)
time.sleep(0.5)
LEDController.turn_off()
time.sleep(0.5)
logger.info("Test: Blink Green 3 times")
for _ in range(3):
LEDController.set_color(0, 255, 0)
time.sleep(0.5)
LEDController.turn_off()
time.sleep(0.5)
logger.info("Test: Blink Blue 3 times")
for _ in range(3):
LEDController.set_color(0, 0, 255)
time.sleep(0.5)
LEDController.turn_off()
time.sleep(0.5)
# Test: Patterns
logger.info("Test: Running color wipe (Red)")
LEDController.color_wipe(255, 0, 0, wait_ms=100)
logger.info("Test: Running color wipe (Green)")
LEDController.color_wipe(0, 255, 0, wait_ms=100)
logger.info("Test: Running color wipe (Blue)")
LEDController.color_wipe(0, 0, 255, wait_ms=100)
logger.info("Test: Running theater chase (Red)")
LEDController.theater_chase(255, 0, 0, wait_ms=100)
logger.info("Test: Running theater chase (Green)")
LEDController.theater_chase(0, 255, 0, wait_ms=100)
logger.info("Test: Running theater chase (Blue)")
LEDController.theater_chase(0, 0, 255, wait_ms=100)
# Turn off LEDs
logger.info("Test: Turning off all LEDs")
LEDController.turn_off()
logger.info("LEDController tests completed.")
if __name__ == "__main__":
run_tests()