123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- package Plugins::SqueezeESP32::Graphics;
- use strict;
- use base qw(Slim::Display::Squeezebox2);
- use Slim::Utils::Prefs;
- use Slim::Utils::Log;
- my $prefs = preferences('plugin.squeezeesp32');
- my $log = logger('plugin.squeezeesp32');
- my $VISUALIZER_NONE = 0;
- my $VISUALIZER_VUMETER = 1;
- my $VISUALIZER_SPECTRUM_ANALYZER = 2;
- my $VISUALIZER_WAVEFORM = 3;
- {
-
- __PACKAGE__->mk_accessor('rw', 'modes');
- __PACKAGE__->mk_accessor('rw', qw(vfdmodel));
- }
- sub new {
- my $class = shift;
- my $client = shift;
-
- my $display = $class->SUPER::new($client);
- my $cprefs = $prefs->client($client);
-
- $cprefs->init( {
- width => 128,
- small_VU => 15,
- spectrum => { scale => 25,
- small => { size => 25, band => 5.33 },
- full => { band => 8 },
- },
- }
- );
-
- $display->init_accessor(
- modes => $display->build_modes,
- vfdmodel => 'graphic-<width>x32',
- );
-
- return $display;
- }
- =comment
- sub modes {
- return \@modes;
- }
- =cut
- sub nmodes {
- return scalar($
- }
- sub displayWidth {
- my $display = shift;
- my $client = $display->client;
-
-
-
-
- my $mode = 0;
-
- if ( $display->showVisualizer() && !defined($client->modeParam('visu')) ) {
- my $cprefs = preferences('server')->client($client);
- $mode = $cprefs->get('playingDisplayModes')->[ $cprefs->get('playingDisplayMode') ];
- }
-
- if ($display->widthOverride) {
- return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
- } else {
- return $display->modes->[$mode || 0]{width};
- }
- }
- sub brightnessMap {
- return (65535, 10, 50, 100, 200);
- }
- =comment
- sub bytesPerColumn {
- return 4;
- }
- =cut
- sub displayHeight {
- return 32;
- }
- sub build_modes {
- my $client = shift->client;
- my $cprefs = $prefs->client($client);
-
- my $width = shift || $cprefs->get('width') || 128;
- my $small_VU = $cprefs->get('small_VU');
- my $spectrum = $cprefs->get('spectrum');
-
- my @modes = (
-
- { desc => ['BLANK'],
- bar => 0, secs => 0, width => $width,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['PROGRESS_BAR'],
- bar => 1, secs => 0, width => $width,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['ELAPSED'],
- bar => 0, secs => 1, width => $width,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['ELAPSED', 'AND', 'PROGRESS_BAR'],
- bar => 1, secs => 1, width => $width,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['REMAINING'],
- bar => 0, secs => -1, width => $width,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['CLOCK'],
- bar => 0, secs => 0, width => $width, clock => 1,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['SETUP_SHOWBUFFERFULLNESS'],
- bar => 0, secs => 0, width => $width, fullness => 1,
- params => [$VISUALIZER_NONE] },
-
- { desc => ['VISUALIZER_VUMETER_SMALL'],
- bar => 0, secs => 0, width => $width, _width => int -($small_VU*$width/100),
-
- params => [$VISUALIZER_VUMETER, int ($small_VU*$width/100), 32, int -($small_VU*$width/100), 0, 2] },
-
- { desc => ['VISUALIZER_SPECTRUM_ANALYZER_SMALL'],
- bar => 0, secs => 0, width => $width, _width => int -($spectrum->{small}->{size}*$width/100),
-
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($spectrum->{small}->{size}*$width/100), 32, int -($spectrum->{small}->{size}*$width/100), 0, 2, int ($spectrum->{small}->{size}/100*$width/$spectrum->{small}->{band}), $spectrum->{scale}] },
-
- { desc => ['VISUALIZER_VUMETER'],
- bar => 0, secs => 0, width => $width,
- params => [$VISUALIZER_VUMETER] },
-
- { desc => ['VISUALIZER_SPECTRUM_ANALYZER'],
- bar => 0, secs => 0, width => $width,
-
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
-
- { desc => ['VISUALIZER_VUMETER', 'AND', 'ELAPSED'],
- bar => 0, secs => 1, width => $width,
- params => [$VISUALIZER_VUMETER] },
-
- { desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'ELAPSED'],
- bar => 0, secs => 1, width => $width,
-
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
-
- { desc => ['VISUALIZER_VUMETER', 'AND', 'REMAINING'],
- bar => 0, secs => -1, width => $width,
- params => [$VISUALIZER_VUMETER] },
-
- { desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'REMAINING'],
- bar => 0, secs => -1, width => $width,
-
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
- );
-
- return \@modes;
- }
- 1;
|