Skip to content

Commit

Permalink
added 7segment functions
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Feb 14, 2022
1 parent 340f104 commit 7ad2393
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 20 deletions.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions commandkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (b *Talkkonnect) cmdCurrentVolume() {
if OLEDEnabled {
oledDisplay(false, 6, 1, "Volume "+strconv.Itoa(OrigVolume))
}

b.sevenSegment("localvolume", strconv.Itoa(OrigVolume))
}
}

Expand All @@ -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")
Expand All @@ -214,6 +215,7 @@ func (b *Talkkonnect) cmdVolumeUp() {
if OLEDEnabled {
oledDisplay(false, 6, 1, "Max Vol")
}
b.sevenSegment("localvolume", "100")
}
}
TTSEvent("digitalvolumeup")
Expand Down Expand Up @@ -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")
Expand All @@ -255,6 +257,7 @@ func (b *Talkkonnect) cmdVolumeDown() {
if OLEDEnabled {
oledDisplay(false, 6, 1, "Min Vol")
}
b.sevenSegment("localvolume", "0")
}
}
TTSEvent("digitalvolumedown")
Expand Down Expand Up @@ -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()
}
Expand Down
39 changes: 39 additions & 0 deletions display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
47 changes: 36 additions & 11 deletions gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package talkkonnect

import (
"log"
"strconv"
"time"

"github.com/stianeikeland/go-rpio"
Expand Down Expand Up @@ -609,7 +610,7 @@ func (b *Talkkonnect) initGPIO() {
} else {
log.Println("debug: Rotary Button is pressed")
playIOMedia("iorotarybutton")
nextEnabledRotaryEncoderFunction()
b.nextEnabledRotaryEncoderFunction()
}
}
} else {
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -1055,23 +1056,47 @@ 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
}

if len(RotaryFunctions) == RotaryFunction.Item+1 {
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
Expand Down
6 changes: 2 additions & 4 deletions onevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ad2393

Please sign in to comment.