forked from CoinCulture/point-of-sale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardware.go
42 lines (35 loc) · 958 Bytes
/
hardware.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
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
)
// notification can be a buzzer or a light, or something else ...
func activateNotification() error {
_, err = exec.Command("python", "hardware/notification.py").Output()
if err != nil {
return err
}
return nil
}
// https://learn.adafruit.com/networked-thermal-printer-using-cups-and-raspberry-pi/overview
// hacked together from the above tutorial
func printTheChit(braceletNum int, amount, foodItem string) error {
file, err := ioutil.TempFile(os.TempDir(), "toPrint")
defer os.Remove(file.Name())
number := fmt.Sprintf("#%v", braceletNum)
item := strings.ToUpper(foodItem)
amount = fmt.Sprintf("x%s", amount)
space := "______"
_, err = file.WriteString(fmt.Sprintf("%s\n%s\n%s\n%s", number, item, amount, space))
if err != nil {
return err
}
_, err = exec.Command("./hardware/printer.sh", file.Name()).Output()
if err != nil {
return err
}
return nil
}