@@ -89,6 +89,28 @@ def __init__(self, config):
8989
9090 cmd_STOP_LED_EFFECTS_help = 'Stops all led_effects'
9191
92+ def _transmit_chain (self , chain ):
93+
94+ # Force update (dotstar workaround)
95+ if hasattr (chain , "prev_data" ):
96+ chain .prev_data = None
97+
98+ helper = getattr (chain , 'led_helper' , None )
99+ if helper is None :
100+ raise RuntimeError ("Klipper version not compatible: chain has no 'led_helper'." )
101+
102+ # Request a transmit
103+ helper .need_transmit = True
104+
105+ if hasattr (helper , '_check_transmit' ):
106+ helper ._check_transmit ()
107+ elif hasattr (helper , 'check_transmit' ):
108+ # Older Klipper / Kalico API
109+ helper .check_transmit (None )
110+ else :
111+ raise RuntimeError ("Klipper version not compatible: led_helper missing '_check_transmit' and 'check_transmit'." )
112+
113+
92114 def _handle_ready (self ):
93115 self .shutdown = False
94116 self .reactor = self .printer .get_reactor ()
@@ -107,8 +129,7 @@ def _handle_shutdown(self):
107129 if not effect .runOnShutown :
108130 for chain in self .ledChains :
109131 chain .led_helper .set_color (None , (0.0 , 0.0 , 0.0 , 0.0 ))
110- chain .led_helper .need_transmit = True
111- chain .led_helper ._check_transmit ()
132+ self ._transmit_chain (chain )
112133
113134 pass
114135
@@ -233,11 +254,8 @@ def _getFrames(self, eventtime):
233254 chainsToUpdate .add (chain )
234255
235256 for chain in chainsToUpdate :
236- if hasattr (chain ,"prev_data" ):
237- chain .prev_data = None # workaround to force update of dotstars
238257 if not self .shutdown :
239- chain .led_helper .need_transmit = True
240- chain .led_helper ._check_transmit ()
258+ self ._transmit_chain (chain )
241259 if self .effects :
242260 next_eventtime = min (self .effects , key = lambda x : x .nextEventTime )\
243261 .nextEventTime
@@ -368,7 +386,13 @@ def __init__(self, config):
368386 if self .analogPin :
369387 ppins = self .printer .lookup_object ('pins' )
370388 self .mcu_adc = ppins .setup_pin ('adc' , self .analogPin )
371- self .mcu_adc .setup_adc_sample (ANALOG_SAMPLE_TIME , ANALOG_SAMPLE_COUNT )
389+ if hasattr (self .mcu_adc , 'setup_adc_sample' ):
390+ self .mcu_adc .setup_adc_sample (ANALOG_SAMPLE_TIME , ANALOG_SAMPLE_COUNT )
391+ elif hasattr (self .mcu_adc , 'setup_minmax' ):
392+ self .mcu_adc .setup_minmax (ANALOG_SAMPLE_TIME , ANALOG_SAMPLE_COUNT )
393+ else :
394+ raise RuntimeError (
395+ "Klipper version not compatible: mcu_adc missing 'setup_adc_sample' and 'setup_minmax'." )
372396 self .mcu_adc .setup_adc_callback (ANALOG_REPORT_TIME , self .adcCallback )
373397 query_adc = self .printer .load_object (self .config , 'query_adc' )
374398 query_adc .register_adc (self .name , self .mcu_adc )
0 commit comments