diff --git a/klippy/extras/bed_mesh.py b/klippy/extras/bed_mesh.py index 3850b5e4e..38b3233b8 100644 --- a/klippy/extras/bed_mesh.py +++ b/klippy/extras/bed_mesh.py @@ -793,9 +793,9 @@ def set_adaptive_mesh(self, gcmd): new_probe_count = max(new_x_probe_count, new_y_probe_count) # Adaptive meshes require odd number of points new_probe_count += 1 - (new_probe_count % 2) - self.mesh_config["x_count"] = self.mesh_config[ - "y_count" - ] = new_probe_count + self.mesh_config["x_count"] = self.mesh_config["y_count"] = ( + new_probe_count + ) else: self.mesh_min = adjusted_mesh_min self.mesh_max = adjusted_mesh_max @@ -1504,9 +1504,9 @@ def __init__(self, config, bedmesh): self.profiles[name] = {} zvals = profile.getlists("points", seps=(",", "\n"), parser=float) self.profiles[name]["points"] = zvals - self.profiles[name][ - "mesh_params" - ] = params = collections.OrderedDict() + self.profiles[name]["mesh_params"] = params = ( + collections.OrderedDict() + ) for key, t in PROFILE_OPTIONS.items(): if t is int: params[key] = profile.getint(key) diff --git a/klippy/extras/bed_tilt.py b/klippy/extras/bed_tilt.py index 5f4cbf6cf..2b09cb35a 100644 --- a/klippy/extras/bed_tilt.py +++ b/klippy/extras/bed_tilt.py @@ -90,6 +90,7 @@ def probe_finalize(self, offsets, positions): "z_adjust": z_offset, } logging.info("Initial bed_tilt parameters: %s", params) + # Perform coordinate descent def adjusted_height(pos, params): x, y, z = pos diff --git a/klippy/extras/bus.py b/klippy/extras/bus.py index adebc35a4..d81f3fb68 100644 --- a/klippy/extras/bus.py +++ b/klippy/extras/bus.py @@ -38,6 +38,7 @@ def resolve_bus_name(mcu, param, bus): # SPI ###################################################################### + # Helper code for working with devices connected to an MCU via an SPI bus class MCU_SPI: def __init__( @@ -176,6 +177,7 @@ def MCU_SPI_from_config( # I2C ###################################################################### + # Helper code for working with devices connected to an MCU via an I2C bus class MCU_I2C: def __init__(self, mcu, bus, addr, speed, sw_pins=None): @@ -297,6 +299,7 @@ def MCU_I2C_from_config(config, default_addr=None, default_speed=100000): # Bus synchronized digital outputs ###################################################################### + # Helper code for a gpio that updates on a cmd_queue class MCU_bus_digital_out: def __init__(self, mcu, pin_desc, cmd_queue=None, value=0): diff --git a/klippy/extras/delta_calibrate.py b/klippy/extras/delta_calibrate.py index 9d8aaada9..4eb4b587e 100644 --- a/klippy/extras/delta_calibrate.py +++ b/klippy/extras/delta_calibrate.py @@ -13,6 +13,7 @@ # calibration uses this coordinate system because it allows a position # to be described independent of the software parameters. + # Load a stable position from a config entry def load_config_stable(config, option): return config.getfloatlist(option, count=3) @@ -31,6 +32,7 @@ def load_config_stable(config, option): # How much to prefer a distance measurement over a height measurement MEASURE_WEIGHT = 0.5 + # Convert distance measurements made on the calibration object to # 3-tuples of (actual_distance, stable_position1, stable_position2) def measurements_to_distances(measured_params, delta_params): @@ -214,6 +216,7 @@ def calculate_params(self, probe_positions, distances): z_weight = 1.0 if distances: z_weight = len(distances) / (MEASURE_WEIGHT * len(probe_positions)) + # Perform coordinate descent def delta_errorfunc(params): try: diff --git a/klippy/extras/display/display.py b/klippy/extras/display/display.py index 2b10fa86e..bd61aa399 100644 --- a/klippy/extras/display/display.py +++ b/klippy/extras/display/display.py @@ -23,6 +23,7 @@ "hd44780_spi": hd44780_spi.hd44780_spi, } + # Storage of [display_template my_template] config sections class DisplayTemplate: def __init__(self, config): diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py index da82e5bff..af45e0f6c 100644 --- a/klippy/extras/display/menu.py +++ b/klippy/extras/display/menu.py @@ -311,9 +311,9 @@ def add_parents(self, parents): self._parents.append(parents) def assert_recursive_relation(self, parents=None): - assert self not in ( - parents or self._parents - ), "Recursive relation of '%s' container" % (self.get_ns(),) + assert self not in (parents or self._parents), ( + "Recursive relation of '%s' container" % (self.get_ns(),) + ) def insert_item(self, s, index=None): self._insert_item(s, index) diff --git a/klippy/extras/exclude_object.py b/klippy/extras/exclude_object.py index 75d52f463..4a66d4524 100644 --- a/klippy/extras/exclude_object.py +++ b/klippy/extras/exclude_object.py @@ -104,9 +104,9 @@ def _get_extrusion_offsets(self): ) if offset is None: offset = [0.0, 0.0, 0.0, 0.0] - self.extrusion_offsets[ - self.toolhead.get_extruder().get_name() - ] = offset + self.extrusion_offsets[self.toolhead.get_extruder().get_name()] = ( + offset + ) return offset def get_position(self): diff --git a/klippy/extras/firmware_retraction.py b/klippy/extras/firmware_retraction.py index b393b0fbf..731502897 100644 --- a/klippy/extras/firmware_retraction.py +++ b/klippy/extras/firmware_retraction.py @@ -80,7 +80,6 @@ def _get_config_params(self): # Helper method to register commands and instantiate required objects def _handle_ready(self): - self.gcode_move = self.printer.lookup_object("gcode_move") self.toolhead = self.printer.lookup_object("toolhead") diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index 9960b1baa..c68c0f41c 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -563,15 +563,10 @@ def load_profile(self, profile_name, gcmd, verbose): if profile["smooth_time"] is None else profile["smooth_time"] ) - msg = ( - "Target: %.2f\n" - "Tolerance: %.4f\n" - "Control: %s\n" - % ( - profile["pid_target"], - profile["pid_tolerance"], - profile["control"], - ) + msg = "Target: %.2f\n" "Tolerance: %.4f\n" "Control: %s\n" % ( + profile["pid_target"], + profile["pid_tolerance"], + profile["control"], ) if smooth_time is not None: msg += "Smooth Time: %.3f\n" % smooth_time diff --git a/klippy/extras/led.py b/klippy/extras/led.py index 8c8c19994..8b4c7feae 100644 --- a/klippy/extras/led.py +++ b/klippy/extras/led.py @@ -9,6 +9,7 @@ # Time between each led template update RENDER_TIME = 0.500 + # Helper code for common LED initialization and control class LEDHelper: def __init__(self, config, update_func, led_count=1): @@ -66,6 +67,7 @@ def cmd_SET_LED(self, gcmd): transmit = gcmd.get_int("TRANSMIT", 1) sync = gcmd.get_int("SYNC", 1) color = (red, green, blue, white) + # Update and transmit data def lookahead_bgfunc(print_time): self.set_color(index, color) @@ -205,6 +207,7 @@ def cmd_SET_LED_TEMPLATE(self, gcmd): PIN_MIN_TIME = 0.100 MAX_SCHEDULE_TIME = 5.0 + # Handler for PWM controlled LEDs class PrinterPWMLED: def __init__(self, config): diff --git a/klippy/extras/manual_probe.py b/klippy/extras/manual_probe.py index 709fd4463..0fa73f509 100644 --- a/klippy/extras/manual_probe.py +++ b/klippy/extras/manual_probe.py @@ -153,6 +153,7 @@ def verify_no_manual_probe(printer): Z_BOB_MINIMUM = 0.500 BISECT_MAX = 0.200 + # Helper script to determine a Z height class ManualProbeHelper: def __init__(self, printer, gcmd, finalize_callback): diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py index 0e6d14f0b..1fe697698 100644 --- a/klippy/extras/replicape.py +++ b/klippy/extras/replicape.py @@ -96,7 +96,10 @@ def set_pwm(self, print_time, value): self._is_enable = is_enable self._reactor.register_async_callback( ( - lambda e, s=self, pt=print_time, ie=is_enable: s._replicape.note_pwm_enable( + lambda e, + s=self, + pt=print_time, + ie=is_enable: s._replicape.note_pwm_enable( pt, s._channel, ie ) ) diff --git a/klippy/extras/spi_temperature.py b/klippy/extras/spi_temperature.py index b63c160ff..5556ced37 100644 --- a/klippy/extras/spi_temperature.py +++ b/klippy/extras/spi_temperature.py @@ -360,9 +360,7 @@ def calc_temp(self, adc): # R_div_nominal = 1. + CVD_A * temp + CVD_B * temp**2 # Solve for temp using quadratic equation: # temp = (-b +- sqrt(b**2 - 4ac)) / 2a - discriminant = math.sqrt( - CVD_A**2 - 4.0 * CVD_B * (1.0 - R_div_nominal) - ) + discriminant = math.sqrt(CVD_A**2 - 4.0 * CVD_B * (1.0 - R_div_nominal)) temp = (-CVD_A + discriminant) / (2.0 * CVD_B) return temp diff --git a/klippy/extras/stepper_enable.py b/klippy/extras/stepper_enable.py index 6ca12e3a9..1c7d5d69a 100644 --- a/klippy/extras/stepper_enable.py +++ b/klippy/extras/stepper_enable.py @@ -7,6 +7,7 @@ DISABLE_STALL_TIME = 0.100 + # Tracking of shared stepper enable pins class StepperEnablePin: def __init__(self, mcu_enable, enable_count): diff --git a/klippy/extras/thermistor.py b/klippy/extras/thermistor.py index 88f87c208..99a2a23ee 100644 --- a/klippy/extras/thermistor.py +++ b/klippy/extras/thermistor.py @@ -8,6 +8,7 @@ KELVIN_TO_CELSIUS = -273.15 + # Analog voltage to temperature converter for thermistors class Thermistor: def __init__(self, pullup, inline_resistor): diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index a211f4228..e7ba9ddd5 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -302,8 +302,7 @@ def reg_read(self, reg, chain_pos): params = self.spi.spi_transfer(cmd) pr = bytearray(params["response"]) pr = pr[ - (self.chain_len - chain_pos) - * 5 : (self.chain_len - chain_pos + 1) + (self.chain_len - chain_pos) * 5 : (self.chain_len - chain_pos + 1) * 5 ] return (pr[1] << 24) | (pr[2] << 16) | (pr[3] << 8) | pr[4] @@ -329,8 +328,7 @@ def reg_write(self, reg, val, chain_pos, print_time=None): ) pr = bytearray(params["response"]) pr = pr[ - (self.chain_len - chain_pos) - * 5 : (self.chain_len - chain_pos + 1) + (self.chain_len - chain_pos) * 5 : (self.chain_len - chain_pos + 1) * 5 ] return (pr[1] << 24) | (pr[2] << 16) | (pr[3] << 8) | pr[4] diff --git a/klippy/extras/tmc_uart.py b/klippy/extras/tmc_uart.py index 41a562e80..74a4b9664 100644 --- a/klippy/extras/tmc_uart.py +++ b/klippy/extras/tmc_uart.py @@ -62,6 +62,7 @@ def activate(self, instance_id): # TMC uart communication ###################################################################### + # Share mutexes so only one active tmc_uart command on a single mcu at # a time. This helps limit cpu usage on slower micro-controllers. class PrinterTMCUartMutexes: @@ -85,6 +86,7 @@ def lookup_tmc_uart_mutex(mcu): TMC_BAUD_RATE = 40000 TMC_BAUD_RATE_AVR = 9000 + # Code for sending messages on a TMC uart class MCU_TMC_uart_bitbang: def __init__(self, rx_pin_params, tx_pin_params, select_pins_desc): diff --git a/klippy/extras/trad_rack.py b/klippy/extras/trad_rack.py index 87eef2691..ff24f522b 100644 --- a/klippy/extras/trad_rack.py +++ b/klippy/extras/trad_rack.py @@ -17,7 +17,6 @@ class TradRack: - VARS_CALIB_BOWDEN_LOAD_LENGTH = "tr_calib_bowden_load_length" VARS_CALIB_BOWDEN_UNLOAD_LENGTH = "tr_calib_bowden_unload_length" VARS_CONFIG_BOWDEN_LENGTH = "tr_config_bowden_length" @@ -120,11 +119,9 @@ def __init__(self, config): self.eject_length = config.getfloat( "eject_length", default=30.0, above=0.0 ) - self.config_bowden_length = ( - self.bowden_load_length - ) = self.bowden_unload_length = config.getfloat( - "bowden_length", above=0.0 - ) + self.config_bowden_length = self.bowden_load_length = ( + self.bowden_unload_length + ) = config.getfloat("bowden_length", above=0.0) self.extruder_load_length = config.getfloat( "extruder_load_length", above=0.0 ) @@ -2281,12 +2278,12 @@ def __init__(self, config, buffer_pull_speed, is_extruder_synced): # Flush tracking self.flush_timer = self.reactor.register_timer(self._flush_handler) self.do_kick_flush_timer = True - self.last_flush_time = ( - self.last_sg_flush_time - ) = self.min_restart_time = 0.0 - self.need_flush_time = ( - self.step_gen_time - ) = self.clear_history_time = 0.0 + self.last_flush_time = self.last_sg_flush_time = ( + self.min_restart_time + ) = 0.0 + self.need_flush_time = self.step_gen_time = self.clear_history_time = ( + 0.0 + ) # Kinematic step generation scan window time tracking self.kin_flush_delay = toolhead.SDS_CHECK_TIME self.kin_flush_times = [] diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py index faf43f615..3c953ed6c 100644 --- a/klippy/extras/z_tilt.py +++ b/klippy/extras/z_tilt.py @@ -193,6 +193,7 @@ def probe_finalize(self, offsets, positions): z_offset = offsets[2] logging.info("Calculating bed tilt with: %s", positions) params = {"x_adjust": 0.0, "y_adjust": 0.0, "z_adjust": z_offset} + # Perform coordinate descent def adjusted_height(pos, params): x, y, z = pos diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py index 5f696a68f..7fd309658 100644 --- a/klippy/kinematics/delta.py +++ b/klippy/kinematics/delta.py @@ -106,8 +106,7 @@ def ratio_to_xy(ratio): return ( ratio * math.sqrt( - min_arm_length**2 / (ratio**2 + 1.0) - - half_min_step_dist**2 + min_arm_length**2 / (ratio**2 + 1.0) - half_min_step_dist**2 ) + half_min_step_dist - radius @@ -283,9 +282,7 @@ def get_position_from_stable(self, stable_position): self.stepdists, self.towers, self.abs_endstops, stable_position ) ] - return mathutil.trilateration( - sphere_coords, [a**2 for a in self.arms] - ) + return mathutil.trilateration(sphere_coords, [a**2 for a in self.arms]) def calc_stable_position(self, coord): # Return a stable_position from a cartesian coordinate diff --git a/klippy/mathutil.py b/klippy/mathutil.py index a166f1fb6..a53ad6d79 100644 --- a/klippy/mathutil.py +++ b/klippy/mathutil.py @@ -11,6 +11,7 @@ # Coordinate descent ###################################################################### + # Helper code that implements coordinate descent def coordinate_descent(adj_params, params, error_func): # Define potential changes @@ -91,6 +92,7 @@ def wrapper(): # Trilateration ###################################################################### + # Trilateration finds the intersection of three spheres. See the # wikipedia article for the details of the algorithm. def trilateration(sphere_coords, radius2): diff --git a/klippy/mcu.py b/klippy/mcu.py index 65745c5cf..654912fe6 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -1361,16 +1361,12 @@ def stats(self, eventtime): Common_MCU_errors = { - ( - "Timer too close", - ): """ + ("Timer too close",): """ This often indicates the host computer is overloaded. Check for other processes consuming excessive CPU time, high swap usage, disk errors, overheating, unstable voltage, or similar system problems on the host computer.""", - ( - "Missed scheduling of next ", - ): """ + ("Missed scheduling of next ",): """ This is generally indicative of an intermittent communication failure between micro-controller and host.""", ( @@ -1386,9 +1382,7 @@ def stats(self, eventtime): This generally occurs when the micro-controller has been requested to step at a rate higher than it is capable of obtaining.""", - ( - "Command request", - ): """ + ("Command request",): """ This generally occurs in response to an M112 G-Code command or in response to an internal error in the host software.""", } diff --git a/klippy/msgproto.py b/klippy/msgproto.py index a99aa3da3..b3840754f 100644 --- a/klippy/msgproto.py +++ b/klippy/msgproto.py @@ -156,6 +156,7 @@ def parse(self, s, pos): "%*s": PT_buffer(), } + # Lookup the message types for a format string def lookup_params(msgformat, enumerations={}): out = [] diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 080724c3a..d065ea4df 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -296,9 +296,9 @@ def __init__(self, config): self.flush_timer = self.reactor.register_timer(self._flush_handler) self.do_kick_flush_timer = True self.last_flush_time = self.min_restart_time = 0.0 - self.need_flush_time = ( - self.step_gen_time - ) = self.clear_history_time = 0.0 + self.need_flush_time = self.step_gen_time = self.clear_history_time = ( + 0.0 + ) # Kinematic step generation scan window time tracking self.kin_flush_delay = SDS_CHECK_TIME self.kin_flush_times = [] diff --git a/klippy/util.py b/klippy/util.py index 1bf0190f4..e40f493c9 100644 --- a/klippy/util.py +++ b/klippy/util.py @@ -12,6 +12,7 @@ # Low-level Unix commands ###################################################################### + # Return the SIGINT interrupt handler back to the OS default def fix_sigint(): signal.signal(signal.SIGINT, signal.SIG_DFL) @@ -19,6 +20,7 @@ def fix_sigint(): fix_sigint() + # Set a file-descriptor as non-blocking def set_nonblock(fd): fcntl.fcntl( diff --git a/klippy/webhooks.py b/klippy/webhooks.py index e28bcaaa2..b8a44fef9 100644 --- a/klippy/webhooks.py +++ b/klippy/webhooks.py @@ -19,7 +19,6 @@ if sys.version_info.major < 3: def json_loads_byteify(data, ignore_dicts=False): - if isinstance(data, bytes): return data.decode("utf-8") if isinstance(data, list): diff --git a/scripts/avrsim.py b/scripts/avrsim.py index d0c63f756..c32913ff2 100755 --- a/scripts/avrsim.py +++ b/scripts/avrsim.py @@ -10,6 +10,7 @@ SERIALBITS = 10 # 8N1 = 1 start, 8 data, 1 stop SIMULAVR_FREQ = 10**9 + # Class to read serial data from AVR serial transmit pin. class SerialRxPin(pysimulavr.PySimulationMember, pysimulavr.Pin): def __init__(self, baud, terminal): diff --git a/scripts/calibrate_shaper.py b/scripts/calibrate_shaper.py index 32f9e09db..77c2f2521 100755 --- a/scripts/calibrate_shaper.py +++ b/scripts/calibrate_shaper.py @@ -47,6 +47,7 @@ def parse_log(logname): # Shaper calibration ###################################################################### + # Find the best shaper parameters def calibrate_shaper( datas, @@ -58,7 +59,7 @@ def calibrate_shaper( shaper_freqs, max_smoothing, test_damping_ratios, - max_freq + max_freq, ): helper = shaper_calibrate.ShaperCalibrate(printer=None) if isinstance(datas[0], shaper_calibrate.CalibrationData): diff --git a/scripts/graph_accelerometer.py b/scripts/graph_accelerometer.py index 465199602..b50e0f728 100755 --- a/scripts/graph_accelerometer.py +++ b/scripts/graph_accelerometer.py @@ -86,6 +86,7 @@ def plot_accel(datas, lognames): # Frequency graphing ###################################################################### + # Calculate estimated "power spectral density" def calc_freq_response(data, max_freq): if isinstance(data, shaper_calibrate.CalibrationData): diff --git a/scripts/graph_extruder.py b/scripts/graph_extruder.py index de5ae4698..9b3e16ba0 100755 --- a/scripts/graph_extruder.py +++ b/scripts/graph_extruder.py @@ -80,6 +80,7 @@ def trim_lists(*lists): # Common data filters ###################################################################### + # Generate estimated first order derivative def gen_deriv(data): return [0.0] + [ @@ -127,6 +128,7 @@ def calc_weighted(positions, smooth_time): SMOOTH_TIME = 0.040 PRESSURE_ADVANCE = 0.045 + # Calculate raw pressure advance positions def calc_pa_raw(positions): pa = PRESSURE_ADVANCE * INV_SEG_TIME diff --git a/scripts/graph_motion.py b/scripts/graph_motion.py index 1096b041f..79a88de6d 100755 --- a/scripts/graph_motion.py +++ b/scripts/graph_motion.py @@ -87,6 +87,7 @@ def get_acc_pos_ao6(rel_t, start_v, accel, move_t): get_acc_pos = get_acc_pos_ao2 get_acc = get_accel + # Calculate positions based on 'Moves' list def gen_positions(): out = [] @@ -150,6 +151,7 @@ def trim_lists(*lists): # Common data filters ###################################################################### + # Generate estimated first order derivative def gen_deriv(data): return [0.0] + [ @@ -211,7 +213,7 @@ def calc_weighted4(positions, smooth_time): out = [0.0] * len(positions) for i in indexes(positions): weighted_data = [ - positions[j] * ((offset**2 - (j - i) ** 2)) ** 2 + positions[j] * (offset**2 - (j - i) ** 2) ** 2 for j in range(i - offset, i + offset) ] out[i] = sum(weighted_data) * weight diff --git a/scripts/logextract.py b/scripts/logextract.py index ee5bf793d..1e7cc65c0 100755 --- a/scripts/logextract.py +++ b/scripts/logextract.py @@ -198,6 +198,7 @@ def add_high_bits(val, ref, mask): + "," ) + # MCU "Sent" shutdown message parsing class MCUSentStream: def __init__(self, mcu, count): @@ -238,6 +239,7 @@ def get_lines(self): + "," ) + # MCU "Receive" shutdown message parsing class MCUReceiveStream: def __init__(self, mcu): @@ -280,6 +282,7 @@ def get_lines(self): + r'|"[^"]*"))' ) + # MCU shutdown message parsing class MCUStream: def __init__(self, name): @@ -345,6 +348,7 @@ def get_lines(self): r"^queue_step " + count_s + r": t=" + clock_s + r" " ) + # Kinematic "trapq" shutdown message parsing class StepperStream: def __init__(self, name, mcu_name, mcus): @@ -376,6 +380,7 @@ def get_lines(self): trapq_move_r = re.compile(r"^move " + count_s + r": pt=" + time_s) + # Kinematic "trapq" shutdown message parsing class TrapQStream: def __init__(self, name, mcus): @@ -411,6 +416,7 @@ def get_lines(self): gcode_cmd_r = re.compile(r"^Read " + time_s + r": (?P['\"].*)$") varlist_split_r = re.compile(r"([^ ]+)=") + # G-Code shutdown message parsing class GCodeStream: def __init__(self, shutdown_line_num, logname): @@ -474,6 +480,7 @@ def get_lines(self): api_cmd_r = re.compile(r"^Received " + time_s + r": \{.*\}$") + # API server shutdowm message parsing class APIStream: def __init__(self): @@ -511,6 +518,7 @@ def get_lines(self): + r"$" ) + # Stats message parsing and high-level message dispatch class StatsStream: def __init__(self, shutdown_line_num, logname): diff --git a/scripts/motan/analyzers.py b/scripts/motan/analyzers.py index eed809f05..582a073b6 100644 --- a/scripts/motan/analyzers.py +++ b/scripts/motan/analyzers.py @@ -14,6 +14,7 @@ # Analyzer handlers: {name: class, ...} AHandlers = {} + # Calculate a derivative (position to velocity, or velocity to accel) class GenDerivative: ParametersMin = ParametersMax = 1 @@ -52,6 +53,7 @@ def generate_data(self): AHandlers["derivative"] = GenDerivative + # Calculate an integral (accel to velocity, or velocity to position) class GenIntegral: ParametersMin = 1 @@ -120,6 +122,7 @@ def generate_data(self): AHandlers["integral"] = GenIntegral + # Calculate a pointwise 2-norm of several datasets (e.g. compute velocity or # accel from its x, y,... components) class GenNorm2: @@ -232,6 +235,7 @@ def generate_data(self): AHandlers["smooth"] = GenSmoothed + # Calculate a kinematic stepper position from the toolhead requested position class GenKinematicPosition: ParametersMin = ParametersMax = 1 @@ -285,6 +289,7 @@ def generate_data_passthrough(self): AHandlers["kin"] = GenKinematicPosition + # Calculate a toolhead x/y position from corexy stepper positions class GenCorexyPosition: ParametersMin = ParametersMax = 3 @@ -320,6 +325,7 @@ def generate_data(self): AHandlers["corexy"] = GenCorexyPosition + # Calculate a position deviation class GenDeviation: ParametersMin = ParametersMax = 2 @@ -356,6 +362,7 @@ def generate_data(self): # Analyzer management and data generation ###################################################################### + # Return a description of available analyzers def list_datasets(): datasets = [] diff --git a/scripts/spi_flash/spi_flash.py b/scripts/spi_flash/spi_flash.py index 46d2440b3..071bb5b66 100644 --- a/scripts/spi_flash/spi_flash.py +++ b/scripts/spi_flash/spi_flash.py @@ -243,6 +243,7 @@ def sdio_set_speed(self, speed): STA_WRITE_PROTECT = 1 << 2 SECTOR_SIZE = 512 + # FAT16/32 File System Support class FatFS: def __init__(self, ser, spi=True): @@ -624,7 +625,7 @@ def init_sd(self): resp = self._send_command_with_response( "SEND_IF_COND", (1 << 8) | check_pattern ) - resp = resp.strip(b"\xFF") + resp = resp.strip(b"\xff") if resp and resp[0] & (1 << 2): # CMD8 is illegal, this is a version 1.0 card self.sd_version = 1 @@ -658,7 +659,7 @@ def init_sd(self): ) # Read OCR Register (CMD58) resp = self._send_command_with_response("READ_OCR", 0) - resp = resp.strip(b"\xFF") + resp = resp.strip(b"\xff") # If 'READ_OCR' is illegal then this is likely MMC. # At this time MMC is not supported if len(resp) == 5: @@ -726,7 +727,7 @@ def _check_command(self, expected, cmd, args, is_app_cmd=False, tries=15): resp, rt = func(cmd, args, get_rt=True) # logging.info("flash_sdcard: Check cmd %s, response: %s" # % (cmd, repr(resp))) - resp = resp.strip(b"\xFF") + resp = resp.strip(b"\xff") if resp and expected == resp[0]: return True tries -= 1 @@ -953,7 +954,7 @@ def write_sector(self, sector, data): ) else: status = self._send_command_with_response("SEND_STATUS", 0) - status = status.strip(b"\xFF") + status = status.strip(b"\xff") if len(status) == 2: if status[1] != 0: err_msgs.append( @@ -1009,7 +1010,7 @@ def check_for_ocr_errors(reg): resp = self._send_command_with_response( "SEND_IF_COND", (1 << 8) | check_pattern ) - resp = resp.strip(b"\xFF") + resp = resp.strip(b"\xff") if len(resp) != 4: # CMD8 is illegal, this is a version 1.0 card self.sd_version = 1 @@ -1021,7 +1022,6 @@ def check_for_ocr_errors(reg): "compatible voltage range" ) if self.sd_version == 2: - # Init card and come out of idle (ACMD41) # Version 2 Cards may init before checking the OCR # Allow vor LVDS card with 1.8v, too. @@ -1330,7 +1330,7 @@ def write_sector(self, sector, data): raise OSError( "flash_sdcard: Write error." " Card is not in transfer state: 0x%02X" - % (((status[3] >> 1) & 0x0F)) + % ((status[3] >> 1) & 0x0F) ) diff --git a/scripts/whconsole.py b/scripts/whconsole.py index 0293ee5b0..8154ff894 100755 --- a/scripts/whconsole.py +++ b/scripts/whconsole.py @@ -6,6 +6,7 @@ # This file may be distributed under the terms of the GNU GPLv3 license. import sys, os, optparse, socket, fcntl, select, json, errno, time + # Set a file-descriptor as non-blocking def set_nonblock(fd): fcntl.fcntl(