File tree Expand file tree Collapse file tree
src/HL/actionneur_capteur Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,18 +21,19 @@ def __init__(self,serveur):
2121 self .bus = smbus .SMBus (1 ) # 1 indicates /dev/i2c-1
2222 self .log .info ("I2C: bus ouvert sur /dev/i2c-1" )
2323
24- time . sleep ( 0.5 ) # Give some time for the bus to settle
24+
2525
2626 #initialization of i2c send and received
2727 threading .Thread (target = self .start_send , daemon = True ).start ()
2828 threading .Thread (target = self .start_received , daemon = True ).start ()
2929
3030 def start_send (self ):
3131 """Envoie vitesse/direction régulièrement au microcontroleur. (toute les frames actuellement)"""
32+ time .sleep (1 ) # Give some time for the target_speed and direction to be set
3233 self .log .info ("Thread I2C loop démarré" )
3334 while self .send_running :
3435 try :
35- data = struct .pack ('<ff' , float (round ( self .serveur .target_speed )) , float (round ( self .serveur .direction ) ))
36+ data = struct .pack ('<ff' , float (self .serveur .target_speed ), float (self .serveur .direction ))
3637 self .bus .write_i2c_block_data (SLAVE_ADDRESS , 0 , list (data ))
3738 time .sleep (1e-5 ) # Short delay to prevent overwhelming the bus
3839 except Exception as e :
You can’t perform that action at this time.
0 commit comments