GithubHelp home page GithubHelp logo

test-mass-forker-org-1 / jacdac-circuitpython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/jacdac-circuitpython

0.0 0.0 0.0 6.77 MB

Jacdac support for CircuitPython

Home Page: https://aka.ms/jacdac

License: MIT License

Python 100.00%

jacdac-circuitpython's Introduction

Jacdac CircuitPython

This repository implements Jacdac in CircuitPython.

Usage

from jacdac import JDStack
import board
import time

jd = JDStack(board.P12)

while True:
    # other app code
    jd.process()
    time.sleep(.1)

Above is the most minimal program to operate the JACDAC stack. process() must be called regularly to process received packets and to regularly send advertisements from your device. In the sample above, process() is called every 100 milliseconds, though the time between calls to process is tuned depending on bus activity and application demands.

For example, if your program is hosting the accelerometer service, process() will need to be called at least every 10 milliseconds. The accelerometer service may be configured to stream packets every 10 milliseconds, which defines the minimum process() call speed:

from jacdac import JDStack, JDAccelerometer
import time
import adafruit_lsm6ds.lsm6ds33
import board

jd = JDStack(board.P12)
i2c = board.I2C()
accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(i2c)
jd_accel = JDAccelerometer(accelerometer, jd)
jd.add_service(jd_accel)


while True:
    # other app code
    jd.process()
    time.sleep(.01)

Installation

Currently, Jacdac is not merged into mainline CircuitPython and only works on NRF52-based boards. A Jacdac-enabled uf2 CircuitPython file for the Adafruit Clue is provided in the samples folder (samples/JD_CPY_CLUE.uf2). If you are using a different NRF52-based board, you will have to compile CircuitPython yourself by:

  1. clone https://github.com/jamesadevine/circuitpython and checkout the jacdac branch.
  2. git submodule init && git submodule sync && git submodule update
  3. cd ports/nrf
  4. make BOARD=<your board> -j 10. For instance to build for clue the command would be: make BOARD=clue_nrf52840_express -j 10. The list of boards can be found in ports/nrf/boards

To use the JACDAC stack in your CircuitPython program simply copy jacdac.py to the libs folder on the CIRCUITPY drive. For some of the samples contained in this repository, additional libraries are also required:

  • adafruit_bus_device
  • adafruit_lsm6ds
  • adafruit_display_text
  • adafruit_register

The latest versions of these libraries can be obtained from the Adafruit CircuitPython Bundle. After installation the CIRCUITPY drive should look like:

circuitpython flash drive layout

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

jacdac-circuitpython's People

Contributors

jamesadevine avatar microsoftopensource avatar pelikhan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.