Skip to content

Commit 1f40974

Browse files
authored
Merge pull request #272 from Z-Bolt/2.7.0-dev
merge 2.7.0-dev into master
2 parents 7ef3c02 + b6fdb9d commit 1f40974

File tree

216 files changed

+7863
-1814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+7863
-1814
lines changed

Makefile

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ JESSIE_GO_TAGS := gtk_3_14
3232

3333
# Build information
3434
#GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7)
35-
VERSION := 2.6.1
35+
VERSION := 2.7.0
3636
BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S)
3737
#BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
3838

debian/octoscreen.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ExecStart=/usr/bin/xinit /usr/bin/OctoScreen -- :0 -nolisten tcp -nocursor
1111
ExecStartPost=/bin/bash /etc/octoscreen/disablescreenblank.sh 0
1212
StandardOutput=journal
1313
Restart=always
14-
WatchdogSec=10s
14+
WatchdogSec=20s
1515

1616
[Install]
1717
WantedBy=graphical.target

docs/ButtonImages.html

+45
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
body {
55
font-family: Arial, Helvetica, sans-serif;
66
color: white;
7+
background-color: rgb(143, 194, 60);
78
background-color: black;
89
margin: 20px;
910
}
@@ -65,6 +66,23 @@
6566
<img src="../styles/z-bolt/images/extruder.svg" />
6667
<div>extruder</div>
6768

69+
70+
<img src="../styles/z-bolt/images/extruder-typeB.svg" />
71+
<div>extruder-typeB</div>
72+
73+
<img src="../styles/z-bolt/images/extruder-typeB-1.svg" />
74+
<div>extruder-typeB-1</div>
75+
76+
<img src="../styles/z-bolt/images/extruder-typeB-2.svg" />
77+
<div>extruder-typeB-2</div>
78+
79+
<img src="../styles/z-bolt/images/extruder-typeB-3.svg" />
80+
<div>extruder-typeB-3</div>
81+
82+
<img src="../styles/z-bolt/images/extruder-typeB-4.svg" />
83+
<div>extruder-typeB-4</div>
84+
85+
6886
<img src="../styles/z-bolt/images/fan-off.svg" />
6987
<div>fan-off</div>
7088

@@ -83,6 +101,9 @@
83101
<img src="../styles/z-bolt/images/filament-spool.svg" />
84102
<div>filament-spool</div>
85103

104+
<img src="../styles/z-bolt/images/file-gcode.svg" />
105+
<div>file-gcode</div>
106+
86107
<img src="../styles/z-bolt/images/file-stl.svg" />
87108
<div>file-stl</div>
88109

@@ -182,6 +203,9 @@
182203
<img src="../styles/z-bolt/images/nozzle.svg" />
183204
<div>nozzle</div>
184205

206+
<img src="../styles/z-bolt/images/octoprint-tentacle.svg" />
207+
<div>octoprint-tentacle</div>
208+
185209
<img src="../styles/z-bolt/images/open.svg" />
186210
<div>open</div>
187211

@@ -221,6 +245,27 @@
221245
<img src="../styles/z-bolt/images/shutdown.svg" />
222246
<div>shutdown</div>
223247

248+
<img src="../styles/z-bolt/images/speed-0%.svg" />
249+
<div>speed-0%</div>
250+
251+
<img src="../styles/z-bolt/images/speed-17%.svg" />
252+
<div>speed-17%</div>
253+
254+
<img src="../styles/z-bolt/images/speed-34%.svg" />
255+
<div>speed-34%</div>
256+
257+
<img src="../styles/z-bolt/images/speed-50%.svg" />
258+
<div>speed-50%</div>
259+
260+
<img src="../styles/z-bolt/images/speed-67%.svg" />
261+
<div>speed-67%</div>
262+
263+
<img src="../styles/z-bolt/images/speed-83%.svg" />
264+
<div>speed-83%</div>
265+
266+
<img src="../styles/z-bolt/images/speed-100%.svg" />
267+
<div>speed-100%</div>
268+
224269
<img src="../styles/z-bolt/images/speed-fast.svg" />
225270
<div>speed-fast</div>
226271

interfaces/ITemperatureDataDisplay.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package interfaces
22

33
import (
4-
"github.com/mcuadros/go-octoprint"
4+
// "github.com/Z-Bolt/OctoScreen/octoprintApis"
5+
"github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
56
)
67

78
type ITemperatureDataDisplay interface {
8-
UpdateTemperatureData(temperatureData map[string]octoprint.TemperatureData)
9+
UpdateTemperatureData(temperatureData map[string]dataModels.TemperatureData)
910
}

logger/contextHook.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package logger
2+
3+
import (
4+
// "io"
5+
// "os"
6+
"path"
7+
"runtime"
8+
"strings"
9+
// "time"
10+
11+
"github.com/sirupsen/logrus"
12+
)
13+
14+
15+
type ContextHook struct{}
16+
17+
func (hook ContextHook) Levels() []logrus.Level {
18+
return logrus.AllLevels
19+
}
20+
21+
func (hook ContextHook) Fire(entry *logrus.Entry) error {
22+
pc := make([]uintptr, 3, 3)
23+
cnt := runtime.Callers(6, pc)
24+
25+
for i := 0; i < cnt; i++ {
26+
fu := runtime.FuncForPC(pc[i] - 1)
27+
name := fu.Name()
28+
if !strings.Contains(strings.ToLower(name), "github.com/sirupsen/logrus") {
29+
file, line := fu.FileLine(pc[i] - 1)
30+
entry.Data["file"] = path.Base(file)
31+
entry.Data["func"] = path.Base(name)
32+
entry.Data["line"] = line
33+
break
34+
}
35+
}
36+
37+
return nil
38+
}

logger/logger.go

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
package logger
2+
3+
import (
4+
"fmt"
5+
"io"
6+
standardLog "log"
7+
"os"
8+
// "path"
9+
// "runtime"
10+
"strings"
11+
"sync"
12+
// "time"
13+
14+
"github.com/sirupsen/logrus"
15+
)
16+
17+
18+
var _mutex *sync.RWMutex = nil
19+
var _indentLevel int = -1
20+
var _indentation string = ""
21+
const INDENTATION_TOKEN = " "
22+
const INDENTATION_TOKEN_LENGTH = 4
23+
24+
var _logrusLogger *logrus.Logger
25+
var _logrusEntry *logrus.Entry
26+
var _logLevel logrus.Level
27+
var _strLogLevel string
28+
29+
30+
func init() {
31+
_mutex = &sync.RWMutex {}
32+
33+
_indentLevel = 0
34+
_indentation = ""
35+
36+
_logrusLogger = logrus.New()
37+
_logrusLogger.AddHook(ContextHook{})
38+
39+
//
40+
// TODO: ...(maybe?) it would be nice it this could be made generic,
41+
// but this is getting set in init().
42+
var logFilePath = os.Getenv("OCTOSCREEN_LOG_FILE_PATH")
43+
//
44+
45+
if logFilePath == "" {
46+
standardLog.Print("logger.init() - logFilePath is was not defined. Now using just the standard console output.")
47+
_logrusLogger.Out = os.Stdout
48+
} else {
49+
standardLog.Printf("logger.init() - logFilePath is: %s", logFilePath)
50+
file, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
51+
if err == nil {
52+
standardLog.Printf("logger.init() - OpenFile() succeeded and now setting log.Out to %s", logFilePath)
53+
_logrusLogger.Out = file
54+
55+
_logrusLogger.Out = io.MultiWriter(os.Stdout, file)
56+
logrus.SetOutput(_logrusLogger.Out)
57+
} else {
58+
standardLog.Printf("logger.init() - OpenFile() FAILED! err is: %s", err.Error())
59+
standardLog.Print("Failed to open the log file, defaulting to use the standard console output.")
60+
_logrusLogger.Out = os.Stdout
61+
}
62+
}
63+
64+
_logrusEntry = _logrusLogger.WithFields(logrus.Fields{})
65+
66+
// Start off with the logging level set to debug until we get a chance to read the configuration settings.
67+
SetLogLevel(logrus.DebugLevel)
68+
}
69+
70+
func readIndentation() string {
71+
_mutex.RLock()
72+
var indentation = _indentation
73+
_mutex.RUnlock()
74+
75+
return indentation
76+
}
77+
78+
func writeIndentation(indentation string) {
79+
_mutex.Lock()
80+
_indentation = indentation
81+
_mutex.Unlock()
82+
}
83+
84+
85+
func SetLogLevel(newLevel logrus.Level) {
86+
_logLevel = newLevel
87+
_strLogLevel = strings.ToLower(_logLevel.String())
88+
89+
_logrusLogger.SetLevel(_logLevel)
90+
standardLog.Printf("logger.SetLogLevel() - the log level is now set to: %s", _strLogLevel)
91+
}
92+
93+
func LogLevel() string {
94+
// Returns a lower case string.
95+
return _strLogLevel
96+
}
97+
98+
99+
func TraceEnter(functionName string) {
100+
message := fmt.Sprintf("%sentering %s", readIndentation(), functionName)
101+
_logrusEntry.Debug(message)
102+
_indentLevel++
103+
indentation := readIndentation() + INDENTATION_TOKEN
104+
writeIndentation(indentation)
105+
}
106+
107+
func TraceLeave(functionName string) {
108+
_indentLevel--
109+
110+
indentation := readIndentation()
111+
indentation = indentation[:(_indentLevel * INDENTATION_TOKEN_LENGTH)]
112+
writeIndentation(indentation)
113+
114+
message := fmt.Sprintf("%sleaving %s", readIndentation(), functionName)
115+
_logrusEntry.Debug(message)
116+
}
117+
118+
119+
func LogError(currentFunctionName, functionCalledName string, err error) {
120+
if err != nil {
121+
_logrusEntry.Errorf("%s%s - %s returned an error: %q", readIndentation(), currentFunctionName, functionCalledName, err)
122+
} else {
123+
_logrusEntry.Errorf("%s%s - %s returned an error", readIndentation(), currentFunctionName, functionCalledName)
124+
}
125+
}
126+
127+
func LogFatalError(currentFunctionName, functionCalledName string, err error) {
128+
if err != nil {
129+
_logrusEntry.Fatalf("%s%s - %s returned an error: %q", readIndentation(), currentFunctionName, functionCalledName, err)
130+
} else {
131+
_logrusEntry.Fatalf("%s%s - %s returned an error", readIndentation(), currentFunctionName, functionCalledName)
132+
}
133+
}
134+
135+
136+
func Debug(args ...interface{}) {
137+
_logrusEntry.Debug(readIndentation() + fmt.Sprint(args...))
138+
}
139+
140+
func Debugf(format string, args ...interface{}) {
141+
_logrusEntry.Debugf(readIndentation() + format, args...)
142+
}
143+
144+
145+
func Info(args ...interface{}) {
146+
_logrusEntry.Info(readIndentation() + fmt.Sprint(args...))
147+
}
148+
149+
func Infof(format string, args ...interface{}) {
150+
_logrusEntry.Infof(readIndentation() + format, args...)
151+
}
152+
153+
154+
func Warn(args ...interface{}) {
155+
_logrusEntry.Warn(readIndentation() + fmt.Sprint(args...))
156+
}
157+
158+
func Warnf(format string, args ...interface{}) {
159+
_logrusEntry.Warnf(readIndentation() + format, args...)
160+
}
161+
162+
163+
func Error(args ...interface{}) {
164+
_logrusEntry.Error(readIndentation() + fmt.Sprint(args...))
165+
}
166+
167+
func Errorf(format string, args ...interface{}) {
168+
_logrusEntry.Errorf(readIndentation() + format, args...)
169+
}
170+
171+
172+
func Fatal(args ...interface{}) {
173+
_logrusEntry.Fatal(readIndentation() + fmt.Sprint(args...))
174+
}
175+
176+
func Fatalf(format string, args ...interface{}) {
177+
_logrusEntry.Fatalf(readIndentation() + format, args...)
178+
}
179+
180+
func Panic(args ...interface{}) {
181+
_logrusEntry.Panic(readIndentation() + fmt.Sprint(args...))
182+
}
183+
184+
func Panicf(format string, args ...interface{}) {
185+
_logrusEntry.Panicf(readIndentation() + format, args...)
186+
}

0 commit comments

Comments
 (0)