{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Adafruit Blinka and LSM6DSOX\n",
"
\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
" # Python Software Package Installation\n",
"import sys\n",
"!{sys.executable} -m pip install adafruit-circuitpython-lsm6ds ipympl"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Verify this cell returns acceleration data before proceeding**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Acceleration: X:-2.70, Y: 9.18, Z: 2.01 m/s^2\n"
]
}
],
"source": [
"# Set an Environment Variable so Adafruit Blinka knows we're using the MCP2221\n",
"import os\n",
"os.environ[\"BLINKA_MCP2221\"] = \"1\"\n",
"\n",
"# Import CircuitPython Libraries\n",
"import board\n",
"import busio\n",
"import adafruit_lsm6ds\n",
"\n",
"i2c = busio.I2C(board.SCL, board.SDA)\n",
"sox = adafruit_lsm6ds.LSM6DSOX(i2c)\n",
"\n",
"print(\"Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2\"%(sox.acceleration))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/javascript": [
"/* Put everything inside the global mpl namespace */\n",
"window.mpl = {};\n",
"\n",
"\n",
"mpl.get_websocket_type = function() {\n",
" if (typeof(WebSocket) !== 'undefined') {\n",
" return WebSocket;\n",
" } else if (typeof(MozWebSocket) !== 'undefined') {\n",
" return MozWebSocket;\n",
" } else {\n",
" alert('Your browser does not have WebSocket support. ' +\n",
" 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
" 'Firefox 4 and 5 are also supported but you ' +\n",
" 'have to enable WebSockets in about:config.');\n",
" };\n",
"}\n",
"\n",
"mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
" this.id = figure_id;\n",
"\n",
" this.ws = websocket;\n",
"\n",
" this.supports_binary = (this.ws.binaryType != undefined);\n",
"\n",
" if (!this.supports_binary) {\n",
" var warnings = document.getElementById(\"mpl-warnings\");\n",
" if (warnings) {\n",
" warnings.style.display = 'block';\n",
" warnings.textContent = (\n",
" \"This browser does not support binary websocket messages. \" +\n",
" \"Performance may be slow.\");\n",
" }\n",
" }\n",
"\n",
" this.imageObj = new Image();\n",
"\n",
" this.context = undefined;\n",
" this.message = undefined;\n",
" this.canvas = undefined;\n",
" this.rubberband_canvas = undefined;\n",
" this.rubberband_context = undefined;\n",
" this.format_dropdown = undefined;\n",
"\n",
" this.image_mode = 'full';\n",
"\n",
" this.root = $('