Catch git up to current work eek
This commit is contained in:
parent
98b19ce936
commit
3261b6c97a
|
|
@ -2,4 +2,5 @@
|
||||||
.vscode
|
.vscode
|
||||||
*.tmp.*
|
*.tmp.*
|
||||||
node_modules
|
node_modules
|
||||||
cardiograph.code-workspace
|
cardiograph.code-workspace
|
||||||
|
*venv*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
[submodule "src/argparser"]
|
[submodule "src/argparser"]
|
||||||
path = src/opter
|
path = src/opter
|
||||||
url = https://git.nloewen.com/n/argv-parser.git
|
url = https://git.nloewen.com/n/argv-parser.git
|
||||||
|
[submodule "src/python/opter-py"]
|
||||||
|
path = src/python/opter-py
|
||||||
|
url = https://git.nloewen.com/n/opter-py.git
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import board
|
||||||
|
import displayio
|
||||||
|
import vectorio
|
||||||
|
import terminalio
|
||||||
|
from adafruit_display_text import label
|
||||||
|
|
||||||
|
group = displayio.Group()
|
||||||
|
board.DISPLAY.root_group = group
|
||||||
|
|
||||||
|
text = "Hello world"
|
||||||
|
text_area = label.Label(terminalio.FONT, text=text)
|
||||||
|
text_area.x = 10
|
||||||
|
text_area.y = 10
|
||||||
|
group.append(text_area)
|
||||||
|
|
||||||
|
palette = displayio.Palette(1)
|
||||||
|
palette[0] = 0xff00ff
|
||||||
|
|
||||||
|
circle = vectorio.Circle(pixel_shader=palette, radius=5, x=5, y=5)
|
||||||
|
group.append(circle)
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#meowbit
|
||||||
|
|
||||||
|
import keypad
|
||||||
|
import board
|
||||||
|
|
||||||
|
km = keypad.KeyMatrix(
|
||||||
|
row_pins = (board.P0, board.P1, board.P2, board.P3),
|
||||||
|
column_pins = (board.P4, board.P6, board.P8, board.P9) )
|
||||||
|
|
||||||
|
while True:
|
||||||
|
event = km.events.get()
|
||||||
|
if event:
|
||||||
|
print(event.key_number, event.released)
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import time
|
||||||
|
import board
|
||||||
|
import neopixel
|
||||||
|
|
||||||
|
pixels = neopixel.NeoPixel(board.A3, 5*5, brightness=0.5, auto_write=True)
|
||||||
|
|
||||||
|
for i in range(50):
|
||||||
|
pixels.fill((50, 0, 0)) # red
|
||||||
|
time.sleep(0.5)
|
||||||
|
pixels.fill((0,0,50)) # blue
|
||||||
|
time.sleep(0.5)
|
||||||
|
print(i)
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,181 @@
|
||||||
|
# SPDX-FileCopyrightText: 2016 Damien P. George
|
||||||
|
# SPDX-FileCopyrightText: 2017 Scott Shawcroft for Adafruit Industries
|
||||||
|
# SPDX-FileCopyrightText: 2019 Carter Nelson
|
||||||
|
# SPDX-FileCopyrightText: 2019 Roy Hooper
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
"""
|
||||||
|
`neopixel` - NeoPixel strip driver
|
||||||
|
====================================================
|
||||||
|
|
||||||
|
* Author(s): Damien P. George, Scott Shawcroft, Carter Nelson, Rose Hooper
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
from neopixel_write import neopixel_write
|
||||||
|
|
||||||
|
import adafruit_pixelbuf
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Used only for typing
|
||||||
|
from typing import Optional, Type
|
||||||
|
from types import TracebackType
|
||||||
|
import microcontroller
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = "6.3.15"
|
||||||
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel.git"
|
||||||
|
|
||||||
|
|
||||||
|
# Pixel color order constants
|
||||||
|
RGB = "RGB"
|
||||||
|
"""Red Green Blue"""
|
||||||
|
GRB = "GRB"
|
||||||
|
"""Green Red Blue"""
|
||||||
|
RGBW = "RGBW"
|
||||||
|
"""Red Green Blue White"""
|
||||||
|
GRBW = "GRBW"
|
||||||
|
"""Green Red Blue White"""
|
||||||
|
|
||||||
|
|
||||||
|
class NeoPixel(adafruit_pixelbuf.PixelBuf):
|
||||||
|
"""
|
||||||
|
A sequence of neopixels.
|
||||||
|
|
||||||
|
:param ~microcontroller.Pin pin: The pin to output neopixel data on.
|
||||||
|
:param int n: The number of neopixels in the chain
|
||||||
|
:param int bpp: Bytes per pixel. 3 for RGB and 4 for RGBW pixels.
|
||||||
|
:param float brightness: Brightness of the pixels between 0.0 and 1.0 where 1.0 is full
|
||||||
|
brightness
|
||||||
|
:param bool auto_write: True if the neopixels should immediately change when set. If False,
|
||||||
|
`show` must be called explicitly.
|
||||||
|
:param str pixel_order: Set the pixel color channel order. The default is GRB if bpp is set
|
||||||
|
to 3, otherwise GRBW is used as the default.
|
||||||
|
|
||||||
|
Example for Circuit Playground Express:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import neopixel
|
||||||
|
from board import *
|
||||||
|
|
||||||
|
RED = 0x100000 # (0x10, 0, 0) also works
|
||||||
|
|
||||||
|
pixels = neopixel.NeoPixel(NEOPIXEL, 10)
|
||||||
|
for i in range(len(pixels)):
|
||||||
|
pixels[i] = RED
|
||||||
|
|
||||||
|
Example for Circuit Playground Express setting every other pixel red using a slice:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import neopixel
|
||||||
|
from board import *
|
||||||
|
import time
|
||||||
|
|
||||||
|
RED = 0x100000 # (0x10, 0, 0) also works
|
||||||
|
|
||||||
|
# Using ``with`` ensures pixels are cleared after we're done.
|
||||||
|
with neopixel.NeoPixel(NEOPIXEL, 10) as pixels:
|
||||||
|
pixels[::2] = [RED] * (len(pixels) // 2)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
.. py:method:: NeoPixel.show()
|
||||||
|
|
||||||
|
Shows the new colors on the pixels themselves if they haven't already
|
||||||
|
been autowritten.
|
||||||
|
|
||||||
|
The colors may or may not be showing after this function returns because
|
||||||
|
it may be done asynchronously.
|
||||||
|
|
||||||
|
.. py:method:: NeoPixel.fill(color)
|
||||||
|
|
||||||
|
Colors all pixels the given ***color***.
|
||||||
|
|
||||||
|
.. py:attribute:: brightness
|
||||||
|
|
||||||
|
Overall brightness of the pixel (0 to 1.0)
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
pin: microcontroller.Pin,
|
||||||
|
n: int,
|
||||||
|
*,
|
||||||
|
bpp: int = 3,
|
||||||
|
brightness: float = 1.0,
|
||||||
|
auto_write: bool = True,
|
||||||
|
pixel_order: str = None
|
||||||
|
):
|
||||||
|
if not pixel_order:
|
||||||
|
pixel_order = GRB if bpp == 3 else GRBW
|
||||||
|
elif isinstance(pixel_order, tuple):
|
||||||
|
order_list = [RGBW[order] for order in pixel_order]
|
||||||
|
pixel_order = "".join(order_list)
|
||||||
|
|
||||||
|
self._power = None
|
||||||
|
if (
|
||||||
|
sys.implementation.version[0] >= 7
|
||||||
|
and getattr(board, "NEOPIXEL", None) == pin
|
||||||
|
):
|
||||||
|
power = getattr(board, "NEOPIXEL_POWER_INVERTED", None)
|
||||||
|
polarity = power is None
|
||||||
|
if not power:
|
||||||
|
power = getattr(board, "NEOPIXEL_POWER", None)
|
||||||
|
if power:
|
||||||
|
try:
|
||||||
|
self._power = digitalio.DigitalInOut(power)
|
||||||
|
self._power.switch_to_output(value=polarity)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
n, brightness=brightness, byteorder=pixel_order, auto_write=auto_write
|
||||||
|
)
|
||||||
|
|
||||||
|
self.pin = digitalio.DigitalInOut(pin)
|
||||||
|
self.pin.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
def deinit(self) -> None:
|
||||||
|
"""Blank out the NeoPixels and release the pin."""
|
||||||
|
self.fill(0)
|
||||||
|
self.show()
|
||||||
|
self.pin.deinit()
|
||||||
|
if self._power:
|
||||||
|
self._power.deinit()
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exception_type: Optional[Type[BaseException]],
|
||||||
|
exception_value: Optional[BaseException],
|
||||||
|
traceback: Optional[TracebackType],
|
||||||
|
):
|
||||||
|
self.deinit()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "[" + ", ".join([str(x) for x in self]) + "]"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def n(self) -> int:
|
||||||
|
"""
|
||||||
|
The number of neopixels in the chain (read-only)
|
||||||
|
"""
|
||||||
|
return len(self)
|
||||||
|
|
||||||
|
def write(self) -> None:
|
||||||
|
""".. deprecated: 1.0.0
|
||||||
|
|
||||||
|
Use ``show`` instead. It matches Micro:Bit and Arduino APIs."""
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def _transmit(self, buffer: bytearray) -> None:
|
||||||
|
neopixel_write(self.pin, buffer)
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Open the binary file in read-binary mode
|
||||||
|
with open('test-multiply.bin', 'rb') as file:
|
||||||
|
# Read the entire file contents
|
||||||
|
binary_data = file.read()
|
||||||
|
|
||||||
|
# Convert the binary data to a string of hex bytes
|
||||||
|
hex_string = binary_data.hex()
|
||||||
|
|
||||||
|
# Print the hex string
|
||||||
|
print(hex_string)
|
||||||
|
|
||||||
|
|
||||||
|
# Open the binary file in read-binary mode
|
||||||
|
with open('test-multiply.bin', 'rb') as file:
|
||||||
|
# Read the entire file contents into a bytearray
|
||||||
|
byte_data = bytearray(file.read())
|
||||||
|
|
||||||
|
# Print the bytearray
|
||||||
|
print(byte_data)
|
||||||
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,10 @@
|
||||||
|
import board
|
||||||
|
import busio
|
||||||
|
from adafruit_ht16k33 import matrix
|
||||||
|
i2c = busio.I2C(board.GP17, board.GP16) # scl, sda
|
||||||
|
|
||||||
|
matrix = matrix.Matrix8x8(i2c)
|
||||||
|
matrix.fill(0) # Clear the matrix.
|
||||||
|
matrix[0, 0] = 1
|
||||||
|
matrix.brightness = 1
|
||||||
|
matrix.blink_rate = 2
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
"""Example for pi pico. Blinking LED"""
|
||||||
|
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
import time
|
||||||
|
|
||||||
|
led = digitalio.DigitalInOut(board.LED)
|
||||||
|
led.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
led.value = True
|
||||||
|
|
||||||
|
for i in range(50):
|
||||||
|
led.value = not led.value
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
"""Example for pi pico. Button-controlled LED.
|
||||||
|
|
||||||
|
Wiring: switch to ground pin on pico, and to pin 18.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
|
||||||
|
led = digitalio.DigitalInOut(board.LED)
|
||||||
|
led.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
switch = digitalio.DigitalInOut(board.GP18)
|
||||||
|
switch.direction = digitalio.Direction.INPUT
|
||||||
|
switch.pull = digitalio.Pull.UP
|
||||||
|
|
||||||
|
while True:
|
||||||
|
led.value = not switch.value
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# pi pico
|
||||||
|
|
||||||
|
import keypad
|
||||||
|
import board
|
||||||
|
|
||||||
|
keymatrix = keypad.KeyMatrix(
|
||||||
|
row_pins = (board.GP5, board.GP6, board.GP7, board.GP8),
|
||||||
|
column_pins = (board.GP9, board.GP10, board.GP11, board.GP12, board.GP13) )
|
||||||
|
|
||||||
|
keymap = {
|
||||||
|
15:"0", 16:"1", 17:"2", 18:"3", 19:"runhalt",
|
||||||
|
10:"4", 11:"5", 12:"6", 13:"7", 14:"step",
|
||||||
|
5:"8", 6:"9", 7:"A", 8:"B", 9:"addrdata",
|
||||||
|
0:"C", 1:"D", 2:"E", 3:"F", 4:"NA" }
|
||||||
|
|
||||||
|
while True:
|
||||||
|
event = keymatrix.events.get()
|
||||||
|
if event:
|
||||||
|
print(event.key_number, event.released, keymap[event.key_number])
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import board
|
||||||
|
import keypad
|
||||||
|
|
||||||
|
keymatrix = keypad.KeyMatrix(
|
||||||
|
row_pins = (board.GP5, board.GP6, board.GP7, board.GP8),
|
||||||
|
column_pins = (board.GP9, board.GP10, board.GP11, board.GP12, board.GP13) )
|
||||||
|
|
||||||
|
keymap = {
|
||||||
|
15:"0", 16:"1", 17:"2", 18:"3", 19:"runhalt",
|
||||||
|
10:"4", 11:"5", 12:"6", 13:"7", 14:"step",
|
||||||
|
5:"8", 6:"9", 7:"A", 8:"B", 9:"addr",
|
||||||
|
0:"C", 1:"D", 2:"E", 3:"F", 4:"data" }
|
||||||
|
|
||||||
|
while True:
|
||||||
|
keypad_event = keymatrix.events.get()
|
||||||
|
keyPressed = True if (keypad_event and keypad_event.released ) else False
|
||||||
|
key = keymap[keypad_event.key_number] if keyPressed else False
|
||||||
|
if key:
|
||||||
|
print(key)
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
"""Example for pi pico. Blinking LED"""
|
||||||
|
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
import time
|
||||||
|
from tm1637_display import TM1637Display
|
||||||
|
|
||||||
|
display_1 = TM1637Display(board.GP0, board.GP1, length=4)
|
||||||
|
display_1.print("1234")
|
||||||
|
|
||||||
|
display_2 = TM1637Display(board.GP2, board.GP3, length=4)
|
||||||
|
display_2.print("ABCD")
|
||||||
|
|
||||||
|
print("end")
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2013-2024, Kim Davies and contributors.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 1d98a0707c3e61e362d2d3d5413b475437b5de0e
|
|
||||||
Loading…
Reference in New Issue