Browse Source

changed charset

Keelan Lightfoot 7 years ago
parent
commit
008abfff5d
2 changed files with 11 additions and 3 deletions
  1. 10
    2
      code.go
  2. 1
    1
      examples/main.go

+ 10
- 2
code.go View File

@@ -98,6 +98,7 @@ type CodeSet struct {
98 98
 	UnshiftCode byte
99 99
 
100 100
 	runeToCodeSet map[rune]code
101
+	initialized   bool
101 102
 }
102 103
 
103 104
 type code struct {
@@ -105,8 +106,15 @@ type code struct {
105 106
 	v     byte
106 107
 }
107 108
 
108
-//Initialize is fun
109
-func (cs *CodeSet) Initialize() *CodeSet {
109
+//LoadCharset is fun
110
+func LoadCharset(cs *CodeSet) *CodeSet {
111
+	if !cs.initialized {
112
+		cs.initialize()
113
+	}
114
+	return cs
115
+}
116
+
117
+func (cs *CodeSet) initialize() *CodeSet {
110 118
 
111 119
 	cs.runeToCodeSet = make(map[rune]code)
112 120
 

+ 1
- 1
examples/main.go View File

@@ -16,7 +16,7 @@ func main() {
16 16
 		SampleRate: 8000,
17 17
 	}
18 18
 
19
-	charset := openbaudot.USTTY.Initialize()
19
+	charset := openbaudot.LoadCharset(&openbaudot.USTTY)
20 20
 
21 21
 	encoderIn := make(chan rune)
22 22
 	modulatorIn := make(chan byte)