From 79580676ffd1af38c796c9befd918cbc93e75ddc Mon Sep 17 00:00:00 2001 From: ft-Demo <fischertechnik-team@fischer.de> Date: Mon, 24 Mar 2025 11:18:54 +0000 Subject: [PATCH] commit by robo pro coding --- test_RX_i2c_device_apds9960.blockly | 103 +++++++++++++--------------- test_RX_i2c_device_apds9960.py | 9 --- 2 files changed, 49 insertions(+), 63 deletions(-) diff --git a/test_RX_i2c_device_apds9960.blockly b/test_RX_i2c_device_apds9960.blockly index 087ffb1..c9acf25 100644 --- a/test_RX_i2c_device_apds9960.blockly +++ b/test_RX_i2c_device_apds9960.blockly @@ -6,77 +6,72 @@ <block type="util_python_imports" id="BuNdg{crGi4?b.2~{7~v" x="0" y="0"> <field name="value">import board&#10;import busio&#10;from adafruit_bus_device.i2c_device import I2CDevice</field> </block> - <block type="start_block" id="7s|$pr*xo|Z,AfuHs:~," deletable="false" x="0" y="143"> + <block type="start_block" id="7s|$pr*xo|Z,AfuHs:~," deletable="false" x="0" y="147"> <statement name="statement"> <block type="util_python" id="h9BK3DENhX`}qv`{TWOi"> <field name="value">global I2C_ADDRESS, I2C_FREQ&#10;I2C_ADDRESS = 0x39&#10;I2C_FREQ = 400000</field> <next> - <block type="util_python" id=")px9GxFT)zf|]UgfXzO{"> - <field name="value">#https://learn.adafruit.com/circuitpython-essentials/circuitpython-i2c&#10;i2c =busio.I2C(board.SCL1, board.SDA1, frequency=I2C_FREQ)&#10;while not i2c.try_lock():&#10; pass&#10;try:&#10; print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()],)&#10;finally: # unlock the i2c bus&#10; i2c.unlock()&#10;i2c.deinit()</field> + <block type="procedures_callnoreturn" id="$9oTrqt3G(urnDwDYP4l"> + <mutation name="init_apds9960"/> <next> - <block type="procedures_callnoreturn" id="$9oTrqt3G(urnDwDYP4l"> - <mutation name="init_apds9960"/> - <next> - <block type="loop_endless" id="^x^S51cswn:O`*PQ]4y`"> - <statement name="DO"> - <block type="variables_set" id="L2^pM.*F[Qe?EQ~GO-?e"> - <field name="VAR" id="oR++S;mcb{0#_9.Ygmsm">p</field> + <block type="loop_endless" id="^x^S51cswn:O`*PQ]4y`"> + <statement name="DO"> + <block type="variables_set" id="L2^pM.*F[Qe?EQ~GO-?e"> + <field name="VAR" id="oR++S;mcb{0#_9.Ygmsm">p</field> + <value name="VALUE"> + <block type="procedures_callreturn" id="m]9k~Ltl)q`uNSi{932?"> + <mutation name="read_proximity"/> + </block> + </value> + <next> + <block type="variables_set" id="L)(#U-4%Id2,J9#;_db*"> + <field name="VAR" id="4O_I38Wy6BRf)BM*VH26">crgb</field> <value name="VALUE"> - <block type="procedures_callreturn" id="m]9k~Ltl)q`uNSi{932?"> - <mutation name="read_proximity"/> + <block type="procedures_callreturn" id="3%s}Ne:a/yuMwA8xgF?f"> + <mutation name="read_color"/> </block> </value> <next> - <block type="variables_set" id="L)(#U-4%Id2,J9#;_db*"> - <field name="VAR" id="4O_I38Wy6BRf)BM*VH26">crgb</field> - <value name="VALUE"> - <block type="procedures_callreturn" id="3%s}Ne:a/yuMwA8xgF?f"> - <mutation name="read_color"/> + <block type="text_print" id="1qYCMl76SC1E;cu,:TON"> + <value name="TEXT"> + <shadow type="text" id="qsC!BE@Jt.he~U`NlD)1"> + <field name="TEXT"/> + </shadow> + <block type="text_format" id="-`~Gq?(V=-wt*1beWJI%"> + <mutation items="2"/> + <value name="value"> + <shadow type="text" id="hXm5G!E96aQz+t!8}_$M"> + <field name="TEXT">p:{} crgb:{}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="variables_get" id="U,Z,zCnFY8qQY7@n6hAz"> + <field name="VAR" id="oR++S;mcb{0#_9.Ygmsm">p</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="e6{`B~*CUgAXS.8.^.I~"> + <field name="VAR" id="4O_I38Wy6BRf)BM*VH26">crgb</field> + </block> + </value> </block> </value> <next> - <block type="text_print" id="1qYCMl76SC1E;cu,:TON"> - <value name="TEXT"> - <shadow type="text" id="qsC!BE@Jt.he~U`NlD)1"> - <field name="TEXT"/> + <block type="util_wait_for" id="LOxBp4_n{-EMeuwk)[rN"> + <field name="format">s</field> + <value name="value"> + <shadow type="math_number" id="#SjCO!ZSK2es)nXW0(-B"> + <field name="NUM">1</field> </shadow> - <block type="text_format" id="-`~Gq?(V=-wt*1beWJI%"> - <mutation items="2"/> - <value name="value"> - <shadow type="text" id="hXm5G!E96aQz+t!8}_$M"> - <field name="TEXT">p:{} crgb:{}</field> - </shadow> - </value> - <value name="ADD0"> - <block type="variables_get" id="U,Z,zCnFY8qQY7@n6hAz"> - <field name="VAR" id="oR++S;mcb{0#_9.Ygmsm">p</field> - </block> - </value> - <value name="ADD1"> - <block type="variables_get" id="e6{`B~*CUgAXS.8.^.I~"> - <field name="VAR" id="4O_I38Wy6BRf)BM*VH26">crgb</field> - </block> - </value> - </block> </value> - <next> - <block type="util_wait_for" id="LOxBp4_n{-EMeuwk)[rN"> - <field name="format">s</field> - <value name="value"> - <shadow type="math_number" id="#SjCO!ZSK2es)nXW0(-B"> - <field name="NUM">1</field> - </shadow> - </value> - </block> - </next> </block> </next> </block> </next> </block> - </statement> + </next> </block> - </next> + </statement> </block> </next> </block> @@ -84,7 +79,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="LVWB4_6?3S^)gS5X-1=2" x="0" y="796"> + <block type="procedures_defnoreturn" id="LVWB4_6?3S^)gS5X-1=2" x="0" y="583"> <field name="NAME">init_apds9960</field> <statement name="STACK"> <block type="util_python" id="1Ih*vWYKj$v__eB9t[Fm"> @@ -92,7 +87,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="$gw-UIsnMpvX.:]#!e=g" x="0" y="1170"> + <block type="procedures_defreturn" id="$gw-UIsnMpvX.:]#!e=g" x="0" y="971"> <field name="NAME">read_proximity</field> <statement name="STACK"> <block type="util_python" id="Q?$)/A/Y{)3d5ZnZ)^k:"> @@ -105,7 +100,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="#_GPa5z$AtaN0.`.0.|0" x="0" y="1499"> + <block type="procedures_defreturn" id="#_GPa5z$AtaN0.`.0.|0" x="0" y="1312"> <field name="NAME">read_color</field> <statement name="STACK"> <block type="util_python" id="||FIP;f:l$]7l1hJl*?#"> diff --git a/test_RX_i2c_device_apds9960.py b/test_RX_i2c_device_apds9960.py index 7588fe2..a1f6a52 100644 --- a/test_RX_i2c_device_apds9960.py +++ b/test_RX_i2c_device_apds9960.py @@ -78,15 +78,6 @@ async def run(instance): global I2C_ADDRESS, I2C_FREQ I2C_ADDRESS = 0x39 I2C_FREQ = 400000 - #https://learn.adafruit.com/circuitpython-essentials/circuitpython-i2c - i2c =busio.I2C(board.SCL1, board.SDA1, frequency=I2C_FREQ) - while not i2c.try_lock(): - pass - try: - print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()],) - finally: # unlock the i2c bus - i2c.unlock() - i2c.deinit() await init_apds9960() while True: p = await read_proximity() -- GitLab