diff --git a/screenshots/adjust_parameters_print.png b/screenshots/adjust_parameters_print.png new file mode 100644 index 000000000..8652cf1e3 Binary files /dev/null and b/screenshots/adjust_parameters_print.png differ diff --git a/src/app/main-screen/main-screen.component.html b/src/app/main-screen/main-screen.component.html index 466c38dc8..3d6c8fa0b 100644 --- a/src/app/main-screen/main-screen.component.html +++ b/src/app/main-screen/main-screen.component.html @@ -1,4 +1,4 @@ -
+ +
+ + + + +
diff --git a/src/app/print-control/print-control.component.html b/src/app/print-control/print-control.component.html index c1ae58331..6aeac66ec 100644 --- a/src/app/print-control/print-control.component.html +++ b/src/app/print-control/print-control.component.html @@ -50,12 +50,55 @@ back - - - :( - - - This feature has not been implemented yet. If you really, really want it before anything else - go to GitHub - and like issue #55. + + + + + + + + + +
diff --git a/src/app/print-control/print-control.component.scss b/src/app/print-control/print-control.component.scss index dd86909c7..b100d36f6 100644 --- a/src/app/print-control/print-control.component.scss +++ b/src/app/print-control/print-control.component.scss @@ -48,7 +48,13 @@ text-align: center; margin-top: 8vh; margin-bottom: 7vh; - margin-left: calc(50% - 11vw) + margin-left: calc(50% - 11vw); + + &-small { + display: block; + width: 7.5vw; + margin: -9vw auto 0; + } } &__cancel { @@ -77,4 +83,60 @@ } } } + + &__adjust { + &__wrapper { + display: block; + width: 90vw; + margin: 6vh 5vw; + } + + &__change-parameter { + width: 27vw; + text-align: center; + } + + &__controller { + border: solid .6vw; + border-radius: 3vw; + width: 19.5vw; + margin-left: .9vw; + + &-value { + font-size: 5vw; + font-weight: 500; + + &-unit { + font-size: 2.5vw; + font-weight: 400; + } + } + + &-increase { + padding: 3vh 6vw; + font-weight: 500; + } + + &-decrease { + padding: 3vh 6vw; + font-weight: 500; + } + } + + &__name { + margin-top: 5vh; + display: block; + font-size: 3.5vw; + } + + &__save { + display: block; + width: 15vw; + text-align: center; + margin: auto; + padding: 1.3vh 0; + border: 0.6vw solid; + border-radius: 2.5vw; + } + } } diff --git a/src/app/print-control/print-control.component.ts b/src/app/print-control/print-control.component.ts index 20caa7d2d..754cd299a 100644 --- a/src/app/print-control/print-control.component.ts +++ b/src/app/print-control/print-control.component.ts @@ -1,5 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { JobService } from '../job.service'; +import { PrinterService, PrinterStatusAPI } from '../printer.service'; +import { take } from 'rxjs/operators'; @Component({ selector: 'app-print-control', @@ -12,7 +14,12 @@ export class PrintControlComponent implements OnInit { public controlView = ControlView; public view = ControlView.MAIN; - constructor(private jobService: JobService) { } + public temperatureHotend; + public temperatureHeatbed; + public feedrate; + public flowrate; + + constructor(private jobService: JobService, private printerService: PrinterService) { } ngOnInit() { } @@ -47,6 +54,7 @@ export class PrintControlComponent implements OnInit { public showControlOverlay(event?) { this.stopPropagation(event); + this.loadData(); this.view = ControlView.MAIN; this.showControls = true; } @@ -75,6 +83,48 @@ export class PrintControlComponent implements OnInit { this.stopPropagation(event); } + private loadData() { + this.temperatureHotend = '?'; + this.temperatureHeatbed = '?'; + this.flowrate = 100; + this.feedrate = 100; + this.printerService.getObservable().pipe(take(1)).subscribe((printerStatus: PrinterStatusAPI) => { + this.temperatureHotend = printerStatus.nozzle.set; + this.temperatureHeatbed = printerStatus.heatbed.set; + }); + } + + public changeTemperatureHotend(value: number) { + this.temperatureHotend += value; + if (this.temperatureHotend < 0) { this.temperatureHotend = 0; } + if (this.temperatureHotend > 999) { this.temperatureHotend = 999; } + } + + public changeTemperatureHeatbed(value: number) { + this.temperatureHeatbed += value; + if (this.temperatureHeatbed < 0) { this.temperatureHeatbed = 0; } + if (this.temperatureHeatbed > 999) { this.temperatureHeatbed = 999; } + } + + public changeFeedrate(value: number) { + this.feedrate += value; + if (this.feedrate < 50) { this.feedrate = 50; } + if (this.feedrate > 200) { this.feedrate = 200; } + } + + public changeFlowrate(value: number) { + this.flowrate += value; + if (this.flowrate < 75) { this.flowrate = 75; } + if (this.flowrate > 125) { this.flowrate = 125; } + } + + public setAdjustParameters() { + this.printerService.setTemperatureHotend(this.temperatureHotend); + this.printerService.setTemperatureHeatbed(this.temperatureHeatbed); + this.printerService.setFeedrate(this.feedrate); + this.printerService.setFlowrate(this.flowrate); + } + } diff --git a/src/app/printer.service.ts b/src/app/printer.service.ts index bca10e975..23d064712 100644 --- a/src/app/printer.service.ts +++ b/src/app/printer.service.ts @@ -17,7 +17,7 @@ export class PrinterService { observable: Observable; constructor(private http: HttpClient, private configService: ConfigService, private notificationService: NotificationService) { - this.observable = new Observable((observer: Observer) => { + this.observable = new Observable((observer: Observer) => { timer(500, this.configService.getAPIInterval()).subscribe(_ => { if (this.httpGETRequest) { this.httpGETRequest.unsubscribe(); @@ -94,6 +94,66 @@ export class PrinterService { ); } + public setTemperatureHotend(temperature: number) { + const temperatureHotendCommand: TemperatureHotendCommand = { + command: 'target', + targets: { + tool0: temperature + } + }; + this.httpPOSTRequest = this.http.post(this.configService.getURL('printer/tool'), temperatureHotendCommand, + this.configService.getHTTPHeaders()) + .subscribe( + () => null, (error: HttpErrorResponse) => { + this.notificationService.setError('Can\'t set Hotend Temperature!', error.message); + } + ); + } + + public setTemperatureHeatbed(temperature: number) { + const temperatureHeatbedCommand: TemperatureHeatbedCommand = { + command: 'target', + target: temperature + }; + this.httpPOSTRequest = this.http.post(this.configService.getURL('printer/bed'), temperatureHeatbedCommand, + this.configService.getHTTPHeaders()) + .subscribe( + () => null, (error: HttpErrorResponse) => { + this.notificationService.setError('Can\'t set Heatbed Temperature!', error.message); + } + ); + } + + public setFeedrate(feedrate: number) { + if (feedrate === 100) { return; } + const feedrateCommand: FeedrateCommand = { + command: 'feedrate', + factor: feedrate + }; + this.httpPOSTRequest = this.http.post(this.configService.getURL('printer/printhead'), feedrateCommand, + this.configService.getHTTPHeaders()) + .subscribe( + () => null, (error: HttpErrorResponse) => { + this.notificationService.setError('Can\'t set Feedrate!', error.message); + } + ); + } + + public setFlowrate(flowrate: number) { + if (flowrate === 100) { return; } + const flowrateCommand: FeedrateCommand = { + command: 'flowrate', + factor: flowrate + }; + this.httpPOSTRequest = this.http.post(this.configService.getURL('printer/tool'), flowrateCommand, + this.configService.getHTTPHeaders()) + .subscribe( + () => null, (error: HttpErrorResponse) => { + this.notificationService.setError('Can\'t set Flowrate!', error.message); + } + ); + } + public isPrinterOffline(): Promise { return new Promise((resolve) => { this.http.get(this.configService.getURL('connection'), this.configService.getHTTPHeaders()) @@ -132,3 +192,21 @@ interface JogCommand { interface GCodeCommand { commands: string[]; } + +interface FeedrateCommand { + command: string; + factor: number; +} + +interface TemperatureHotendCommand { + command: string; + targets: { + tool0: number; + tool1?: number; + }; +} + +interface TemperatureHeatbedCommand { + command: string; + target: number; +}