Skip to content

Commit

Permalink
Merge pull request #78 from deshipu/compass-docs
Browse files Browse the repository at this point in the history
Add initial documentation for the compass
  • Loading branch information
ntoll committed Nov 7, 2015
2 parents c7c8bbf + 129a3c2 commit d3f8483
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
68 changes: 68 additions & 0 deletions docs/compass.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Compass
*******

.. py:module:: microbit.compass
This module lets you access the build-in electronic compass. Before using,
the compass should be calibrated, otherwise the readings may be wrong.


Functions
=========

.. py:function:: calibrate()
Starts the calibration process. After this is called, the user should
lay the board flat on the table and rotate it horizontally, until the
process is finished.

.. py:function:: is_calibrated()
Returns ``True`` if the compass has been successfully calibrated, and
returns ``False`` otherwise.


.. py:function:: is_calibrating()
Returns ``True`` if the calibration process is in progress, and ``False``
if it has finished or hasn't been started yet.


.. py:function:: clear_calibrarion()
Undoes the calibration, making the compass uncalibrated again.


.. py:function:: get_x()
Gives the reading of the magnetic force on the ``x`` axis, as a
positive or negative integer, depending on the direction of the
force.


.. py:function:: get_y()
Gives the reading of the magnetic force on the ``x`` axis, as a
positive or negative integer, depending on the direction of the
force.


.. py:function:: get_z()
Gives the reading of the magnetic force on the ``x`` axis, as a
positive or negative integer, depending on the direction of the
force.


.. py:function:: heading()
Gives the compass heading, calculated from the above readings, as an
integer in the range from 0 to 360, representing the angle in degrees,
clockwise, with north as 0.


Example
=======

.. include:: ../examples/compass.py
:code: python
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Contents:
api_design_heuristics.rst
microbit_micropython_api.rst
music_api.rst
compass.rst


Indices and tables
Expand Down

0 comments on commit d3f8483

Please sign in to comment.