@@ -3,6 +3,7 @@ import type { GetterTree } from 'vuex'
33import type { RootState } from '../types'
44import type { PrinterState , Heater , Fan , Led , OutputPin , Sensor , RunoutSensor , KnownExtruder , MCU , Endstop , ExtruderStepper , Extruder , Stepper , ScrewsTiltAdjustScrew , ScrewsTiltAdjust , BedScrews , BedSize , GcodeCommands , TimeEstimates , KlippyApp , ExcludeObjectPart , KlipperPrinterConfig , BeaconModel , BedScrewsScrew , ExtruderKey , Probe } from './types'
55import getKlipperType from '@/util/get-klipper-type'
6+ import getMcusFromConfig from '@/util/get-klipper-mcus-from-config'
67import i18n from '@/plugins/i18n'
78import type { GcodeHelp } from '../console/types'
89import { Globals } from '@/globals'
@@ -334,9 +335,12 @@ export const getters = {
334335 for ( const key of mcuKeys ) {
335336 const config = state . printer . configfile . settings [ key . toLowerCase ( ) ]
336337
338+ const name = key . split ( ' ' , 2 ) . pop ( ) || ''
339+
337340 mcus . push ( {
338- name : key ,
341+ name,
339342 prettyName : Vue . $filters . prettyCase ( key ) ,
343+ key,
340344 ...state . printer [ key ] ,
341345 config,
342346 } )
@@ -345,6 +349,20 @@ export const getters = {
345349 return mcus
346350 } ,
347351
352+ getNonCriticalDisconnectedMcuNames : ( state , getters ) : string [ ] => {
353+ const klippyApp : KlippyApp = getters . getKlippyApp
354+
355+ if ( ! klippyApp . isKalico ) {
356+ return [ ]
357+ }
358+
359+ const mcus : MCU [ ] = getters . getMcus
360+
361+ return mcus
362+ . filter ( mcu => mcu . non_critical_disconnected )
363+ . map ( mcu => mcu . name )
364+ } ,
365+
348366 getHasExtruder : ( state ) => {
349367 return state . printer . extruder != null
350368 } ,
@@ -745,7 +763,8 @@ export const getters = {
745763 * Return available temperature probes / sensors.
746764 */
747765 getSensors : ( state , getters ) : Sensor [ ] => {
748- const klippyApp : KlippyApp = getters . getKlippyApp
766+ const nonCriticalDisconnectedMcuNames = new Set (
767+ getters . getNonCriticalDisconnectedMcuNames as string [ ] )
749768
750769 const sensors = Object . keys ( state . printer )
751770 . filter ( key => (
@@ -771,27 +790,13 @@ export const getters = {
771790 const color = Vue . $colorset . next ( getKlipperType ( key ) , key )
772791 const config = state . printer . configfile . settings [ key . toLowerCase ( ) ]
773792
774- const mcu = (
775- klippyApp . isKalico &&
793+ const mcus = (
794+ nonCriticalDisconnectedMcuNames . size > 0 &&
776795 config != null &&
777- (
778- (
779- 'i2c_mcu' in config &&
780- config . i2c_mcu
781- ) ||
782- (
783- 'sensor_mcu' in config &&
784- config . sensor_mcu
785- ) ||
786- (
787- 'sensor_pin' in config &&
788- config . sensor_pin ?. includes ( ':' ) &&
789- config . sensor_pin . split ( ':' ) [ 0 ]
790- )
791- )
796+ getMcusFromConfig ( config )
792797 )
793798
794- const kalicoTemperatureOverride = mcu && mcu !== 'mcu' && state . printer [ ` mcu ${ mcu } ` ] ?. non_critical_disconnected
799+ const kalicoTemperatureOverride = mcus && mcus . some ( mcu => nonCriticalDisconnectedMcuNames . has ( mcu ) )
795800 ? {
796801 temperature : null
797802 }
0 commit comments