forked from talkkonnect/talkkonnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.go
127 lines (110 loc) · 4.32 KB
/
display.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* talkkonnect headless mumble client/gateway with lcd screen and channel control
* Copyright (C) 2018-2019, Suvir Kumar <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* talkkonnect is the based on talkiepi and barnard by Daniel Chote and Tim Cooper
*
* The Initial Developer of the Original Code is
* Suvir Kumar <[email protected]>
* Portions created by the Initial Developer are Copyright (C) Suvir Kumar. All Rights Reserved.
*
* Contributor(s):
*
* Suvir Kumar <[email protected]>
*
* My Blog is at www.talkkonnect.com
* The source code is hosted at github.com/talkkonnect
*
* oleddisplay.go modified to work with talkkonnect
*/
package talkkonnect
import (
"log"
"strings"
hd44780 "github.com/talkkonnect/go-hd44780"
)
//var mutex = &sync.Mutex{}
func oledDisplay(OledClear bool, OledRow int, OledColumn int, OledText string) {
//mutex.Lock()
//defer mutex.Unlock()
if !OLEDEnabled {
log.Println("error: OLED Function Called in Error!")
return
}
if OLEDInterfacetype != "i2c" {
log.Println("error: Only i2c OLED Screens Supported Now!")
return
}
if !OledClear && len(OledText) > 0 && LCDIsDark {
Oled.DisplayOn()
}
if OledClear {
Oled.Clear()
log.Println("debug: OLED Clearing Screen")
if len(OledText) == 0 {
return
}
}
Oled.SetCursor(OledRow, 0)
var rpadding = int(OLEDDisplayColumns)
if len(OledText) <= int(OLEDDisplayColumns) {
rpadding = int(OLEDDisplayColumns) - len(OledText)
}
var text string = OledText + strings.Repeat(" ", rpadding)
Oled.SetCursor(OledRow, OLEDStartColumn)
if len(OledText) >= int(OLEDDisplayColumns) {
Oled.Write(OledText[:OLEDDisplayColumns])
} else {
Oled.Write(text)
}
}
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")
}
}