Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Jun 5, 2024
2 parents 4c3054d + be1dcb6 commit 499c764
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 66 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Beacon Klipper is the klipper module for using the [Beacon](https://beacon3d.com

## Firmware Release Notes

### Beacon 2.0.1 - June 4, 2024
- Fixed USB enumeration issue affecting fast host controllers

### Beacon 2.0.0 - May 29, 2024
- Beacon Contact Release
- Adopted RTIC - The Hardware Accelerated Rust RTOS
Expand Down
140 changes: 76 additions & 64 deletions beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from mcu import MCU, MCU_trsync
from clocksync import SecondarySync
from extras.danger_options import get_danger_options
import msgproto

STREAM_BUFFER_LIMIT_DEFAULT = 100
STREAM_TIMEOUT = 1.0
Expand Down Expand Up @@ -282,81 +283,92 @@ def do():
pconfig.runtime_warning(result)
except AttributeError:
logging.info(result)
return result
else:
return ""

def _build_config(self):
self._check_mcu_version()

self.beacon_stream_cmd = self._mcu.lookup_command(
"beacon_stream en=%u", cq=self.cmd_queue
)
self.beacon_set_threshold = self._mcu.lookup_command(
"beacon_set_threshold trigger=%u untrigger=%u", cq=self.cmd_queue
)
self.beacon_home_cmd = self._mcu.lookup_command(
"beacon_home trsync_oid=%c trigger_reason=%c trigger_invert=%c",
cq=self.cmd_queue,
)
self.beacon_stop_home_cmd = self._mcu.lookup_command(
"beacon_stop_home", cq=self.cmd_queue
)
self.beacon_nvm_read_cmd = self._mcu.lookup_query_command(
"beacon_nvm_read len=%c offset=%hu",
"beacon_nvm_data bytes=%*s offset=%hu",
cq=self.cmd_queue,
)
self.beacon_contact_home_cmd = self._mcu.lookup_command(
"beacon_contact_home trsync_oid=%c trigger_reason=%c trigger_type=%c",
cq=self.cmd_queue,
)
self.beacon_contact_query_cmd = self._mcu.lookup_query_command(
"beacon_contact_query",
"beacon_contact_state triggered=%c detect_clock=%u",
cq=self.cmd_queue,
)
self.beacon_contact_stop_home_cmd = self._mcu.lookup_command(
"beacon_contact_stop_home",
cq=self.cmd_queue,
)
version_info = self._check_mcu_version()

constants = self._mcu.get_constants()
try:
self.beacon_stream_cmd = self._mcu.lookup_command(
"beacon_stream en=%u", cq=self.cmd_queue
)
self.beacon_set_threshold = self._mcu.lookup_command(
"beacon_set_threshold trigger=%u untrigger=%u", cq=self.cmd_queue
)
self.beacon_home_cmd = self._mcu.lookup_command(
"beacon_home trsync_oid=%c trigger_reason=%c trigger_invert=%c",
cq=self.cmd_queue,
)
self.beacon_stop_home_cmd = self._mcu.lookup_command(
"beacon_stop_home", cq=self.cmd_queue
)
self.beacon_nvm_read_cmd = self._mcu.lookup_query_command(
"beacon_nvm_read len=%c offset=%hu",
"beacon_nvm_data bytes=%*s offset=%hu",
cq=self.cmd_queue,
)
self.beacon_contact_home_cmd = self._mcu.lookup_command(
"beacon_contact_home trsync_oid=%c trigger_reason=%c trigger_type=%c",
cq=self.cmd_queue,
)
self.beacon_contact_query_cmd = self._mcu.lookup_query_command(
"beacon_contact_query",
"beacon_contact_state triggered=%c detect_clock=%u",
cq=self.cmd_queue,
)
self.beacon_contact_stop_home_cmd = self._mcu.lookup_command(
"beacon_contact_stop_home",
cq=self.cmd_queue,
)

self._mcu_freq = self._mcu._mcu_freq
constants = self._mcu.get_constants()

self.inv_adc_max = 1.0 / constants.get("ADC_MAX")
self.temp_smooth_count = constants.get("BEACON_ADC_SMOOTH_COUNT")
self.thermistor = thermistor.Thermistor(10000.0, 0.0)
self.thermistor.setup_coefficients_beta(25.0, 47000.0, 4101.0)
self._mcu_freq = self._mcu._mcu_freq

self.toolhead = self.printer.lookup_object("toolhead")
self.trapq = self.toolhead.get_trapq()
self.inv_adc_max = 1.0 / constants.get("ADC_MAX")
self.temp_smooth_count = constants.get("BEACON_ADC_SMOOTH_COUNT")
self.thermistor = thermistor.Thermistor(10000.0, 0.0)
self.thermistor.setup_coefficients_beta(25.0, 47000.0, 4101.0)

self.mcu_temp = BeaconMCUTempHelper.build_with_nvm(self)
self.model_temp = self.model_temp_builder.build_with_nvm(self)
if self.model_temp:
self.fmin = self.model_temp.fmin
if self.model is None:
self.model = self.models.get(self.default_model_name, None)
if self.model:
self._apply_threshold()
self.toolhead = self.printer.lookup_object("toolhead")
self.trapq = self.toolhead.get_trapq()

if self.beacon_stream_cmd is not None:
self.beacon_stream_cmd.send([1 if self._stream_en else 0])
if self._stream_en:
curtime = self.reactor.monotonic()
self.reactor.update_timer(
self._stream_timeout_timer, curtime + STREAM_TIMEOUT
)
else:
self.reactor.update_timer(self._stream_timeout_timer, self.reactor.NEVER)
self.mcu_temp = BeaconMCUTempHelper.build_with_nvm(self)
self.model_temp = self.model_temp_builder.build_with_nvm(self)
if self.model_temp:
self.fmin = self.model_temp.fmin
if self.model is None:
self.model = self.models.get(self.default_model_name, None)
if self.model:
self._apply_threshold()

if constants.get("BEACON_HAS_ACCEL", 0) == 1:
logging.info("Enabling Beacon accelerometer")
if self.accel_helper is None:
self.accel_helper = BeaconAccelHelper(
self, self.accel_config, constants
if self.beacon_stream_cmd is not None:
self.beacon_stream_cmd.send([1 if self._stream_en else 0])
if self._stream_en:
curtime = self.reactor.monotonic()
self.reactor.update_timer(
self._stream_timeout_timer, curtime + STREAM_TIMEOUT
)
else:
self.accel_helper.reinit(constants)
self.reactor.update_timer(
self._stream_timeout_timer, self.reactor.NEVER
)

if constants.get("BEACON_HAS_ACCEL", 0) == 1:
logging.info("Enabling Beacon accelerometer")
if self.accel_helper is None:
self.accel_helper = BeaconAccelHelper(
self, self.accel_config, constants
)
else:
self.accel_helper.reinit(constants)

except msgproto.error as e:
if version_info != "":
raise msgproto.error(version_info + "\n\n" + str(e))
raise

def _extend_stats(self):
parts = [
Expand Down
Binary file modified firmware/revd.dfu
Binary file not shown.
Binary file modified firmware/revh.dfu
Binary file not shown.
4 changes: 2 additions & 2 deletions update_firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def check_device_is_beacon(devpath):
if manufacturer != "Beacon" and vendor != "04d8":
return False
product = read_dev_file(devpath, "product")
if not product.startswith("Beacon "):
if product is None or not product.startswith("Beacon "):
return False
rev = product[7:].lower()
if not rev.startswith("rev"):
Expand Down Expand Up @@ -170,7 +170,7 @@ def task_check(device_path):
if actual_fw_version != desired_fw_version:
print(
"Outdated Beacon firmware version %s, current version is %s.\n"
"Please run `install.sh` or `update_firmware.py all` to update to the latest version.\n"
"Please run `install.sh` or `update_firmware.py update all` to update to the latest version.\n"
"Using an outdated firmware version can result in instability or failures."
% (actual_fw_version, desired_fw_version)
)
Expand Down

0 comments on commit 499c764

Please sign in to comment.