Skip to content

Instantly share code, notes, and snippets.

@nmz787
nmz787 / csvToGnomePlanner.py
Last active Jul 26, 2018
Converts a CSV with columns [Type, Duration, Name, Description] into Gnome Planner format (which can generate a Gantt chart).
View csvToGnomePlanner.py
"""
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
@nmz787
nmz787 / machine.py
Last active Apr 30, 2021
micropython mock library - for checking syntax of your MicroPython from Linux
View machine.py
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
View wiktionary_audio_video_flashcards.py
"""
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 / dump_regs.py
Last active Mar 10, 2017
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
View dump_regs.py
"""
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}
@nmz787
nmz787 / hv_pulser_attempted_reproduction.py
Last active Dec 14, 2019
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
View hv_pulser_attempted_reproduction.py
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 / cryptominisat_router.py
Last active Oct 27, 2016
An attempt at making a point-to-point route solver for 3D grids, using DIMACS SAT clauses with cryptominisat
View cryptominisat_router.py
from collections import OrderedDict
import os
import subprocess
import sys
import multiprocessing
import itertools
def split_seq(iterable, size):
it = iter(iterable)
@nmz787
nmz787 / monosat_router.py
Last active Apr 5, 2017
An attempt at making a point-to-point route solver for 3D grids, using graph reasoning through monosat
View monosat_router.py
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 / buildozer.spec
Created Sep 3, 2016
kivy test for HTC DualLens SDK
View buildozer.spec
[app]
# (str) Title of your application
title = My Application
# (str) Package name
package.name = myapp
# (str) Package domain (needed for android/ios packaging)
package.domain = org.test
@nmz787
nmz787 / main.py
Last active Sep 6, 2019
Half-decent LED-PWM and capacitive-sense GPIO coroutines (in micropython, on GHI Electronics G30TH -- essentiall Nucleo F401 but with different pins and pin names)
View main.py
import pyb
from pyb import Timer
# timer 2 will be created with a frequency of 10 kHz
tim=pyb.Timer(4,freq=10000);
# attach the timer to the LED GPIO, turning the brightness OFF to begin
tchannel = tim.channel(3, Timer.PWM, pin=pyb.Pin.board.JP32, pulse_width_percent=0)
# setup comm channel, for debug prints
# uart = pyb.UART(2, 9600) # init with given baudrate
@nmz787
nmz787 / pycosat.c
Created Jun 29, 2016
pycosat.c extended with hacked Noddy class example
View pycosat.c
/*
Copyright (c) 2013, Ilan Schnell, Continuum Analytics, Inc.
Python bindings to picosat (http://fmv.jku.at/picosat/)
This file is published under the same license as picosat itself, which
uses an MIT style license.
*/
#define PYCOSAT_URL "https://pypi.python.org/pypi/pycosat"
#include <Python.h>
#include "structmember.h"