/ README.rst
README.rst
  1  Introduction
  2  ============
  3  
  4  .. image:: https://readthedocs.org/projects/adafruit-circuitpython-dymoscale/badge/?version=latest
  5      :target: https://circuitpython.readthedocs.io/projects/dymoscale/en/latest/
  6      :alt: Documentation Status
  7  
  8  .. image:: https://img.shields.io/discord/327254708534116352.svg
  9      :target: https://adafru.it/discord
 10      :alt: Discord
 11  
 12  .. image:: https://github.com/adafruit/Adafruit_CircuitPython_DymoScale/workflows/Build%20CI/badge.svg
 13      :target: https://github.com/adafruit/Adafruit_CircuitPython_DymoScale/actions/
 14      :alt: Build Status
 15  
 16  CircuitPython interface for `DYMO <http://www.dymo.com/en-US>`_ postage scales.
 17  
 18  NOTE: This library will not work on embedded linux, only on microcontrollers.
 19  
 20  Dependencies
 21  =============
 22  This driver depends on:
 23  
 24  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 25  
 26  Please ensure all dependencies are available on the CircuitPython filesystem.
 27  This is easily achieved by downloading
 28  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 29  
 30  Installing from PyPI
 31  --------------------
 32  On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
 33  PyPI <https://pypi.org/project/adafruit-circuitpython-dymoscale/>`_. To install for current user:
 34  
 35  .. code-block:: shell
 36  
 37      pip3 install adafruit-circuitpython-dymoscale
 38  
 39  To install system-wide (this may be required in some cases):
 40  
 41  .. code-block:: shell
 42  
 43      sudo pip3 install adafruit-circuitpython-dymoscale
 44  
 45  To install in a virtual environment in your current project:
 46  
 47  .. code-block:: shell
 48  
 49      mkdir project-name && cd project-name
 50      python3 -m venv .env
 51      source .env/bin/activate
 52      pip3 install adafruit-circuitpython-dymoscale
 53  
 54  Usage Example
 55  =============
 56  
 57  Initialize the scale by passing it a data pin and a pin to toggle the units button:
 58  
 59  .. code-block:: python
 60  
 61      # initialize the dymo scale
 62      units_pin = digitalio.DigitalInOut(board.D3)
 63      units_pin.switch_to_output()
 64      dymo = adafruit_dymoscale.DYMOScale(board.D4, units_pin)
 65  
 66  Get the item's weight from the scale:
 67  
 68  .. code-block:: python
 69  
 70      reading = dymo.weight
 71      print(reading.weight)
 72  
 73  Get the item's units from the scale:
 74  
 75  .. code-block:: python
 76  
 77      print(reading.units)
 78  
 79  To toggle between units (simulate a button press):
 80  
 81  .. code-block:: python
 82  
 83      dymo.toggle_unit_button(switch_unit=True)
 84  
 85  To toggle the unit button, but preserve the unit displayed:
 86  
 87  .. code-block:: python
 88  
 89      dymo.toggle_unit_button()
 90  
 91  
 92  Contributing
 93  ============
 94  
 95  Contributions are welcome! Please read our `Code of Conduct
 96  <https://github.com/adafruit/Adafruit_CircuitPython_DymoScale/blob/master/CODE_OF_CONDUCT.md>`_
 97  before contributing to help this project stay welcoming.
 98  
 99  Documentation
100  =============
101  
102  For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.