diff --git a/README.rst b/README.rst index 41c31c2..5b08afc 100644 --- a/README.rst +++ b/README.rst @@ -51,6 +51,7 @@ Designed for CircuitPython (SAMD21 and SAMD51) - `Adafruit ItsyBitsy M4 Express `__ + Other Adafruit Boards ~~~~~~~~~~~~~~~~~~~~~ @@ -59,7 +60,7 @@ Other Adafruit Boards Other Boards ~~~~~~~~~~~~~~~~~~~~~ - `Raspberry Pi Pico `__ - +- `PJRC Teensy 4.1 __ Download -------- diff --git a/circuitpython_kernel/board.py b/circuitpython_kernel/board.py index 92e4599..3345184 100644 --- a/circuitpython_kernel/board.py +++ b/circuitpython_kernel/board.py @@ -13,6 +13,7 @@ ADAFRUIT_VID = 0x239A # SAMD ESP8266_VID = 0x10C4 # Huzzah ESP8266 PICO_VID = 0x239A # PICO PI +TENNSY_VID = 0x16c0 #PJRC Teensy 4.1 # repl commands CHAR_CTRL_A = b'\x01' @@ -145,7 +146,7 @@ def _find_board(self): for port in comports(): # print out each device BOARD_LOGGER.debug(port.device) - if port.vid == ADAFRUIT_VID or port.vid == ESP8266_VID or port.vid == PICO_VID: + if port.vid == ADAFRUIT_VID or port.vid == ESP8266_VID or port.vid == PICO_VID or port.vid == TEENSY_VID: BOARD_LOGGER.debug(f"CircuitPython Board Found at: {port.device}") BOARD_LOGGER.debug(f"Connected? {self.connected}") return port.device diff --git a/docs/boardprep.md b/docs/boardprep.md index 7121234..95ae32b 100644 --- a/docs/boardprep.md +++ b/docs/boardprep.md @@ -4,7 +4,7 @@ Before you start using the CircuitPython_Kernel, you'll need a board running CircuitPython. If you're not sure if the board plugged into your computer is running CircuitPython, check your file explorer for a drive named `CIRCUITPY` -## Designed for CircuitPython (SAMD21, SAMD51 and RP2040) +## Designed for CircuitPython (SAMD21, SAMD51 and RP2040, NXP iMXRT1062) ### Boards Supported: @@ -19,7 +19,7 @@ the board plugged into your computer is running CircuitPython, check your file e - [ItsyBitsy M4](https://www.adafruit.com/product/3727) - [Raspberry Pi Pico RP2040](https://www.adafruit.com/product/4864) - + - [PJRC Teensy 4.1](https://www.adafruit.com/product/4622) ### Installing CircuitPython Firmware @@ -49,6 +49,18 @@ Use `screen` program: screen 115200 +## PJRC Teensy 4.1 + +The Teensy line of microcontrollers have a different installation to the standard circuitpython installation, requiring a program called Teensy Loader and a hex file. + +### Installing CircuitPython Firmware + +- Download the Teensy Loader Application: https://www.pjrc.com/teensy/loader.html +- Install the loader following the guide for your specific operating system. +- Download the [CircuitPython Firmware (.hex file) from the CircuitPython Website](https://circuitpython.org/board/teensy41/) +- Once the Teensy Loader is downloaded, press the onboard push button on the Teensy, this places the teensy in the halfkay bootlader mode. +- Open the Teensy Loader Application and select the left most button and upload the downloaded .hex file. +- Unplug and plug the Teensy back in and you are ready to go. ## ampy diff --git a/examples/CPX_Blink_Teensy.ipynb b/examples/CPX_Blink_Teensy.ipynb new file mode 100644 index 0000000..621fe86 --- /dev/null +++ b/examples/CPX_Blink_Teensy.ipynb @@ -0,0 +1,160 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "double-loading", + "metadata": {}, + "source": [ + "## Blinking an LED" + ] + }, + { + "cell_type": "markdown", + "id": "increasing-booth", + "metadata": {}, + "source": [ + "The traditional Hello World in Microcontrollers is the blinking of the onboard LED. This can be done using this Jupyter Notebook." + ] + }, + { + "cell_type": "markdown", + "id": "colonial-ratio", + "metadata": {}, + "source": [ + "![cpx led](https://cdn-shop.adafruit.com/970x728/4622-03.jpg)" + ] + }, + { + "cell_type": "markdown", + "id": "guilty-cincinnati", + "metadata": {}, + "source": [ + "To Begin let's make sure the kernel in the top left hand corner says CircuitPython. This can be modified by going to the kernel tab and selecting change kernel.\n", + "\n", + "Once this is done we can confirm that Jupyter can read our circuit python board by running:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "protecting-cache", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "print(os.uname())" + ] + }, + { + "cell_type": "markdown", + "id": "individual-hybrid", + "metadata": {}, + "source": [ + "Next to be able to turn on and off the LEDs we import board and digitalIO. Board allows access to the specific pins on the Teensy. DigitalIO creates objects for IO based programming." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "balanced-steps", + "metadata": {}, + "outputs": [], + "source": [ + "import digitalio\n", + "import board" + ] + }, + { + "cell_type": "markdown", + "id": "breeding-supervision", + "metadata": {}, + "source": [ + "Create the digitalio.DigitalInOut object for the LED in the Teensy (Teensy's onboard LED is at D13)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "decreased-little", + "metadata": {}, + "outputs": [], + "source": [ + "cpx_led = digitalio.DigitalInOut(board.D13)" + ] + }, + { + "cell_type": "markdown", + "id": "gorgeous-first", + "metadata": {}, + "source": [ + "Let's change the direction of digitialio.Direction to be an OUTPUT" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "satellite-recycling", + "metadata": {}, + "outputs": [], + "source": [ + "cpx_led.direction = digitalio.Direction.OUTPUT" + ] + }, + { + "cell_type": "markdown", + "id": "arabic-aluminum", + "metadata": {}, + "source": [ + "Finally, let's turn it on by changing the value of the pin to True" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "increased-target", + "metadata": {}, + "outputs": [], + "source": [ + "cpx_led.value = True" + ] + }, + { + "cell_type": "markdown", + "id": "union-lease", + "metadata": {}, + "source": [ + "Don't want the LED on? Turn it off by switching the value from True to False" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "noble-record", + "metadata": {}, + "outputs": [], + "source": [ + "cpx_led.value = False" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "CircuitPython", + "language": "python", + "name": "circuitpython" + }, + "language_info": { + "codemirror_mode": { + "name": "python", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "pygments_lexer": "python3", + "version": "3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}