Skip to content

Corion/HID-LoupedeckCT

Repository files navigation

Travis Build Status AppVeyor Build Status

NAME

HID::LoupedeckCT - Perl driver for the Loupedeck CT keyboard

SYNOPSIS

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};

    # ...
});

ACCESSORS

uri

The (websocket) URI where the Loupedeck device can be contacted. If not given, this is autodetected.

ua

The Mojo::UserAgent used for talking to the Loupedeck CT.

tx

The Websocket transaction used for talking.

METHODS

HID::LoupedecCT->list_loupedeck_devices

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.

->send_command $command, $payload

$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.

->hexdump $prefix, $string

Helper to dump bytes sent or received to STDOUT.

->button_from_xy

Helper to return a button number from X/Y touch coordinates

->button_rect $button

my( $screen, $x,$y,$w,$h ) = $ld->button_rect(6);

Helper to return rectangle coordinates from a button number

->connect $uri

$ld->connect->then(sub {
    say "Connected to Loupedeck";
});

->disconnect

$ld->disconnect->get;

Disconnects gracefully from the Loupedeck.

->read_register $register

$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.

->read_register $register

$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.

->get_backlight_level

$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.

->set_backlight_level $level, %options

$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;

->restore_backlight_level

$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.

->vibrate $pattern

$ld->vibrate()->retain; # default
$ld->vibrate(10);       # do-de

Vibrates the Loupedeck CT in the given pattern.

->set_flashdrive $enable

$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.

->reset

$ld->reset

Resets/restarts the Loupedeck device

->redraw_screen

$ld->redraw_screen->retain;

This updates the screen after paint operations.

->set_button_color $button, $r, $g, $b

$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.

->load_image

->load_image_button

$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.

SEE ALSO

https://github.com/bitfocus/loupedeck-ct/blob/master/index.js

https://github.com/CommandPost/CommandPost/blob/develop/src/extensions/hs/loupedeck/init.lua

About

Perl driver for the Loupedeck CT keyboard

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages