diff --git a/client.go b/client.go index ddc51b6..3e7aec7 100644 --- a/client.go +++ b/client.go @@ -531,6 +531,7 @@ func (b *Talkkonnect) ClientStart() { // Set VT index to Zero Config.Accounts.Account[AccountIndex].Voicetargets.ID[0].IsCurrent = true + b.sevenSegment("mumblechannel", strconv.Itoa(int(b.Client.Self.Channel.ID))) keyPressListenerLoop: for { @@ -611,7 +612,7 @@ keyPressListenerLoop: case term.KeyCtrlX: b.cmdDumpXMLConfig() case term.KeyCtrlZ: - nextEnabledRotaryEncoderFunction() + b.nextEnabledRotaryEncoderFunction() //b.cmdConnNextServer() default: if _, ok := TTYKeyMap[ev.Ch]; ok { diff --git a/commandkeys.go b/commandkeys.go index e19fa7f..911b633 100644 --- a/commandkeys.go +++ b/commandkeys.go @@ -175,7 +175,7 @@ func (b *Talkkonnect) cmdCurrentVolume() { if OLEDEnabled { oledDisplay(false, 6, 1, "Volume "+strconv.Itoa(OrigVolume)) } - + b.sevenSegment("localvolume", strconv.Itoa(OrigVolume)) } } @@ -202,6 +202,7 @@ func (b *Talkkonnect) cmdVolumeUp() { if OLEDEnabled { oledDisplay(false, 6, 1, "Volume "+strconv.Itoa(origVolume)) } + b.sevenSegment("localvolume", strconv.Itoa(origVolume)) } } else { log.Println("debug: F5 Increase Volume") @@ -214,6 +215,7 @@ func (b *Talkkonnect) cmdVolumeUp() { if OLEDEnabled { oledDisplay(false, 6, 1, "Max Vol") } + b.sevenSegment("localvolume", "100") } } TTSEvent("digitalvolumeup") @@ -242,7 +244,7 @@ func (b *Talkkonnect) cmdVolumeDown() { if OLEDEnabled { oledDisplay(false, 6, 1, "Volume "+strconv.Itoa(origVolume)) } - + b.sevenSegment("localvolume", strconv.Itoa(origVolume)) } } else { log.Println("debug: F6 Increase Volume Already") @@ -255,6 +257,7 @@ func (b *Talkkonnect) cmdVolumeDown() { if OLEDEnabled { oledDisplay(false, 6, 1, "Min Vol") } + b.sevenSegment("localvolume", "0") } } TTSEvent("digitalvolumedown") @@ -439,6 +442,7 @@ func (b *Talkkonnect) cmdQuitTalkkonnect() { log.Printf("debug: Ctrl-C Terminate Program Requested \n") duration := time.Since(StartTime) log.Printf("info: Talkkonnect Now Running For %v \n", secondsToHuman(int(duration.Seconds()))) + b.sevenSegment("bye", "") TTSEvent("quittalkkonnect") CleanUp() } diff --git a/display.go b/display.go index d036de9..95eae24 100644 --- a/display.go +++ b/display.go @@ -86,3 +86,42 @@ func oledDisplay(OledClear bool, OledRow int, OledColumn int, OledText string) { func LcdDisplay(lcdtextshow [4]string, PRSPin int, PEPin int, PD4Pin int, PD5Pin int, PD6Pin int, PD7Pin int, LCDInterfaceType string, LCDI2CAddress byte) { go hd44780.LcdDisplay(LcdText, LCDRSPin, LCDEPin, LCDD4Pin, LCDD5Pin, LCDD6Pin, LCDD7Pin, LCDInterfaceType, LCDI2CAddress) } + +func (b *Talkkonnect) sevenSegment(function string, value string) { + if Config.Global.Hardware.IO.Max7219.Enabled { + if function == "mumblechannel" { + prefix := "c" + if b.findEnabledRotaryEncoderFunction("mumblechannel") { + Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, prefix+value) + } + } + if function == "localvolume" { + prefix := "u" + if b.findEnabledRotaryEncoderFunction("localvolume") { + Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, prefix+value) + } + } + if function == "radiochannel" { + prefix := "r" + if b.findEnabledRotaryEncoderFunction("radiochannel") { + Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, prefix+value) + } + } + if function == "voicetarget" { + prefix := "t" + if b.findEnabledRotaryEncoderFunction("voicetarget") { + Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, prefix+value) + } + } + if function == "hello" { + prefix := "hello" + Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, prefix) + } + if function == "bye" { + prefix := "bye" + Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, prefix) + } + } else { + log.Println("debug: Max7219 Seven Segment Not Enabled") + } +} diff --git a/gpio.go b/gpio.go index 6027331..6570ef3 100644 --- a/gpio.go +++ b/gpio.go @@ -33,6 +33,7 @@ package talkkonnect import ( "log" + "strconv" "time" "github.com/stianeikeland/go-rpio" @@ -609,7 +610,7 @@ func (b *Talkkonnect) initGPIO() { } else { log.Println("debug: Rotary Button is pressed") playIOMedia("iorotarybutton") - nextEnabledRotaryEncoderFunction() + b.nextEnabledRotaryEncoderFunction() } } } else { @@ -998,19 +999,19 @@ func (b *Talkkonnect) rotaryAction(direction string) { log.Println("debug: Rotating Clockwise") switch RotaryFunction.Function { case "mumblechannel": - if findEnabledRotaryEncoderFunction("mumblechannel") { + if b.findEnabledRotaryEncoderFunction("mumblechannel") { b.ChannelUp() } case "localvolume": - if findEnabledRotaryEncoderFunction("localvolume") { + if b.findEnabledRotaryEncoderFunction("localvolume") { b.cmdVolumeUp() } case "radiochannel": - if findEnabledRotaryEncoderFunction("radiochannel") { + if b.findEnabledRotaryEncoderFunction("radiochannel") { go radioChannelIncrement("up") } case "voicetarget": - if findEnabledRotaryEncoderFunction("voicetarget") { + if b.findEnabledRotaryEncoderFunction("voicetarget") { b.VTMove("up") } default: @@ -1023,19 +1024,19 @@ func (b *Talkkonnect) rotaryAction(direction string) { log.Println("debug: Rotating CounterClockwise") switch RotaryFunction.Function { case "mumblechannel": - if findEnabledRotaryEncoderFunction("mumblechannel") { + if b.findEnabledRotaryEncoderFunction("mumblechannel") { b.ChannelDown() } case "localvolume": - if findEnabledRotaryEncoderFunction("localvolume") { + if b.findEnabledRotaryEncoderFunction("localvolume") { b.cmdVolumeDown() } case "radiochannel": - if findEnabledRotaryEncoderFunction("radiochannel") { + if b.findEnabledRotaryEncoderFunction("radiochannel") { go radioChannelIncrement("down") } case "voicetarget": - if findEnabledRotaryEncoderFunction("voicetarget") { + if b.findEnabledRotaryEncoderFunction("voicetarget") { b.VTMove("down") } default: @@ -1055,11 +1056,23 @@ func createEnabledRotaryEncoderFunctions() { } } -func nextEnabledRotaryEncoderFunction() { +func (b *Talkkonnect) nextEnabledRotaryEncoderFunction() { if len(RotaryFunctions) > RotaryFunction.Item+1 { RotaryFunction.Item++ RotaryFunction.Function = RotaryFunctions[RotaryFunction.Item].Function log.Printf("info: Current Rotary Item %v Function %v\n", RotaryFunction.Item, RotaryFunction.Function) + if RotaryFunction.Function == "mumblechannel" { + b.sevenSegment("mumblechannel", strconv.Itoa(int(b.Client.Self.Channel.ID))) + } + if RotaryFunction.Function == "localvolume" { + b.cmdCurrentVolume() + } + if RotaryFunction.Function == "radiochannel" { + b.sevenSegment("radiochannel", "") + } + if RotaryFunction.Function == "voicetarget" { + b.sevenSegment("voicetarget", "") + } return } @@ -1067,11 +1080,23 @@ func nextEnabledRotaryEncoderFunction() { RotaryFunction.Item = 0 RotaryFunction.Function = RotaryFunctions[0].Function log.Printf("info: Current Rotary Item %v Function %v\n", RotaryFunction.Item, RotaryFunction.Function) + if RotaryFunction.Function == "mumblechannel" { + b.sevenSegment("mumblechannel", strconv.Itoa(int(b.Client.Self.Channel.ID))) + } + if RotaryFunction.Function == "localvolume" { + b.cmdCurrentVolume() + } + if RotaryFunction.Function == "radiochannel" { + b.sevenSegment("radiochannel", "") + } + if RotaryFunction.Function == "voicetarget" { + b.sevenSegment("voicetarget", "") + } return } } -func findEnabledRotaryEncoderFunction(findFunction string) bool { +func (b *Talkkonnect) findEnabledRotaryEncoderFunction(findFunction string) bool { for _, functionName := range Config.Global.Hardware.IO.RotaryEncoder.Control { if findFunction == functionName.Function { return functionName.Enabled diff --git a/onevent.go b/onevent.go index 54f4e59..ed409b5 100644 --- a/onevent.go +++ b/onevent.go @@ -240,9 +240,7 @@ func (b *Talkkonnect) OnUserChange(e *gumble.UserChangeEvent) { log.Println("info:", cleanstring(e.User.Name), " Changed Channel to ", e.User.Channel.Name) LcdText[2] = cleanstring(e.User.Name) + "->" + e.User.Channel.Name LcdText[3] = "" - if Config.Global.Hardware.IO.Max7219.Enabled { - Max7219(Config.Global.Hardware.IO.Max7219.Max7219Cascaded, Config.Global.Hardware.IO.Max7219.SPIBus, Config.Global.Hardware.IO.Max7219.SPIDevice, Config.Global.Hardware.IO.Max7219.Brightness, strconv.Itoa(int(b.Client.Self.Channel.ID))) - } + b.sevenSegment("mumblechannel", strconv.Itoa(int(b.Client.Self.Channel.ID))) case gumble.UserChangeComment: info = "chg comment" case gumble.UserChangeAudio: @@ -253,8 +251,8 @@ func (b *Talkkonnect) OnUserChange(e *gumble.UserChangeEvent) { info = "chg rec status" case gumble.UserChangeStats: info = "chg stats" - if info != "chg channel" { + if info != "" { log.Println("info: User ", cleanstring(e.User.Name), " ", info, "Event type=", e.Type, " channel=", e.User.Channel.Name) diff --git a/version.go b/version.go index bf023c1..789bda4 100644 --- a/version.go +++ b/version.go @@ -31,8 +31,8 @@ package talkkonnect const ( - talkkonnectVersion string = "2.10.10" - talkkonnectReleased string = "Feb 12 2022" + talkkonnectVersion string = "2.10.11" + talkkonnectReleased string = "Feb 14 2022" ) /* Release Notes