Skip to content

Commit cf5c472

Browse files
committed
upgraded to evm_2.2.4 v2
1 parent 4896658 commit cf5c472

11 files changed

Lines changed: 864 additions & 822 deletions

tmf8829/examples/example_logger_all_pre_configurations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use_histograms = 0
2929
use_iterations = 2000
3030

31-
results3dcorrected = True
31+
results3dcorrected = False
3232
resultsInXYZ = True
3333
###################################################################################
3434
## Example for the Tmf8829Logger

tmf8829/examples/example_logger_dual_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use_histograms = 1
2929
use_iterations = 500
3030

31-
results3dcorrected = True
31+
results3dcorrected = False
3232
resultsInXYZ = True
3333
###################################################################################
3434
## Example for the Tmf8829Logger

tmf8829/hex/tmf8829_application.hex

Lines changed: 820 additions & 786 deletions
Large diffs are not rendered by default.

tmf8829/tmf8829_application.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
from aos_com.hal_register_io import HalRegisterIo
1717
from register_page_converter import RegisterPageConverter
1818

19+
# additional interrupt bits
20+
TMF8829_INT_MOTION = 0x02 # motion interrupt bit
21+
TMF8829_INT_PROXIMITY = 0x04 # proximity interrupt bit
1922

2023
class Tmf8829Application(Tmf8829Bootloader, Tmf8829AppCommon):
2124
"""The TMF8829 application class for the Shield Evm Board.
2225
"""
2326

24-
VERSION = 1.10
27+
VERSION = 1.12
2528
"""Version log
2629
- 1.0 First version
2730
- 1.1 add FP mode 48x32
@@ -35,6 +38,7 @@ class Tmf8829Application(Tmf8829Bootloader, Tmf8829AppCommon):
3538
- 1.9 added info parameter readout
3639
- 1.10 added support for dual mode
3740
- 1.11 splitted up tmf8829_application to tmf8829_application_common and tmf8829_application
41+
- 1.12 support for motion detection and proximity
3842
"""
3943

4044
def __init__(self, hal:HalRegisterIo, gpio_hal:HalRegisterIo=None ):
@@ -191,7 +195,7 @@ def configure(self, period:int = None, iterations:int = None, fp_mode:int = None
191195
spr_spec_single_edge:int=None,spr_spec_cfg:int=None,spr_spec_amp:int=None, add_100_mm_offset:int=None,
192196
mp_top_x:int=None, mp_top_y:int=None, mp_bottom_x:int=None, mp_bottom_y:int=None, ref_mp:int=None ,
193197
motion_distance:int=None, detect_snr:int=None, release_snr:int=None, motion_adjacent:int=None,
194-
dual_mode:int=None, high_accuracy_iterations:int=None ):
198+
dual_mode:int=None, high_accuracy_iterations:int=None, prox_distance:int=None ):
195199
"""Function to reconfigure the device.
196200
The config page is loaded with the CMD_LOAD_CONFIG_PAGE command.
197201
The config registers are modified and the new config page is written with the CMD_WRITE_PAGE command.
@@ -275,6 +279,7 @@ def configure(self, period:int = None, iterations:int = None, fp_mode:int = None
275279
motion_adjacent(int,optional):number of adjacent pixel that must have motion to report it. defaults to None.
276280
dual_mode(int,optional): set to 1 to automatically do dual integration, defaults to None.
277281
high_accuracy_iterations(int,optional): 16-bit unsigned integer, short range kilo iterations, defaults to None.
282+
prox_distance(int,optional): 8-bit unsigned integer, proximity detection distance in mm, defaults to None
278283
"""
279284
self.sendCommand( Tmf8829AppRegs.TMF8829_CMD_STAT._cmd_stat._CMD_LOAD_CONFIG_PAGE )
280285
if (period != None):
@@ -494,6 +499,8 @@ def configure(self, period:int = None, iterations:int = None, fp_mode:int = None
494499
if (dual_mode != None):
495500
self.hal.tx( Tmf8829ConfigRegs.TMF8829_CFG_ENABLE_DUAL_MODE.addr, dual_mode )
496501
self.cfg_dualMode = dual_mode
502+
if (prox_distance != None):
503+
self.hal.tx( Tmf8829ConfigRegs.TMF8829_CFG_PROX_DISTANCE.addr, prox_distance )
497504

498505
self.sendCommand( Tmf8829AppRegs.TMF8829_CMD_STAT._cmd_stat._CMD_WRITE_PAGE )
499506

tmf8829/tmf8829_application_common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ def getFullPixelResult(frames, toMM = False, deleteNone = True, pointCloud = Fal
396396
frames: list[bytearray] the result frames in the right order as received by the device.
397397
toMM: Changes the distance results from 0.25mm to mm. Note do not use this option if the results are in bins
398398
deleteNone: Remove None items from MP Results.
399-
pointCloud: do point cloud correction
400-
distanceToXYZ: only for pointCloud correction, reports instead of a distance the xyz values
399+
pointCloud: do point cloud correction, only done if distanceToXYZ = False
400+
distanceToXYZ: reports distance the xyz values, if this option is used, the distance will not be point cloud corrected.
401401
Returns:
402402
List[row][col] tmf8829MPResult structures
403403
"""
@@ -417,7 +417,7 @@ def getFullPixelResult(frames, toMM = False, deleteNone = True, pointCloud = Fal
417417
if deleteNone:
418418
pixelResults = Tmf8829AppCommon.pixelResultsDeleteNoneParam(pixelResults)
419419

420-
if pointCloud == True:
420+
if (pointCloud == True) or (distanceToXYZ == True):
421421
Tmf8829AppCommon.pixelResults3dPointcloudCorr(pixelResults, fpMode, reportXYZ= distanceToXYZ)
422422

423423
return pixelResults
@@ -467,7 +467,7 @@ def pixelResults3dPointcloudCorr(pixelResults, fp_mode, reportXYZ=False):
467467
if peak['distance'] != None:
468468
if reportXYZ:
469469
distanceCorr = peak['distance'] / zCorrSimple
470-
peak.pop("distance")
470+
# peak.pop("distance") do not remove distance
471471
peak['x']= round(distanceCorr*x_dist)
472472
peak['y']= round(distanceCorr*y_dist)
473473
peak['z']= round(distanceCorr)

tmf8829/tmf8829_application_registers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# * *
55
# *FOR FULL LICENSE TEXT SEE LICENSES-MIT.TXT *
66
# *****************************************************************************
7-
87
import ctypes
98

109
class Tmf8829_application_registers:

tmf8829/tmf8829_bootloader.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def enable(self, send_wake_up_sequence:bool = True) -> bool:
7878
self.gpio_hal.com.gpioSet(w_mask=self.gpio_hal.com.enable_pin, value=self.gpio_hal.com.enable_pin)
7979
time.sleep(0.003) # wait for 3 milliseconds until the device comes up.
8080
if send_wake_up_sequence:
81-
return self.powerUp()
81+
return self.wakeUp(powerup_select=Tmf8829HostRegs.ENABLE._powerup_select._FORCE_BOOTMONITOR) #force boot monitor
8282
return True
8383
return False
8484

@@ -112,28 +112,19 @@ def forceBootmonitor(self):
112112
self.io.regWrite( self.reg.ENABLE, powerup_select=1, pon=1 ) # make sure device is powered
113113
self.reset()
114114

115-
def powerUp(self) -> bool:
116-
"""Power up the TMF8829"""
117-
self.io.regWrite( self.reg.ENABLE, pon=1 ) # request a power up = wakeup
118-
time.sleep(0.003) # wait for 3 milliseconds until the device comes up.
119-
self.io.regRead( self.reg.ENABLE ) # read back
120-
if self.reg.ENABLE.cpu_ready:
121-
return True
122-
return False
123-
124-
def wakeUp(self) -> bool:
115+
def wakeUp(self, powerup_select = Tmf8829HostRegs.ENABLE._powerup_select._RAM) -> bool:
125116
"""wakeup up the TMF8829"""
126-
self.io.regWrite( self.reg.ENABLE, pon=1, powerup_select = 2 ) # request a power up = wakeup
117+
self.io.regWrite( self.reg.ENABLE, pon=1, powerup_select = powerup_select ) # request a power up = wakeup
127118
time.sleep(0.003) # wait for 3 milliseconds until the device comes up.
128119
self.io.regRead( self.reg.ENABLE ) # read back
129120
if self.reg.ENABLE.cpu_ready:
130121
return True
131122
return False
132123

133-
def powerDown(self) -> bool:
124+
def gotoStandby(self) -> bool:
134125
"""Power down the TMF8829"""
135126
if self.isDeviceWakeup():
136-
self.io.regWrite( self.reg.ENABLE, poff=1) # request power down
127+
self.io.regWrite( self.reg.ENABLE, poff=1) # request standby
137128
time.sleep(0.003) # wait for xx milliseconds until the device powers down
138129
self.io.regRead( self.reg.ENABLE ) # read again from HW to see new state
139130
if self.reg.ENABLE.cpu_ready == 0 and ( self.reg.ENABLE.standby_mode == 1 or self.reg.ENABLE.timed_standby_mode == 1 ):

tmf8829/tmf8829_config_page.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,11 +1062,26 @@ class _post_processing:
10621062
mask = 255
10631063
width = 8
10641064
shift = 0
1065-
_PERSISTENCE = 0 # persistence algorithm enabled
1066-
_MOTION = 1 # motion detection, (also int_persistence must be set to >=1 in field TMF8829_CFG_INT_PERSISTENCE)
1065+
_PERSISTENCE = 0 # persistence algorithm enabled, Persistence Interrupt is bit 1
1066+
_MOTION = 1 # motion detection, Motion Interrupt is bit 1, (also int_persistence must be set to >=1 in field TMF8829_CFG_INT_PERSISTENCE),
1067+
_MOTION_ALWAYS_RESULTS = 2 # same as motion detection but result frames are always published, Motion Interrupt is bit 1, (also int_persistence must be set to >=1 in field TMF8829_CFG_INT_PERSISTENCE)
10671068
def __init__(self):
10681069
self.post_processing = self._post_processing.reset
10691070

1071+
class TMF8829_CFG_PROX_DISTANCE(ctypes.LittleEndianStructure):
1072+
addr = 0x6e
1073+
_pack_ = 1
1074+
_fields_ = [
1075+
("prox_distance",ctypes.c_uint8,8),
1076+
]
1077+
class _prox_distance:
1078+
reset = 0
1079+
mask = 255
1080+
width = 8
1081+
shift = 0
1082+
def __init__(self):
1083+
self.prox_distance = self._prox_distance.reset
1084+
10701085
class TMF8829_CFG_CROP_TOP_X(ctypes.LittleEndianStructure):
10711086
addr = 0x70
10721087
_pack_ = 1
@@ -1556,6 +1571,7 @@ def __init__(self):
15561571
self.TMF8829_CFG_INT_THRESHOLD_HIGH_MSB = Tmf8829_config_page.TMF8829_CFG_INT_THRESHOLD_HIGH_MSB()
15571572
self.TMF8829_CFG_INT_PERSISTENCE = Tmf8829_config_page.TMF8829_CFG_INT_PERSISTENCE()
15581573
self.TMF8829_CFG_POST_PROCESSING = Tmf8829_config_page.TMF8829_CFG_POST_PROCESSING()
1574+
self.TMF8829_CFG_PROX_DISTANCE = Tmf8829_config_page.TMF8829_CFG_PROX_DISTANCE()
15591575
self.TMF8829_CFG_CROP_TOP_X = Tmf8829_config_page.TMF8829_CFG_CROP_TOP_X()
15601576
self.TMF8829_CFG_CROP_TOP_Y = Tmf8829_config_page.TMF8829_CFG_CROP_TOP_Y()
15611577
self.TMF8829_CFG_CROP_BOTTOM_X = Tmf8829_config_page.TMF8829_CFG_CROP_BOTTOM_X()

tmf8829/zeromq/cfg_client.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@
44
"period": 33,
55
"iterations": 600
66
},
7-
"logging": {
8-
"3d_correction": true
9-
},
107
"record_frames":3
118
}

tmf8829/zeromq/tmf8829_host_com_reg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Union(ctypes.Union, AsDictMixin):
134134
TMF8829_ZEROMQ_HOST_H5_BOARD = 4 # macro
135135
TMF8829_ZEROMQ_HEADER_INFO_SIZE = 64 # macro
136136
TMF8829_ZEROMQ_IDENTIFY_INFO_SIZE = 56 # macro
137-
EVM_VERSION = "2.2.3 " # macro
137+
EVM_VERSION = "2.2.4 " # macro
138138
class struct__tmf8829ZmqDeviceInfo(Structure):
139139
pass
140140

0 commit comments

Comments
 (0)