The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Device::Hypnocube - Control a hypnocube

VERSION

version 1.900.400

SYNOPSIS

    my $cube = Device::Hypnocube->new( serial => '/dev/ttyS1' );
    $cube->clear() ;
    $cube->xplane( 0, 'red') ;
    $cube->update() ;

DESCRIPTION

Control the 4x4x4 Hypnocube available from usb.brando.com (http://usb.brando.com/4x4x4-multi-color-led-cube_p01963c35d15.html) see also http://www.hypnocube.com/ I consider the front to be the side with the power and serial connectors 0,0,0 is then at bottom back left

NAME

 Device::Hypnocube

AUTHOR

 kevin mulholland, moodfarm@cpan.org

VERSIONS

 v1.1  2014-03-05  adding in background processing
 v0.4  2013-05-03  use Moo and all that that entails
 v0.3  2011-03-14  open write perms of buffer file
 v0.2  2011-01-26  adding rate limiting
 v0.1  2010-12-31  initial work

Methods

new

Establish a serial connection with the Hypnocube device

Parameters

serial

serial port device, eg /dev/ttyS1

timeout

timeout for serial connection, default 10s

verbose

output extra _debugging information

do_not_init

Do not connect to the hypnocube

ping

 send a ping to the device, let it know that we are still here
 we need to keep doing this to stop it droping into auto display mode
 though in practice it seems like we do not need to do this

login

tell the device we want to use it

logout

tell the device we are finished with it

info

Ask the device for info, also gets version, fetched during login

reset

reset the device

last_error

ask the device for the last error we caused

send_data

send stuff to the device the payload should already be in the right format, ie packed

update

update the display on the cube

flip

flip display buffer

list_colors

show what colors are available

get_color

determine the colors or use a default

clear

clear the display to a block of color

set_buffer

set the buffer from an array of

get_buffer

get the buffer

buffer_offset

calculate the offset into a display buffer for a given pixel returns the offset

pixel

set a pixel in the display to a color if green blue undef then color looks up in colors, if color missing then error returned and nothing set return 0 OK, 1 error

xplane

set one place of the display to be a single color plane should be 0..Y_SIZE, ie 0..3 return 0 OK, 1 error, 2 out of range

yplane

set one place of the display to be a single color plane should be 0..Y_SIZE, ie 0..3 return 0 OK, 1 error, 2 out of range

zplane

set one plane of the display to be a single color plane should be 0..Z_SIZE, ie 0..3 return 0 OK, 1 error, 2 out of range

get_bytes

get the buffer as an arayref of bytes suitable for throwing at the hypnocube

AUTHOR

Kevin Mulholland <moodfarm@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Kevin Mulholland.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.