Skip to content

Commit

Permalink
add setter and getter for Boson external sync mode
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Zenaldin <[email protected]>
  • Loading branch information
Matthew Zenaldin authored and jveitchmichaelis committed Apr 16, 2024
1 parent bfa3da7 commit 4a97211
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/flirpy/camera/boson.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,30 @@ def get_gain_mode(self):

return res

def set_external_sync_mode(self, sync_mode):
"""
Set the external sync mode
FLR_BOSON_EXT_SYNC_DISABLE_MODE = 0
FLR_BOSON_EXT_SYNC_MASTER_MODE = 1
FLR_BOSON_EXT_SYNC_SLAVE_MODE = 2
FLR_BOSON_EXT_SYNC_END = 3
"""
function_id = 0x50098
command = struct.pack(">I", sync_mode)
self._send_packet(function_id, data=command)

def get_external_sync_mode(self):
function_id = 0x50099

res = self._send_packet(function_id)
res = self._decode_packet(res, receive_size=4)

if res is not None and len(res) == 4:
res = struct.unpack(">I", res)[0]

return res

def _decode_packet(self, data, receive_size=0):
"""
Decodes a data packet from the camera.
Expand Down
6 changes: 6 additions & 0 deletions test/test_boson.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,9 @@ def test_ffc_mode_auto():
camera.set_ffc_auto()
mode = camera.get_ffc_mode()
assert mode == flirpy.camera.boson.FLR_BOSON_AUTO_FFC


def test_get_external_sync_mode():
with Boson() as camera:
ext_sync_mode = camera.get_external_sync_mode()
assert ext_sync_mode in [0, 1, 2, 3]

0 comments on commit 4a97211

Please sign in to comment.