Skip to content

Commit

Permalink
Merge branch 'main' into reset_velocity_limits
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlz authored Dec 11, 2024
2 parents 0538761 + 136149b commit 1dc30b5
Show file tree
Hide file tree
Showing 76 changed files with 801 additions and 723 deletions.
3 changes: 3 additions & 0 deletions klippy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_NAME = "Kalico"

from .printer import * # noqa: E402, F403
3 changes: 3 additions & 0 deletions klippy/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .printer import main

main()
20 changes: 20 additions & 0 deletions klippy/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys


def hotpatch_modules():
"""
This is a compatibility shim for legacy external modules
to fix
Redirect legacy `import x` to `import klippy.x`
"""

for module_name, module in list(sys.modules.items()):
if not module_name.startswith("klippy."):
continue

hotpatched_name = module_name.removeprefix("klippy.")
if hotpatched_name in sys.modules:
continue

sys.modules[hotpatched_name] = module
6 changes: 4 additions & 2 deletions klippy/configfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Copyright (C) 2016-2021 Kevin O'Connor <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import sys, os, glob, re, time, logging, configparser, io, mathutil
from extras.danger_options import get_danger_options
import sys, os, glob, re, time, logging, configparser, io
from .extras.danger_options import get_danger_options
from . import mathutil


error = configparser.Error

Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/adc_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, bisect

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

######################################################################
# Interface between MCU adc and heater temperature callbacks
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/aht10.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from . import bus

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

######################################################################
# Compatible Sensors:
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/bed_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, math, json, collections
from . import probe
from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

PROFILE_VERSION = 1
PROFILE_OPTIONS = {
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/bed_tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
import mathutil
from klippy import mathutil
from . import probe


Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/bltouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
from . import probe
from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

SIGNAL_PERIOD = 0.020
MIN_CMD_TIME = 5 * SIGNAL_PERIOD
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/bme280.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from . import bus

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

REPORT_TIME = 0.8
BME280_CHIP_ADDR = 0x76
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2018,2019 Kevin O'Connor <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import mcu
from klippy import mcu


def resolve_bus_name(mcu, param, bus):
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/delta_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
import math
import mathutil
from klippy import mathutil
from . import probe

# A "stable position" is a 3-tuple containing the number of steps
Expand Down
5 changes: 3 additions & 2 deletions klippy/extras/ds18b20.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# Copyright (C) 2020 Alan Lord <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, mcu
import logging

from extras.danger_options import get_danger_options
from klippy import mcu
from .danger_options import get_danger_options

DS18_REPORT_TIME = 3.0
# Temperature can be sampled at any time but conversion time is ~750ms, so
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/endstop_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, logging
import stepper
from klippy import stepper

TRINAMIC_DRIVERS = [
"tmc2130",
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/extruder_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2019 Simo Apell <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
from kinematics import extruder
from klippy.kinematics import extruder


class PrinterExtruderStepper:
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/force_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, logging
import chelper
from klippy import chelper

BUZZ_DISTANCE = 1.0
BUZZ_VELOCITY = BUZZ_DISTANCE / 0.250
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/gcode_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import traceback, logging, ast, copy, json, threading
import jinja2, math
import configfile
from klippy import configfile

PYTHON_SCRIPT_PREFIX = "!"

Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/homing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import math
import logging
from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

# HOMING_START_DELAY = 0.001
# ENDSTOP_SAMPLE_TIME = 0.000015
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/htu21d.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from . import bus

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

######################################################################
# NOTE: The implementation requires write support of length 0
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/input_shaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import collections
import chelper
from klippy import chelper
from . import shaper_defs


Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/lm75.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from . import bus

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

LM75_CHIP_ADDR = 0x48
LM75_I2C_SPEED = 100000
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/manual_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2019-2021 Kevin O'Connor <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import stepper, chelper
from klippy import stepper, chelper
from . import force_move


Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/motion_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
import chelper
from klippy import chelper
from . import bulk_sensor


Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
import pins
import math
from klippy import pins
from . import manual_probe

HINT_TIMEOUT = """
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/probe_eddy_current.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, bisect
import mcu
from klippy import mcu
from . import ldc1612, probe, manual_probe


Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/pwm_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2017-2023 Kevin O'Connor <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import chelper
from klippy import chelper

MAX_SCHEDULE_TIME = 5.0

Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/replicape.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, os
import pins, mcu
from klippy import pins, mcu
from . import bus

REPLICAPE_MAX_CURRENT = 3.84
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/shaper_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import multiprocessing
import traceback

shaper_defs = importlib.import_module(".shaper_defs", "extras")
from . import shaper_defs

MIN_FREQ = 5.0
MAX_FREQ = 200.0
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/sht3x.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from . import bus

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

######################################################################
# Compatible Sensors:
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/spi_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import math, logging
from . import bus

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

######################################################################
# SensorBase
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import os, time, logging
from extras.danger_options import get_danger_options
from .danger_options import get_danger_options


class PrinterSysStats:
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/sx1509.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2018 Florian Heilmann <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import pins
from klippy import pins
from . import bus

# Word registers
Expand Down
50 changes: 37 additions & 13 deletions klippy/extras/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pathlib
import platform
import sys
import shlex
import threading
import urllib.request
import uuid
Expand Down Expand Up @@ -129,9 +130,7 @@ def cmd_TELEMETRY_EXAMPLE(self, gcmd):
with filename.open("w", encoding="utf-8") as fp:
json.dump(data, fp, indent=2)

gcmd.respond_info(
f"Example telemetry saved to {filename.relative_to(pathlib.Path.home())}"
)
gcmd.respond_info(f"Example telemetry saved to {filename}")

def _get_machine_id(self):
"""
Expand Down Expand Up @@ -198,26 +197,51 @@ def _collect_platform(self):
{
"machine": "x86_64",
"os_release": {
"NAME": "Debian GNU/Linux",
"ID": "debian",
"PRETTY_NAME": "Debian GNU/Linux trixie/sid",
"VERSION_CODENAME": "trixie",
"HOME_URL": "https://www.debian.org/",
"SUPPORT_URL": "https://www.debian.org/support",
"BUG_REPORT_URL": "https://bugs.debian.org/"
},
"os_release": { ... },
"version": "#1 SMP PREEMPT_DYNAMIC Debian 6.12~rc6-1~exp1 (2024-11-10)",
"python": "3.12.7 (main, Nov 8 2024, 17:55:36) [GCC 14.2.0]"
}
"""
return {
"machine": platform.machine(),
"os_release": platform.freedesktop_os_release(),
"os_release": self._collect_os_release(),
"version": platform.version(),
"python": sys.version,
}

def _collect_os_release(self):
"""
Collect the freedesktop OS-RELEASE information.
See also `platform.freedesktop_os_release()` (available in Python 3.10+)
{
"NAME": "Debian GNU/Linux",
"ID": "debian",
"PRETTY_NAME": "Debian GNU/Linux trixie/sid",
"VERSION_CODENAME": "trixie",
"HOME_URL": "https://www.debian.org/",
"SUPPORT_URL": "https://www.debian.org/support",
"BUG_REPORT_URL": "https://bugs.debian.org/"
}
"""
paths = [
pathlib.Path("/etc/os-release"),
pathlib.Path("/usr/lib/os-release"),
]
path = next(filter(pathlib.Path.exists, paths), None)
if not path:
return

result = {}
with path.open("r") as fp:
for line in fp:
if "=" not in line:
continue
key, value = line.split("=", maxsplit=1)
result[key] = shlex.split(value)[0]

return result

def _collect_printer_objects(self):
"""
Collect a list of all enabled objects in the current Kalico runtime
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/temperature_combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

REPORT_TIME = 0.300

Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/temperature_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import logging

from extras.danger_options import get_danger_options
from .danger_options import get_danger_options

HOST_REPORT_TIME = 1.0
RPI_PROC_TEMP_FILE = "/sys/class/thermal/thermal_zone0/temp"
Expand Down
Loading

0 comments on commit 1dc30b5

Please sign in to comment.