@@ -28,7 +28,16 @@ export interface PrinterInfo {
28
28
29
29
export type PrinterInfoState = 'ready' | 'startup' | 'shutdown' | 'error'
30
30
31
- export interface KlipperPrinterState {
31
+ type NonZeroDigit = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
32
+ type Digit = '0' | NonZeroDigit
33
+
34
+ export type ExtruderKey = 'extruder' | `extruder${NonZeroDigit } ` | `extruder${NonZeroDigit } ${Digit } `
35
+
36
+ type KlipperPrinterStateBaseType = {
37
+ [ key in ExtruderKey ] ?: KlipperPrinterExtruderState
38
+ }
39
+
40
+ export interface KlipperPrinterState extends KlipperPrinterStateBaseType {
32
41
[ key : string ] : any ;
33
42
34
43
// These keys are always available
@@ -81,10 +90,6 @@ export interface KlipperPrinterState {
81
90
82
91
hall_filament_width_sensor ?: KlipperPrinterHallFilamentWidthSensorState ;
83
92
84
- extruder ?: KlipperPrinterExtruderState ;
85
-
86
- [ key : `extruder${number } `] : KlipperPrinterExtruderState ;
87
-
88
93
heater_bed ?: KlipperPrinterHeaterBedState ;
89
94
90
95
[ key : `heater_generic ${string } `] : KlipperPrinterHeaterGenericState ;
@@ -198,7 +203,7 @@ export interface KlipperPrinterToolheadState {
198
203
print_time : number ;
199
204
stalls : number ;
200
205
estimated_print_time : number ;
201
- extruder : string ;
206
+ extruder : '' | ExtruderKey ;
202
207
position : [ number , number , number , number ] ;
203
208
max_velocity : number ;
204
209
max_accel : number ;
@@ -564,26 +569,30 @@ export interface KlipperPrinterBeaconState {
564
569
export interface KlipperPrinterConfig extends Record < string , Record < string , string > > {
565
570
}
566
571
567
- export interface KlipperPrinterSettings {
572
+ type KlipperPrinterSettingsBaseType = {
573
+ [ key in ExtruderKey ] ?: KlipperPrinterExtruderSettings
574
+ }
575
+
576
+ export interface KlipperPrinterSettings extends KlipperPrinterSettingsBaseType {
568
577
[ key : string ] : any ;
569
578
570
579
mcu ?: KlipperPrinterMcuSettings ;
571
580
572
- [ key : `mcu ${string } `] : KlipperPrinterMcuSettings ;
581
+ [ key : `mcu ${Lowercase < string > } `] : KlipperPrinterMcuSettings ;
573
582
574
- [ key : `tmc${'2130' | '2208' | '2209' | '2660' | '2240' | '5160' } ${string } `] : KlipperPrinterTmcSettings ;
583
+ [ key : `tmc${'2130' | '2208' | '2209' | '2660' | '2240' | '5160' } ${Lowercase < string > } `] : KlipperPrinterTmcSettings ;
575
584
576
585
fan ?: KlipperPrinterFanSettings ;
577
586
578
- [ key : `${ ' heater_fan' } ${string } `] : KlipperPrinterHeaterFanSettings ;
587
+ [ key : `heater_fan ${Lowercase < string > } `] : KlipperPrinterHeaterFanSettings ;
579
588
580
- [ key : `${ ' controller_fan' } ${string } `] : KlipperPrinterControllerFanSettings ;
589
+ [ key : `controller_fan ${Lowercase < string > } `] : KlipperPrinterControllerFanSettings ;
581
590
582
- [ key : `output_pin ${string } `] : KlipperPrinterOutputPinSettings ;
591
+ [ key : `output_pin ${Lowercase < string > } `] : KlipperPrinterOutputPinSettings ;
583
592
584
- [ key : `${'led' | 'neopixel' | 'dotstar' | 'pca9533' | 'pca9632' } ${string } `] : KlipperPrinterLedSettings ;
593
+ [ key : `${'led' | 'neopixel' | 'dotstar' | 'pca9533' | 'pca9632' } ${Lowercase < string > } `] : KlipperPrinterLedSettings ;
585
594
586
- [ key : `temperature_sensor ${string } `] : KlipperPrinterTemperatureSensorSettings ;
595
+ [ key : `temperature_sensor ${Lowercase < string > } `] : KlipperPrinterTemperatureSensorSettings ;
587
596
588
597
safe_z_home ?: KlipperPrinterSafeZHomeSettings ;
589
598
@@ -593,7 +602,7 @@ export interface KlipperPrinterSettings {
593
602
594
603
board_pins ?: KlipperPrinterBoardPinsSettings ;
595
604
596
- [ key : `bed_mesh ${string } `] : KlipperPrinterBedMeshModelSettings ;
605
+ [ key : `bed_mesh ${Lowercase < string > } `] : KlipperPrinterBedMeshModelSettings ;
597
606
598
607
bed_screws ?: KlipperPrinterBedScrewsSettings ;
599
608
@@ -613,11 +622,11 @@ export interface KlipperPrinterSettings {
613
622
614
623
delta_calibrate ?: KlipperPrinterDeltaCalibrateSettings ;
615
624
616
- [ key : `gcode_macro ${string } `] : KlipperPrinterGcodeMacroSettings ;
625
+ [ key : `gcode_macro ${Lowercase < string > } `] : KlipperPrinterGcodeMacroSettings ;
617
626
618
627
heater_bed ?: KlipperPrinterHeaterBedSettings ;
619
628
620
- [ key : `verify_heater ${string } `] : KlipperPrinterVerifyHeaterSettings ;
629
+ [ key : `verify_heater ${Lowercase < string > } `] : KlipperPrinterVerifyHeaterSettings ;
621
630
622
631
probe ?: KlipperPrinterProbeSettings ;
623
632
@@ -627,27 +636,23 @@ export interface KlipperPrinterSettings {
627
636
628
637
printer ?: KlipperPrinterPrinterSettings ;
629
638
630
- [ key : `stepper_${string } `] : KlipperPrinterStepperSettings ;
639
+ [ key : `stepper_${Lowercase < string > } `] : KlipperPrinterStepperSettings ;
631
640
632
- [ key : `extruder_stepper ${string } `] : KlipperPrinterExtruderStepperSettings ;
641
+ [ key : `extruder_stepper ${Lowercase < string > } `] : KlipperPrinterExtruderStepperSettings ;
633
642
634
643
idle_timeout ?: KlipperPrinterIdleTimeoutSettings ;
635
644
636
- extruder ?: KlipperPrinterExtruderSettings ;
637
-
638
- [ key : `extruder${number } `] : KlipperPrinterExtruderSettings ;
639
-
640
645
exclude_object ?: KlipperPrinterExcludeObjectSettings ;
641
646
642
- [ key : `endstop_phase ${string } `] : KlipperPrinterEndstopPhaseSettings ;
647
+ [ key : `endstop_phase ${Lowercase < string > } `] : KlipperPrinterEndstopPhaseSettings ;
643
648
644
- [ key : `display_template ${string } `] : KlipperPrinterDisplayTemplateSettings ;
649
+ [ key : `display_template ${Lowercase < string > } `] : KlipperPrinterDisplayTemplateSettings ;
645
650
646
651
// These keys are for external modules
647
652
648
653
beacon ?: KlipperPrinterBeaconSettings ;
649
654
650
- [ key : `beacon model ${string } `] : KlipperPrinterBeaconModelSettings ;
655
+ [ key : `beacon model ${Lowercase < string > } `] : KlipperPrinterBeaconModelSettings ;
651
656
}
652
657
653
658
export interface KlipperPrinterMcuSettings {
@@ -1033,7 +1038,7 @@ export interface KlipperPrinterBeaconModelSettings extends Record<string, any> {
1033
1038
1034
1039
export interface KnownExtruder {
1035
1040
name : string ;
1036
- key : 'extruder' | `extruder${ number } ` ;
1041
+ key : ExtruderKey ;
1037
1042
}
1038
1043
1039
1044
export interface Extruder extends KlipperPrinterExtruderState {
@@ -1042,7 +1047,7 @@ export interface Extruder extends KlipperPrinterExtruderState {
1042
1047
}
1043
1048
1044
1049
export interface ExtruderStepper extends StepperType < ExtruderStepperConfig > {
1045
- motion_queue ?: string | null ;
1050
+ motion_queue ?: ExtruderKey | null ;
1046
1051
pressure_advance ?: number ;
1047
1052
smooth_time ?: number ;
1048
1053
}
0 commit comments