@@ -273,6 +273,7 @@ Visca.compatibility = {
273
273
-- When the first preset is 1, leave it nil (or set to 0).
274
274
-- When the first preset is 0, set the offset to 1.
275
275
-- The preset recalled at the camera is 'preset - <preset_nr_offset>'
276
+ pantilt_pan_bytes = 4 -- The number of bytes used for the pan argument in absolute pan/tilt commands
276
277
}
277
278
278
279
@@ -431,16 +432,32 @@ function Visca.PayloadReply:get_inquiry_data_for(inquiry_payload)
431
432
end
432
433
elseif category == Visca .categories .pan_tilter then
433
434
if inquiry_command == Visca .inquiry_commands .pantilt_position then
434
- data = {
435
- pan = bit .lshift (bit .band (self .arguments [1 ] or 0 , 0x0F ), 12 ) +
436
- bit .lshift (bit .band (self .arguments [2 ] or 0 , 0x0F ), 8 ) +
437
- bit .lshift (bit .band (self .arguments [3 ] or 0 , 0x0F ), 4 ) +
438
- bit .band (self .arguments [4 ] or 0 , 0x0F ),
439
- tilt = bit .lshift (bit .band (self .arguments [5 ] or 0 , 0x0F ), 12 ) +
440
- bit .lshift (bit .band (self .arguments [6 ] or 0 , 0x0F ), 8 ) +
441
- bit .lshift (bit .band (self .arguments [7 ] or 0 , 0x0F ), 4 ) +
442
- bit .band (self .arguments [8 ] or 0 , 0x0F )
443
- }
435
+ if self .argument_cnt == 8 then
436
+ data = {
437
+ pantilt_pan_bytes = 4 ,
438
+ pan = bit .lshift (bit .band (self .arguments [1 ] or 0 , 0x0F ), 12 ) +
439
+ bit .lshift (bit .band (self .arguments [2 ] or 0 , 0x0F ), 8 ) +
440
+ bit .lshift (bit .band (self .arguments [3 ] or 0 , 0x0F ), 4 ) +
441
+ bit .band (self .arguments [4 ] or 0 , 0x0F ),
442
+ tilt = bit .lshift (bit .band (self .arguments [5 ] or 0 , 0x0F ), 12 ) +
443
+ bit .lshift (bit .band (self .arguments [6 ] or 0 , 0x0F ), 8 ) +
444
+ bit .lshift (bit .band (self .arguments [7 ] or 0 , 0x0F ), 4 ) +
445
+ bit .band (self .arguments [8 ] or 0 , 0x0F )
446
+ }
447
+ elseif self .argument_cnt == 9 then
448
+ data = {
449
+ pantilt_pan_bytes = 5 ,
450
+ pan = bit .lshift (bit .band (self .arguments [1 ] or 0 , 0x0F ), 16 ) +
451
+ bit .lshift (bit .band (self .arguments [2 ] or 0 , 0x0F ), 12 ) +
452
+ bit .lshift (bit .band (self .arguments [3 ] or 0 , 0x0F ), 8 ) +
453
+ bit .lshift (bit .band (self .arguments [4 ] or 0 , 0x0F ), 4 ) +
454
+ bit .band (self .arguments [5 ] or 0 , 0x0F ),
455
+ tilt = bit .lshift (bit .band (self .arguments [6 ] or 0 , 0x0F ), 12 ) +
456
+ bit .lshift (bit .band (self .arguments [7 ] or 0 , 0x0F ), 8 ) +
457
+ bit .lshift (bit .band (self .arguments [8 ] or 0 , 0x0F ), 4 ) +
458
+ bit .band (self .arguments [9 ] or 0 , 0x0F )
459
+ }
460
+ end
444
461
end
445
462
end
446
463
@@ -1347,23 +1364,44 @@ function Visca.Connection:Cam_PanTilt_Absolute(speed, pan, tilt)
1347
1364
1348
1365
local msg = Visca .Message .new ()
1349
1366
msg .payload_type = Visca .payload_types .visca_command
1350
- msg .payload = {
1351
- Visca .packet_consts .req_addr_base + bit .band (Visca .default_camera_nr or 1 , 0x0F ),
1352
- Visca .packet_consts .command ,
1353
- Visca .categories .pan_tilter ,
1354
- Visca .commands .pantilt_absolute ,
1355
- speed , -- Pan speed
1356
- speed , -- Tilt speed
1357
- bit .band (bit .rshift (pan , 12 ), 0x0F ),
1358
- bit .band (bit .rshift (pan , 8 ), 0x0F ),
1359
- bit .band (bit .rshift (pan , 4 ), 0x0F ),
1360
- bit .band (pan , 0x0F ),
1361
- bit .band (bit .rshift (tilt , 12 ), 0x0F ),
1362
- bit .band (bit .rshift (tilt , 8 ), 0x0F ),
1363
- bit .band (bit .rshift (tilt , 4 ), 0x0F ),
1364
- bit .band (tilt , 0x0F ),
1365
- Visca .packet_consts .terminator
1366
- }
1367
+ if not self .compatibility .pantilt_pan_bytes or self .compatibility .pantilt_pan_bytes == 4 then
1368
+ msg .payload = {
1369
+ Visca .packet_consts .req_addr_base + bit .band (Visca .default_camera_nr or 1 , 0x0F ),
1370
+ Visca .packet_consts .command ,
1371
+ Visca .categories .pan_tilter ,
1372
+ Visca .commands .pantilt_absolute ,
1373
+ speed , -- Pan speed
1374
+ speed , -- Tilt speed
1375
+ bit .band (bit .rshift (pan , 12 ), 0x0F ),
1376
+ bit .band (bit .rshift (pan , 8 ), 0x0F ),
1377
+ bit .band (bit .rshift (pan , 4 ), 0x0F ),
1378
+ bit .band (pan , 0x0F ),
1379
+ bit .band (bit .rshift (tilt , 12 ), 0x0F ),
1380
+ bit .band (bit .rshift (tilt , 8 ), 0x0F ),
1381
+ bit .band (bit .rshift (tilt , 4 ), 0x0F ),
1382
+ bit .band (tilt , 0x0F ),
1383
+ Visca .packet_consts .terminator
1384
+ }
1385
+ elseif self .compatibility .pantilt_pan_bytes == 5 then
1386
+ msg .payload = {
1387
+ Visca .packet_consts .req_addr_base + bit .band (Visca .default_camera_nr or 1 , 0x0F ),
1388
+ Visca .packet_consts .command ,
1389
+ Visca .categories .pan_tilter ,
1390
+ Visca .commands .pantilt_absolute ,
1391
+ speed , -- Pan/Tilt speed
1392
+ 00 , -- Fixed
1393
+ bit .band (bit .rshift (pan , 16 ), 0x0F ),
1394
+ bit .band (bit .rshift (pan , 12 ), 0x0F ),
1395
+ bit .band (bit .rshift (pan , 8 ), 0x0F ),
1396
+ bit .band (bit .rshift (pan , 4 ), 0x0F ),
1397
+ bit .band (pan , 0x0F ),
1398
+ bit .band (bit .rshift (tilt , 12 ), 0x0F ),
1399
+ bit .band (bit .rshift (tilt , 8 ), 0x0F ),
1400
+ bit .band (bit .rshift (tilt , 4 ), 0x0F ),
1401
+ bit .band (tilt , 0x0F ),
1402
+ Visca .packet_consts .terminator
1403
+ }
1404
+ end
1367
1405
1368
1406
return self :send (msg )
1369
1407
end
0 commit comments