You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

  1. Introduction
  2. ============
  3. .. image:: https://readthedocs.org/projects/adafruit-platformdetect/badge/?version=latest
  4. :target: https://circuitpython.readthedocs.io/projects/platformdetect/en/latest/
  5. :alt: Documentation Status
  6. .. image:: https://img.shields.io/discord/327254708534116352.svg
  7. :target: https://discord.gg/nBQh6qu
  8. :alt: Discord
  9. .. image:: https://github.com/adafruit/Adafruit_Python_PlatformDetect/workflows/Build%20CI/badge.svg
  10. :target: https://github.com/adafruit/Adafruit_Python_PlatformDetect/actions
  11. :alt: Build Status
  12. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  13. :target: https://github.com/psf/black
  14. :alt: Code Style: Black
  15. This library provides best-guess platform detection for a range of single-board
  16. computers and (potentially) other platforms. It was written primarily for use
  17. in `Adafruit_Blinka <https://github.com/adafruit/Adafruit_Blinka>`_, but may be
  18. useful in other contexts.
  19. Platform detection is divided into "chip" and "board" detection, with the latter
  20. generally dependent on the former. Platform info is gathered from:
  21. - Python's `sys.platform`
  22. - Various files on Linux systems:
  23. - /proc/cpuinfo (for processor info, Raspberry Pi hardware revisions, etc.)
  24. - /proc/device-tree/compatible (for 96Boards info)
  25. - Beaglebone EEPROM board IDs
  26. - Distribution-specific files such as /etc/armbian-release.
  27. Dependencies
  28. =============
  29. This driver depends on:
  30. * Python 3.5 or higher
  31. Installing from PyPI
  32. =====================
  33. On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
  34. PyPI <https://pypi.org/project/Adafruit-PlatformDetect/>`_. To install for current user:
  35. .. code-block:: shell
  36. pip3 install Adafruit-PlatformDetect
  37. To install system-wide (this may be required in some cases):
  38. .. code-block:: shell
  39. sudo pip3 install Adafruit-PlatformDetect
  40. To install in a virtual environment in your current project:
  41. .. code-block:: shell
  42. mkdir project-name && cd project-name
  43. python3 -m venv .env
  44. source .env/bin/activate
  45. pip3 install Adafruit-PlatformDetect
  46. Usage Example
  47. =============
  48. .. code-block:: python
  49. from adafruit_platformdetect import Detector
  50. detector = Detector()
  51. print("Chip id: ", detector.chip.id)
  52. print("Board id: ", detector.board.id)
  53. # Check for specific board models:
  54. print("Pi 3B+? ", detector.board.RASPBERRY_PI_3B_PLUS)
  55. print("BBB? ", detector.board.BEAGLEBONE_BLACK)
  56. print("Orange Pi PC? ", detector.board.ORANGE_PI_PC)
  57. print("generic Linux PC? ", detector.board.GENERIC_LINUX_PC)
  58. Contributing
  59. ============
  60. Contributions are welcome! Please read our `Code of Conduct
  61. <https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/master/CODE_OF_CONDUCT.md>`_
  62. before contributing to help this project stay welcoming.
  63. Documentation
  64. =============
  65. 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>`_.