Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
d236d0c4
Commit
d236d0c4
authored
7 years ago
by
Mike Causer
Committed by
Damien George
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
docs/pyboard/quickref: Add info for Switch, RTC, CAN, Accel classes.
parent
933eab46
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/pyboard/quickref.rst
+51
-3
51 additions, 3 deletions
docs/pyboard/quickref.rst
with
51 additions
and
3 deletions
docs/pyboard/quickref.rst
+
51
−
3
View file @
d236d0c4
...
...
@@ -39,18 +39,33 @@ Use the :mod:`time <utime>` module::
start = time.ticks_ms() # get value of millisecond counter
delta = time.ticks_diff(time.ticks_ms(), start) # compute time difference
LEDs
----
Internal
LEDs
----
---------
See :ref:`pyb.LED <pyb.LED>`. ::
from pyb import LED
led = LED(1) # red
led
led = LED(1) #
1=
red
, 2=green, 3=yellow, 4=blue
led.toggle()
led.on()
led.off()
# LEDs 3 and 4 support PWM intensity (0-255)
LED(4).intensity() # get intensity
LED(4).intensity(128) # set intensity to half
Internal switch
---------------
See :ref:`pyb.Switch <pyb.Switch>`. ::
from pyb import Switch
sw = Switch()
sw.value() # returns True or False
sw.callback(lambda: pyb.LED(1).toggle())
Pins and GPIO
-------------
...
...
@@ -99,6 +114,17 @@ See :ref:`pyb.Timer <pyb.Timer>`. ::
tim.freq(0.5) # 0.5 Hz
tim.callback(lambda t: pyb.LED(1).toggle())
RTC (real time clock)
---------------------
See :ref:`pyb.RTC <pyb.RTC>` ::
from pyb import RTC
rtc = RTC()
rtc.datetime((2017, 8, 23, 1, 12, 48, 0, 0)) # set a specific date and time
rtc.datetime() # get date and time
PWM (pulse width modulation)
----------------------------
...
...
@@ -167,3 +193,25 @@ See :ref:`pyb.I2C <pyb.I2C>`. ::
i2c.recv(5, 0x42) # receive 5 bytes from slave
i2c.mem_read(2, 0x42, 0x10) # read 2 bytes from slave 0x42, slave memory 0x10
i2c.mem_write('xy', 0x42, 0x10) # write 2 bytes to slave 0x42, slave memory 0x10
CAN bus (controller area network)
---------------------------------
See :ref:`pyb.CAN <pyb.CAN>`. ::
from pyb import CAN
can = CAN(1, CAN.LOOPBACK)
can.setfilter(0, CAN.LIST16, 0, (123, 124, 125, 126))
can.send('message!', 123) # send a message with id 123
can.recv(0) # receive message on FIFO 0
Internal accelerometer
----------------------
See :ref:`pyb.Accel <pyb.Accel>`. ::
from pyb import Accel
accel = Accel()
print(accel.x(), accel.y(), accel.z(), accel.tilt())
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