Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test_RX_i2c_device_apds9960
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fischertechnik examples
RX Controller
test_RX_i2c_device_apds9960
Commits
79580676
Commit
79580676
authored
2 weeks ago
by
ft-Demo
Browse files
Options
Downloads
Patches
Plain Diff
commit by robo pro coding
parent
2d6d842b
Branches
master
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test_RX_i2c_device_apds9960.blockly
+49
-54
49 additions, 54 deletions
test_RX_i2c_device_apds9960.blockly
test_RX_i2c_device_apds9960.py
+0
-9
0 additions, 9 deletions
test_RX_i2c_device_apds9960.py
with
49 additions
and
63 deletions
test_RX_i2c_device_apds9960.blockly
+
49
−
54
View file @
79580676
...
...
@@ -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="14
3
">
<block type="start_block" id="7s|$pr*xo|Z,AfuHs:~," deletable="false" x="0" y="14
7
">
<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>
</
statemen
t>
</
nex
t>
</block>
</
nex
t>
</
statemen
t>
</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="1
499
">
<block type="procedures_defreturn" id="#_GPa5z$AtaN0.`.0.|0" x="0" y="1
312
">
<field name="NAME">read_color</field>
<statement name="STACK">
<block type="util_python" id="||FIP;f:l$]7l1hJl*?#">
...
...
This diff is collapsed.
Click to expand it.
test_RX_i2c_device_apds9960.py
+
0
−
9
View file @
79580676
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment