Added configuration

This commit is contained in:
2024-05-02 22:18:48 +01:00
parent a5e08510f0
commit c4054b3a23
5 changed files with 94 additions and 7 deletions
+9 -6
View File
@@ -1,8 +1,10 @@
package thermalprinter
import (
"fmt"
"sync"
"thermalPrinter/config"
"thermalPrinter/device"
encodings "thermalPrinter/encoding"
)
@@ -19,7 +21,10 @@ type TP struct {
func (p *TP) Print(message string) {
processed := p.TextProcessor.Process(message)
p.Device.Write(processed)
_, err := p.Device.Write(processed)
if err != nil {
fmt.Println("Err: ", err)
}
}
func GetInstance(customDev device.WriteableDevice) *TP {
@@ -27,13 +32,11 @@ func GetInstance(customDev device.WriteableDevice) *TP {
var p encodings.Parser
p.Initialize()
devSocket := device.PrinterSocket{
Host: "",
Port: "",
}
cfg := config.GetInstance()
device := cfg.GetWriteableDevice()
instance = &TP{
Device: &devSocket,
Device: device,
TextProcessor: p,
}
})