-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpca9685pw_testpy.py
126 lines (107 loc) · 3.51 KB
/
pca9685pw_testpy.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import unittest
import pca9685pw
import smbus
address = 0b1000011 #address pins [1][A5][A4][A3][A2][A1][A0]
frequency = 600 #hertz 64 recomended for Servos
class TestPCM(unittest.TestCase):
def test_smbus(self):
pwm = pca9685pw.Pca9685pw()
self.assertIsInstance(pwm, pca9685pw.Pca9685pw)
self.assertTrue(pwm.defaultBus == 0)
self.assertIsInstance(pwm.bus, smbus.SMBus)
def test_address(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
self.assertTrue(pwm.defaultAddress == address)
def test_reset(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.reset()
def test_setFrequency(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
def test_setTimes(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setTimes(0,000,4030)
pwm.setTimes(1,4000,4030)
pwm.setTimes(2,000,4030)
def test_getTimes(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.getTimes(0)
pwm.getTimes(1)
pwm.getTimes(2)
def test_setPercent(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setPercent(0,99)
pwm.setPercent(1,99)
pwm.setPercent(2,99)
def test_setColourRed(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,255,0,0)
def test_setColourGreen(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,0,255,0)
def test_setColourBlue(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,0,0,255)
def test_setColourPurple(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,217,27,224)
def test_setColourYellow(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,232,225,19)
def test_setColourCyan(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,19,232,221)
def test_setColourDimCyan(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,9,115,110)
def test_fadePurpleToCyan(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,217,27,224)
pwm.fadeToColour(0,19,232,221)
def test_fadeRainbow(self):
pwm = pca9685pw.Pca9685pw()
pwm.defaultAddress = address
pwm.setFrequency(frequency)
pwm.reset()
pwm.setColour(0,255,0,0)
pwm.fadeToColour(0,255,128,0)
pwm.fadeToColour(0,246,255,0)
pwm.fadeToColour(0,0,255,0)
pwm.fadeToColour(0,0,0,255)
pwm.fadeToColour(0,140,0,255)
if __name__ == '__main__':
unittest.main()