# Display Test code use strict; package Plugins::DisplayTest; sub getDisplayName { return 'PLUGIN_DISPLAY_TEST'; } sub strings { return ' PLUGIN_DISPLAY_TEST EN Display Test '}; my %fontSymbols = ( 'notesymbol' => "\x01", 'rightarrow' => "\x02", 'progressEnd' => "\x03", 'progress1e' => "\x04", 'progress2e' => "\x05", 'progress3e' => "\x06", 'progress1' => "\x07", 'progress2' => "\x08", 'progress3' => "\x09", 'cursor' => "\x0a", 'mixable' => "\x0b", 'circle' => "\x0c", 'filledcircle'=> "\x0d", 'square' => "\x0e", 'filledsquare'=> "\x0f", 'bell' => "\x10", 'hardspace' => "\x20" ); sub symbols { # hash can't use $client->symbols my $line = shift; return $fontSymbols{$line} if exists $fontSymbols{$line}; } my $current = 1; # current display node # Define a menu structure so that push and bumps can be tested # 'screen' refers hash to display, 'up'/'down'/'left'/'right' the node to move to if that button is pressed my $menu = { # top level menu 1 => { 'screen' => 'm1', 'up' => 111, 'down' => 2, 'left' => undef, 'right' => 11, }, 2 => { 'screen' => 'm2', 'up' => 1, 'down' => 3, 'left' => undef, 'right' => 21, }, 3 => { 'screen' => 'm3', 'up' => 2, 'down' => 4, 'left' => undef, 'right' => 31, }, 4 => { 'screen' => 'm4', 'up' => 2, 'down' => 111, 'left' => undef, 'right' => 41, }, 111 => { 'screen' =>'exit','up' => 3, 'down' => 1, 'left' => 'exit','right' => undef, }, # display hash tests 11 => { 'screen' => 's1', 'up' => 19, 'down' => 12, 'left' => 1, 'right' => undef, }, 12 => { 'screen' => 's2', 'up' => 11, 'down' => 13, 'left' => 1, 'right' => undef, }, 13 => { 'screen' => 's3', 'up' => 12, 'down' => 14, 'left' => 1, 'right' => undef, }, 14 => { 'screen' => 's4', 'up' => 13, 'down' => 15, 'left' => 1, 'right' => undef, }, 15 => { 'screen' => 's5', 'up' => 14, 'down' => 16, 'left' => 1, 'right' => undef, }, 16 => { 'screen' => 's6', 'up' => 15, 'down' => 17, 'left' => 1, 'right' => undef, }, 17 => { 'screen' => 's7', 'up' => 16, 'down' => 18, 'left' => 1, 'right' => undef, }, 18 => { 'screen' => 's8', 'up' => 17, 'down' => 19, 'left' => 1, 'right' => undef, }, 19 => { 'screen' => 's9', 'up' => 18, 'down' => 11, 'left' => 1, 'right' => undef, }, # menu tests for push & bumps 21 => { 'screen' => 'p1', 'up' => undef, 'down' => 22, 'left' => 2, 'right' => undef, }, 22 => { 'screen' => 'p2', 'up' => 21, 'down' => 23, 'left' => 2, 'right' => undef, }, 23 => { 'screen' => 'p3', 'up' => 22, 'down' => undef, 'left' => 2, 'right' => undef, }, 31 => { 'screen' => 'p21','up' => undef, 'down' => 32, 'left' => 3, 'right' => undef, }, 32 => { 'screen' => 'p22','up' => 31, 'down' => 33, 'left' => 3, 'right' => undef, }, 33 => { 'screen' => 'p23','up' => 32, 'down' => undef, 'left' => 3, 'right' => 34, }, 34 => { 'screen' => 's9','up' => undef, 'down' => undef, 'left' => 33, 'right' => undef, }, 41 => { 'screen' => 'p24','up' => undef, 'down' => 42, 'left' => 4, 'right' => undef, }, 42 => { 'screen' => 'p25','up' => 41, 'down' => 43, 'left' => 4, 'right' => undef, }, 43 => { 'screen' => 'p26','up' => 42, 'down' => undef, 'left' => 4, 'right' => undef, }, 0 => { 'screen' => 's0', 'up' => 1, 'down' => 1, 'left' => undef, 'right' => undef, }, }; # Define screens to display for each node in the menu structure # # NB in display hashes below, "symbols()" is used in place of "$client->symbols()" my $screens = { 'm1' => { 'line' => [ 'Display Test', 'New/Old Hash Tests'], 'overlay' => [ undef, symbols('rightarrow') ], 'screen2' => {}, }, 'm2' => { 'line' => [ 'Display Test', '1 Screen Push/Bump Tests'], 'overlay' => [ undef, symbols('rightarrow') ], 'screen2' => {}, }, 'm3' => { 'line' => [ 'Display Test', '2 Screen Push/Bump Tests'], 'overlay' => [ undef, symbols('rightarrow') ], 'screen2' => {}, }, 'm4' => { 'line' => [ 'Display Test', '2 Screen Now Playing Demo'], 'overlay' => [ undef, symbols('rightarrow') ], 'screen2' => {}, }, 'p1' => { 'line' => [ 'Menu Test', 'Menu Item 1'], }, 'p2' => { 'line' => [ 'Menu Test', 'Menu Item 2'], }, 'p3' => { 'line' => [ 'Menu Test', 'Menu Item 3'], }, 'p21' => { 'screen1' => { 'line' => [ 'Menu Test', 'Menu Item 1'], }, 'screen2' => { 'line' => [ 'Menu Screen 2', 'Menu Item 1' ], }, }, 'p22' => { 'screen1' => { 'line' => [ 'Menu Test', 'Menu Item 2'], }, 'screen2' => { 'line' => [ 'Menu Screen 2', 'Menu Item 2' ], }, }, 'p23' => { 'screen1' => { 'line' => [ 'Menu Test', 'Menu Item 3'], }, 'screen2' => { 'line' => [ 'Menu Screen 2', 'Menu Item 3' ], }, }, 'p24' => { 'screen1' => { 'line' => [ 'Now Playing 1/3', '1. Happy Birthday to You'], }, 'screen2' => { 'line' => [ 'Album: The Third Grade Concerts', 'Artist: Twisted Sister' ], }, }, 'p25' => { 'screen1' => { 'line' => [ 'Now Playing 2/3', '2. My Book'], }, 'screen2' => { 'line' => [ 'Album: Choke', 'Artist: Beautiful South' ], }, }, 'p26' => { 'screen1' => { 'line' => [ 'Now Playing 3/3', '5. White Sale'], }, 'screen2' => { 'line' => [ 'Album: Pale Sun Crescent Moon', 'Artist: Cowboy Junkies' ], }, }, 'exit'=> { 'line' => [ 'Display Test', '< to exit' ], }, 's1' => # Old hash, screen 1 only - 2 lines + overlays { 'line1' => 'Old Hash - S1', 'line2' => '2 Line Display', 'overlay1'=> symbols('notesymbol'), 'overlay2'=> symbols('rightarrow'), }, 's2' => # Old hash, screen 1 only - 2 lines centered { 'center1' => 'Old Hash - S1', 'center2' => '2 Line Centered', }, 's3' => # New hash, screen 1 only - 2 lines + overlays { 'line' => [ 'New Hash - S1', '2 Line Display' ], 'overlay' => [ symbols('notesymbol'), symbols('rightarrow') ], }, 's4' => # New hash, screen 1 only - 2 lines centered { 'center' => [ 'New Hash - S1', '2 Line Centered' ], }, 's5' => # New hash, screen 1 only - 3 lines centered - fixed font { 'center' => [ 'New Hash - S1', '3 Line Centered', 'Third Line'], 'fonts' => { 'graphic-320x32' => 'threeline' }, }, 's6' => # New hash, screen 1 only - 3 lines + overlays - fixed font { 'line' => [ 'New Hash - S1', '3 Line Display', 'Third Line'], 'overlay' => [ symbols('notesymbol'), symbols('rightarrow'), symbols('bell') ], 'fonts' => { 'graphic-320x32' => 'threeline' }, }, 's7' => # New hash, screen 2 only - 2 lines + overlays { 'screen2' => { 'line' => [ 'New Hash - S2', '2 Line Display' ], 'overlay' => [ symbols('notesymbol'), symbols('rightarrow') ], }, }, 's8' => # New hash, screen 1 and 2 - 2 lines + overlays { 'line' => [ 'Line 1 - S1', 'Line 2' ], 'fonts' => { 'graphic-320x32' => { 'overlay' => [ 'standard.1' ] }, }, 'screen2' => { 'line' => [ 'New Hash - S2 - x y z ab c Long text which will scroll', '2 Line Display - Long text which could scroll...' ], 'overlay' => [ symbols('notesymbol'), symbols('rightarrow') ], }, }, 's9' => # New hash, screen 2 only - 3 line centered - fixed font { 'screen2' => { 'center' =>[ 'Screen2', '3 Lines Centered', 'Third Line'], 'fonts' => { 'graphic-320x32' => 'threeline' }, }, }, 's0' => # New hash, clear screens { 'screen1' => {}, 'screen2' => {}, }, }; my $sb_screen = { 'screen1' => { 'center' => [ 'Show Briefly Demo', 'Screen 1' ], }, 'screen2' => { 'center' => [ 'Show Briefly Demo', 'Screen 2' ], }, }; our %functions = ( 'left' => sub { my $client = shift; my $button = shift; return if ($button ne 'left'); if ($menu->{$current}->{left} eq 'exit'){ Slim::Buttons::Common::popModeRight($client); } elsif (defined $menu->{$current}->{left}){ $current = $menu->{$current}->{left}; $client->pushRight(); } else { $client->bumpLeft(); } }, 'right' => sub { my $client = shift; my $button = shift; return if ($button ne 'right'); if (defined $menu->{$current}->{right}) { $current = $menu->{$current}->{right}; $client->pushLeft(); } else { $client->bumpRight(); } }, 'down' => sub { my $client = shift; my $button = shift; return if ($button ne 'down'); if (defined $menu->{$current}->{down}) { $current = $menu->{$current}->{down}; $client->pushDown(); } else { $client->bumpDown(); } }, 'up' => sub { my $client = shift; my $button = shift; return if ($button ne 'up'); if (defined $menu->{$current}->{up}) { $current = $menu->{$current}->{up}; $client->pushUp(); } else { $client->bumpUp(); } }, 'numberScroll' => sub { my $client = shift; my $button = shift; my $digit = shift; if ($digit) { $current = $digit + 10; $client->update(); } else { $client->showBriefly($sb_screen, { duration => 5 } ); } }, ); sub getFunctions { return \%functions; } sub setMode { my $client = shift; $client->lines(\&lines); $client->param('screen2', 'displaytest'); } sub lines { my $client = shift; return $screens->{$menu->{$current}->{screen}}; } 1; __END__ # Local Variables: # tab-width:4 # indent-tabs-mode:t # End: