From c520248888ed41492d10698859f9ac0c3964483a Mon Sep 17 00:00:00 2001 From: Michiel Wong Baird Date: Tue, 28 Jan 2020 20:40:31 -0800 Subject: [PATCH 1/4] Added a button for the PSU - First pass - Needs to be configurable --- Makefile | 2 + styles/z-bolt/images/psu-off.svg | 62 ++++++++++++++++++++++++++++++ styles/z-bolt/images/psu-off2.svg | 63 +++++++++++++++++++++++++++++++ styles/z-bolt/images/psu-on.svg | 63 +++++++++++++++++++++++++++++++ ui/idle_status.go | 2 +- ui/menu.go | 2 +- ui/splash.go | 12 +++++- ui/system.go | 12 +++++- ui/ui.go | 9 ++--- 9 files changed, 218 insertions(+), 9 deletions(-) create mode 100644 styles/z-bolt/images/psu-off.svg create mode 100644 styles/z-bolt/images/psu-off2.svg create mode 100644 styles/z-bolt/images/psu-on.svg diff --git a/Makefile b/Makefile index 9c4b7423..0561f927 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,8 @@ build-internal: prepare-internal cd $(WORKDIR); \ debuild --prepend-path=/usr/local/go/bin/ --preserve-env -us -uc; \ cp ../*.deb /build/; + cp ./debian/octoscreen/usr/bin/OctoScreen /build/; + prepare-internal: dch --create -v $(VERSION)-1 --package $(PACKAGE_NAME) empty; \ diff --git a/styles/z-bolt/images/psu-off.svg b/styles/z-bolt/images/psu-off.svg new file mode 100644 index 00000000..d8689ef7 --- /dev/null +++ b/styles/z-bolt/images/psu-off.svg @@ -0,0 +1,62 @@ + + + + + +Created by potrace 1.15, written by Peter Selinger 2001-2017 + + + image/svg+xml + + + + + + + + + diff --git a/styles/z-bolt/images/psu-off2.svg b/styles/z-bolt/images/psu-off2.svg new file mode 100644 index 00000000..7879564f --- /dev/null +++ b/styles/z-bolt/images/psu-off2.svg @@ -0,0 +1,63 @@ + + + + + +Created by potrace 1.15, written by Peter Selinger 2001-2017 + + + image/svg+xml + + + + + + + + + diff --git a/styles/z-bolt/images/psu-on.svg b/styles/z-bolt/images/psu-on.svg new file mode 100644 index 00000000..642d4304 --- /dev/null +++ b/styles/z-bolt/images/psu-on.svg @@ -0,0 +1,63 @@ + + + + + +Created by potrace 1.15, written by Peter Selinger 2001-2017 + + + image/svg+xml + + + + + + + + + diff --git a/ui/idle_status.go b/ui/idle_status.go index 1eb68d23..2afe9941 100644 --- a/ui/idle_status.go +++ b/ui/idle_status.go @@ -42,7 +42,7 @@ func (m *idleStatusPanel) initialize() { if m.UI.Settings == nil || len(m.UI.Settings.MenuStructure) == 0 { Logger.Info("Loading default menu") - menuItems = getDeafultMenu() + menuItems = getDefaultMenu() } else { Logger.Info("Loading octo menu") menuItems = m.UI.Settings.MenuStructure diff --git a/ui/menu.go b/ui/menu.go index aa1301f1..d8617e6b 100644 --- a/ui/menu.go +++ b/ui/menu.go @@ -67,7 +67,7 @@ func (m *menuPanel) initialize() { m.arrangeMenuItems(m.g, m.items, 4) } -func getDeafultMenu() []octoprint.MenuItem { +func getDefaultMenu() []octoprint.MenuItem { default_menu := `[ { diff --git a/ui/splash.go b/ui/splash.go index f94f06ae..7aeca159 100644 --- a/ui/splash.go +++ b/ui/splash.go @@ -2,12 +2,14 @@ package ui import ( "github.com/gotk3/gotk3/gtk" + "time" ) type SplashPanel struct { CommonPanel Label *gtk.Label RetryButton *gtk.Button + PSUButton *PSUControl } func NewSplashPanel(ui *UI) *SplashPanel { @@ -23,6 +25,7 @@ func (m *SplashPanel) initialize() { m.Label.SetLineWrap(true) m.Label.SetMaxWidthChars(30) m.Label.SetText("Initializing printer...") + m.b = NewBackgroundTask(time.Second*10, m.update) main := MustBox(gtk.ORIENTATION_VERTICAL, 15) main.SetVAlign(gtk.ALIGN_END) @@ -42,11 +45,14 @@ func (m *SplashPanel) initialize() { func (m *SplashPanel) createActionBar() gtk.IWidget { bar := MustBox(gtk.ORIENTATION_HORIZONTAL, 5) bar.SetHAlign(gtk.ALIGN_END) - + m.PSUButton = PSUControlNew(m.UI, m.UI.Printer) + m.PSUButton.SetProperty("width-request", m.Scaled(100)) + m.PSUButton.SetProperty("visible", true) m.RetryButton = MustButtonImageStyle("Retry", "refresh.svg", "color2", m.releaseFromHold) m.RetryButton.SetProperty("width-request", m.Scaled(100)) m.RetryButton.SetProperty("visible", true) bar.Add(m.RetryButton) + bar.Add(m.PSUButton) ctx, _ := m.RetryButton.GetStyleContext() ctx.AddClass("hidden") @@ -84,3 +90,7 @@ func (m *SplashPanel) showNetwork() { func (m *SplashPanel) showSystem() { m.UI.Add(SystemPanel(m.UI, m)) } + +func (m *SplashPanel) update() { + m.PSUButton.update() +} diff --git a/ui/system.go b/ui/system.go index 2dc94a9e..2732d7e2 100644 --- a/ui/system.go +++ b/ui/system.go @@ -2,6 +2,7 @@ package ui import ( "fmt" + "time" "github.com/dustin/go-humanize" "github.com/gotk3/gotk3/gtk" @@ -16,6 +17,7 @@ type systemPanel struct { CommonPanel list *gtk.Box + psuContol *PSUControl } func SystemPanel(ui *UI, parent Panel) *systemPanel { @@ -36,7 +38,10 @@ func (m *systemPanel) initialize() { m.Grid().Attach(m.createOctoPrintInfo(), 1, 0, 2, 1) m.Grid().Attach(m.createOctoScreenInfo(), 3, 0, 2, 1) - m.Grid().Attach(m.createSystemInfo(), 1, 1, 4, 1) + m.Grid().Attach(m.createSystemInfo(), 1, 1, 3, 1) + m.psuContol = m.addPsuButton() + m.psuContol.update() + m.Grid().Attach(m.psuContol.Button, 4, 1, 1, 1) if b := m.createCommandButton("Octo Restart", "restart", "color2"); b != nil { m.Grid().Attach(b, 3, 2, 1, 1) @@ -49,6 +54,7 @@ func (m *systemPanel) initialize() { if b := m.createCommandButton("Shutdown", "shutdown", "color1"); b != nil { m.Grid().Attach(b, 1, 2, 1, 1) } + m.b = NewBackgroundTask(time.Second*10, m.psuContol.update) } func (m *systemPanel) createOctoPrintInfo() *gtk.Box { @@ -90,6 +96,10 @@ func (m *systemPanel) createOctoScreenInfo() *gtk.Box { return info } +func (m *systemPanel) addPsuButton() *PSUControl { + return PSUControlNew(m.UI, m.UI.Printer) +} + func (m *systemPanel) createSystemInfo() *gtk.Box { info := MustBox(gtk.ORIENTATION_VERTICAL, 0) diff --git a/ui/ui.go b/ui/ui.go index 480a025d..c3b9ccd4 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -135,12 +135,10 @@ func (ui *UI) verifyConnection() { case s.Current.State.IsPrinting(): newUiState = "printing" case s.Current.State.IsError(): - fallthrough + fallthrough //Sigh case s.Current.State.IsOffline(): - if err := (&octoprint.ConnectRequest{}).Do(ui.Printer); err != nil { - newUiState = "splash" - splashMessage = "Loading..." - } + newUiState = "splash" + splashMessage = "Loading..." case s.Current.State.IsConnecting(): splashMessage = string(s.Current.State) } @@ -199,6 +197,7 @@ func (m *UI) loadSettings() { func (m *UI) update() { if m.connectionAttempts > 8 { + m.sdNotify("WATCHDOG=1") m.s.putOnHold() return } else if m.UIState == "splash" { From 238a76063bbf03c026c2e72c230c7e313a4d1fde Mon Sep 17 00:00:00 2001 From: JeffB42 <10328858+JeffB42@users.noreply.github.com> Date: Thu, 30 Jul 2020 20:50:42 -0700 Subject: [PATCH 2/4] changed filename clip length to 20 to prevent going past screen bounds --- ui/print_status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/print_status.go b/ui/print_status.go index 9805d820..36bb3914 100644 --- a/ui/print_status.go +++ b/ui/print_status.go @@ -259,7 +259,7 @@ func (m *printStatusPanel) updateJob() { if s.Job.File.Name != "" { file = s.Job.File.Name file = strings.Replace(file, ".gcode", "", -1) - file = strEllipsisLen(file, 35) + file = strEllipsisLen(file, 20) } m.file.Label.SetLabel(file) From 7d0fc084752d29b8c545b85d90e6e83637bd021e Mon Sep 17 00:00:00 2001 From: JeffB42 <10328858+JeffB42@users.noreply.github.com> Date: Thu, 30 Jul 2020 20:58:13 -0700 Subject: [PATCH 3/4] fixed typo, renamed getDeafultMenu to getDefaultMenu --- ui/idle_status.go | 18 ++++++++---------- ui/menu.go | 3 +-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ui/idle_status.go b/ui/idle_status.go index 1eb68d23..564d645c 100644 --- a/ui/idle_status.go +++ b/ui/idle_status.go @@ -42,7 +42,7 @@ func (m *idleStatusPanel) initialize() { if m.UI.Settings == nil || len(m.UI.Settings.MenuStructure) == 0 { Logger.Info("Loading default menu") - menuItems = getDeafultMenu() + menuItems = getDefaultMenu() } else { Logger.Info("Loading octo menu") menuItems = m.UI.Settings.MenuStructure @@ -82,29 +82,28 @@ func (m *idleStatusPanel) showTools() { g := MustGrid() g.SetRowHomogeneous(true) g.SetColumnHomogeneous(true) - m.Grid().Attach(g, 1, 0, 2, 3) - - g.Attach(m.tool0, 1, 0, 2, 1) - g.Attach(m.bed, 1, 1, 2, 1) + g.Attach(m.tool0, 1, 0, 2, 1) + g.Attach(m.bed, 1, 1, 2, 1) case 2: m.Grid().Attach(m.tool0, 1, 0, 2, 1) m.Grid().Attach(m.tool1, 1, 1, 2, 1) - m.Grid().Attach(m.bed, 1, 2, 2, 1) + m.Grid().Attach(m.bed, 1, 2, 2, 1) + case 3: m.Grid().Attach(m.tool0, 1, 0, 1, 1) m.Grid().Attach(m.tool1, 2, 0, 1, 1) m.Grid().Attach(m.tool2, 1, 1, 2, 1) - m.Grid().Attach(m.bed, 1, 2, 2, 1) + m.Grid().Attach(m.bed, 1, 2, 2, 1) + case 4: m.Grid().Attach(m.tool0, 1, 0, 1, 1) m.Grid().Attach(m.tool1, 2, 0, 1, 1) m.Grid().Attach(m.tool2, 1, 1, 1, 1) m.Grid().Attach(m.tool3, 2, 1, 1, 1) - m.Grid().Attach(m.bed, 1, 2, 2, 1) + m.Grid().Attach(m.bed, 1, 2, 2, 1) } - } func (m *idleStatusPanel) updateTemperature() { @@ -159,7 +158,6 @@ type ToolHeatup struct { } func ToolHeatupNew(num int, printer *octoprint.Client) *ToolHeatup { - var ( image string tool string diff --git a/ui/menu.go b/ui/menu.go index aa1301f1..8645cccd 100644 --- a/ui/menu.go +++ b/ui/menu.go @@ -67,8 +67,7 @@ func (m *menuPanel) initialize() { m.arrangeMenuItems(m.g, m.items, 4) } -func getDeafultMenu() []octoprint.MenuItem { - +func getDefaultMenu() []octoprint.MenuItem { default_menu := `[ { "name": "Home", From 19c0275e1183ba10b6a2d6fbd9e50c2318a909fe Mon Sep 17 00:00:00 2001 From: Hypertoken Date: Mon, 3 Aug 2020 22:10:12 -0700 Subject: [PATCH 4/4] updated to my repy --- README.md | 10 +++++----- debian/control | 2 +- debian/copyright | 2 +- debian/watch | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 28eecd99..e37d31d1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OctoScreen [![GitHub release](https://img.shields.io/github/release/boardthatpowder/OctoScreen.svg)](https://github.com/boardthatpowder/OctoScreen/releases) [![license](https://img.shields.io/github/license/boardthatpowder/OctoScreen.svg)]() +# OctoScreen [![GitHub release](https://img.shields.io/github/release/boardthatpowder/OctoScreen.svg)](https://github.com/Hypertoken/OctoScreen/releases) [![license](https://img.shields.io/github/license/boardthatpowder/OctoScreen.svg)]() _OctoScreen_, LCD touch interface for our Octoprint based on GTK+3, that allows you to control your 3D Printer, like you can do with any [LCD panel](http://reprap.org/wiki/RepRapTouch), but using _OctoPrint_ and a Raspberry Pi. It's a _X application_ to be executed directly in the X Server without any windows manager or browser, as _frontend of a [OctoPrint](http://octoprint.org) server_ in a Raspberry Pi @@ -36,7 +36,7 @@ resources. This is the main reason because I develop this X application to be executed in my 3d printer. -## [Roadmap](https://github.com/boardthatpowder/OctoScreen/projects/2) +## [Roadmap](https://github.com/Hypertoken/OctoScreen/projects/2) Installation ------------ @@ -61,12 +61,12 @@ Also you may need to install video drive, usually **no screens found** error ind ### Install from .deb package The recommended way to install *OctoScreen* is use the `.deb` packages -from the [Releases](https://github.com/boardthatpowder/OctoScreen/releases) page. The packages +from the [Releases](https://github.com/Hypertoken/OctoScreen/releases) page. The packages are available for Debian Stretch based distributions such as Raspbian and OctoPi. For example for a Raspbian Stretch: ```sh -wget https://github.com/boardthatpowder/OctoScreen/releases/download/v2.5.1/octoscreen_2.5-1_armhf.deb +wget https://github.com/Hypertoken/OctoScreen/releases/download/v2.5.1/octoscreen_2.5-1_armhf.deb sudo dpkg -i octoscreen_2.5-1_armhf.deb ``` @@ -116,7 +116,7 @@ the `.deb` package you can configure it at `/etc/octoscreen/config`. - `OCTOSCREEN_RESOLUTION` - Resolution of the application, should be configured to the resolution of your screen. Optimal resolution for OctoScreen is no less than 800x480, so if the physical resolution of your screen is 480x320, it's recommended to set the software resolution 800x533. If you are using Raspbian you can do it by changing [`hdmi_cvt`](https://www.raspberrypi.org/documentation/configuration/config-txt/video.md) param in `/boot/config.txt` file. -### [Menu Configuration](https://github.com/boardthatpowder/OctoScreen/blob/master/docs/README.md) +### [Menu Configuration](https://github.com/Hypertoken/OctoScreen/blob/master/docs/README.md) ### Custom controls and commands diff --git a/debian/control b/debian/control index b67a38e3..3059d1cc 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Build-Depends: debhelper (>= 9), libcairo2-dev (>= 1.14.0), libgtk-3-dev (>= 3.14) Standards-Version: 4.1.1 -Homepage: https://github.com/boardthatpowder/OctoScreen +Homepage: https://github.com/Hypertoken/OctoScreen Vcs-Browser: https://anonscm.debian.org/cgit/pkg-go/packages/octoscreen.git Vcs-Git: https://anonscm.debian.org/git/pkg-go/packages/octoscreen.git XS-Go-Import-Path: github.com/boardthatpowder/OctoScreen diff --git a/debian/copyright b/debian/copyright index 49e385f7..f4de2f1e 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,6 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: OctoScreen -Source: https://github.com/boardthatpowder/OctoScreen +Source: https://github.com/Hypertoken/OctoScreen Files: * Copyright: 2017 Máximo Cuadros diff --git a/debian/watch b/debian/watch index 3683c30f..b5fb418d 100644 --- a/debian/watch +++ b/debian/watch @@ -1,4 +1,4 @@ version=3 opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/octoscreen-\$1\.tar\.gz/,\ uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/ \ - https://github.com/boardthatpowder/OctoScreen/tags .*/v?(\d\S*)\.tar\.gz + https://github.com/Hypertoken/OctoScreen/tags .*/v?(\d\S*)\.tar\.gz