screen: allow custom moonraker url/port

This commit is contained in:
Jordan Ruthe 2020-12-16 23:02:33 -05:00
parent bcbbc03151
commit c3f96418ea
5 changed files with 21 additions and 8 deletions

View File

@ -12,6 +12,10 @@ config is included here: [ks_includes/KlipperScreen.conf](../ks_includes/Klipper
## Main Options
```
[main]
# Define the moonraker host/port if different from 127.0.0.1 and 7125
moonraker_host: 127.0.0.1
moonraker_port: 7125
# Invert axis in move panel. Default is False. Change to true to invert
invert_x: False
invert_y: False

View File

@ -2,6 +2,7 @@
#### 2020 12 16
* Config file can now be specified when running from the command line
* Moonraker host/port can be specified in the configuration file
#### 2020 12 09
* Z value in job status now reflects the gcode Z value. This allows people with ABL to have a better understanding of Z

View File

@ -1,4 +1,6 @@
[main]
moonraker_host: 127.0.0.1
moonraker_port: 7125
[preheat PLA]
bed = 40

View File

@ -38,13 +38,13 @@ class KlippyWebsocket(threading.Thread):
callback_table = {}
timeout = None
def __init__(self, screen, callback):
def __init__(self, screen, callback, host, port):
threading.Thread.__init__(self)
self._screen = screen
self._callback = callback
self.klippy = MoonrakerApi(self)
self._url = "127.0.0.1:7125"
self._url = "%s:%s" % (host, port)
def connect (self):
#r = requests.get(

View File

@ -93,7 +93,9 @@ class KlipperScreen(Gtk.Window):
self.lang = gettext.translation('KlipperScreen', localedir='ks_includes/locales')
_ = self.lang.gettext
self.apiclient = KlippyRest("127.0.0.1",7125)
self.apiclient = KlippyRest(self._config.get_main_config_option("moonraker_host"),
self._config.get_main_config_option("moonraker_port"))
Gtk.Window.__init__(self)
self.width = self._config.get_main_config().getint("width", Gdk.Screen.get_width(Gdk.Screen.get_default()))
self.height = self._config.get_main_config().getint("height", Gdk.Screen.get_height(Gdk.Screen.get_default()))
@ -108,11 +110,15 @@ class KlipperScreen(Gtk.Window):
self.printer_initializing(_("Initializing"))
self._ws = KlippyWebsocket(self, {
"on_connect": self.init_printer,
"on_message": self._websocket_callback,
"on_close": self.printer_initializing
})
self._ws = KlippyWebsocket(self,
{
"on_connect": self.init_printer,
"on_message": self._websocket_callback,
"on_close": self.printer_initializing
},
self._config.get_main_config_option("moonraker_host"),
self._config.get_main_config_option("moonraker_port")
)
self._ws.connect()
# Disable DPMS