Skip to content
This repository has been archived by the owner on Nov 24, 2019. It is now read-only.

Как собрать? #70

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
debian/changelog
pkg/
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORKDIR := $(shell pwd)
BUILD_PATH := $(WORKDIR)/build
DOCKER_IMAGE_BUILD = mcuadros/octoprint-tft-build

DEBIAN_PACKAGES = JESSIE STRETCH
DEBIAN_PACKAGES = STRETCH
STRETCH_NAME := stretch
STRETCH_IMAGE := golang:1.9-stretch
STRETCH_GO_TAGS := gtk_3_22
Expand All @@ -26,15 +26,15 @@ JESSIE_GO_TAGS := gtk_3_14


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

ifneq ($(BRANCH), master)
VERSION := $(shell echo $(BRANCH)| sed -e 's/v//g')
endif
#ifneq ($(BRANCH), master)
# VERSION := $(shell echo $(BRANCH)| sed -e 's/v//g')
#endif

# Package information
PACKAGE_NAME = octoprint-tft
Expand Down Expand Up @@ -66,7 +66,7 @@ build-internal: prepare-internal
cp ../*.deb /build/;

prepare-internal:
dch --create -v $(VERSION)-1 --package $(PACKAGE_NAME) empty; \
dch --create -v $(VERSION) --package $(PACKAGE_NAME) empty; \
cd $(WORKDIR)/..; \
tar -czf octoprint-tft_$(VERSION).orig.tar.gz --exclude-vcs OctoPrint-TFT

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OctoPrint-TFT [![GitHub release](https://img.shields.io/github/release/mcuadros/OctoPrint-TFT.svg)](https://github.com/mcuadros/OctoPrint-TFT/releases) [![license](https://img.shields.io/github/license/mcuadros/OctoPrint-TFT.svg)]()
OctoPrint-TFT [![GitHub release](https://img.shields.io/github/release/Z-Bolt/OctoPrint-TFT.svg)](https://github.com/Z-Bolt/OctoPrint-TFT/releases) [![license](https://img.shields.io/github/license/Z-Bolt/OctoPrint-TFT.svg)]()
=============

_OctoPrint-TFT_, a touch interface for TFT touch modules based on GTK+3.
Expand Down
10 changes: 10 additions & 0 deletions debian/local/disablescreenblank.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

screen=${1:-0}

# wait 10s for the display manager service to start and attach to screen
sleep 10

/usr/bin/xset -display :$screen s off # deactivate screen saver
/usr/bin/xset -display :$screen -dpms # disable DPMS
/usr/bin/xset -display :$screen s noblank # disable screen blanking
3 changes: 3 additions & 0 deletions debian/local/octoprint-tft-environment
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ OCTOPRINT_TFT_STYLE_PATH=/opt/octoprint-tft/styles/default/
# Resolution of the application, should be configured to the resolution of your
# screen, for example 800x480. By default 480x320.
OCTOPRINT_TFT_RESOLUTION=

# Location of file for logging (Optional)
OCTOPRINT_TFT_LOG_FILE=
1 change: 1 addition & 0 deletions debian/octoprint-tft.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
debian/local/octoprint-tft-environment etc
debian/local/insserv.conf.d etc
debian/local/disablescreenblank.sh etc
1 change: 1 addition & 0 deletions debian/octoprint-tft.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then
echo "Display manager service is masked" >&2
elif [ -e "$SERVICE" ]; then
ln -sf "$SERVICE" "$DEFAULT_SERVICE"
chmod +x /etc/disablescreenblank.sh
else
echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2
rm -f "$DEFAULT_SERVICE"
Expand Down
7 changes: 4 additions & 3 deletions debian/octoprint-tft.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ [email protected]
After=systemd-user-sessions.service [email protected] plymouth-quit.service

[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=/etc/octoprint-tft-environment
ExecStart=/usr/bin/xinit /usr/bin/OctoPrint-TFT -- :0 -nolisten tcp -nocursor
ExecStartPost=/etc/disablescreenblank.sh 0
StandardOutput=journal
Restart=always
RestartSec=1s
TimeoutStopSec=5s
IgnoreSIGPIPE=no
WatchdogSec=10s

[Install]
WantedBy=graphical.target
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
"strconv"
"strings"

"github.com/mcuadros/OctoPrint-TFT/ui"

"github.com/gotk3/gotk3/gtk"
"github.com/mcuadros/OctoPrint-TFT/ui"
"gopkg.in/yaml.v1"
)

Expand Down Expand Up @@ -61,6 +60,7 @@ func main() {
gtk.Init(nil)

settings, _ := gtk.SettingsGetDefault()

settings.SetProperty("gtk-application-prefer-dark-theme", true)

width, height := getSize()
Expand Down
12 changes: 12 additions & 0 deletions styles/default/images/logo-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions styles/default/images/open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions styles/default/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

.dialog { border: 2px solid black; }

.notification {
Expand All @@ -14,3 +15,47 @@
.error {
background-color:rgba(204, 30, 30, 0.7);
}

scrollbar, scrollbar button {
border: none;
background-color: #000;
}

window {
background-color: #000;
}

scrollbar slider {
/* -GtkScrollbar-has-backward-stepper: true; */
/* -GtkScrollbar-has-forward-stepper: true; */
min-width: 52px;
border-radius: 8px;
}

progress, trough {
min-height: 20px;
}



/* GtkWindow {
background-color: green;
border-width: 3px;
border-color: blue;
} */

/* GtkButton {
background-image: none;
background-color:#1010FF;
margin:2px;
border-radius:0;
} */


/* button, entry {
color: #ff00ea;
font: 12px "Comic Sans";
background-color: #1010FF;
} */


68 changes: 55 additions & 13 deletions ui/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import (
var Version = "0.1.x"
var Build = "no-set"

const panelW = 4
const panelH = 2

type Panel interface {
Grid() *gtk.Grid
Show()
Expand All @@ -27,10 +24,12 @@ type Panel interface {
}

type CommonPanel struct {
UI *UI
g *gtk.Grid
b *BackgroundTask
p Panel
UI *UI
g *gtk.Grid
b *BackgroundTask
p Panel
panelW int
panelH int

buttons []gtk.IWidget
}
Expand All @@ -40,14 +39,14 @@ func NewCommonPanel(ui *UI, parent Panel) CommonPanel {
g.SetRowHomogeneous(true)
g.SetColumnHomogeneous(true)

return CommonPanel{UI: ui, g: g, p: parent}
return CommonPanel{UI: ui, g: g, p: parent, panelW: 4, panelH: 2}
}

func (p *CommonPanel) Initialize() {
last := panelW * panelH
last := p.panelW * p.panelH
if last < len(p.buttons) {
cols := math.Ceil(float64(len(p.buttons)) / float64(panelW))
last = int(cols) * panelW
cols := math.Ceil(float64(len(p.buttons)) / float64(p.panelW))
last = int(cols) * p.panelW
}

for i := len(p.buttons) + 1; i < last; i++ {
Expand All @@ -62,8 +61,8 @@ func (p *CommonPanel) Parent() Panel {
}

func (p *CommonPanel) AddButton(b gtk.IWidget) {
x := len(p.buttons) % panelW
y := len(p.buttons) / panelW
x := len(p.buttons) % p.panelW
y := len(p.buttons) / p.panelW
p.g.Attach(b, x+1, y, 1, 1)
p.buttons = append(p.buttons, b)
}
Expand Down Expand Up @@ -160,6 +159,49 @@ type Step struct {
Value interface{}
}

func MustPressedButton(label, i string, pressed func(), speed time.Duration) *gtk.Button {
img := MustImageFromFile(i)
released := make(chan bool)
var mutex sync.Mutex

b, err := gtk.ButtonNewWithLabel(label)
if err != nil {
panic(err)
}

b.SetImage(img)
b.SetAlwaysShowImage(true)
b.SetImagePosition(gtk.POS_TOP)
b.SetVExpand(true)
b.SetHExpand(true)

if pressed != nil {
b.Connect("pressed", func() {
go func() {
for {
select {
case <-released:
return
default:
mutex.Lock()
pressed()
time.Sleep(speed * time.Millisecond)
mutex.Unlock()
}
}
}()
})
}

if released != nil {
b.Connect("released", func() {
released <- true
})
}

return b
}

func MustStepButton(image string, s ...Step) *StepButton {
var l string
if len(s) != 0 {
Expand Down
7 changes: 4 additions & 3 deletions ui/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ func (m *defaultPanel) initialize() {
m.Grid().Attach(MustButtonImage("Heat Up", "heat-up.svg", m.showTemperature), 2, 0, 1, 1)
m.Grid().Attach(MustButtonImage("Move", "move.svg", m.showMove), 3, 0, 1, 1)
m.Grid().Attach(MustButtonImage("Home", "home.svg", m.showHome), 4, 0, 1, 1)
m.Grid().Attach(MustButtonImage("Filament", "filament.svg", m.showFilament), 1, 1, 1, 1)
m.Grid().Attach(MustButtonImage("Control", "control.svg", m.showControl), 2, 1, 1, 1)
m.Grid().Attach(MustButtonImage("Files", "files.svg", m.showFiles), 3, 1, 1, 1)

m.Grid().Attach(MustButtonImage("Print", "files.svg", m.showFiles), 1, 1, 1, 1)
m.Grid().Attach(MustButtonImage("Filament", "filament.svg", m.showFilament), 2, 1, 1, 1)
m.Grid().Attach(MustButtonImage("Control", "control.svg", m.showControl), 3, 1, 1, 1)
m.Grid().Attach(MustButtonImage("System", "settings.svg", m.showSystem), 4, 1, 1, 1)
}

Expand Down
Loading