Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
#
# This is a revised version from https://github.com/pyserial/pyserial/pull/566.
#
# This is a module that gathers a list of serial ports including details on OSX
#
# code originally from https://github.com/makerbot/pyserial/tree/master/serial/tools
# with contributions from cibomahto, dgs3, FarMcKon, tedbrandston
# and modifications by cliechti, hoihu, hardkrash
#
import time
import random
from adafruit_magtag.magtag import MagTag
magtag = MagTag()
magtag.network.connect()
key = "fontaine-status"
latest_id = ""
@Neradoc
Neradoc / unquarantine.scpt
Created April 29, 2021 22:04
Unquarantien downloaded files on macos with an applescript droplet
(*
loosely based on "Unquarantine" by Henrik Nyh <http://henrik.nyh.se/2007/10/lift-the-leopard-download-quarantine>
This Folder Action handler is triggered whenever items are added to the attached folder.
It gets rid of Leopard's annoying "this application was downloaded from the Internet" warnings by stripping the "quarantine" property.
Now also runs as a droplet or a standalone application if, like me, you juste need sometimes to stop the madenning dialog to appear for every file of a downloaded (unzipped) zip archive.
*)
on adding folder items to thisFolder after receiving addedItems
my unQuarantine(addedItems)
@Neradoc
Neradoc / I2C_tests.py
Last active April 26, 2021 16:37
I2C tests with the Sparkfun SerLCD qwiic LCD
"""
This is a test for an error on the Sparkfun SerLCD
> OSError: [Errno 19] Unsupported operation
Tested on:
- QT PY RP2040 using the STEMMA QT port
- SparkFun 16x2 SerLCD - RGB Backlight (Qwiic)
The errors seems to happen when many writes are done in fast succession.
DELAY = 0 -> Almost always errors at a seemingly random number of characters.
@Neradoc
Neradoc / compare_board_info_files.py
Last active March 25, 2021 02:33
Compare `files.json` files generated by Circuitpython `build_board_info.py`
import json
liste = set()
def print_once(text):
global liste
if text not in liste:
liste.add(text)
print(text)
def compare_files(oldfile_name,newfile_name):
@Neradoc
Neradoc / code_potar_blink_tasko.py
Last active May 1, 2021 18:43
My first example to discover how to use tasko (with a while True task and a scheduled task)
@Neradoc
Neradoc / test-circuitpython-build-tools.sh
Last active March 15, 2021 07:09
This is how I test circuitpython-build-tools (creation of the Circuitpython Librairies Bundle)
# https://github.com/adafruit/circuitpython-build-tools/
echo "don't run this script, it's more a list of commands to copy and paste as you need them"
exit 1
# installing the repositories, run only once
gh repo clone adafruit/Adafruit_CircuitPython_Bundle
cd Adafruit_CircuitPython_Bundle
git submodule init
@Neradoc
Neradoc / code_potar_neopixel_naive.py
Created March 13, 2021 04:17
My exploration of naive (bad) async, and a tasko version, of a potentiometer controlling neopixels
import board
import time
from analogio import AnalogIn
from digitalio import DigitalInOut,Pull
from simpleio import map_range
from neopixel import NeoPixel
# LED to blink
led = DigitalInOut(board.LED)
led.switch_to_output()
AtoQ = {
"0" : ")",
"1" : "!",
"2" : "@",
"3" : "#",
"4" : "$",
"5" : "%",
"6" : "^",
"7" : "&",
"8" : "*",
# The MIT License (MIT)
#
# Copyright (c) 2017 Dan Halbert
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: