mirror make branch changes on plugin (need to point there ...)

This commit is contained in:
Philippe G
2020-12-02 14:06:49 -08:00
parent 3dc2ed9629
commit 99019cd22f
6 changed files with 78 additions and 30 deletions

View File

@@ -17,6 +17,17 @@ my $VISUALIZER_WAVEFORM = 3;
my $VISUALIZER_VUMETER_ESP32 = 0x11;
my $VISUALIZER_SPECTRUM_ANALYZER_ESP32 = 0x12;
my %SPECTRUM_DEFAULTS = (
scale => 25,
small => {
size => 25,
band => 5.33
},
full => {
band => 8
},
);
{
#__PACKAGE__->mk_accessor('array', 'modes');
__PACKAGE__->mk_accessor('rw', 'modes');
@@ -33,14 +44,16 @@ sub new {
$cprefs->init( {
width => 128,
small_VU => 15,
spectrum => { scale => 25,
small => { size => 25, band => 5.33 },
full => { band => 8 },
},
}
);
$display->init_accessor(
spectrum => \%SPECTRUM_DEFAULTS,
} );
$prefs->migrateClient(2, sub {
my ($cprefs, $client) = @_;
sanitizeSpectrum($cprefs->get('spectrum'));
1;
});
$display->init_accessor(
modes => $display->build_modes,
# Only seems to matter for screensaver and update to decide font. Not
# any value is acceptable, so use Boom value which seems to be best
@@ -106,6 +119,16 @@ sub displayHeight {
return 32;
}
sub sanitizeSpectrum {
my ($spectrum) = shift;
$spectrum->{small}->{size} ||= $SPECTRUM_DEFAULTS{small}->{size};
$spectrum->{small}->{band} ||= $SPECTRUM_DEFAULTS{small}->{band};
$spectrum->{full}->{band} ||= $SPECTRUM_DEFAULTS{full}->{band};
return $spectrum;
}
sub build_modes {
my $client = shift->client;
my $cprefs = $prefs->client($client);
@@ -118,9 +141,9 @@ sub build_modes {
my $width_low = ($artwork->{'enable'} && $artwork->{'x'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width;
my $small_VU = $cprefs->get('small_VU');
my $spectrum = $cprefs->get('spectrum');
my $small_spectrum_pos = { x => $width - int ($spectrum->{small}->{size} * $width / 100),
my $spectrum = sanitizeSpectrum($cprefs->get('sprectrum'));
my $small_spectrum_pos = { x => $width - int ($spectrum->{small}->{size} * $width / 100),
width => int ($spectrum->{small}->{size} * $width / 100),
};
my $small_VU_pos = { x => $width - int ($small_VU * $width / 100),
@@ -224,7 +247,7 @@ my @extra = (
);
@modes = (@modes, @extra) if $cprefs->get('height') > 32;
return \@modes;
}