Skip to content

Instantly share code, notes, and snippets.

@aerialist
aerialist / euler_quaternion_unity.py
Last active March 6, 2022 14:15
Conver Euler angles to Quaternion, in the same manner as Unity
#!/usr/bin/env python
# coding: utf-8
# This code try to produce same quaternion from euler angles as Unity
# https://docs.unity3d.com/ScriptReference/Quaternion.html
# Oritinal code is from
# https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine/12122899#12122899
import numpy as np
@aerialist
aerialist / readme.md
Created April 30, 2020 13:29
Don't use external power for uCurrent gold

uCurrent Gold from EEVBlog is an excellent handy tool to measure mA or uA order of low current on battery powered IoT devices. https://www.eevblog.com/projects/ucurrent/

It normally run on CR2032 3v battery and it's voltage swing is capped to 0-1.2V. It also drains out poor quality cheap CR2032s rather quickly.

The web pages reads that you could extend the voltage swing by increasing the battery voltage, upto 5.5v. But don't be tempted add a DC jack to use external power supply!!

It's negative pole is used to make "virtual ground". It needs to be independent from the ground of DUT. So it's important the device runs on battery.

@aerialist
aerialist / read_scopy_csv.py
Last active April 25, 2020 03:08
Read csv file from ADALM2000 Scopy and create Python Pandas DataFrame
import pandas as pd
import datetime
def make_dt(timestr, start_dt):
"""
Take starting datetime object and time stamp string in '23:20:35' format
Return a datetime object with date info from starting datetime and time info from time stamp string
"""
ts = datetime.datetime.strptime(timestr, "%H:%M:%S")
@aerialist
aerialist / main.py
Created April 21, 2020 13:56
PySide2 QML boiler plate
# This Python file uses the following encoding: utf-8
# https://qmlbook.github.io/ch18-python/python.html
# This bug has already been fixed
# We can connect in QML
# https://bugreports.qt.io/browse/PYSIDE-634
# https://wiki.qt.io/Qt_for_Python_Signals_and_Slots
import sys
__ __
\ \ /\ / /
\ \ / \ / /
\ \/ /\ \/ /
\ / \ /
/ /\ / /\
/ /\ \/ /\ \
/ / \ / \ \
/_/ \/ \_\
@aerialist
aerialist / switchbot_bluepy.py
Created May 1, 2017 11:03
Activate switchbot by python with bluepy on Raspberry Pi
# Activate switchbot by python with bluepy on Raspberry Pi
# https://github.com/IanHarvey/bluepy
#
# Switchbot's API is taken from this
# https://github.com/OpenWonderLabs/python-host
import binascii
from bluepy.btle import Peripheral
# find your switchbot address by
"{:02X}".format(10)
# 0A
"{:#04X}".format(10)
# 0X0A