Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CircuitPython - a Python implementation for teaching coding with microcontrollers

License

NotificationsYou must be signed in to change notification settings

adafruit/circuitpython

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://s3.amazonaws.com/adafruit-circuit-python/CircuitPython_Repo_header_logo.png

Build StatusDoc StatusLicenseDiscordWeblate

circuitpython.org |Get CircuitPython |Documentation |Contributing |Branding |Differences from Micropython |Project Structure

CircuitPython is abeginner friendly, open source version of Python for tiny, inexpensivecomputers called microcontrollers. Microcontrollers are the brains of many electronics including awide variety of development boards used to build hobby projects and prototypes. CircuitPython inelectronics is one of the best ways to learn to code because it connects code to reality. Simplyinstall CircuitPython on a supported USB board usually via drag and drop and then edit acode.pyfile on the CIRCUITPY drive. The code will automatically reload. No software installs are neededbesides a text editor (we recommendMu for beginners.)

Starting with CircuitPython 7.0.0, some boards may only be connectable over Bluetooth Low Energy(BLE). Those boards provide serial and file access over BLE instead of USB using open protocols.(Some boards may use both USB and BLE.) BLE access can be done from a variety of apps includingcode.circuitpython.org.

CircuitPython features unified Python core APIs and a growing list of 300+ device libraries anddrivers that work with it. These libraries also work on single board computers with regularPython via theAdafruit Blinka Library.

CircuitPython is based onMicroPython. Seebelow for differences. Most, but not all, CircuitPythondevelopment is sponsored byAdafruit and is available on their educationaldevelopment boards. Please support both MicroPython and Adafruit.

Get CircuitPython

Official binaries for all supported boards are available throughcircuitpython.org/downloads. The site includes stable, unstable andcontinuous builds. Full release notes are available throughGitHub releases as well.

Documentation

Guides and videos are available through theAdafruit LearningSystem under theCircuitPythoncategory. An APIreference is also available onRead the Docs. A collection of awesomeresources can be found atAwesome CircuitPython.

Specifically useful documentation when starting out:

Contributing

SeeCONTRIBUTING.mdfor full guidelines but please be aware that by contributing to thisproject you are agreeing to theCode ofConduct.Contributors who follow theCode ofConductare welcome to submit pull requests and they will be promptly reviewedby project admins. Please join theDiscord too.

Branding

While we are happy to see CircuitPython forked and modified, we'd appreciate it if forked releasesnot use the name "CircuitPython" or the Blinka logo. "CircuitPython" means something special tous and those who learn about it. As a result, we'd like to make sure products referring to it meet acommon set of requirements.

If you'd like to use the term "CircuitPython" and Blinka for your product here is what we ask:

  • Your product is supported by the primary"adafruit/circuitpython" repo. This way we canupdate any custom code as we update the CircuitPython internals.
  • Your product is listed oncircuitpython.org (sourcehere). This is to ensure that a user of yourproduct can always download the latest version of CircuitPython from the standard place.
  • Your product supports at least one standard "Workflow" for serial and file access:
    • With a user accessible USB plug which appears as a CIRCUITPY drive when plugged in.
    • With file and serial access over Bluetooth Low Energy using the BLE Workflow.
    • With file access over WiFi using the WiFi Workflow with serial access over USB and/or WebSocket.
  • Boards that do not support the USB Workflow should be clearly marked.

If you choose not to meet these requirements, then we ask you call your version of CircuitPythonsomething else (for example, SuperDuperPython) and not use the Blinka logo. You can say it is"CircuitPython-compatible" if most CircuitPython drivers will work with it.


Differences fromMicroPython

CircuitPython:

  • Supports native USB on most boards and BLE otherwise, allowing file editing without special tools.
  • Floats (aka decimals) are enabled for all builds.
  • Error messages are translated into 10+ languages.
  • Concurrency within Python is not well supported. Interrupts and threading are disabled.async/await keywords are available on some boards for cooperative multitasking. Some concurrencyis achieved with native modules for tasks that require it such as audio file playback.

Behavior

  • The order that files are run and the state that is shared betweenthem. CircuitPython's goal is to clarify the role of each file andmake each file independent from each other.
    • boot.py runs only once on start up beforeworkflows are initialized. This lays the ground work for configuring USB atstartup rather than it being fixed. Since serial is not available,output is written toboot_out.txt.
    • code.py (ormain.py) is run after every reload until itfinishes or is interrupted. After it is done running, the vm andhardware is reinitialized.This means you cannot read state fromcode.pyin the REPL anymore, as the REPL is a fresh vm. CircuitPython's goal for thischange includes reducing confusion about pins and memory being used.
    • After the main code is finished the REPL can be entered by pressing any key.- If the filerepl.py exists, it is executed before the REPL Prompt is shown- In safe mode this functionality is disabled, to ensure the REPL Prompt can always be reached
    • Autoreload state will be maintained across reload.
  • Adds a safe mode that does not run user code after a hard crash or brown out. This makes itpossible to fix code that causes nasty crashes by making it available through mass storage afterthe crash. A reset (the button) is needed after it's fixed to get back into normal mode.
  • A 1 second delay is added to the boot process during which time the status LED will flash, andresetting the device or pressing the boot button will force the device into safe mode. This delaycan be removed by a compile time option (CIRCUITPY_SKIP_SAFE_MODE_WAIT).
  • Safe mode may be handled programmatically by providing asafemode.py.safemode.py is run if the board has reset due to entering safe mode, unless the safe modeinitiated by the user by pressing button(s).USB is not available so nothing can be printed.safemode.py can determine why the safe mode occurredusingsupervisor.runtime.safe_mode_reason, and take appropriate action. For instance,if a hard crash occurred,safemode.py may do amicrocontroller.reset()to automatically restart despite the crash.If the battery is low, but is being charged,safemode.py may put the board in deep sleepfor a while. Or it may simply reset, and havecode.py check the voltage and do the sleep.
  • RGB status LED indicating CircuitPython state.- One green flash - code completed without error.- Two red flashes - code ended due to an exception.- Three yellow flashes - safe mode. May be due to CircuitPython internal error.
  • Re-runscode.py or other main file after file system writes by a workflow. (Disable withsupervisor.disable_autoreload())
  • Autoreload is disabled while the REPL is active.
  • code.py may also be namedcode.txt,main.py, ormain.txt.
  • boot.py may also be namedboot.txt.
  • safemode.py may also be namedsafemode.txt.

API

  • Unified hardware APIs. Documented onReadTheDocs.
  • API docs are Python stubs within the C files inshared-bindings.
  • Nomachine API.

Modules

  • No module aliasing. (uos andutime are not available asos andtime respectively.) Insteados,time, andrandom are CPython compatible.
  • Newstorage module which manages file system mounts.(Functionality fromuos in MicroPython.)
  • Modules with a CPython counterpart, such astime,os andrandom, are strictsubsetsof theirCPythonversion.Therefore, code from CircuitPython is runnable on CPython but notnecessarily the reverse.
  • tick count is available astime.monotonic()

Project Structure

Here is an overview of the top-level source code directories.

Core

The core code ofMicroPython is sharedamongst ports including CircuitPython:

  • docs High level user documentation in Sphinx reStructuredTextformat.
  • drivers External device drivers written in Python.
  • examples A few example Python scripts.
  • extmod Shared C code used in multiple ports' modules.
  • lib Shared core C code including externally developed librariessuch as FATFS.
  • logo The CircuitPython logo.
  • mpy-cross A cross compiler that converts Python files to bytecode prior to being run in MicroPython. Useful for reducing librarysize.
  • py Core Python implementation, including compiler, runtime, andcore library.
  • shared-bindings Shared definition of Python modules, their docsand backing C APIs. Ports must implement the C API to support thecorresponding module.
  • shared-module Shared implementation of Python modules that may bebased oncommon-hal.
  • tests Test framework and test scripts.
  • tools Various tools, including the pyboard.py module.

Ports

Ports include the code unique to a microcontroller line.

The following ports are available:atmel-samd,cxd56,espressif,litex,mimxrt10xx,nordic,raspberrypi,renode,silabs (efr32),stm,unix.

However, not all ports are fully functional. Some have limited functionality and known serious bugs.For details, refer to thePort status section in thelatest release notes.

Boards

  • Eachport has aboards directory containing boardswhich belong to a specific microcontroller line.
  • A list of native modules supported by a particular board can be foundhere.

Back to Top

About

CircuitPython - a Python implementation for teaching coding with microcontrollers

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C88.2%
  • Python8.4%
  • Makefile2.2%
  • Linker Script0.3%
  • Shell0.2%
  • HTML0.2%
  • Other0.5%

[8]ページ先頭

©2009-2025 Movatter.jp