Skip to content

Instantly share code, notes, and snippets.

@nmz787
nmz787 / monosat_router.py
Last active April 5, 2017 04:30
An attempt at making a point-to-point route solver for 3D grids, using graph reasoning through monosat
from collections import OrderedDict, defaultdict
import os
import sys
import subprocess
from copy import deepcopy
from monosat import *
from time import time
# enable using multiple levels of dict keys automatically, even if nested levels don't yet exist
NestedDict = lambda: defaultdict(NestedDict)
@nmz787
nmz787 / cryptominisat_router.py
Last active October 27, 2016 08:35
An attempt at making a point-to-point route solver for 3D grids, using DIMACS SAT clauses with cryptominisat
from collections import OrderedDict
import os
import subprocess
import sys
import multiprocessing
import itertools
def split_seq(iterable, size):
it = iter(iterable)
@nmz787
nmz787 / hv_pulser_attempted_reproduction.py
Last active December 14, 2019 19:51
ok, seems I have 2 glitch-free PWM channels which are 180 degrees out-of-phase... controllable for pulse width and period at the top with two variables. TIM1 starts TIM2 and TIM5... then after a number of interrupts on TIM2, it shuts itself down and attaches a shutdown-timer to TIM3
import pyb
from pyb import Timer
import micropython
import stm
#john's sript actual pulse width 181 us, 448 us period (pulse to pulse)
# Use with pyb.freq(96000000) and prescaler=11 for .25 usec timer ticks.
xfmr_pulse_period = 1570 # (= usec * 4) Same as toggle_half_cycle duration.
xfmr_pulse_w = 332 # (= usec * 4)
@nmz787
nmz787 / dump_regs.py
Last active March 10, 2017 08:10
tables and a function to print a CSV-style register dump, on an STM32 MCU running MicroPython. Just import and call the dump function, then copy the serial output from your terminal
"""
usage:
import dump_regs
dump_regs.dump_regs()
"""
import re
import stm
# basically this, with some deletions (FLASH, DBGMCU):
# {m for m in dir(stm) if '_' not in m}
"""
wiktionary audio vidio flasher (like automated flashcards).
An app that gets words from wiktionary,
and if there is an associated audio clip,
displays the word on-screen in a Tkinter GUI,
and plays the audio pronunciations available.
Change the seed_word_name variable as you desire.
target audience: babies, language learning
@nmz787
nmz787 / machine.py
Last active May 11, 2023 14:07
micropython mock library - for checking syntax of your MicroPython from Linux
class _board(object):
def __getattr__(self, *args, **kwargs):
return 1
from pyb import Pin as Pin
from pyb import I2C as I2C
from stm import mem32, mem16, mem8
@nmz787
nmz787 / csvToGnomePlanner.py
Last active July 26, 2018 06:55
Converts a CSV with columns [Type, Duration, Name, Description] into Gnome Planner format (which can generate a Gantt chart).
"""
usage: csvToGnomePlanner.py <input path> <output path> <start YYYYMMDD>
Converts a CSV with columns [Type, Duration, Name, Description] into Gnome Planner format (which can generate a Gantt chart).
where Column Definitions are:
Type : 'Subtask' or anything else (normal Task is implied)
Duration : '<number> <unit>' where units are [day, week, month]
NOTE: Tasks which have Subtasks CANNOT have duration... they derive this from the Subtasks
Name : text
Description : text
"""
parse and print the characters stored in the HEX ROM associated with the MAX1000 POV LED TEXT demo
(here: https://github.com/vpecanins/max1000-tutorial/tree/master/demo02_led_text)
.hex format is:
First character (:) = Start of a record
Next two characters = Record length (in this example, 10h)
Next four characters = Load address (in this example, 0080h)
@nmz787
nmz787 / rounded_cube_test.py
Last active September 14, 2018 21:48
test rounded edge.stl brlcad-python-tcl
from python_brlcad_tcl.brlcad_tcl import *
class rounded_cube(BrlCadModel):
def __init__(self, brl_db):
super(rounded_cube, self). __init__(brl_db)
self.center_name = None
self.edge = 10
c1 = [0, 0, 0]
c2 = [self.edge, self.edge, self.edge]
@nmz787
nmz787 / convert_fib_str.py
Last active February 1, 2019 07:49
image 2 FIB and FIB 2 image - requires openCV, wxPython, PIL, numpy
#!/usr/bin/python
""" image 2 FIB and FIB 2 image
Usage:
convert_fib_str.py fromstr <str> [--video] [--out=<out_file_path>]
convert_fib_str.py tostr <image> [--out=<out_file_path>] [--stretch] [--invert]
"""
# from __future__ import print_function
import traceback
import sys
import math