Skip to content

Commit

Permalink
customizable babystep gcode (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnchartedBull authored Oct 5, 2020
1 parent a05b045 commit 607f8d8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 44 deletions.
8 changes: 2 additions & 6 deletions src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion src/app/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -285,6 +289,7 @@ interface Printer {
name: string;
xySpeed: number;
zSpeed: number;
zBabystepGCode: string;
defaultTemperatureFanSpeed: DefaultTemperatureFanSpeed;
}

Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions src/app/config/no-config/no-config.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -258,6 +256,7 @@ export class NoConfigComponent implements OnInit {
name: '',
xySpeed: 150,
zSpeed: 5,
zBabystepGCode: 'M290 Z',
defaultTemperatureFanSpeed: {
hotend: 200,
heatbed: 60,
Expand Down
9 changes: 7 additions & 2 deletions src/app/print-control/print-control.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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}`);
}
}

Expand Down
33 changes: 0 additions & 33 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@
required
/>
<br />
<label for="accessToken" class="settings__input-label">API Key</label>
<input
type="text"
id="accessToken"
class="settings__input"
name="accessToken"
style="width: 44.94vw"
[(ngModel)]="this.config.octoprint.accessToken"
required
/>
</form>
<span class="settings__heading-2">Printer</span>
<form class="settings__form">
Expand Down Expand Up @@ -309,29 +299,6 @@
</span>
<div class="settings__scroll">
<span class="settings__heading-2">General</span>
<label for="api-polling-interval" class="settings__input-label">
Value Refresh Interval
<span>(ms)</span>
</label>
<input
type="number"
id="api-polling-interval"
class="settings__input"
name="api-polling-interval"
style="width: 44.94vw"
[(ngModel)]="config.octodash.pollingInterval"
required
/>
<div
class="settings__checkbox-container"
(click)="config.octodash.touchscreen = !config.octodash.touchscreen"
>
<span class="settings__checkbox">
<span class="settings__checkbox-checked" *ngIf="config.octodash.touchscreen"></span>
</span>
<span class="settings__checkbox-descriptor">Use Touchscreen</span>
</div>
<br />
<div
class="settings__checkbox-container"
(click)="config.octodash.turnScreenOffWhileSleeping = !config.octodash.turnScreenOffWhileSleeping"
Expand Down

0 comments on commit 607f8d8

Please sign in to comment.