mirror of
https://github.com/bassamanator/Sovol-SV06-firmware.git
synced 2025-11-08 13:31:16 +00:00
Add get_variable util macro. Rename adxl-direct.cfg->adxl-rpi-direct.cfg.
This commit is contained in:
52
cfgs/GET_VARIABLE.cfg
Normal file
52
cfgs/GET_VARIABLE.cfg
Normal file
@@ -0,0 +1,52 @@
|
||||
# Author FatalBulletHit, https://github.com/FatalBulletHit
|
||||
[gcode_macro GET_VARIABLE]
|
||||
gcode:
|
||||
{% set names = (params.NAME).split('.')|list %}
|
||||
{% set join = (params.JOIN)|default(1)|int %}
|
||||
|
||||
{% set _dummy0 = namespace( break = 0 ) %}
|
||||
{% set _dummy1 = namespace( out = printer[names|first] ) %}
|
||||
|
||||
{% for name in names if _dummy0.break == 0 %}
|
||||
{% if loop.index > 1 %}
|
||||
{% if name in _dummy1.out %}
|
||||
{% set _dummy1.out = _dummy1.out[name] %}
|
||||
{% elif name[0] in '0123456789' and _dummy1.out is iterable and _dummy1.out is not string and _dummy1.out is not mapping and _dummy1.out|length > name[0]|int %}
|
||||
{% set _dummy1.out = _dummy1.out[name|int] %}
|
||||
{% else %}
|
||||
{% set _dummy0.break = loop.index0 %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if _dummy1.out is boolean %}
|
||||
{ action_respond_info('Type: boolean') }
|
||||
{% elif _dummy1.out is float %}
|
||||
{ action_respond_info('Type: float') }
|
||||
{% elif _dummy1.out is integer %}
|
||||
{ action_respond_info('Type: integer') }
|
||||
{% elif _dummy1.out is mapping %}
|
||||
{ action_respond_info('Type: mapping') }
|
||||
{% elif _dummy1.out is string %}
|
||||
{ action_respond_info('Type: string') }
|
||||
{% elif _dummy1.out is iterable %}
|
||||
{ action_respond_info('Type: iterable') }
|
||||
{% elif _dummy1.out is none %}
|
||||
{ action_respond_info('Type: none') }
|
||||
{% elif _dummy1.out is undefined %}
|
||||
{ action_respond_info('Type: undefined') }
|
||||
{% elif _dummy1.out is callable %}
|
||||
{ action_respond_info('Type: callable') }
|
||||
{% else %}
|
||||
{ action_respond_info('Type: unknown') }
|
||||
{% endif %}
|
||||
|
||||
{% if join and _dummy1.out is iterable and _dummy1.out is not string and _dummy1.out is not mapping %}
|
||||
{ action_respond_info('%s' % _dummy1.out|join("\n")) }
|
||||
{% else %}
|
||||
{ action_respond_info('%s' % _dummy1.out) }
|
||||
{% endif %}
|
||||
|
||||
{% if _dummy0.break != 0 %}
|
||||
{ action_respond_info('"printer.%s" does not contain "%s"!' % (names[0:_dummy0.break]|join('.'), names[_dummy0.break])) }
|
||||
{% endif %}
|
||||
@@ -4,9 +4,10 @@
|
||||
[include ./cfgs/CALIBRATION.cfg]
|
||||
[include ./cfgs/kamp/KAMP_Settings.cfg]
|
||||
[include ./cfgs/TEST_SPEED.cfg]
|
||||
[include ./cfgs/GET_VARIABLE.cfg]
|
||||
[include ./cfgs/timelapse.cfg]
|
||||
|
||||
# NOTE Uncomment the ONE of the following lines if you're using an adxl345
|
||||
# [include ./cfgs/adxl-rp2040.cfg]
|
||||
# [include ./cfgs/adxl-rpi-pico-2x.cfg]
|
||||
# [include ./cfgs/adxl-direct.cfg]
|
||||
# [include ./cfgs/adxl-rpi-direct.cfg]
|
||||
|
||||
Reference in New Issue
Block a user