From 607f8d88d6945f3b820073b7d295a6f154655434 Mon Sep 17 00:00:00 2001 From: Timon G Date: Mon, 5 Oct 2020 21:00:06 +0200 Subject: [PATCH] customizable babystep gcode (#1043) --- src/app/app.service.ts | 8 ++--- src/app/config/config.service.ts | 12 ++++++- .../config/no-config/no-config.component.ts | 3 +- .../print-control/print-control.component.ts | 9 +++-- src/app/settings/settings.component.html | 33 ------------------- 5 files changed, 21 insertions(+), 44 deletions(-) diff --git a/src/app/app.service.ts b/src/app/app.service.ts index dfcc20792..223ba031c 100644 --- a/src/app/app.service.ts +++ b/src/app/app.service.ts @@ -35,17 +35,13 @@ export class AppService { 'Please restart your system. If the issue persists open an issue on GitHub.', ); } - this.updateError = [ - ".filament should have required property 'useM600'", - ".octodash should have required property 'preferPreviewWhilePrinting'", - ]; + this.updateError = [".printer should have required property 'zBabystepGCode'"]; } // If the errors can be automatically fixed return true here public autoFixError(): boolean { const config = this.configService.getCurrentConfig(); - config.filament.useM600 = false; - config.octodash.preferPreviewWhilePrinting = false; + config.printer.zBabystepGCode = 'M290 Z'; this.configService.saveConfig(config); this.configService.updateConfig(); return true; diff --git a/src/app/config/config.service.ts b/src/app/config/config.service.ts index d62876369..a968511a1 100644 --- a/src/app/config/config.service.ts +++ b/src/app/config/config.service.ts @@ -258,6 +258,10 @@ export class ConfigService { public getAccessKey(): string { return this.config.octoprint.accessToken; } + + public getZBabystepGCode(): string { + return this.config.printer.zBabystepGCode; + } } interface HttpHeader { @@ -285,6 +289,7 @@ interface Printer { name: string; xySpeed: number; zSpeed: number; + zBabystepGCode: string; defaultTemperatureFanSpeed: DefaultTemperatureFanSpeed; } @@ -376,7 +381,7 @@ const schema = { printer: { $id: '#/properties/printer', type: 'object', - required: ['name', 'xySpeed', 'zSpeed', 'defaultTemperatureFanSpeed'], + required: ['name', 'xySpeed', 'zSpeed', 'zBabystepGCode', 'defaultTemperatureFanSpeed'], properties: { name: { $id: '#/properties/printer/properties/name', @@ -391,6 +396,11 @@ const schema = { $id: '#/properties/printer/properties/zSpeed', type: 'integer', }, + zBabystepGCode: { + $id: '#/properties/printer/properties/zBabystepGCode', + type: 'string', + pattern: '^(.*)$', + }, defaultTemperatureFanSpeed: { $id: '#/properties/printer/properties/defaultTemperatureFanSpeed', type: 'object', diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index d92649068..6ce2e8f2e 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -1,4 +1,3 @@ -import { HttpClient } from '@angular/common/http'; import { ChangeDetectorRef, Component, NgZone, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { NotificationService } from 'src/app/notification/notification.service'; @@ -35,7 +34,6 @@ export class NoConfigComponent implements OnInit { public constructor( private configService: ConfigService, - private http: HttpClient, private router: Router, private notificationService: NotificationService, private octoprintScriptService: OctoprintScriptService, @@ -258,6 +256,7 @@ export class NoConfigComponent implements OnInit { name: '', xySpeed: 150, zSpeed: 5, + zBabystepGCode: 'M290 Z', defaultTemperatureFanSpeed: { hotend: 200, heatbed: 60, diff --git a/src/app/print-control/print-control.component.ts b/src/app/print-control/print-control.component.ts index 014bd6e72..b84970ce8 100644 --- a/src/app/print-control/print-control.component.ts +++ b/src/app/print-control/print-control.component.ts @@ -1,6 +1,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; import { take } from 'rxjs/operators'; +import { ConfigService } from '../config/config.service'; import { Job, JobService, JobStatus } from '../job.service'; import { PrinterService, PrinterStatusAPI } from '../printer.service'; @@ -24,7 +25,11 @@ export class PrintControlComponent implements OnInit, OnDestroy { public flowrate: number; public zOffset: number; - public constructor(private jobService: JobService, private printerService: PrinterService) { + public constructor( + private jobService: JobService, + private printerService: PrinterService, + private configService: ConfigService, + ) { this.temperatureHotend = 0; this.temperatureHeatbed = 0; this.flowrate = 100; @@ -214,7 +219,7 @@ export class PrintControlComponent implements OnInit, OnDestroy { public babystepZ(value: number): void { // gotta love JS for that one. this.zOffset = Math.round((this.zOffset + value) * 100) / 100; - this.printerService.executeGCode(`M290 Z${value}`); + this.printerService.executeGCode(`${this.configService.getZBabystepGCode()}${value}`); } } diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 1514202bd..b7747d4b7 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -67,16 +67,6 @@ required />
- - Printer
@@ -309,29 +299,6 @@
General - - -
- - - - Use Touchscreen -
-