https://github.com/digitalartifex/qklipper
Qt based Klipper/Moonraker library
https://github.com/digitalartifex/qklipper
3d-printing klipper library qt6
Last synced: 18 days ago
JSON representation
Qt based Klipper/Moonraker library
- Host: GitHub
- URL: https://github.com/digitalartifex/qklipper
- Owner: DigitalArtifex
- License: gpl-3.0
- Created: 2024-08-28T14:58:24.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-03-30T00:38:39.000Z (about 2 months ago)
- Last Synced: 2025-03-30T01:32:02.764Z (about 2 months ago)
- Topics: 3d-printing, klipper, library, qt6
- Language: C++
- Homepage:
- Size: 14.6 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

# QKlipper
Qt based Klipper/Moonraker library (ALPHA - convenience methods still being ported over the next couple of days as well as QML compatability)## Setup
```
git clone https://github.com/DigitalArtifex/QKlipper.git
cd QKlipper
```You can configure and build the project by either cloning and opening the QKlipper repo in QtCreator, or use the `qt-cmake` tool provided by the target kit. In this example we are targeting the Qt 6.8.1 kit for GCC64, which has been installed to `/opt/Qt`. To keep the source directory clean, we first create our build directory and execute `qt-cmake` from there.
```
mkdir -p build/release
cd build/release
/opt/Qt/6.8.1/gcc_64/bin/qt-cmake -S $PWD/../../ -B $PWD
cmake --build $PWD
sudo cmake --install $PWD
```## Usage
### Qt Project File
```
LIBS += -L$$[QT_HOST_LIBS] -lQt$$[QT_MAJOR_VERSION]
```### CMake Project File
```
find_package(QKlipper 1.0.1 REQUIRED)target_link_libraries(MyProject
PRIVATE
${QKlipper_LIBRARIES}
)```
### Local connections
```
//Creating a local instance
QKlipperInstance *instance = new QKlipperInstance();
instance->setName("QKlipper Test");
//address and port for non-rpc calls
instance->setPort(7125);
instance->setAddress("http://localhost");
//instance location is required for local connections
instance->setInstanceLocation("/home/parametheus/printer_data");
instance->connect();
```
Local connections require `setInstanceLoction` to be called with the fully qualified path of the klipper installation.### Remote connections
```
//Creating a remote instance
QKlipperInstance *instance = new QKlipperInstance();
instance->setName("QKlipper Test");
//address and port for klipper instance
instance->setPort(7125);
instance->setAddress("http://artifex"); //it is best to use the hostname, IP or full domain name. Avoid using .local
instance->connect();
```Once `QKlipperInstance->connect()` has been called the QKlipperConole will attempt to connect to the sockets and begin the startup sequence.
## Usage
In order to interface with the Klipper instance we need to make sure the console has connected and syncronized. The easiest way to do this is to connect to
the **QKlipperInstance::connected()** signal. If you want, you can instead connect to the **QKlipperConsole::connectionStateChanged()** to react to the individual
states of the connection process.
```
class MyClass : QObject
{
Q_OBJECT
QKlipperPrinter *printer = nullptr;
QKlipperInstance *instance = nullptr;
public:
MyClass(QObject *parent = nullptr) : QObject{parent}
{
//Creating a local instance
instance = new QKlipperInstance();
instance->setName("QKlipper Test");
//address and port for non-rpc calls
instance->setPort(7125);
instance->setAddress("localhost"); //do not include http
//instance location is required for local connections
instance->setInstanceLocation("/home/parametheus/printer_data");
//connect to the signal
connect(instance, SIGNAL(connected), this, SLOT(onInstanceConnected()));
//set the printer object
printer = instance->printer();
//connect to Klipper
instance->connect();
}
protected slots:
void onInstanceConnected()
{
//console is ready
printer->toolhead()->home(); //homes the toolhead
printer->toolhead()->setPosition(100, 50, 50); //sets absolute position
printer->bed()->setTargetTemperature(60); //sets the target temp (C)
}
};
```