Skip to content

Instantly share code, notes, and snippets.

@bveina
bveina / FactorioBlueprintStringConvert.py
Created February 8, 2021 19:47
converts blueprint strings to json streams and back again needs binascii and zlib.
import zlib
import binascii
def jsonToBlueprint(jsonfilename,outputfilename):
with open(jsonfilename,'rt') as f:
plain = f.read()
compressed = zlib.compress(plain.encode('utf-8'),level=9)
base = binascii.b2a_base64(compressed,newline=False)
with open(outputfilename,'wt') as f:
f.write("0")
@bveina
bveina / AD2_Weigand37Decoder.js
Last active January 13, 2021 01:10
if you hook up a standard weigand reader to an analog discover (or other device that works with digilent waveforms) with DIO0 connected to DATA0 and DIO1 connected to DATA1. this will display Facility code, Card Number and Parity Checks on the logic analyzer.
// rgData: input, raw digital sample array
// rgValue: output, decoded data array
// rgFlag: output, decoded flag array
// reference: https://www.ooaccess.com/kb/37-bit-fc/
//
const cSamples = rgData.length // number of acquisition samples
const numBits=37;
var pData, fData = 0; // previous and current bit value
var result = 0;
@bveina
bveina / netum.py
Last active August 4, 2020 14:18
create Netum custom barcodes
# uses https://github.com/damiandennis/code128cgen
# the config barcodes for the netum C570 barcode scanner have controll characters hidden inside them.
# to create your own (ie 2050209)
# MakeMyCode("205020",9,"2050209\nAutomatic")
# creates 2050209.png
import code128cgen
def MakeMyCode(codeStart,codeDigit,text):
@bveina
bveina / asyncAPA_Test.py
Created June 29, 2018 22:03
the basic framework for multithreaded control of led strips.
clock = Pin(14,Pin.OUT) #wemos D5
data = Pin(13,Pin.OUT) #wemos D7
numPixels=20
apa = APA102(clock,data,numPixels)
seg1 = Segment(apa,0,9,Segment.dotScan,rainbow,2000,False) # outer ring
seg2 = Segment(apa,10,19,Segment.blink,primary,2000,False) # inner ring