Skip to content

Commit 5c7cb4f

Browse files
authored
Merge pull request #290 from Z-Bolt/2.7.2-dev
2.7.2-dev into master
2 parents 1cf8a70 + ecfc324 commit 5c7cb4f

Some content is hidden

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

49 files changed

+203
-117
lines changed

Makefile

+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.7.1
35+
VERSION := 2.7.2
3636
BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S)
3737
#BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
3838

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ There are two ways to install OctoScreen: the recommended and supported way is t
8383

8484
For example, to install on a new RaspberryPi with OctoPi:
8585
```sh
86-
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.1/octoscreen_2.7.1_armhf.deb
87-
sudo dpkg -i octoscreen_2.7.1_armhf.deb
86+
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.2/octoscreen_2.7.2_armhf.deb
87+
sudo dpkg -i octoscreen_2.7.2_armhf.deb
8888
```
8989

9090
Or to update an existing version of OctoScreen:
9191
```sh
92-
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.1/octoscreen_2.7.1_armhf.deb
92+
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.2/octoscreen_2.7.2_armhf.deb
9393
sudo dpkg -r octoscreen
94-
sudo dpkg -i octoscreen_2.7.1_armhf.deb
94+
sudo dpkg -i octoscreen_2.7.2_armhf.deb
9595
sudo reboot now
9696
```
9797

@@ -153,6 +153,7 @@ The basic configuration is handled via environment variables, if you are using t
153153

154154
- `OCTOSCREEN_RESOLUTION` - Resolution of the application, and 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. Please see [Setting Up OctoScreen and Your Display](https://github.com/Z-Bolt/OctoScreen/wiki/Setting-Up-OctoScreen-and-Your-Display) and [Installing OctoScreen with a 3.5" 480x320 TFT screen](https://github.com/Z-Bolt/OctoScreen/wiki/Installing-OctoScreen-with-a-3.5%22-480x320-TFT-screen) for more information.
155155

156+
- `DISPLAY_CURSOR` - To display the cursor, add `DISPLAY_CURSOR=true` to your config file. In order to display the cursor, you will also need to edit `/lib/systemd/system/octoscreen.service` and remove `-nocursor`
156157

157158

158159

debian/local/octoscreen/config

+5
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ OCTOSCREEN_LOG_LEVEL=Error
5050
OCTOSCREEN_RESOLUTION=800x480
5151
# OCTOSCREEN_RESOLUTION is optional and defaults to 800x480 if missing
5252
# (defined in globalVars.go)
53+
54+
55+
# To display the cursor, uncomment the following line and set to true.
56+
#DISPLAY_CURSOR=true
57+
# You will also need to edit /lib/systemd/system/octoscreen.service and remove "-nocursor"

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=20s
14+
WatchdogSec=40s
1515

1616
[Install]
1717
WantedBy=graphical.target

main.go

+51
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strconv"
1313
"strings"
1414

15+
"github.com/gotk3/gotk3/gdk"
1516
"github.com/gotk3/gotk3/gtk"
1617
"github.com/sirupsen/logrus"
1718

@@ -123,6 +124,8 @@ func main() {
123124

124125
utils.DumpEnvironmentVariables()
125126

127+
setCursor()
128+
126129
if initSucceeded != true {
127130
// readConfig() logs any errors it encounters. Don't display
128131
// the error here, because the error could be long, and we don't
@@ -368,3 +371,51 @@ func getSize() (width int, height int, err error) {
368371
logger.TraceLeave("main.getSize()")
369372
return
370373
}
374+
375+
func setCursor() {
376+
// For reference, see "How to turn on a pointer"
377+
// https://github.com/Z-Bolt/OctoScreen/issues/285
378+
// and "No mouse pointer when running xinit"
379+
// https://www.raspberrypi.org/forums/viewtopic.php?t=139546
380+
381+
displayCursor := strings.ToLower(os.Getenv("DISPLAY_CURSOR"))
382+
if displayCursor != "true" {
383+
return
384+
}
385+
386+
window, err := getRootWindow()
387+
if err != nil {
388+
return
389+
}
390+
391+
cursor, err := getDefaultCursor()
392+
if err != nil {
393+
return
394+
}
395+
396+
window.SetCursor(cursor)
397+
}
398+
399+
func getRootWindow() (*gdk.Window, error) {
400+
screen, err := gdk.ScreenGetDefault()
401+
if err != nil {
402+
return nil, err
403+
}
404+
405+
window, err := screen.GetRootWindow()
406+
407+
return window, err
408+
}
409+
410+
func getDefaultCursor() (*gdk.Cursor, error) {
411+
display, err := gdk.DisplayGetDefault()
412+
if err != nil {
413+
return nil, err
414+
}
415+
416+
// Examples of the different cursors can be found at
417+
// https://developer.gnome.org/gdk3/stable/gdk3-Cursors.html#gdk-cursor-new-from-name
418+
cursor, err := gdk.CursorNewFromName(display, "default")
419+
420+
return cursor, err
421+
}

octoprintApis/BedOffsetRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ type BedOffsetRequest struct {
1919

2020
// Do sends an API request and returns an error if any.
2121
func (cmd *BedOffsetRequest) Do(c *Client) error {
22-
b := bytes.NewBuffer(nil)
23-
if err := cmd.encode(b); err != nil {
22+
buffer := bytes.NewBuffer(nil)
23+
if err := cmd.encode(buffer); err != nil {
2424
return err
2525
}
2626

27-
_, err := c.doJsonRequest("POST", PrinterToolApiUri, b, PrintToolErrors)
27+
_, err := c.doJsonRequest("POST", PrinterToolApiUri, buffer, PrintToolErrors, true)
2828
return err
2929
}
3030

octoprintApis/BedStateRequest.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ type BedStateRequest struct {
2929
// Do sends an API request and returns the API response.
3030
func (cmd *BedStateRequest) Do(c *Client) (*dataModels.TemperatureStateResponse, error) {
3131
uri := fmt.Sprintf("%s?history=%t&limit=%d", PrinterBedApiUri, cmd.IncludeHistory, cmd.Limit)
32-
b, err := c.doJsonRequest("GET", uri, nil, PrintBedErrors)
32+
bytes, err := c.doJsonRequest("GET", uri, nil, PrintBedErrors, true)
3333
if err != nil {
3434
return nil, err
3535
}
3636

37-
r := &dataModels.TemperatureStateResponse{}
38-
if err := json.Unmarshal(b, &r); err != nil {
37+
response := &dataModels.TemperatureStateResponse{}
38+
if err := json.Unmarshal(bytes, &response); err != nil {
3939
return nil, err
4040
}
4141

42-
return r, err
42+
return response, err
4343
}

octoprintApis/BedTargetRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ type BedTargetRequest struct {
1919

2020
// Do sends an API request and returns an error if any.
2121
func (cmd *BedTargetRequest) Do(c *Client) error {
22-
b := bytes.NewBuffer(nil)
23-
if err := cmd.encode(b); err != nil {
22+
buffer := bytes.NewBuffer(nil)
23+
if err := cmd.encode(buffer); err != nil {
2424
return err
2525
}
2626

27-
_, err := c.doJsonRequest("POST", PrinterBedApiUri, b, PrintBedErrors)
27+
_, err := c.doJsonRequest("POST", PrinterBedApiUri, buffer, PrintBedErrors, true)
2828
return err
2929
}
3030

octoprintApis/CancelRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ func (cmd *CancelRequest) Do(c *Client) error {
2121
return err
2222
}
2323

24-
_, err := c.doJsonRequest("POST", JobApiUri, buffer, JobToolErrors)
24+
_, err := c.doJsonRequest("POST", JobApiUri, buffer, JobToolErrors, true)
2525
return err
2626
}

octoprintApis/CommandRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ type CommandRequest struct {
2121

2222
// Do sends an API request and returns an error if any.
2323
func (cmd *CommandRequest) Do(c *Client) error {
24-
b := bytes.NewBuffer(nil)
25-
if err := json.NewEncoder(b).Encode(cmd); err != nil {
24+
buffer := bytes.NewBuffer(nil)
25+
if err := json.NewEncoder(buffer).Encode(cmd); err != nil {
2626
return err
2727
}
2828

29-
_, err := c.doJsonRequest("POST", PrinterCommandApiUri, b, nil)
29+
_, err := c.doJsonRequest("POST", PrinterCommandApiUri, buffer, nil, true)
3030
return err
3131
}

octoprintApis/ConnectRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ type ConnectRequest struct {
3939
func (cmd *ConnectRequest) Do(client *Client) error {
4040
logger.TraceEnter("ConnectRequest.Do()")
4141

42-
bytes := bytes.NewBuffer(nil)
43-
if err := cmd.encode(bytes); err != nil {
42+
buffer := bytes.NewBuffer(nil)
43+
if err := cmd.encode(buffer); err != nil {
4444
logger.LogError("ConnectRequest.Do()", "cmd.encode()", err)
4545
logger.TraceLeave("ConnectRequest.Do()")
4646
return err
4747
}
4848

49-
_, err := client.doJsonRequest("POST", ConnectionApiUri, bytes, ConnectionErrors)
49+
_, err := client.doJsonRequest("POST", ConnectionApiUri, buffer, ConnectionErrors, true)
5050
if err != nil {
5151
logger.LogError("ConnectRequest.go()", "client.doJsonRequest(POST)", err)
5252
}

octoprintApis/ConnectionRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type ConnectionRequest struct{}
1919
func (cmd *ConnectionRequest) Do(client *Client) (*dataModels.ConnectionResponse, error) {
2020
logger.TraceEnter("ConnectionRequest.Do()")
2121

22-
bytes, err := client.doJsonRequest("GET", ConnectionApiUri, nil, nil)
22+
bytes, err := client.doJsonRequest("GET", ConnectionApiUri, nil, nil, true)
2323
if err != nil {
2424
logger.LogError("ConnectionRequest.Do()", "client.doJsonRequest(GET)", err)
2525
logger.TraceLeave("ConnectionRequest.Do()")

octoprintApis/CustomCommandsRequest.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ type CustomCommandsRequest struct{}
1616

1717
// Do sends an API request and returns the API response.
1818
func (cmd *CustomCommandsRequest) Do(c *Client) (*dataModels.CustomCommandsResponse, error) {
19-
b, err := c.doJsonRequest("GET", PrinterCommandCustomApiUri, nil, nil)
19+
bytes, err := c.doJsonRequest("GET", PrinterCommandCustomApiUri, nil, nil, true)
2020
if err != nil {
2121
return nil, err
2222
}
2323

24-
r := &dataModels.CustomCommandsResponse{}
25-
if err := json.Unmarshal(b, r); err != nil {
24+
response := &dataModels.CustomCommandsResponse{}
25+
if err := json.Unmarshal(bytes, response); err != nil {
2626
return nil, err
2727
}
2828

29-
return r, err
29+
return response, err
3030
}

octoprintApis/DeleteFileRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type DeleteFileRequest struct {
2121
// Do sends an API request and returns error if any.
2222
func (req *DeleteFileRequest) Do(c *Client) error {
2323
uri := fmt.Sprintf("%s/%s/%s", FilesApiUri, req.Location, req.Path)
24-
if _, err := c.doJsonRequest("DELETE", uri, nil, FilesLocationDeleteErrors); err != nil {
24+
if _, err := c.doJsonRequest("DELETE", uri, nil, FilesLocationDeleteErrors, true); err != nil {
2525
return err
2626
}
2727

octoprintApis/DisconnectRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ type DisconnectRequest struct{}
1919
func (this *DisconnectRequest) Do(client *Client) error {
2020
logger.TraceEnter("DisconnectRequest.Do()")
2121

22-
bytes := bytes.NewBuffer(nil)
23-
if err := this.encode(bytes); err != nil {
22+
buffer := bytes.NewBuffer(nil)
23+
if err := this.encode(buffer); err != nil {
2424
logger.LogError("DisconnectRequest.Do()", "this.encode(bytes)", err)
2525
logger.TraceLeave("DisconnectRequest.Do()")
2626
return err
2727
}
2828

29-
_, err := client.doJsonRequest("POST", ConnectionApiUri, bytes, ConnectionErrors)
29+
_, err := client.doJsonRequest("POST", ConnectionApiUri, buffer, ConnectionErrors, true)
3030
if err != nil {
3131
logger.LogError("DisconnectRequest.Do()", "client.doJsonRequest(POST)", err)
3232
}

octoprintApis/FakesAckRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ type FakesAckRequest struct{}
2323
func (this *FakesAckRequest) Do(client *Client) error {
2424
logger.TraceEnter("FakesAckRequest.Do()")
2525

26-
bytes := bytes.NewBuffer(nil)
27-
if err := this.encode(bytes); err != nil {
26+
buffer := bytes.NewBuffer(nil)
27+
if err := this.encode(buffer); err != nil {
2828
logger.LogError("FakesAckRequest.Do()", "this.encode(bytes)", err)
2929
logger.TraceLeave("FakesAckRequest.Do()")
3030
return err
3131
}
3232

33-
_, err := client.doJsonRequest("POST", ConnectionApiUri, bytes, ConnectionErrors)
33+
_, err := client.doJsonRequest("POST", ConnectionApiUri, buffer, ConnectionErrors, true)
3434
if err != nil {
3535
logger.LogError("FakesAckRequest.Do()", "client.doJsonRequest(POST)", err)
3636
logger.LogError("main.findConfigFile()", "Current()", err)

octoprintApis/FileRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (request *FileRequest) Do(c *Client) (*dataModels.FileResponse, error) {
3939
request.Recursive,
4040
)
4141

42-
bytes, err := c.doJsonRequest("GET", uri, nil, FilesLocationGETErrors)
42+
bytes, err := c.doJsonRequest("GET", uri, nil, FilesLocationGETErrors, true)
4343
if err != nil {
4444
return nil, err
4545
}

octoprintApis/FilesRequest.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ func (cmd *FilesRequest) Do(c *Client) (*dataModels.FilesResponse, error) {
2929
uri = fmt.Sprintf("%s/%s?recursive=%t", FilesApiUri, cmd.Location, cmd.Recursive)
3030
}
3131

32-
b, err := c.doJsonRequest("GET", uri, nil, FilesLocationGETErrors)
32+
bytes, err := c.doJsonRequest("GET", uri, nil, FilesLocationGETErrors, true)
3333
if err != nil {
3434
return nil, err
3535
}
3636

37-
r := &dataModels.FilesResponse{}
38-
if err := json.Unmarshal(b, r); err != nil {
37+
response := &dataModels.FilesResponse{}
38+
if err := json.Unmarshal(bytes, response); err != nil {
3939
return nil, err
4040
}
4141

42-
if len(r.Children) > 0 {
43-
r.Files = r.Children
42+
if len(response.Children) > 0 {
43+
response.Files = response.Children
4444
}
4545

46-
return r, err
46+
return response, err
4747
}

octoprintApis/FullStateRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (cmd *FullStateRequest) Do(c *Client) (*dataModels.FullStateResponse, error
6969
*/
7070

7171

72-
bytes, err := c.doJsonRequest("GET", uri, nil, PrintErrors)
72+
bytes, err := c.doJsonRequest("GET", uri, nil, PrintErrors, true)
7373
if err != nil {
7474
return nil, err
7575
}

octoprintApis/JobRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type JobRequest struct{}
1515

1616
// Do sends an API request and returns the API response.
1717
func (cmd *JobRequest) Do(client *Client) (*dataModels.JobResponse, error) {
18-
bytes, err := client.doJsonRequest("GET", JobApiUri, nil, nil)
18+
bytes, err := client.doJsonRequest("GET", JobApiUri, nil, nil, true)
1919
if err != nil {
2020
return nil, err
2121
}

octoprintApis/NotificationRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (this *NotificationRequest) Do(client *Client, uiState string) (*dataModels
1919
}
2020

2121
target := fmt.Sprintf("%s?command=get_notification", PluginZBoltOctoScreenApiUri)
22-
bytes, err := client.doJsonRequest("GET", target, nil, ConnectionErrors)
22+
bytes, err := client.doJsonRequest("GET", target, nil, ConnectionErrors, true)
2323
if err != nil {
2424
return nil, err
2525
}

octoprintApis/OctoScreenSettingsRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type OctoScreenSettingsRequest struct {
1717

1818
func (this *OctoScreenSettingsRequest) Do(client *Client, uiState string) (*dataModels.OctoScreenSettingsResponse, error) {
1919
target := fmt.Sprintf("%s?command=get_settings", PluginZBoltOctoScreenApiUri)
20-
bytes, err := client.doJsonRequest("GET", target, nil, ConnectionErrors)
20+
bytes, err := client.doJsonRequest("GET", target, nil, ConnectionErrors, false)
2121
if err != nil {
2222
return nil, err
2323
}

octoprintApis/PauseRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (cmd *PauseRequest) Do(c *Client) error {
2525
return err
2626
}
2727

28-
_, err := c.doJsonRequest("POST", JobApiUri, buffer, JobToolErrors)
28+
_, err := c.doJsonRequest("POST", JobApiUri, buffer, JobToolErrors, true)
2929
return err
3030
}
3131

octoprintApis/PluginManagerInfoRequest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (this *PluginManagerInfoRequest) Do(client *Client, uiState string) (*dataM
2626
return nil, err
2727
}
2828

29-
bytes, err := client.doJsonRequest("GET", pluginManagerRequestURI, params, ConnectionErrors)
29+
bytes, err := client.doJsonRequest("GET", pluginManagerRequestURI, params, ConnectionErrors, true)
3030
if err != nil {
3131
logger.LogError("PluginManagerInfoRequest.Do()", "client.doJsonRequest()", err)
3232
return nil, err

octoprintApis/PrintHeadHomeRequest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ type PrintHeadHomeRequest struct {
1919

2020
// Do sends an API request and returns an error if any.
2121
func (cmd *PrintHeadHomeRequest) Do(c *Client) error {
22-
b := bytes.NewBuffer(nil)
23-
if err := cmd.encode(b); err != nil {
22+
buffer := bytes.NewBuffer(nil)
23+
if err := cmd.encode(buffer); err != nil {
2424
return err
2525
}
2626

27-
_, err := c.doJsonRequest("POST", PrinterPrintHeadApiUri, b, PrintHeadJobErrors)
27+
_, err := c.doJsonRequest("POST", PrinterPrintHeadApiUri, buffer, PrintHeadJobErrors, true)
2828
return err
2929
}
3030

0 commit comments

Comments
 (0)