diff --git a/client.go b/client.go index c6682cf..7b2ea0e 100644 --- a/client.go +++ b/client.go @@ -512,12 +512,12 @@ func (b *Talkkonnect) ClientStart() { if Config.Global.Software.Settings.StreamOnStart { time.Sleep(Config.Global.Software.Settings.StreamOnStartAfter * time.Second) - b.cmdPlayback() + b.cmdPlayback("xml settings") } if Config.Global.Software.Settings.TXOnStart { time.Sleep(Config.Global.Software.Settings.TXOnStartAfter * time.Second) - b.cmdStartTransmitting() + b.cmdStartTransmitting("xml settings") } keyPressListenerLoop: @@ -532,105 +532,105 @@ keyPressListenerLoop: case term.KeyDelete: b.cmdDisplayMenu() case term.KeyF1: - b.cmdChannelUp() + b.cmdChannelUp("tty keyboard") case term.KeyF2: - b.cmdChannelDown() + b.cmdChannelDown("tty keyboard") case term.KeyF3: - b.cmdMuteUnmute("toggle") + b.cmdMuteUnmute("toggle", "tty keyboard") case term.KeyF4: - b.cmdCurrentVolume() + b.cmdCurrentVolume("tty keyboard") case term.KeyF5: - b.cmdVolumeUp() + b.cmdVolumeUp("tty keyboard") case term.KeyF6: - b.cmdVolumeDown() + b.cmdVolumeDown("tty keyboard") case term.KeyF7: - b.cmdListServerChannels() + b.cmdListServerChannels("tty keyboard") case term.KeyF8: - b.cmdStartTransmitting() + b.cmdStartTransmitting("tty keyboard") case term.KeyF9: - b.cmdStopTransmitting() + b.cmdStopTransmitting("tty keyboard") case term.KeyF10: - b.cmdListOnlineUsers() + b.cmdListOnlineUsers("tty keyboard") case term.KeyF11: - b.cmdPlayback() + b.cmdPlayback("tty keyboard") case term.KeyF12: - go b.cmdGPSPosition() + go b.cmdGPSPosition("tty keyboard") case term.KeyCtrlB: - b.cmdLiveReload() + b.cmdLiveReload("tty keyboard") case term.KeyCtrlC: talkkonnectAcknowledgements("\u001b[44;1m") // add blue background to banner reference https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#background-colors - b.cmdQuitTalkkonnect() + b.cmdQuitTalkkonnect("tty keyboard") case term.KeyCtrlD: b.cmdDebugStacktrace() case term.KeyCtrlE: - b.cmdSendEmail() + b.cmdSendEmail("tty keyboard") case term.KeyCtrlF: - b.cmdConnPreviousServer() + b.cmdConnPreviousServer("tty keyboard") case term.KeyCtrlH: - cmdSanityCheck() + cmdSanityCheck("tty keyboard") case term.KeyCtrlI: // New. Audio Recording. Traffic - b.cmdAudioTrafficRecord() + b.cmdAudioTrafficRecord("tty keyboard") case term.KeyCtrlJ: // New. Audio Recording. Mic - b.cmdAudioMicRecord() + b.cmdAudioMicRecord("tty keyboard") case term.KeyCtrlK: // New/ Audio Recording. Combo - b.cmdAudioMicTrafficRecord() + b.cmdAudioMicTrafficRecord("tty keyboard") case term.KeyCtrlL: - b.cmdClearScreen() + b.cmdClearScreen("tty keyboard") case term.KeyCtrlO: - b.cmdPingServers() + b.cmdPingServers("tty keyboard") case term.KeyCtrlN: - b.cmdConnNextServer() + b.cmdConnNextServer("tty keyboard") case term.KeyCtrlP: - b.cmdPanicSimulation() + b.cmdPanicSimulation("tty keyboard") case term.KeyCtrlG: - b.cmdPlayRepeaterTone() + b.cmdPlayRepeaterTone("tty keyboard") case term.KeyCtrlR: - b.cmdRepeatTxLoop() + b.cmdRepeatTxLoop("tty keyboard") case term.KeyCtrlS: - b.cmdScanChannels() + b.cmdScanChannels("tty keyboard") case term.KeyCtrlT: - cmdThanks() + cmdThanks("tty keyboard") case term.KeyCtrlU: - b.cmdShowUptime() + b.cmdShowUptime("tty keyboard") case term.KeyCtrlV: - b.cmdDisplayVersion() + b.cmdDisplayVersion("tty keyboard") case term.KeyCtrlX: - b.cmdDumpXMLConfig() + b.cmdDumpXMLConfig("tty keyboard") default: if _, ok := TTYKeyMap[ev.Ch]; ok { switch strings.ToLower(TTYKeyMap[ev.Ch].Command) { case "channelup": - b.cmdChannelUp() + b.cmdChannelUp("tty keyboard") case "channeldown": - b.cmdChannelDown() + b.cmdChannelDown("tty keyboard") case "serverup": - b.cmdConnNextServer() + b.cmdConnNextServer("tty keyboard") case "serverdown": - b.cmdConnPreviousServer() + b.cmdConnPreviousServer("tty keyboard") case "mute": - b.cmdMuteUnmute("mute") + b.cmdMuteUnmute("mute", "tty keyboard") case "unmute": - b.cmdMuteUnmute("unmute") + b.cmdMuteUnmute("unmute", "tty keyboard") case "mute-toggle": - b.cmdMuteUnmute("toggle") + b.cmdMuteUnmute("toggle", "tty keyboard") case "stream-toggle": - b.cmdPlayback() + b.cmdPlayback("tty keyboard") case "volumeup": - b.cmdVolumeUp() + b.cmdVolumeUp("tty keyboard") case "volumedown": - b.cmdVolumeDown() + b.cmdVolumeDown("tty keyboard") case "setcomment": if TTYKeyMap[ev.Ch].ParamValue == "setcomment" { log.Println("info: Set Commment ", TTYKeyMap[ev.Ch].ParamValue) b.Client.Self.SetComment(TTYKeyMap[ev.Ch].ParamValue) } case "transmitstart": - b.cmdStartTransmitting() + b.cmdStartTransmitting("tty keyboard") case "transmitstop": - b.cmdStopTransmitting() + b.cmdStopTransmitting("tty keyboard") case "record": - b.cmdAudioTrafficRecord() - b.cmdAudioMicRecord() + b.cmdAudioTrafficRecord("tty keyboard") + b.cmdAudioMicRecord("tty keyboard") case "voicetargetset": Paramvalue, err := strconv.Atoi(TTYKeyMap[ev.Ch].ParamValue) if err != nil { diff --git a/clientcommands.go b/clientcommands.go index b4cd17b..697e780 100644 --- a/clientcommands.go +++ b/clientcommands.go @@ -127,7 +127,6 @@ func (b *Talkkonnect) TransmitStart() { } b.BackLightTimer() - t := time.Now() LastSpeaker = "" if Config.Global.Software.Settings.SimplexWithMute { err := volume.Mute(Config.Global.Software.Settings.OutputDevice) @@ -141,7 +140,6 @@ func (b *Talkkonnect) TransmitStart() { if IsPlayStream { IsPlayStream = false NowStreaming = false - time.Sleep(100 * time.Millisecond) for _, sound := range Config.Global.Software.Sounds.Sound { if sound.Enabled { @@ -155,21 +153,10 @@ func (b *Talkkonnect) TransmitStart() { } if Config.Global.Hardware.TargetBoard == "rpi" { - GPIOOutPin("transmit", "on") - MyLedStripTransmitLEDOn() - if LCDEnabled { - LcdText[0] = "Online/TX" - LcdText[3] = "TX at " + t.Format("15:04:05") - LcdDisplay(LcdText, LCDRSPin, LCDEPin, LCDD4Pin, LCDD5Pin, LCDD6Pin, LCDD7Pin, LCDInterfaceType, LCDI2CAddress) - } - if OLEDEnabled { - Oled.DisplayOn() - LCDIsDark = false - oledDisplay(false, 0, 1, "Online/TX") - oledDisplay(false, 3, 1, "TX at "+t.Format("15:04:05")) - oledDisplay(false, 6, 1, "Please Visit ") - oledDisplay(false, 7, 1, "www.talkkonnect.com") - } + // use groutine so no need to wait for local screen cause it causes delay + go GPIOOutPin("transmit", "on") + go MyLedStripTransmitLEDOn() + go txScreen() } b.IsTransmitting = true diff --git a/commandkeys.go b/commandkeys.go index 58fb5b8..733e45f 100644 --- a/commandkeys.go +++ b/commandkeys.go @@ -50,19 +50,19 @@ func (b *Talkkonnect) cmdDisplayMenu() { b.ParticipantLEDUpdate(true) } -func (b *Talkkonnect) cmdChannelUp() { - log.Println("debug: F1 pressed Channel Up (+) Requested") +func (b *Talkkonnect) cmdChannelUp(source string) { + log.Printf("debug: F1 pressed Channel Up (+) Requested from %v\n", source) b.ChannelUp() } -func (b *Talkkonnect) cmdChannelDown() { - log.Println("debug: F2 pressed Channel Down (-) Requested") +func (b *Talkkonnect) cmdChannelDown(source string) { + log.Printf("debug: F2 pressed Channel Down (-) Requested from %v\n", source) b.ChannelDown() } -func (b *Talkkonnect) cmdMuteUnmute(subCommand string) { +func (b *Talkkonnect) cmdMuteUnmute(subCommand, source string) { - log.Printf("debug: F3 pressed %v Speaker Requested\n", subCommand) + log.Printf("debug: F3 pressed %v Speaker Requested from %v\n", subCommand, source) OrigMuted, err := volume.GetMuted(Config.Global.Software.Settings.OutputMuteControlDevice) if err != nil { @@ -156,13 +156,13 @@ func (b *Talkkonnect) cmdMuteUnmute(subCommand string) { return } } -func (b *Talkkonnect) cmdCurrentVolume() { +func (b *Talkkonnect) cmdCurrentVolume(source string) { OrigVolume, err := volume.GetVolume(Config.Global.Software.Settings.OutputVolControlDevice) if err != nil { log.Printf("error: Unable to get current volume: %+v\n", err) } - log.Println("debug: F4 pressed Volume Level Requested") + log.Printf("debug: F4 pressed Volume Level Requested From =%v\n", source) log.Println("info: Volume Level is at", OrigVolume, "%") TTSEvent("currentvolumelevel") @@ -178,8 +178,8 @@ func (b *Talkkonnect) cmdCurrentVolume() { } } -func (b *Talkkonnect) cmdVolumeUp() { - log.Println("debug: F5 pressed Volume UP (+)") +func (b *Talkkonnect) cmdVolumeUp(source string) { + log.Printf("debug: F5 pressed Volume UP (+) from %v\n", source) origVolume, err := volume.GetVolume(Config.Global.Software.Settings.OutputVolControlDevice) if err != nil { log.Printf("warn: unable to get original volume: %+v volume control will not work!\n", err) @@ -218,8 +218,8 @@ func (b *Talkkonnect) cmdVolumeUp() { TTSEvent("digitalvolumeup") } -func (b *Talkkonnect) cmdVolumeDown() { - log.Println("info: F6 pressed Volume Down (-)") +func (b *Talkkonnect) cmdVolumeDown(source string) { + log.Printf("info: F6 pressed Volume Down (-) from %v\n", source) origVolume, err := volume.GetVolume(Config.Global.Software.Settings.OutputVolControlDevice) if err != nil { log.Printf("warn: unable to get original volume: %+v volume control will not work!\n", err) @@ -259,16 +259,16 @@ func (b *Talkkonnect) cmdVolumeDown() { TTSEvent("digitalvolumedown") } -func (b *Talkkonnect) cmdListServerChannels() { - log.Println("debug: F7 pressed Channel List Requested") +func (b *Talkkonnect) cmdListServerChannels(source string) { + log.Printf("debug: F7 pressed Channel List Requested %v\n", source) TTSEvent("listserverchannels") b.ListChannels(true) b.ParticipantLEDUpdate(true) } -func (b *Talkkonnect) cmdStartTransmitting() { - log.Println("debug: F8 pressed TX Mode Requested (Start Transmitting)") +func (b *Talkkonnect) cmdStartTransmitting(source string) { + log.Printf("debug: F8 pressed TX Mode Requested (Start Transmitting) from %v\n", source) log.Println("info: Start Transmitting") TTSEvent("starttransmitting") @@ -293,8 +293,8 @@ func (b *Talkkonnect) cmdStartTransmitting() { } } -func (b *Talkkonnect) cmdStopTransmitting() { - log.Println("debug: F9 pressed RX Mode Request (Stop Transmitting)") +func (b *Talkkonnect) cmdStopTransmitting(source string) { + log.Printf("debug: F9 pressed RX Mode Request (Stop Transmitting) from %v\n", source) log.Println("info: Stop Transmitting") TTSEvent("stoptransmitting") @@ -319,8 +319,8 @@ func (b *Talkkonnect) cmdStopTransmitting() { } } -func (b *Talkkonnect) cmdListOnlineUsers() { - log.Println("debug: F10 pressed Online User(s) in Current Channel Requested") +func (b *Talkkonnect) cmdListOnlineUsers(source string) { + log.Printf("debug: F10 pressed Online User(s) in Current Channel Requested from %v\n", source) log.Println("info: F10 Online User(s) in Current Channel") TTSEvent("listonlineusers") @@ -330,8 +330,8 @@ func (b *Talkkonnect) cmdListOnlineUsers() { b.ParticipantLEDUpdate(true) } -func (b *Talkkonnect) cmdPlayback() { - log.Println("debug: F11 pressed Start/Stop Stream Stream into Current Channel Requested") +func (b *Talkkonnect) cmdPlayback(source string) { + log.Printf("debug: F11 pressed Start/Stop Stream Stream into Current Channel Requested from %v", source) log.Println("info: Stream into Current Channel") b.BackLightTimer() @@ -358,8 +358,8 @@ func (b *Talkkonnect) cmdPlayback() { } } -func (b *Talkkonnect) cmdGPSPosition() { - log.Println("debug: F12 pressed") +func (b *Talkkonnect) cmdGPSPosition(source string) { + log.Printf("debug: F12 pressed from %v\n", source) log.Println("info: GPS details requested") TTSEvent("requestgpsposition") @@ -387,8 +387,8 @@ func (b *Talkkonnect) cmdGPSPosition() { } -func (b *Talkkonnect) cmdQuitTalkkonnect() { - log.Println("debug: Ctrl-C Terminate Program Requested") +func (b *Talkkonnect) cmdQuitTalkkonnect(source string) { + log.Printf("debug: Ctrl-C Terminate Program Requested from %v\n", source) duration := time.Since(StartTime) log.Printf("info: Talkkonnect Now Running For %v \n", secondsToHuman(int(duration.Seconds()))) TTSEvent("quittalkkonnect") @@ -411,8 +411,8 @@ func (b *Talkkonnect) cmdDebugStacktrace() { goStreamStats() } -func (b *Talkkonnect) cmdSendEmail() { - log.Println("debug: Ctrl-E Pressed") +func (b *Talkkonnect) cmdSendEmail(source string) { + log.Printf("debug: Ctrl-E Pressed from %v\n", source) log.Println("info: Send Email Requested") var i int = 0 @@ -466,8 +466,8 @@ func (b *Talkkonnect) cmdSendEmail() { } } -func (b *Talkkonnect) cmdConnPreviousServer() { - log.Println("debug: Ctrl-F Pressed") +func (b *Talkkonnect) cmdConnPreviousServer(source string) { + log.Printf("debug: Ctrl-F Pressed from %v", source) log.Println("info: Previous Server Requested") TTSEvent("previousserver") @@ -482,9 +482,9 @@ func (b *Talkkonnect) cmdConnPreviousServer() { } } -func (b *Talkkonnect) cmdClearScreen() { +func (b *Talkkonnect) cmdClearScreen(source string) { reset() - log.Println("debug: Ctrl-L Pressed Cleared Screen") + log.Printf("debug: Ctrl-L Pressed Cleared Screen from %v\n", source) if Config.Global.Hardware.TargetBoard == "rpi" { if LCDEnabled { LcdText = [4]string{"nil", "nil", "nil", "nil"} @@ -499,15 +499,15 @@ func (b *Talkkonnect) cmdClearScreen() { } } -func (b *Talkkonnect) cmdPingServers() { - log.Println("debug: Ctrl-O Pressed") +func (b *Talkkonnect) cmdPingServers(source string) { + log.Printf("debug: Ctrl-O Pressed %v\n", source) log.Println("info: Ping Servers") TTSEvent("pingservers") b.pingServers() } -func (b *Talkkonnect) cmdConnNextServer() { - log.Println("debug: Ctrl-N Pressed") +func (b *Talkkonnect) cmdConnNextServer(source string) { + log.Printf("debug: Ctrl-N Pressed from %v\n", source) log.Println("info: Next Server Requested Killing This Session, talkkonnect should be restarted by systemd") TTSEvent("nextserver") @@ -523,8 +523,8 @@ func (b *Talkkonnect) cmdConnNextServer() { } -func (b *Talkkonnect) cmdAudioTrafficRecord() { - log.Println("debug: Ctrl-I Pressed") +func (b *Talkkonnect) cmdAudioTrafficRecord(source string) { + log.Printf("debug: Ctrl-I Pressed from %v\n", source) log.Println("info: Traffic Recording Requested") if !Config.Global.Hardware.AudioRecordFunction.Enabled { log.Println("warn: Audio Recording Function Not Enabled") @@ -555,8 +555,8 @@ func (b *Talkkonnect) cmdAudioTrafficRecord() { } } -func (b *Talkkonnect) cmdAudioMicRecord() { - log.Println("debug: Ctrl-J Pressed") +func (b *Talkkonnect) cmdAudioMicRecord(source string) { + log.Printf("debug: Ctrl-J Pressed from %v\n", source) log.Println("info: Ambient (Mic) Recording Requested") if !Config.Global.Hardware.AudioRecordFunction.Enabled { log.Println("warn: Audio Recording Function Not Enabled") @@ -587,8 +587,8 @@ func (b *Talkkonnect) cmdAudioMicRecord() { } } -func (b *Talkkonnect) cmdAudioMicTrafficRecord() { - log.Println("debug: Ctrl-K Pressed") +func (b *Talkkonnect) cmdAudioMicTrafficRecord(source string) { + log.Printf("debug: Ctrl-K Pressed from %v\n", source) log.Println("info: Recording (Traffic and Mic) Requested") if !Config.Global.Hardware.AudioRecordFunction.Enabled { log.Println("warn: Audio Recording Function Not Enabled") @@ -619,12 +619,12 @@ func (b *Talkkonnect) cmdAudioMicTrafficRecord() { } } -func (b *Talkkonnect) cmdPanicSimulation() { +func (b *Talkkonnect) cmdPanicSimulation(source string) { if !(IsConnected) { return } b.BackLightTimer() - log.Println("debug: Ctrl-P Pressed") + log.Printf("debug: Ctrl-P Pressed from %v\n", source) log.Println("info: Panic Button Start/Stop Simulation Requested") TTSEvent("panicsimulation") @@ -688,7 +688,7 @@ func (b *Talkkonnect) cmdPanicSimulation() { // New. Send email after Panic Event // if Config.Global.Hardware.PanicFunction.PMailEnabled { - b.cmdSendEmail() + b.cmdSendEmail("from panic") log.Println("info: Sending Panic Alert Email To Predefined Email Address") } // @@ -721,36 +721,36 @@ func (b *Talkkonnect) cmdPanicSimulation() { } } -func (b *Talkkonnect) cmdRepeatTxLoop() { - log.Println("debug: Ctrl-R Pressed") +func (b *Talkkonnect) cmdRepeatTxLoop(source string) { + log.Printf("debug: Ctrl-R Pressed from %v\n", source) log.Println("info: Repeat TX Test Requested") isrepeattx = !isrepeattx go b.repeatTx() } -func (b *Talkkonnect) cmdScanChannels() { - log.Println("debug: Ctrl-S Pressed") +func (b *Talkkonnect) cmdScanChannels(source string) { + log.Printf("debug: Ctrl-S Pressed fgrom %v\n", source) log.Println("info: Scanning Channels") TTSEvent("startscanning") b.Scan() } -func cmdThanks() { - log.Println("debug: Ctrl-T Pressed") +func cmdThanks(source string) { + log.Printf("debug: Ctrl-T Pressed from %v\n", source) log.Println("info: Thanks and Acknowledgements Screen Request ") talkkonnectAcknowledgements("\u001b[44;1m") // add blue background to banner reference https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#background-colors } -func (b *Talkkonnect) cmdShowUptime() { - log.Println("debug: Ctrl-U Pressed") +func (b *Talkkonnect) cmdShowUptime(source string) { + log.Printf("debug: Ctrl-U Pressed from %v\n", source) log.Println("info: Talkkonnect Uptime Request ") duration := time.Since(StartTime) log.Printf("info: Talkkonnect Now Running For %v \n", secondsToHuman(int(duration.Seconds()))) } -func (b *Talkkonnect) cmdDisplayVersion() { - log.Println("debug: Ctrl-V Pressed") +func (b *Talkkonnect) cmdDisplayVersion(source string) { + log.Printf("debug: Ctrl-V Pressed from %v\n", source) log.Println("info: Talkkonnect Version Request ") releasedVersion := checkGitHubVersion() if talkkonnectVersion != releasedVersion { @@ -760,15 +760,15 @@ func (b *Talkkonnect) cmdDisplayVersion() { } } -func (b *Talkkonnect) cmdDumpXMLConfig() { - log.Println("debug: Ctrl-X Pressed") +func (b *Talkkonnect) cmdDumpXMLConfig(source string) { + log.Printf("debug: Ctrl-X Pressed from %v\n", source) log.Println("info: Print XML Config " + ConfigXMLFile) TTSEvent("printxmlconfig") printxmlconfig() } -func (b *Talkkonnect) cmdPlayRepeaterTone() { - log.Println("debug: Ctrl-G Pressed") +func (b *Talkkonnect) cmdPlayRepeaterTone(source string) { + log.Printf("debug: Ctrl-G Pressed from %v\n", source) log.Println("info: Play Repeater Tone on Speaker and Simulate RX Signal") b.BackLightTimer() @@ -781,8 +781,8 @@ func (b *Talkkonnect) cmdPlayRepeaterTone() { } -func (b *Talkkonnect) cmdLiveReload() { - log.Println("debug: Ctrl-B Pressed") +func (b *Talkkonnect) cmdLiveReload(source string) { + log.Printf("debug: Ctrl-B Pressed from %v\n", source) log.Println("info: XML Config Live Reload") err := readxmlconfig(ConfigXMLFile, true) if err != nil { @@ -791,8 +791,8 @@ func (b *Talkkonnect) cmdLiveReload() { } } -func cmdSanityCheck() { - log.Println("debug: Ctrl-H Pressed") +func cmdSanityCheck(source string) { + log.Printf("debug: Ctrl-H Pressed from %v\n", source) log.Println("info: XML Sanity Checker") CheckConfigSanity(false) } diff --git a/gpio.go b/gpio.go index 875a933..25ee245 100644 --- a/gpio.go +++ b/gpio.go @@ -111,6 +111,11 @@ var ( NextServerButton gpio.Pin NextServerButtonPin uint NextServerButtonState uint + + RepeaterToneButtonUsed bool + RepeaterToneButton gpio.Pin + RepeaterToneButtonPin uint + RepeaterToneButtonState uint ) var D [8]*mcp23017.Device @@ -267,10 +272,17 @@ func (b *Talkkonnect) initGPIO() { NextServerButtonUsed = true NextServerButtonPin = io.PinNo } + if io.Name == "repeatertone" && io.PinNo > 0 { + log.Printf("debug: GPIO Setup Input Device %v Name %v PinNo %v", io.Device, io.Name, io.PinNo) + RepeaterToneButtonPinPullUp := rpio.Pin(io.PinNo) + RepeaterToneButtonPinPullUp.PullUp() + RepeaterToneButtonUsed = true + RepeaterToneButtonPin = io.PinNo + } } } - if TxButtonUsed || TxToggleUsed || UpButtonUsed || DownButtonUsed || PanicUsed || StreamToggleUsed || CommentUsed || RotaryUsed || VolUpButtonUsed || VolDownButtonUsed || TrackingUsed || MQTT0ButtonUsed || MQTT1ButtonUsed || NextServerButtonUsed { + if TxButtonUsed || TxToggleUsed || UpButtonUsed || DownButtonUsed || PanicUsed || StreamToggleUsed || CommentUsed || RotaryUsed || VolUpButtonUsed || VolDownButtonUsed || TrackingUsed || MQTT0ButtonUsed || MQTT1ButtonUsed || NextServerButtonUsed || RepeaterToneButtonUsed { rpio.Close() } @@ -437,7 +449,7 @@ func (b *Talkkonnect) initGPIO() { } else { log.Println("debug: Panic Button is pressed") playIOMedia("iopanic") - b.cmdPanicSimulation() + b.cmdPanicSimulation("gpio button") time.Sleep(150 * time.Millisecond) } } @@ -490,7 +502,7 @@ func (b *Talkkonnect) initGPIO() { } else { playIOMedia("iostreamtoggle") log.Println("debug: Stream Button is pressed") - b.cmdPlayback() + b.cmdPlayback("gpio button") time.Sleep(150 * time.Millisecond) } } @@ -515,11 +527,11 @@ func (b *Talkkonnect) initGPIO() { if currentStateB != currentStateA && err1 == nil { playIOMedia("iorotarycw") log.Println("debug: Rotating Clockwise") - b.cmdChannelUp() + b.cmdChannelUp("rotary encoder") } else { log.Println("debug: Rotating CounterClockwise") playIOMedia("iorotaryccw") - b.cmdChannelDown() + b.cmdChannelDown("rotary encoder") } } LastStateA = currentStateA @@ -546,7 +558,7 @@ func (b *Talkkonnect) initGPIO() { } else { log.Println("debug: Vol UP Button is pressed") playIOMedia("iovolup") - b.cmdVolumeUp() + b.cmdVolumeUp("gpio button") } } } else { @@ -570,7 +582,7 @@ func (b *Talkkonnect) initGPIO() { } else { log.Println("debug: Vol Down Button is pressed") playIOMedia("iovoldown") - b.cmdVolumeDown() + b.cmdVolumeDown("gpio button") } } } else { @@ -677,7 +689,33 @@ func (b *Talkkonnect) initGPIO() { } else { log.Println("debug: NextServer Button is pressed") playIOMedia("iocnextserver") - b.ChannelUp() + b.cmdConnNextServer("gpio button") + time.Sleep(150 * time.Millisecond) + } + } + } else { + time.Sleep(1 * time.Second) + } + } + }() + } + + if RepeaterToneButtonUsed { + RepeaterToneButton = gpio.NewInput(RepeaterToneButtonPin) + go func() { + for { + if IsConnected { + currentState, err := RepeaterToneButton.Read() + time.Sleep(150 * time.Millisecond) + if currentState != RepeaterToneButtonState && err == nil { + RepeaterToneButtonState = currentState + + if RepeaterToneButtonState == 1 { + log.Println("debug: Repeater Tone Button is released") + } else { + log.Println("debug: Repeater Tone Button is pressed") + playIOMedia("iorepeatertone") + b.cmdPlayRepeaterTone("gpio button") time.Sleep(150 * time.Millisecond) } } diff --git a/usbkeyboard.go b/usbkeyboard.go index 383f57d..f93369a 100644 --- a/usbkeyboard.go +++ b/usbkeyboard.go @@ -66,35 +66,35 @@ func (b *Talkkonnect) USBKeyboard() { switch strings.ToLower(USBKeyMap[rune(ke.Scancode)].Command) { case "channelup": playIOMedia("usbchannelup") - b.cmdChannelUp() + b.cmdChannelUp("usb keyboard") case "channeldown": playIOMedia("usbchanneldown") - b.cmdChannelDown() + b.cmdChannelDown("usb keyboard") case "serverup": playIOMedia("usbserverup") - b.cmdConnNextServer() + b.cmdConnNextServer("usb keyboard") case "serverdown": playIOMedia("usbpreviousserver") - b.cmdConnPreviousServer() + b.cmdConnPreviousServer("usb keyboard") case "mute": playIOMedia("usbmute") - b.cmdMuteUnmute("mute") + b.cmdMuteUnmute("mute", "usb keyboard") case "unmute": - b.cmdMuteUnmute("unmute") + b.cmdMuteUnmute("unmute", "usb keyboard") playIOMedia("usbunmute") case "mute-toggle": playIOMedia("usbmutetoggle") - b.cmdMuteUnmute("toggle") + b.cmdMuteUnmute("toggle", "usb keyboard") playIOMedia("usbmutetoggle") case "stream-toggle": playIOMedia("usbstreamtoggle") - b.cmdPlayback() + b.cmdPlayback("usb keyboard") case "volumeup": playIOMedia("usbvolup") - b.cmdVolumeUp() + b.cmdVolumeUp("usb keyboard") case "volumedown": playIOMedia("usbvoldown") - b.cmdVolumeDown() + b.cmdVolumeDown("usbvoldown") case "setcomment": if USBKeyMap[rune(ke.Scancode)].ParamName == "setcomment" { log.Println("info: Set Commment ", USBKeyMap[rune(ke.Scancode)].ParamValue) @@ -103,14 +103,14 @@ func (b *Talkkonnect) USBKeyboard() { } case "transmitstart": playIOMedia("usbstarttx") - b.cmdStartTransmitting() + b.cmdStartTransmitting("usb keyboard") case "transmitstop": playIOMedia("usbstoptx") - b.cmdStopTransmitting() + b.cmdStopTransmitting("usb keyboard") case "record": playIOMedia("usbrecord") - b.cmdAudioTrafficRecord() - b.cmdAudioMicRecord() + b.cmdAudioTrafficRecord("usb keyboard") + b.cmdAudioMicRecord("usb keyboard") case "voicetargetset": voicetarget, err := strconv.Atoi(USBKeyMap[rune(ke.Scancode)].ParamValue) if err != nil { @@ -124,6 +124,9 @@ func (b *Talkkonnect) USBKeyboard() { playIOMedia("usbmqttpubpayloadset") MQTTPublish(USBKeyMap[rune(ke.Scancode)].ParamValue) } + case "repeatertoneplay": + playIOMedia("iorepeatertone") + b.cmdPlayRepeaterTone("usb keyboard") default: log.Println("error: Command Not Defined ", strings.ToLower(USBKeyMap[rune(ke.Scancode)].Command)) } diff --git a/utils.go b/utils.go index 20dcc31..48621c6 100644 --- a/utils.go +++ b/utils.go @@ -475,3 +475,20 @@ func findMQTTButton(findMQTTButton string) mqttPubButtonStruct { } return mqttPubButtonStruct{"", "", false} } + +func txScreen() { + t := time.Now() + if LCDEnabled { + LcdText[0] = "Online/TX" + LcdText[3] = "TX at " + t.Format("15:04:05") + LcdDisplay(LcdText, LCDRSPin, LCDEPin, LCDD4Pin, LCDD5Pin, LCDD6Pin, LCDD7Pin, LCDInterfaceType, LCDI2CAddress) + } + if OLEDEnabled { + Oled.DisplayOn() + LCDIsDark = false + oledDisplay(false, 0, 1, "Online/TX") + oledDisplay(false, 3, 1, "TX at "+t.Format("15:04:05")) + oledDisplay(false, 6, 1, "Please Visit ") + oledDisplay(false, 7, 1, "www.talkkonnect.com") + } +} diff --git a/version.go b/version.go index 7600eef..cfdb4a9 100644 --- a/version.go +++ b/version.go @@ -31,10 +31,13 @@ package talkkonnect const ( - talkkonnectVersion string = "2.08.04" - talkkonnectReleased string = "Jan 16 2022" + talkkonnectVersion string = "2.08.05" + talkkonnectReleased string = "Jan 17 2022" ) /* Release Notes -1. Added MQTT Buttons to config, gpio, usbkeyboard and ttykeyboard +1. Next Server by GPIO +2. Next Server by USB Keyboard +3. Optimize LCD, OLED on TX for minimize delay on TX +4. Command Keys Show source of Calling Command */