diff --git a/package-lock.json b/package-lock.json
index 8b6a115..3dd092c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "bbctrl",
- "version": "1.0.10b2",
+ "version": "1.0.10b4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "bbctrl",
- "version": "1.0.10b2",
+ "version": "1.0.10b4",
"license": "GPL-3.0+",
"dependencies": {
"browserify": "^17.0.0",
diff --git a/package.json b/package.json
index e7e8200..0610ea7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "bbctrl",
- "version": "1.0.10b2",
+ "version": "1.0.10b4",
"homepage": "https://onefinitycnc.com/",
"repository": "https://github.com/OneFinityCNC/onefinity",
"license": "GPL-3.0+",
diff --git a/src/js/settings-view.js b/src/js/settings-view.js
index 2df783c..6d26b98 100644
--- a/src/js/settings-view.js
+++ b/src/js/settings-view.js
@@ -21,5 +21,11 @@ module.exports = {
this.$dispatch('config-changed');
return false;
}
+ },
+
+ methods: {
+ showScreenRotationDialog: function () {
+ SvelteComponents.showDialog("ScreenRotation");
+ }
}
}
diff --git a/src/pug/templates/settings-view.pug b/src/pug/templates/settings-view.pug
index afeaa52..15ec257 100644
--- a/src/pug/templates/settings-view.pug
+++ b/src/pug/templates/settings-view.pug
@@ -4,16 +4,14 @@ script#settings-view-template(type="text/x-template")
.pure-form.pure-form-aligned
fieldset
- h2 Units
+ h2 Screen
.pure-control-group
- label(for="units") units
- select(name="units", v-model="display_units")
- option(value="METRIC") METRIC
- option(value="IMPERIAL") IMPERIAL
+ label(for="screen-rotation")
+ button.pure-button(name="screen-rotation", @click="showScreenRotationDialog") Change Screen Rotation
fieldset
h2 Probe Dimensions
- templated-input(v-for="templ in template.probe", :name="$key",
+ templated-input(v-for="templ in template.probe", v-if="$key !== 'probe-diameter'", :name="$key"
:model.sync="config.probe[$key]", :template="templ")
fieldset
diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py
index 1a96146..15892c8 100644
--- a/src/py/bbctrl/Web.py
+++ b/src/py/bbctrl/Web.py
@@ -1,4 +1,5 @@
import os
+import re
import json
import tornado
import sockjs.tornado
@@ -349,6 +350,46 @@ class JogHandler(bbctrl.APIHandler):
self.get_ctrl().mach.jog(self.json)
+displayRotatePattern = re.compile(r'display_rotate\s*=\s*(\d)')
+transformationMatrixPattern = re.compile(
+ r'(\n)(\s+)(MatchIsTouchscreen.*?\n)(\s+Option\s+\"TransformationMatrix\".*?\n)(.*?EndSection)', re.DOTALL)
+matchIsTouchscreenPattern = re.compile(
+ r'(\n)(\s+)(MatchIsTouchscreen.*?\n)(.*?EndSection)', re.DOTALL)
+
+
+class ScreenRotationHandler(bbctrl.APIHandler):
+ @gen.coroutine
+ def get(self):
+ with open("/boot/config.txt", 'rt') as config:
+ lines = config.readlines()
+ for line in lines:
+ if line.startswith('display_rotate'):
+ self.write_json({
+ 'rotated': int(displayRotatePattern.search(line).group(1)) != 0
+ })
+ return
+
+ self.write_json({'rotated': False})
+ return
+
+ @gen.coroutine
+ def put_ok(self):
+ rotated = self.json['rotated']
+
+ subprocess.Popen(
+ ['/usr/local/bin/edit-boot-config', 'display_rotate={}'.format(2 if rotated else 0)])
+
+ with open("/usr/share/X11/xorg.conf.d/40-libinput.conf", 'rt') as config:
+ text = config.read()
+ text = transformationMatrixPattern.sub(r'\1\2\3\5', text)
+ if rotated:
+ text = matchIsTouchscreenPattern.sub(r'\1\2\3\2Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"\1\4', text)
+ with open("/usr/share/X11/xorg.conf.d/40-libinput.conf", 'wt') as config:
+ config.write(text)
+
+ subprocess.run('reboot')
+
+
# Base class for Web Socket connections
class ClientConnection(object):
def __init__(self, app):
@@ -484,6 +525,7 @@ class Web(tornado.web.Application):
(r'/api/modbus/write', ModbusWriteHandler),
(r'/api/jog', JogHandler),
(r'/api/video', bbctrl.VideoHandler),
+ (r'/api/screen-rotation', ScreenRotationHandler),
(r'/(.*)', StaticFileHandler,
{'path': bbctrl.get_resource('http/'),
'default_filename': 'index.html'}),
diff --git a/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte b/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte
index de8930b..77e472e 100644
--- a/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte
+++ b/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte
@@ -88,7 +88,7 @@
diff --git a/src/svelte-components/src/dialogs/DialogHost.svelte b/src/svelte-components/src/dialogs/DialogHost.svelte
index c6319dd..1a03f68 100644
--- a/src/svelte-components/src/dialogs/DialogHost.svelte
+++ b/src/svelte-components/src/dialogs/DialogHost.svelte
@@ -1,31 +1,48 @@
-
-
+
+
+
diff --git a/src/svelte-components/src/dialogs/DialogProps.ts b/src/svelte-components/src/dialogs/DialogProps.ts
deleted file mode 100644
index 338c722..0000000
--- a/src/svelte-components/src/dialogs/DialogProps.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { writable } from "svelte/store";
-
-export const HomeMachineProps = writable();
-export type HomeMachinePropsType = {
- open: boolean,
- home: () => void
-}
-
-export const ProbeProps = writable();
-export type ProbePropsType = {
- open: boolean,
- probeType: "xyz" | "z"
-};
diff --git a/src/svelte-components/src/dialogs/ScreenRotationDialog.svelte b/src/svelte-components/src/dialogs/ScreenRotationDialog.svelte
new file mode 100644
index 0000000..0fd78a0
--- /dev/null
+++ b/src/svelte-components/src/dialogs/ScreenRotationDialog.svelte
@@ -0,0 +1,76 @@
+
+
+
+ Rebooting to apply the new screen rotation...
+
+
+
+
+
diff --git a/src/svelte-components/src/dialogs/WifiConnectionDialog.svelte b/src/svelte-components/src/dialogs/WifiConnectionDialog.svelte
index b213330..447783a 100644
--- a/src/svelte-components/src/dialogs/WifiConnectionDialog.svelte
+++ b/src/svelte-components/src/dialogs/WifiConnectionDialog.svelte
@@ -92,7 +92,7 @@
on:click={onConfirm}
disabled={needPassword && (password.length < 8 || password.length > 128)}
>
-
+