diff options
author | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-09-08 14:40:10 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-09-08 14:40:10 -0400 |
commit | 64f73905537e4b1d083afe4c446279a78f9808c0 (patch) | |
tree | f7f22289cb0613dc7a29ac5ee5e87ca5ef61ec8c /view.go | |
parent | d48c52c1298777cba68b6e78dc5cd83dda4f12de (diff) |
Audiotrond exists and properly displays music being played through MPD.
The display includes title, artist, album, and progress bar, and text
scrolls if too long to fit on the screen. Backlight support exists; the
display backlight fades smoothly on and off when the music starts and
stops. After being stopped for a little while, audiotrond switches to a
clock. Currently, audiotrond lacks user interaction support, so it keeps
the keypad backlight off.
Diffstat (limited to 'view.go')
-rw-r--r-- | view.go | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -0,0 +1,47 @@ +// Copyright 2022 Benjamin Barenblat +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +package main + +import "time" + +import ( + "math" + + "benjamin.barenblat.name/audiotrond/cfa635" +) + +type view struct { + LCD *cfa635.LCDState + DisplayBrightness float64 + Mtime time.Time +} + +func updateView(lcd *cfa635.Module, old, new *view) error { + if err := cfa635.Update(lcd, old.LCD, new.LCD); err != nil { + return err + } + + if new.DisplayBrightness != old.DisplayBrightness { + bright := new.DisplayBrightness + if bright < 0 { + bright = 0 + } + if err := lcd.SetBacklight(int(math.Round(new.DisplayBrightness)), 0); err != nil { + return err + } + } + + return nil +} |