Skip to content

Instantly share code, notes, and snippets.

idt12312 /
Last active August 8, 2021 16:50
This script is for KiCad. This renames leading reference number of selected components.
import pcbnew
import re
def _get_selected_modules():
modules = pcbnew.GetBoard().GetModules()
return filter(lambda m: m.IsSelected(), modules)
def _replace_leading_number(target, new):
match ='[0-9]', target)
idx = match.start()
idt12312 /
Last active December 26, 2022 16:42
Save screen image of RIGOL MSO5000 series oscilloscope
import visa
import argparse
from PIL import Image
import io
argparser = argparse.ArgumentParser()
argparser.add_argument('-a', '--address', required=True, help='VISA address like "TCPIP::{ipaddress}::INSTR"')
argparser.add_argument('-o', '--output', help='Output file name (default: "screen.png")', default='screen.png')
args = argparser.parse_args()
idt12312 /
Last active October 19, 2023 16:18
Load waveform and save it as csv file for RIGOL MSO5000 series oscilloscope
import visa
import argparse
import csv
def load_waveform(chidx, points_request):
inst.write(f':WAV:SOUR CHAN{chidx}')
inst.write(':WAV:MODE RAW')
inst.write(f':WAV:POIN {points_request}')
inst.write(':WAV:FORM BYTE')
idt12312 / PIDController.h
Last active September 7, 2018 14:26
This is C++ implementation of MATLAB's 2DOF discrete time PID controller
class PIDController
struct Param
float P;
float I;
import kicad_tools
rList = kicad_tools.findModulesByRe("R\d+")
ledList = kicad_tools.findModulesByRe("D\d+")
kicad_tools.arrangeInLine(ledList, (100,100), (10,0))
#R1を(100mm, 100mm)に移動する
#R1を現在位置から(50mm, 0mm)だけ移動する
import pcbnew
board = pcbnew.GetBoard()
r1 = board.FindModuleByReference("R1")
print r1.GetReference()
idt12312 / TaskBase.h
Created February 1, 2017 04:49
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
class TaskBase {
idt12312 / led_blink_systick.s
Last active December 25, 2016 07:41
アセンブリでSystickを使ってLチカをする : Nucleo STM32F103
idt12312 / led_blink.s
Last active December 25, 2016 06:51
アセンブリでLチカをする : Nucleo STM32F103