@@ -276,29 +276,32 @@ def read_repeat(self):
276
276
self .H .__sendByte__ (CP .I2C_READ_MORE )
277
277
val = self .H .__getByte__ ()
278
278
self .H .__get_ack__ ()
279
+ return val
279
280
except Exception as ex :
280
281
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
281
- return val
282
+
282
283
283
284
def read_end (self ):
284
285
try :
285
286
self .H .__sendByte__ (CP .I2C_HEADER )
286
287
self .H .__sendByte__ (CP .I2C_READ_END )
287
288
val = self .H .__getByte__ ()
288
289
self .H .__get_ack__ ()
290
+ return val
289
291
except Exception as ex :
290
292
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
291
- return val
293
+
292
294
293
295
def read_status (self ):
294
296
try :
295
297
self .H .__sendByte__ (CP .I2C_HEADER )
296
298
self .H .__sendByte__ (CP .I2C_STATUS )
297
299
val = self .H .__getInt__ ()
298
300
self .H .__get_ack__ ()
301
+ return val
299
302
except Exception as ex :
300
303
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
301
- return val
304
+
302
305
303
306
def readBulk (self , device_address , register_address , bytes_to_read ):
304
307
try :
@@ -626,9 +629,10 @@ def send8(self, value):
626
629
self .H .__sendByte__ (value ) # value byte
627
630
v = self .H .__getByte__ ()
628
631
self .H .__get_ack__ ()
632
+ return v
629
633
except Exception as ex :
630
634
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
631
- return v
635
+
632
636
633
637
def send16 (self , value ):
634
638
"""
@@ -651,9 +655,10 @@ def send16(self, value):
651
655
self .H .__sendInt__ (value ) # value byte
652
656
v = self .H .__getInt__ ()
653
657
self .H .__get_ack__ ()
658
+ return v
654
659
except Exception as ex :
655
660
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
656
- return v
661
+
657
662
658
663
def send8_burst (self , value ):
659
664
"""
@@ -762,6 +767,7 @@ def __init__(self, H, vref=3.3, devid=0):
762
767
self .CHANS = {'PCS' : DACCHAN ('PCS' , [0 , 3.3e-3 ], 0 ), 'PV3' : DACCHAN ('PV3' , [0 , 3.3 ], 1 ),
763
768
'PV2' : DACCHAN ('PV2' , [- 3.3 , 3.3 ], 2 ), 'PV1' : DACCHAN ('PV1' , [- 5. , 5. ], 3 )}
764
769
self .CHANNEL_MAP = {0 : 'PCS' , 1 : 'PV3' , 2 : 'PV2' , 3 : 'PV1' }
770
+ self .values = {'PV1' : 0 , 'PV2' : 0 , 'PV3' : 0 , 'PCS' : 0 }
765
771
766
772
def __ignoreCalibration__ (self , name ):
767
773
self .CHANS [name ].calibration_enabled = False
@@ -798,7 +804,8 @@ def __setRawVoltage__(self, name, v):
798
804
'''
799
805
val = self .CHANS [name ].apply_calibration (v )
800
806
self .I2C .writeBulk (self .addr , [64 | (CHAN .channum << 1 ), (val >> 8 ) & 0x0F , val & 0xFF ])
801
- return CHAN .CodeToV (v )
807
+ self .values [name ] = CHAN .CodeToV (v )
808
+ return self .values [name ]
802
809
803
810
def __writeall__ (self , v1 , v2 , v3 , v4 ):
804
811
self .I2C .start (self .addr , 0 )
@@ -871,7 +878,7 @@ class NRF24L01():
871
878
I2C_COMMANDS = 2
872
879
I2C_TRANSACTION = 0 << 4
873
880
I2C_WRITE = 1 << 4
874
- SCAN_I2C = 2 << 4
881
+ I2C_SCAN = 2 << 4
875
882
PULL_SCL_LOW = 3 << 4
876
883
I2C_CONFIG = 4 << 4
877
884
I2C_READ = 5 << 4
@@ -964,9 +971,10 @@ def rxchar(self):
964
971
self .H .__sendByte__ (CP .NRF_RXCHAR )
965
972
value = self .H .__getByte__ ()
966
973
self .H .__get_ack__ ()
974
+ return value
967
975
except Exception as ex :
968
976
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
969
- return value
977
+
970
978
971
979
def txchar (self , char ):
972
980
'''
@@ -989,9 +997,10 @@ def hasData(self):
989
997
self .H .__sendByte__ (CP .NRF_HASDATA )
990
998
value = self .H .__getByte__ ()
991
999
self .H .__get_ack__ ()
1000
+ return value
992
1001
except Exception as ex :
993
1002
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
994
- return value
1003
+
995
1004
996
1005
def flush (self ):
997
1006
'''
@@ -1031,9 +1040,10 @@ def read_register(self, address):
1031
1040
self .H .__sendByte__ (address )
1032
1041
val = self .H .__getByte__ ()
1033
1042
self .H .__get_ack__ ()
1043
+ return val
1034
1044
except Exception as ex :
1035
1045
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
1036
- return val
1046
+
1037
1047
1038
1048
def get_status (self ):
1039
1049
'''
@@ -1070,9 +1080,9 @@ def write_address(self, register, address):
1070
1080
self .H .__sendByte__ (CP .NRFL01 )
1071
1081
self .H .__sendByte__ (CP .NRF_WRITEADDRESS )
1072
1082
self .H .__sendByte__ (register )
1073
- self .H .__sendByte__ (address & 0xFF );
1074
- self .H .__sendByte__ ((address >> 8 ) & 0xFF );
1075
- self .H .__sendByte__ ((address >> 16 ) & 0xFF );
1083
+ self .H .__sendByte__ (address & 0xFF )
1084
+ self .H .__sendByte__ ((address >> 8 ) & 0xFF )
1085
+ self .H .__sendByte__ ((address >> 16 ) & 0xFF )
1076
1086
self .H .__get_ack__ ()
1077
1087
except Exception as ex :
1078
1088
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
@@ -1085,9 +1095,9 @@ def selectAddress(self, address):
1085
1095
try :
1086
1096
self .H .__sendByte__ (CP .NRFL01 )
1087
1097
self .H .__sendByte__ (CP .NRF_WRITEADDRESSES )
1088
- self .H .__sendByte__ (address & 0xFF );
1089
- self .H .__sendByte__ ((address >> 8 ) & 0xFF );
1090
- self .H .__sendByte__ ((address >> 16 ) & 0xFF );
1098
+ self .H .__sendByte__ (address & 0xFF )
1099
+ self .H .__sendByte__ ((address >> 8 ) & 0xFF )
1100
+ self .H .__sendByte__ ((address >> 16 ) & 0xFF )
1091
1101
self .H .__get_ack__ ()
1092
1102
self .CURRENT_ADDRESS = address
1093
1103
if address not in self .sigs :
0 commit comments