@@ -486,6 +486,7 @@ def dynamic_payloads(self, enable):
486486 elif isinstance (enable , int ):
487487 self ._dyn_pl = 0x3F & enable
488488 elif isinstance (enable , (list , tuple )):
489+ self ._dyn_pl = self ._reg_read (DYN_PL_LEN )
489490 for i , val in enumerate (enable ):
490491 if i < 6 and val >= 0 : # skip pipe if val is negative
491492 self ._dyn_pl = (self ._dyn_pl & ~ (1 << i )) | (bool (val ) << i )
@@ -501,7 +502,7 @@ def set_dynamic_payloads(self, enable, pipe_number=None):
501502 if pipe_number is None :
502503 self .dynamic_payloads = bool (enable )
503504 elif 0 <= pipe_number <= 5 :
504- self ._dyn_pl &= ~ (1 << pipe_number )
505+ self ._dyn_pl = self . _reg_read ( DYN_PL_LEN ) & ~ (1 << pipe_number )
505506 self .dynamic_payloads = self ._dyn_pl | (bool (enable ) << pipe_number )
506507 else :
507508 raise IndexError ("pipe_number must be in range [0, 5]" )
@@ -541,6 +542,7 @@ def set_payload_length(self, length, pipe_number=None):
541542 def get_payload_length (self , pipe_number = 0 ):
542543 """Returns an `int` describing the current setting of a specified data
543544 pipe's expected static payload length."""
545+ self ._pl_len [pipe_number ] = self ._reg_read (RX_PL_LENG + pipe_number )
544546 return self ._pl_len [pipe_number ]
545547
546548 @property
@@ -602,12 +604,13 @@ def auto_ack(self, enable):
602604 self ._aa = 0x3F & enable
603605 elif isinstance (enable , (list , tuple )):
604606 for i , val in enumerate (enable ):
607+ self ._aa = self ._reg_read (AUTO_ACK )
605608 if i < 6 and val >= 0 : # skip pipe if val is negative
606609 self ._aa = (self ._aa & ~ (1 << i )) | (bool (val ) << i )
607610 else :
608611 raise ValueError ("auto_ack: {} is not a valid input" % enable )
609- if bool (self ._aa & 1 ) != bool (self ._aa & 0x3E ):
610- self ._aa & = 1
612+ if bool (self ._aa & 1 ) != bool (self ._aa & 0x3E ) and self . _aa & 0x3E :
613+ self ._aa | = 1
611614 self ._reg_write (AUTO_ACK , self ._aa )
612615
613616 def set_auto_ack (self , enable , pipe_number = None ):
@@ -616,7 +619,7 @@ def set_auto_ack(self, enable, pipe_number=None):
616619 if pipe_number is None :
617620 self .auto_ack = bool (enable )
618621 elif 0 <= pipe_number <= 5 :
619- self ._aa &= ~ (1 << pipe_number )
622+ self ._aa = self . _reg_read ( AUTO_ACK ) & ~ (1 << pipe_number )
620623 self .auto_ack = self ._aa | (bool (enable ) << pipe_number )
621624 else :
622625 raise IndexError ("pipe_number must be in range [0, 5]" )
@@ -625,6 +628,7 @@ def get_auto_ack(self, pipe_number=0):
625628 """Returns a `bool` describing the automatic acknowledgement feature
626629 setting about a specific data pipe."""
627630 if 0 <= pipe_number <= 5 :
631+ self ._aa = self ._reg_read (AUTO_ACK )
628632 return bool (self ._aa & (1 << pipe_number ))
629633 raise IndexError ("pipe_number must be in range [0, 5]" )
630634
0 commit comments