Skip to content

Commit

Permalink
Merge pull request #198 from Z-Bolt/2.6.1-dev
Browse files Browse the repository at this point in the history
2.6.1 release
  • Loading branch information
JeffB42 authored Jan 2, 2021
2 parents db28333 + 72318f2 commit 7ef3c02
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ JESSIE_GO_TAGS := gtk_3_14

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

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ There are two ways to install OctoScreen: the recommended and supported way is t

For example, to install on a new RaspberryPi with OctoPi:
```sh
wget https://github.com/Z-Bolt/OctoScreen/releases/download/2.6.0/octoscreen_2.6.0_armhf.deb
sudo dpkg -i octoscreen_2.6-0_armhf.deb
wget https://github.com/Z-Bolt/OctoScreen/releases/download/2.6.1/octoscreen_2.6.1_armhf.deb
sudo dpkg -i octoscreen_2.6.1_armhf.deb
```

Or to update an existing version of OctoScreen:
```sh
wget https://github.com/Z-Bolt/OctoScreen/releases/download/2.6.0/octoscreen_2.6.0_armhf.deb
wget https://github.com/Z-Bolt/OctoScreen/releases/download/2.6.1/octoscreen_2.6.1_armhf.deb
sudo dpkg -r octoscreen
sudo dpkg -i octoscreen_2.6.0_armhf.deb
sudo dpkg -i octoscreen_2.6.1_armhf.deb
sudo reboot now
```

Expand Down Expand Up @@ -138,14 +138,14 @@ The basic configuration is handled via environment variables, if you are using t

- `OCTOPRINT_HOST` - The URL to the OctoPrint server. Example: `http://octopi.local` or `http://localhost:5000`. Note: the protocol (`http://` or `https://`) is required. If the setting for `OCTOPRINT_HOST` does not contain the protocol, an error will be displayed when OctoScreen starts.

- `OCTOPRINT_APIKEY` - OctoScreen expects an [API key]( http://docs.octoprint.org/en/master/api/general.html) to be supplied. This API key can be either the globally configured key, or a user-specific one if “Access Control” is enabled.
- `OCTOPRINT_APIKEY` - OctoScreen expects an [API key]( http://docs.octoprint.org/en/master/api/general.html) to be supplied. The API key can either be set in OctoScreen's config file, or in OctoPrint's config file (OCTOPRINT_CONFIG_FILE below)

- `OCTOSCREEN_STYLE_PATH` - Several themes are supported, and style configurations can be done through CSS. This variable defines the location of the application theme.


#### Optional Configuration Settings

- `OCTOPRINT_CONFIG_FILE` - The location of the OctoPrint's config.yaml file. If empty, the file path used will be the `pi` home folder of the current user.
- `OCTOPRINT_CONFIG_FILE` - The location of OctoPrint's config.yaml file. If empty, the file path used will be the `pi` home folder of the current user. The OCTOPRINT_APIKEY is required, and if it isn't defined in OctoScreen's config file (see OCTOPRINT_APIKEY above) it needs to be defined in OctoPrint's config file.

- `OCTOSCREEN_LOG_FILE_PATH` - The file path to where the log file will be saved. The file path should be a fully qualified path and not only include the path to the log file, but the name of the log file as well (eg `/home/pi/logs/logfile.txt`). The log file is appended to and is never automatically truncated, and will grow over time. If you turn log file logging on (by specifying a path), be sure to turn it off (by setting the value to "").

Expand Down
51 changes: 34 additions & 17 deletions debian/local/octoscreen/config
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
# Required Configuration Settings

# Location of the OctoPrint's config.yaml file. If empty the file will
# be search at the `pi` home folder or the current user. Only used for locally
# installed OctoPrint servers.
OCTOPRINT_CONFIG_FILE=/home/pi/.octoprint/config.yaml

# OctoPrint HTTP address, example `http://localhost:5000`, if OctoPrint is
# locally installed will be read from the config file.
# The URL to the OctoPrint server.
# Example: http://octopi.local or http://localhost:5000.
# Note: the protocol (http:// or https://) is required.
# If the setting for OCTOPRINT_HOST does not contain the protocol,
# an error will be displayed when OctoScreen starts.
OCTOPRINT_HOST=http://localhost:5000

# OctoScreen expects an API key to be supplied. This API key can be either
# the globally configured one or a user specific one if “Access Control”.
# http://docs.octoprint.org/en/master/api/general.html, if OctoPrint is
# locally installed will be read from the config file.

# OctoScreen expects an API key to be supplied. The API key can
# either be set in OctoScreen's config file, or in OctoPrint's config
# file (OCTOPRINT_CONFIG_FILE below)
OCTOPRINT_APIKEY=


# Location of the application theme
OCTOSCREEN_STYLE_PATH=/opt/octoscreen/styles/z-bolt/



# Optional Configuration Settings

# Location of file for logging (optional)
OCTOSCREEN_LOG_LEVEL=Warn
# The location of OctoPrint's config.yaml file.
# If empty, the file path used will be the pi home folder of the current user.
# The OCTOPRINT_APIKEY is required, and if it isn't defined in OctoScreen's
# config file (see OCTOPRINT_APIKEY above), it needs to be defined in OctoPrint's
# config file.
OCTOPRINT_CONFIG_FILE=/home/pi/.octoprint/config.yaml

# Location of file for logging (optional)
OCTOSCREEN_LOG_FILE_PATH=logs/logfile.txt

# Location of the application theme (optional)
OCTOSCREEN_STYLE_PATH=/opt/octoscreen/styles/z-bolt/
# The file path to where the log file will be saved.
# The file path should be a fully qualified path and not only include the path
# to the log file, but the name of the log file as well
# (eg /home/pi/logs/logfile.txt).
# The log file is appended to and is never automatically truncated, and
# will grow over time. If you turn log file logging on (by specifying a path),
# be sure to turn it off (by setting the value to "").
OCTOSCREEN_LOG_FILE_PATH=
#OCTOSCREEN_LOG_FILE_PATH=/home/pi/logs/logfile.txt


# Controls the level of logging.
# Accepted values are (with increasing levels): debug, info, warn, and error.
OCTOSCREEN_LOG_LEVEL=Error


# Resolution of the application, and should be configured to the resolution of your
# screen, for example 800x480.
Expand Down
49 changes: 30 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,56 @@ var (
)

func main() {
utils.Logger.Debug("entering main.main()")
utils.Logger.Debug("OctoScreen - entering main.main()")

gtk.Init(nil)
settings, _ := gtk.SettingsGetDefault()
settings.SetProperty("gtk-application-prefer-dark-theme", true)

utils.DumpEnvironmentVariables()

if utils.RequiredEnvironmentVariablesAreSet() {
if utils.RequiredEnvironmentVariablesAreSet(APIKey) {
width, height := getSize()
// width and height come from EnvResolution/OCTOSCREEN_RESOLUTION
// and aren't required - if not set, ui.New() will use the default
// values (defined in globalVars.go).
_ = ui.New(BaseURL, APIKey, width, height)
} else {
fatalErrorWindow := ui.CreateFatalErrorWindow("Required environment variable is not set:", utils.NameOfMissingRequiredEnvironmentVariable())
fatalErrorWindow := ui.CreateFatalErrorWindow("Required environment variable is not set:", utils.NameOfMissingRequiredEnvironmentVariable(APIKey))
fatalErrorWindow.ShowAll()
}

gtk.Main()

utils.Logger.Debug("leaving main.main()")
utils.Logger.Debug("OctoScreen - leaving main.main()")
}


func init() {
utils.Logger.Debug("entering main.init()")
utils.Logger.Debug("OctoScreen - entering main.init()")

if !utils.RequiredEnvironmentVariablesAreSet() {
utils.Logger.Error("main.init() - RequiredEnvironmentVariablesAreSet() returned false")
ConfigFile = os.Getenv(utils.EnvConfigFile)
if ConfigFile == "" {
ConfigFile = findConfigFile()
}

cfg := readConfig(ConfigFile)
setApiKey(cfg)

if !utils.RequiredEnvironmentVariablesAreSet(APIKey) {
utils.Logger.Error("OctoScreen - main.init() - RequiredEnvironmentVariablesAreSet() returned false")

utils.Logger.Debug("leaving main.init()")
utils.Logger.Debug("OctoScreen - leaving main.init()")
return
}

setLogLevel()

utils.StylePath = os.Getenv(utils.EnvStylePath)
Resolution = os.Getenv(utils.EnvResolution)
ConfigFile = os.Getenv(utils.EnvConfigFile)
if ConfigFile == "" {
ConfigFile = findConfigFile()
}

cfg := readConfig(ConfigFile)
setBaseUrl(cfg)
setApiKey(cfg)

utils.Logger.Debug("leaving main.init()")
utils.Logger.Debug("OctoScreen - leaving main.init()")
}

func setLogLevel() {
Expand Down Expand Up @@ -124,13 +125,23 @@ func setBaseUrl(cfg *config) {
}

func setApiKey(cfg *config) {
utils.Logger.Debug("OctoScreen - entering main.setApiKey()")

APIKey = os.Getenv(utils.EnvAPIKey)
if APIKey == "" {
utils.Logger.Debug("main.setApiKey() - APIKey is empty, now using cfg.API.Key")

APIKey = cfg.API.Key
if cfg.API.Key != "" {
utils.Logger.Infof("main.setApiKey() - found API key in file %q", ConfigFile)
}
}

if APIKey == "" {
utils.Logger.Debug("main.setApiKey() - APIKey is empty!")
} else {
obfuscatedApiKey := utils.GetObfuscatedValue(APIKey)
utils.Logger.Debugf("main.setApiKey() - APIKey is %q", obfuscatedApiKey)
}

utils.Logger.Debug("OctoScreen - leaving main.setApiKey()")
}


Expand Down
2 changes: 1 addition & 1 deletion ui/CommonPanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// OctoScreenVersion - set at compilation time.
var OctoScreenVersion = "2.6.0"
var OctoScreenVersion = "2.6.1"

type CommonPanel struct {
UI *UI
Expand Down
2 changes: 1 addition & 1 deletion ui/IdleStatusPanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (this *idleStatusPanel) initialize() {
utils.Logger.Info(this.UI.Settings)

var menuItems []octoprint.MenuItem
if this.UI.Settings == nil || len(this.UI.Settings.MenuStructure) == 0 {
if this.UI.Settings == nil || this.UI.Settings.MenuStructure == nil || len(this.UI.Settings.MenuStructure) < 1 {
utils.Logger.Info("Loading default menu")
this.UI.Settings.MenuStructure = getDefaultMenuItems(this.UI.Client)
} else {
Expand Down
54 changes: 41 additions & 13 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (this *UI) verifyConnection() {
utils.LogError("ui.verifyConnection()", "s.Current.State is IsOffline, and (ConnectRequest)Do(UI.Client)", err)
splashMessage = "Loading..."
} else {
// Use 'Offline' here and 'offline' later. Having different variations may help in
// Use 'Offline.' here and 'offline!' later. Having different variations may help in
// troubleshooting any issues around this state.
splashMessage = "Printer is Offline."
}
Expand Down Expand Up @@ -212,14 +212,14 @@ func (this *UI) verifyConnection() {

if strings.Contains(strings.ToLower(errMessage), "deadline exceeded") {
// Use 'offline' here, but no ending period.
splashMessage = "Printer is offline"
splashMessage = "Printer is OFFLINE"
} else {
splashMessage = errMessage
}
} else {
// Use 'offline.' here and 'offline' above. Having different variations may help in
// Use 'offline!' here and 'OFFLINE' above. Having different variations may help in
// troubleshooting any issues around this state.
splashMessage = "Printer is offline."
splashMessage = "Printer is offline!"
}
}

Expand Down Expand Up @@ -264,15 +264,15 @@ func (this *UI) verifyConnection() {
func (this *UI) checkNotification() {
utils.Logger.Debug("entering ui.checkNotification()")

if !this.OctoPrintPluginIsAvailable {
utils.Logger.Info("ui.checkNotification() - OctoPrintPluginIsAvailable is false, so not calling GetNotification")
utils.Logger.Debug("leaving ui.checkNotification()")
return
}

notificationRespone, err := (&octoprint.GetNotificationRequest{}).Do(this.Client)
if err != nil {
text := err.Error()
if strings.Contains(strings.ToLower(text), "unexpected status code: 404") {
this.OctoPrintPluginIsAvailable = false
}

utils.LogError("ui.checkNotification()", "Do(GetNotificationRequest)", err)

utils.Logger.Debug("leaving ui.checkNotification()")
return
}
Expand All @@ -289,9 +289,22 @@ func (this *UI) loadSettings() {

settingsResponse, err := (&octoprint.GetSettingsRequest{}).Do(this.Client)
if err != nil {
utils.LogError("ui.loadSettings()", "Do(GetSettingsRequest)", err)
utils.Logger.Error("leaving ui.loadSettings() - Do(GetSettingsRequest) returned an error")
text := err.Error()
if strings.Contains(strings.ToLower(text), "unexpected status code: 404") {
// The call to GetSettings is also used to determine whether or not the
// OctoScreen plug-in is available. If calling GetSettings returns
// a 404, the plug-in isn't available.
this.OctoPrintPluginIsAvailable = false
utils.Logger.Info("The OctoPrint plug-in is not available")
} else {
// If we get back any other kind of error, something bad happened, so log an error.
utils.LogError("ui.loadSettings()", "Do(GetSettingsRequest)", err)
}

utils.Logger.Debug("leaving ui.loadSettings()")
return
} else {
utils.Logger.Info("The call to GetSettings succeeded and the OctoPrint plug-in is available")
}

if !this.validateMenuItems(settingsResponse.MenuStructure, "", true) {
Expand Down Expand Up @@ -364,9 +377,24 @@ func (this *UI) update() {
this.connectionAttempts = 0
}

if this.Settings == nil {
this.loadSettings()

if this.Settings == nil {
this.Settings = &octoprint.GetSettingsResponse {
FilamentInLength: 750.0,
FilamentOutLength: 800.0,
ToolChanger: false,
XAxisInverted: false,
YAxisInverted: false,
ZAxisInverted: false,
MenuStructure: nil,
}
}
}

if this.OctoPrintPluginIsAvailable {
this.checkNotification()
this.loadSettings()
}

this.verifyConnection()
Expand Down
2 changes: 1 addition & 1 deletion uiWidgets/SystemInformationInfoBox.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func createStyledLabel() *gtk.Label {
func (this *SystemInformationInfoBox) refreshMemoryLabel() {
virtualMemoryStat, _ := mem.VirtualMemory()
memoryString := fmt.Sprintf(
"Virtual memory: %s (free) / %s (total)",
"Memory: %s (free) / %s (total)",
humanize.Bytes(virtualMemoryStat.Free),
humanize.Bytes(virtualMemoryStat.Total),
)
Expand Down
8 changes: 5 additions & 3 deletions uiWidgets/TemperatureStatusBox.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ func CreateTemperatureStatusBox(
hotendIndex++

if includeHotends {
strImageFileName := utils.GetNozzleFileName(hotendIndex, hotendCount)
instance.labelWithImages[key] = utils.MustLabelWithImage(strImageFileName, "")
instance.Add(instance.labelWithImages[key])
if hotendIndex <= hotendCount {
strImageFileName := utils.GetNozzleFileName(hotendIndex, hotendCount)
instance.labelWithImages[key] = utils.MustLabelWithImage(strImageFileName, "")
instance.Add(instance.labelWithImages[key])
}
}
}
}
Expand Down
Loading

0 comments on commit 7ef3c02

Please sign in to comment.