HID::LoupedeckCT - Perl driver for the Loupedeck CT keyboard
use feature 'say';
my $ld = HID::LoupedeckCT->new();
say "Connecting to " . $ld->uri;
$ld->connect()->get;
$ld->on('turn' => sub($ld,$info) {
my $knob = $info->{id};
my $direction = $info->{direction};
# ...
});
The (websocket) URI where the Loupedeck device can be contacted. If not given, this is autodetected.
The Mojo::UserAgent used for talking to the Loupedeck CT.
The Websocket transaction used for talking.
my @ipv4_addresses = HID::LoupedecCT->list_loupedeck_devices;
This method lists potential candidates for USB connected Loupedeck CT
devices. It returns them as ws://
URIs for (USB) network connections
and as raw path names for (USB) serial connections.
$ld->send_command( 0x0409, "\03" )->then(sub {
say "Set backlight level to 3.";
});
Sends a command and returns a Future that will be fulfilled with the reply from the device.
Helper to dump bytes sent or received to STDOUT.
Helper to return a button number from X/Y touch coordinates
my( $screen, $x,$y,$w,$h ) = $ld->button_rect(6);
Helper to return rectangle coordinates from a button number
$ld->connect->then(sub {
say "Connected to Loupedeck";
});
$ld->disconnect->get;
Disconnects gracefully from the Loupedeck.
$ld->read_register(2)->then(sub {
my ($info,$data) = @_;
say $info->{register};
say $info->{value};
});
Reads the value of a persistent register.
These registers are mostly used to store configuration values on the device.
$ld->set_register(2,0x12345678)->retain;
Sets the value of a persistent 32-bit register.
These registers are mostly used to store configuration values on the device.
$ld->get_backlight_level->then(sub {
my( $level ) = @_;
});
Reads the value of the backlight level stored in the device.
This level can deviate from the actual level.
$ld->set_backlight_level(9)->retain;
Sets the value of the backlight level and optionally stores in the device for persistence across machines/power loss.
The level ranges from 0 (off) to 9 (bright).
If you pass in the persist
option, the backlight level stored in the
permanent register 2 will be updated.
$ld->set_backlight_level(9, persist => 1)->retain;
$ld->restore_backlight_level->retain;
Restores the value of the backlight level to the level stored on the device.
Use this method at the startup of your program.
$ld->vibrate()->retain; # default
$ld->vibrate(10); # do-de
Vibrates the Loupedeck CT in the given pattern.
$ld->set_flashdrive(1);
Enables or disables the built-in flash drive
You need to unplug and replug the device to get the flash drive recognized by your system.
$ld->reset
Resets/restarts the Loupedeck device
$ld->redraw_screen->retain;
This updates the screen after paint operations.
$ld->set_button_color(10, 127,255,127)->retain;
Sets the backlight colour for a physical button. The button values are 7 to 14 for the round buttons and 15 to 26 for the square buttons.
$ld->load_image_button(
button => 1,
file => 'logo.jpg',
refresh => 1,
)->get;
$ld->load_image_button(
button => 1,
string => "\N{DROMEDARY CAMEL}",
refresh => 1,
bgcolor => [30,30,60],
)->get;
Loads one of the touchscreen buttons with an image file or string.
https://github.com/bitfocus/loupedeck-ct/blob/master/index.js
https://github.com/CommandPost/CommandPost/blob/develop/src/extensions/hs/loupedeck/init.lua