New setting: Max volume
This commit is contained in:
parent
41f8092419
commit
11163f059b
@ -13,6 +13,7 @@ type Settings struct {
|
|||||||
WeatherDelay time.Duration `json:"weather_delay"`
|
WeatherDelay time.Duration `json:"weather_delay"`
|
||||||
WeatherAction string `json:"weather_action"`
|
WeatherAction string `json:"weather_action"`
|
||||||
MaxRunTime time.Duration `json:"max_run_time"`
|
MaxRunTime time.Duration `json:"max_run_time"`
|
||||||
|
MaxVolume uint16 `json:"max_volume"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExistsSettings checks if the settings file can by found at the given path.
|
// ExistsSettings checks if the settings file can by found at the given path.
|
||||||
|
@ -21,6 +21,7 @@ var CommonPlayer *Player
|
|||||||
type Player struct {
|
type Player struct {
|
||||||
Playlist []string
|
Playlist []string
|
||||||
MaxRunTime time.Duration
|
MaxRunTime time.Duration
|
||||||
|
MaxVolume uint16
|
||||||
Stopper chan bool
|
Stopper chan bool
|
||||||
currentCmd *exec.Cmd
|
currentCmd *exec.Cmd
|
||||||
currentCmdCh chan bool
|
currentCmdCh chan bool
|
||||||
@ -77,6 +78,7 @@ func NewPlayer(cfg *config.Config, routines []reveil.Identifier) (*Player, error
|
|||||||
Stopper: make(chan bool, 1),
|
Stopper: make(chan bool, 1),
|
||||||
currentCmdCh: make(chan bool, 1),
|
currentCmdCh: make(chan bool, 1),
|
||||||
MaxRunTime: settings.MaxRunTime * time.Minute,
|
MaxRunTime: settings.MaxRunTime * time.Minute,
|
||||||
|
MaxVolume: uint16(settings.MaxVolume),
|
||||||
weatherTime: settings.WeatherDelay * time.Minute,
|
weatherTime: settings.WeatherDelay * time.Minute,
|
||||||
weatherAction: wact,
|
weatherAction: wact,
|
||||||
claironTime: settings.GongInterval * time.Minute,
|
claironTime: settings.GongInterval * time.Minute,
|
||||||
@ -270,7 +272,11 @@ func (p *Player) NextTrack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) SetVolume(volume uint16) error {
|
func (p *Player) SetVolume(volume uint16) error {
|
||||||
cmd := exec.Command("amixer", "-D", mixerCard, "set", mixerName, fmt.Sprintf("%d", volume))
|
if p.MaxVolume == 0 {
|
||||||
|
p.MaxVolume = 65535
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command("amixer", "-D", mixerCard, "set", mixerName, fmt.Sprintf("%d", uint32(volume)*uint32(p.MaxVolume)/65535))
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,13 @@ export class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update({ language, gong_interval, weather_delay, weather_action, max_run_time }) {
|
update({ language, gong_interval, weather_delay, weather_action, max_run_time, max_volume }) {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
this.gong_interval = gong_interval;
|
this.gong_interval = gong_interval;
|
||||||
this.weather_delay = weather_delay;
|
this.weather_delay = weather_delay;
|
||||||
this.weather_action = weather_action;
|
this.weather_action = weather_action;
|
||||||
this.max_run_time = max_run_time;
|
this.max_run_time = max_run_time;
|
||||||
|
this.max_volume = max_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
async save() {
|
async save() {
|
||||||
|
@ -116,6 +116,20 @@
|
|||||||
<InputGroupText>min</InputGroupText>
|
<InputGroupText>min</InputGroupText>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
|
<FormGroup>
|
||||||
|
<Label for="maxVolume">Volume maximum</Label>
|
||||||
|
<InputGroup>
|
||||||
|
<Input
|
||||||
|
type="range"
|
||||||
|
id="maxVolume"
|
||||||
|
min="0"
|
||||||
|
max="65535"
|
||||||
|
bind:value={settings.max_volume}
|
||||||
|
on:input={submitSettings}
|
||||||
|
/>
|
||||||
|
</InputGroup>
|
||||||
|
</FormGroup>
|
||||||
{/await}
|
{/await}
|
||||||
</Form>
|
</Form>
|
||||||
</Container>
|
</Container>
|
||||||
|
Loading…
Reference in New Issue
Block a user