Skip to content
Snippets Groups Projects
Commit 79580676 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parent 2d6d842b
Branches master
No related tags found
No related merge requests found
......@@ -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&amp;#10;import busio&amp;#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&amp;#10;I2C_ADDRESS = 0x39&amp;#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&amp;#10;i2c =busio.I2C(board.SCL1, board.SDA1, frequency=I2C_FREQ)&amp;#10;while not i2c.try_lock():&amp;#10; pass&amp;#10;try:&amp;#10; print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()],)&amp;#10;finally: # unlock the i2c bus&amp;#10; i2c.unlock()&amp;#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*?#">
......
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment