mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-03-06 10:04:40 -07:00
motan: Rename "adxl345" dataset to "accelerometer"
Make it possible to use other types of accelerometers in the motan_graph.py tool. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
43b2d55d9b
commit
3aa56f3bd0
2 changed files with 11 additions and 9 deletions
|
|
@ -12,9 +12,9 @@ ClientInfo = {'program': 'motan_data_logger', 'version': 'v0.1'}
|
|||
# Available subscriptions when a given config type is found
|
||||
ConfigSubscriptions = [
|
||||
# (cfgtype, capture_name, api_request, request_params)
|
||||
('adxl345', '{ct}:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('lis2dw', '{ct}:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('mpu9250', '{ct}:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('adxl345', 'accelerometer:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('lis2dw', 'accelerometer:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('mpu9250', 'accelerometer:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('angle', '{ct}:{csn}', '{ct}/dump_{ct}', {'sensor': '{csn}'}),
|
||||
('probe_eddy_current', 'ldc1612:{csn}', 'ldc1612/dump_ldc1612',
|
||||
{'sensor': '{csn}'}),
|
||||
|
|
|
|||
|
|
@ -393,25 +393,26 @@ class HandleStepPhase:
|
|||
LogHandlers["step_phase"] = HandleStepPhase
|
||||
|
||||
# Extract accelerometer data
|
||||
class HandleADXL345:
|
||||
class HandleAccelerometer:
|
||||
SubscriptionIdParts = 2
|
||||
ParametersMin = ParametersMax = 2
|
||||
DataSets = [
|
||||
('adxl345(<name>,<axis>)', 'Accelerometer for given axis (x, y, or z)'),
|
||||
('accelerometer(<name>,<axis>)',
|
||||
'Accelerometer for given axis (x, y, or z)'),
|
||||
]
|
||||
def __init__(self, lmanager, name, name_parts):
|
||||
self.name = name
|
||||
self.adxl_name = name_parts[1]
|
||||
self.accel_name = name_parts[1]
|
||||
self.jdispatch = lmanager.get_jdispatch()
|
||||
self.next_accel_time = self.last_accel_time = 0.
|
||||
self.next_accel = self.last_accel = (0., 0., 0.)
|
||||
self.cur_data = []
|
||||
self.data_pos = 0
|
||||
if name_parts[2] not in 'xyz':
|
||||
raise error("Unknown adxl345 data selection '%s'" % (name,))
|
||||
raise error("Unknown accelerometer data selection '%s'" % (name,))
|
||||
self.axis = 'xyz'.index(name_parts[2])
|
||||
def get_label(self):
|
||||
label = '%s %s acceleration' % (self.adxl_name, 'xyz'[self.axis])
|
||||
label = '%s %s acceleration' % (self.accel_name, 'xyz'[self.axis])
|
||||
return {'label': label, 'units': 'Acceleration\n(mm/s^2)'}
|
||||
def pull_data(self, req_time):
|
||||
axis = self.axis
|
||||
|
|
@ -434,7 +435,8 @@ class HandleADXL345:
|
|||
self.next_accel_time, x, y, z = self.cur_data[self.data_pos]
|
||||
self.next_accel = (x, y, z)
|
||||
self.data_pos += 1
|
||||
LogHandlers["adxl345"] = HandleADXL345
|
||||
LogHandlers["accelerometer"] = HandleAccelerometer
|
||||
LogHandlers["adxl345"] = HandleAccelerometer # XXX - old capture name
|
||||
|
||||
# Extract positions from magnetic angle sensor
|
||||
class HandleAngle:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue