summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMike Causer <mcauser@gmail.com>2017-10-06 01:01:05 +1100
committerDamien George <damien.p.george@gmail.com>2017-10-10 15:22:11 +1100
commitd236d0c415bc34c96e7155ab116258a026b2cda6 (patch)
treef3774e21857e97949208db3443870efbfb941a22
parent933eab46fcf2dcca2c3ca3d04b714f238e6020e1 (diff)
downloadmicropython-d236d0c415bc34c96e7155ab116258a026b2cda6.tar.gz
micropython-d236d0c415bc34c96e7155ab116258a026b2cda6.zip
docs/pyboard/quickref: Add info for Switch, RTC, CAN, Accel classes.
-rw-r--r--docs/pyboard/quickref.rst54
1 files changed, 51 insertions, 3 deletions
diff --git a/docs/pyboard/quickref.rst b/docs/pyboard/quickref.rst
index 5690dddb0c..48798aad3e 100644
--- a/docs/pyboard/quickref.rst
+++ b/docs/pyboard/quickref.rst
@@ -39,17 +39,32 @@ 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())