@@ -115,7 +115,7 @@ def __init__(self, address=IOE_ADDRESS, motor_gear_ratio=50, init_motors=True, i
115115
116116 def reinit (self ):
117117 try :
118- self .__ioe = SuperIOE (i2c_addr = self .address , perform_reset = True )
118+ self .ioe = SuperIOE (i2c_addr = self .address , perform_reset = True )
119119 except TimeoutError :
120120 raise TimeoutError (NO_IOE_MSG ) from None
121121 except OSError :
@@ -126,20 +126,20 @@ def reinit(self):
126126 self .motors = None
127127 self .encoders = None
128128 if self .__init_motors :
129- self .motors = [Motor (self .__ioe , self .IOE_MOTOR_A_PINS ), Motor (self .__ioe , self .IOE_MOTOR_B_PINS )]
130- self .encoders = [Encoder (self .__ioe , 1 , self .IOE_ENCODER_A_PINS , counts_per_rev = self .__cpr , count_microsteps = True ),
131- Encoder (self .__ioe , 2 , self .IOE_ENCODER_B_PINS , counts_per_rev = self .__cpr , count_microsteps = True )]
129+ self .motors = [Motor (self .ioe , self .IOE_MOTOR_A_PINS ), Motor (self .ioe , self .IOE_MOTOR_B_PINS )]
130+ self .encoders = [Encoder (self .ioe , 1 , self .IOE_ENCODER_A_PINS , counts_per_rev = self .__cpr , count_microsteps = True ),
131+ Encoder (self .ioe , 2 , self .IOE_ENCODER_B_PINS , counts_per_rev = self .__cpr , count_microsteps = True )]
132132
133133 self .servos = None
134134 if self .__init_servos :
135- self .servos = [Servo (self .__ioe , self .IOE_SERVO_PINS [i ]) for i in range (NUM_SERVOS )]
135+ self .servos = [Servo (self .ioe , self .IOE_SERVO_PINS [i ]) for i in range (NUM_SERVOS )]
136136
137- self .__ioe .set_mode (self .IOE_VOLTAGE_SENSE , ADC )
138- self .__ioe .set_mode (self .IOE_CURRENT_SENSES [0 ], ADC )
139- self .__ioe .set_mode (self .IOE_CURRENT_SENSES [1 ], ADC )
137+ self .ioe .set_mode (self .IOE_VOLTAGE_SENSE , ADC )
138+ self .ioe .set_mode (self .IOE_CURRENT_SENSES [0 ], ADC )
139+ self .ioe .set_mode (self .IOE_CURRENT_SENSES [1 ], ADC )
140140
141141 def __del__ (self ):
142- self .__ioe .reset ()
142+ self .ioe .reset ()
143143 GPIO .cleanup ()
144144
145145 def switch_pressed (self ):
@@ -160,13 +160,13 @@ def disable_motors(self):
160160 motor .disable ()
161161
162162 def read_voltage (self ):
163- return (self .__ioe .input (self .IOE_VOLTAGE_SENSE ) * (10 + 3.9 )) / 3.9
163+ return (self .ioe .input (self .IOE_VOLTAGE_SENSE ) * (10 + 3.9 )) / 3.9
164164
165165 def read_motor_current (self , motor ):
166166 if motor < 0 or motor >= NUM_MOTORS :
167167 raise ValueError ("motor out of range. Expected MOTOR_A (0) or MOTOR_B (1)" )
168168
169- return self .__ioe .input (self .IOE_CURRENT_SENSES [motor ]) / self .SHUNT_RESISTOR
169+ return self .ioe .input (self .IOE_CURRENT_SENSES [motor ]) / self .SHUNT_RESISTOR
170170
171171 def mute_audio (self ):
172172 GPIO .output (self .PI_AMP_EN_PIN , False )
@@ -179,18 +179,18 @@ def gpio_pin_mode(self, gpio, mode=None):
179179 raise ValueError ("gpio out of range. Expected GPIO_1 (0), GPIO_2 (1), GPIO_3 (2) or GPIO_4 (3)" )
180180
181181 if mode is None :
182- return self .__ioe .get_mode (self .IOE_GPIO_PINS [gpio ])
182+ return self .ioe .get_mode (self .IOE_GPIO_PINS [gpio ])
183183 else :
184- self .__ioe .set_mode (self .IOE_GPIO_PINS [gpio ], mode )
184+ self .ioe .set_mode (self .IOE_GPIO_PINS [gpio ], mode )
185185
186186 def gpio_pin_value (self , gpio , value = None ):
187187 if gpio < 0 or gpio >= NUM_GPIOS :
188188 raise ValueError ("gpio out of range. Expected GPIO_1 (0), GPIO_2 (1), GPIO_3 (2) or GPIO_4 (3)" )
189189
190190 if value is None :
191- return self .__ioe .input (self .IOE_GPIO_PINS [gpio ])
191+ return self .ioe .input (self .IOE_GPIO_PINS [gpio ])
192192 else :
193- self .__ioe .output (self .IOE_GPIO_PINS [gpio ], value )
193+ self .ioe .output (self .IOE_GPIO_PINS [gpio ], value )
194194
195195 def servo_pin_mode (self , servo , mode = None ):
196196 if self .servos is not None :
@@ -200,9 +200,9 @@ def servo_pin_mode(self, servo, mode=None):
200200 raise ValueError ("servo out of range. Expected SERVO_1 (0), SERVO_2 (1), SERVO_3 (2) or SERVO_4 (3)" )
201201
202202 if mode is None :
203- return self .__ioe .get_mode (self .IOE_SERVO_PINS [servo ])
203+ return self .ioe .get_mode (self .IOE_SERVO_PINS [servo ])
204204 else :
205- self .__ioe .set_mode (self .IOE_SERVO_PINS [servo ], mode )
205+ self .ioe .set_mode (self .IOE_SERVO_PINS [servo ], mode )
206206
207207 def servo_pin_value (self , servo , value = None , load = True , wait_for_load = False ):
208208 if self .servos is not None :
@@ -212,9 +212,9 @@ def servo_pin_value(self, servo, value=None, load=True, wait_for_load=False):
212212 raise ValueError ("servo out of range. Expected SERVO_1 (0), SERVO_2 (1), SERVO_3 (2) or SERVO_4 (3)" )
213213
214214 if value is None :
215- return self .__ioe .input (self .IOE_SERVO_PINS [servo ])
215+ return self .ioe .input (self .IOE_SERVO_PINS [servo ])
216216 else :
217- self .__ioe .output (self .IOE_SERVO_PINS [servo ], value , load = load , wait_for_load = wait_for_load )
217+ self .ioe .output (self .IOE_SERVO_PINS [servo ], value , load = load , wait_for_load = wait_for_load )
218218
219219 def servo_pin_load (self , servo , wait_for_load = True ):
220220 if self .servos is not None :
@@ -223,8 +223,8 @@ def servo_pin_load(self, servo, wait_for_load=True):
223223 if servo < 0 or servo >= NUM_SERVOS :
224224 raise ValueError ("servo out of range. Expected SERVO_1 (0), SERVO_2 (1), SERVO_3 (2) or SERVO_4 (3)" )
225225
226- module = self .__ioe .get_pwm_module (self .IOE_SERVO_PINS [servo ])
227- self .__ioe .pwm_load (module , wait_for_load )
226+ module = self .ioe .get_pwm_module (self .IOE_SERVO_PINS [servo ])
227+ self .ioe .pwm_load (module , wait_for_load )
228228
229229 def servo_pin_frequency (self , servo , frequency , load = True , wait_for_load = True ):
230230 if self .servos is not None :
@@ -233,8 +233,8 @@ def servo_pin_frequency(self, servo, frequency, load=True, wait_for_load=True):
233233 if servo < 0 or servo >= NUM_SERVOS :
234234 raise ValueError ("servo out of range. Expected SERVO_1 (0), SERVO_2 (1), SERVO_3 (2) or SERVO_4 (3)" )
235235
236- module = self .__ioe .get_pwm_module (self .IOE_SERVO_PINS [servo ])
237- self .__ioe .set_pwm_frequency (frequency , module , load = load , wait_for_load = wait_for_load )
236+ module = self .ioe .get_pwm_module (self .IOE_SERVO_PINS [servo ])
237+ self .ioe .set_pwm_frequency (frequency , module , load = load , wait_for_load = wait_for_load )
238238
239239 def encoder_from_gpio_pins (self , channel , gpio_a , gpio_b , direction = NORMAL_DIR , counts_per_rev = ROTARY_CPR , count_microsteps = False ):
240240 if self .encoders is not None :
@@ -252,7 +252,7 @@ def encoder_from_gpio_pins(self, channel, gpio_a, gpio_b, direction=NORMAL_DIR,
252252 if gpio_b < 0 or gpio_b >= NUM_GPIOS :
253253 raise ValueError ("gpio_b out of range. Expected GPIO_1 (0), GPIO_2 (1), GPIO_3 (2) or GPIO_4 (3)" )
254254
255- return Encoder (self .__ioe , channel , (self .IOE_GPIO_PINS [gpio_a ], self .IOE_GPIO_PINS [gpio_b ]), direction = direction , counts_per_rev = counts_per_rev , count_microsteps = count_microsteps )
255+ return Encoder (self .ioe , channel , (self .IOE_GPIO_PINS [gpio_a ], self .IOE_GPIO_PINS [gpio_b ]), direction = direction , counts_per_rev = counts_per_rev , count_microsteps = count_microsteps )
256256
257257 def motor_from_servo_pins (self , servo_p , servo_n , direction = NORMAL_DIR , speed_scale = MotorState .DEFAULT_SPEED_SCALE , zeropoint = MotorState .DEFAULT_ZEROPOINT ,
258258 deadzone = MotorState .DEFAULT_DEADZONE , freq = MotorState .DEFAULT_FREQUENCY , mode = MotorState .DEFAULT_DECAY_MODE ):
@@ -265,29 +265,29 @@ def motor_from_servo_pins(self, servo_p, servo_n, direction=NORMAL_DIR, speed_sc
265265 if servo_n < 0 or servo_n >= NUM_SERVOS :
266266 raise ValueError ("servo_n out of range. Expected SERVO_1 (0), SERVO_2 (1), SERVO_3 (2) or SERVO_4 (3)" )
267267
268- return Motor (self .__ioe , (self .IOE_SERVO_PINS [servo_p ], self .IOE_SERVO_PINS [servo_n ]), direction = direction ,
268+ return Motor (self .ioe , (self .IOE_SERVO_PINS [servo_p ], self .IOE_SERVO_PINS [servo_n ]), direction = direction ,
269269 speed_scale = speed_scale , zeropoint = zeropoint , deadzone = deadzone , freq = freq , mode = mode )
270270
271271 def activate_watchdog (self ):
272- self .__ioe .activate_watchdog ()
272+ self .ioe .activate_watchdog ()
273273
274274 def deactivate_watchdog (self ):
275- self .__ioe .deactivate_watchdog ()
275+ self .ioe .deactivate_watchdog ()
276276
277277 def feed_watchdog (self ):
278- self .__ioe .reset_watchdog_counter ()
278+ self .ioe .reset_watchdog_counter ()
279279
280280 def watchdog_timeout_occurred (self ):
281- return self .__ioe .watchdog_timeout_occurred ()
281+ return self .ioe .watchdog_timeout_occurred ()
282282
283283 def clear_watchdog_timeout (self ):
284- self .__ioe .clear_watchdog_timeout ()
284+ self .ioe .clear_watchdog_timeout ()
285285
286286 def is_watchdog_active (self ):
287- return self .__ioe .is_watchdog_active ()
287+ return self .ioe .is_watchdog_active ()
288288
289289 def set_watchdog_control (self , divider ):
290- self .__ioe .set_watchdog_control (divider )
290+ self .ioe .set_watchdog_control (divider )
291291
292292
293293if __name__ == "__main__" :
0 commit comments