@@ -100,6 +100,72 @@ tests:
100100 expect_true : true
101101 mode : [hardware]
102102
103+ - name : " Get accel offset returns defaults"
104+ action : script
105+ script : |
106+ ox, oy, oz = dev.get_accel_offset()
107+ result = ox == 0.0 and oy == 0.0 and oz == 0.0
108+ expect_true : true
109+ mode : [mock]
110+
111+ - name : " Set accel offset updates stored values"
112+ action : script
113+ script : |
114+ dev.set_accel_offset(0.01, -0.02, 0.03)
115+ ox, oy, oz = dev.get_accel_offset()
116+ result = ox == 0.01 and oy == -0.02 and oz == 0.03
117+ expect_true : true
118+ mode : [mock]
119+
120+ - name : " Acceleration g applies accel offsets"
121+ action : script
122+ script : |
123+ dev.set_accel_offset(0.1, -0.2, 0.3)
124+ ax, ay, az = dev.acceleration_g()
125+ result = (
126+ abs(ax - (-0.1)) < 0.01
127+ and abs(ay - 0.2) < 0.01
128+ and abs(az - 0.7) < 0.01
129+ )
130+ expect_true : true
131+ mode : [mock]
132+
133+ - name : " Acceleration ms2 applies accel offsets"
134+ action : script
135+ script : |
136+ dev.set_accel_offset(0.1, 0.0, 0.0)
137+ ax, ay, az = dev.acceleration_ms2()
138+ result = abs(ax - (-0.1 * 9.80665)) < 0.02
139+ expect_true : true
140+ mode : [mock]
141+
142+ - name : " Orientation changes with accel offset"
143+ action : script
144+ script : |
145+ dev.set_accel_offset(0.0, 0.0, 2.0)
146+ result = dev.orientation() == "SCREEN_UP"
147+ expect_true : true
148+ mode : [mock]
149+
150+ - name : " Set and get accel offset on hardware"
151+ action : script
152+ script : |
153+ dev.set_accel_offset(0.01, -0.02, 0.03)
154+ ox, oy, oz = dev.get_accel_offset()
155+ result = ox == 0.01 and oy == -0.02 and oz == 0.03
156+ expect_true : true
157+ mode : [hardware]
158+
159+ - name : " Accel offset affects hardware readings"
160+ action : script
161+ script : |
162+ ax1, ay1, az1 = dev.acceleration_g()
163+ dev.set_accel_offset(0.1, 0.0, 0.0)
164+ ax2, ay2, az2 = dev.acceleration_g()
165+ result = abs((ax1 - ax2) - 0.1) < 0.05
166+ expect_true : true
167+ mode : [hardware]
168+
103169 # ----- Gyroscope -----
104170
105171 - name : " Gyroscope raw returns tuple of 3 ints"
0 commit comments