Skip to content

Instantly share code, notes, and snippets.

View mipsparc's full-sized avatar

mipsparc mipsparc

View GitHub Profile
@mipsparc
mipsparc / osc.c
Created October 28, 2018 14:27
ハンドメイド電子回路「連絡ブザくん」ソースコード。波形データを入れ替えると、任意波形が発生できるぞ!
#include "mcc_generated_files/mcc.h"
void setNextLevel(void);
unsigned char curve1[] = {
39, 40, 26, 56, 39, 14, 58, 34, 46, 47, 39, 44, 37, 34, 37, 32, 28,
39, 38, 39, 47, 45, 42, 45, 40, 37, 37, 29, 39, 39, 32, 45, 45, 37,
39, 37, 37, 36, 34, 38, 39, 43, 46, 42, 42, 41, 38, 37, 40, 36, 34,
37, 37, 37, 41,
};
@mipsparc
mipsparc / break_reader.c
Created December 2, 2018 04:10
ブレーキ統合ユニットからボタンやブレーキハンドル角度を読み出すやつ
#include "mcc_generated_files/mcc.h"
void main(void)
{
// initialize the device
SYSTEM_Initialize();
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
@mipsparc
mipsparc / FREQROL.py
Created December 4, 2018 09:24
三菱電機のインバータ FREQROLをPythonとRS485で動かすやつ。MITライセンス。安全にはまったく配慮していないので、十分気をつけてください。
#! /usr/bin/env python3
#coding:utf-8
import serial
import time
class FREQROL:
def __init__(self):
self.ser = serial.Serial(
port='/dev/ttyUSB0', # ここをRS485デバイスに書き換える。COM0など
@mipsparc
mipsparc / dep_bell.py
Created June 3, 2019 04:02
発車メロディ(発車ベル)ながすやつ for Linux/Mac/Windows
#coding:utf-8
# Requirements: Python3, PySerial, Pygame
# 同じディレクトリに bell.wav と announce.wav を用意する
# 「どこでも発車ベル」と同じボタンをつなぐ
# シリアルポートを設定する
import serial
import time
import pygame
@mipsparc
mipsparc / sekkin.py
Created August 3, 2019 03:48
接近メロディーながすやつ
#coding:utf-8
import serial
import time
import pygame
# シリアルポートのデバイスファイル名に差し替える
port = '/dev/sekkin'
pygame.mixer.init(44100, -16, 1, 256)
@mipsparc
mipsparc / retribe_xmls.js
Last active October 12, 2019 07:42
2日以内のDMARC XMLを取得するサンプルコード
function retribeXMLs()
{
var xmls = [];
var messages;
var zipblob;
var fileblob;
// 2日以内のすべてのスレッドを取得
var threads = GmailApp.search('newer_than:2d');
@mipsparc
mipsparc / dmarc.xml
Last active September 25, 2019 11:16
DMARCのXMLで特に見るべきポイント
<feedback>
<report_metadata>
<org_name>受信者名</org_name>
<date_range>
<begin>開始UNIX TIME</begin>
<end>終了UNIX TIME</end>
</date_range>
</report_metadata>
<record>
<!-- recordは1つのXMLに複数含まれうる -->
@mipsparc
mipsparc / dsair2_analog_test.py
Last active May 10, 2020 02:58
DSair2 鉄道模型コントローラでアナログ鉄道模型をPythonから制御する、あくまでサンプルコード
#coding:utf-8
import serial
import time
def send(s, value):
s.write(value.encode('ascii') + b'\n')
s.flush()
def init_dsair2(s):
@mipsparc
mipsparc / OHC-PC01A.py
Last active March 17, 2021 22:53
三鶯重工(サンイン重工)のワンハンドルマスコンをPythonで扱うためのサンプルコード・プロトタイプです。一応動きます
#coding: utf-8
# サンイン重工 OHC-PC01AコントローラからPythonへ繋ぎこむライブラリ
import pygame
import time
class OHC_PC01A:
def __init__(self):
pygame.init()
@mipsparc
mipsparc / RaspberryPi_Pico_USB_Serial.py
Created February 21, 2022 12:19
Raspberry Pi PicoでUSBシリアル通信をするサンプルコード。
from machine import Pin, PWM
from time import sleep
pwm = PWM(Pin(15))
# 80kHz
pwm.freq(80000)
pwm.duty_u16(0)
line = ""
while True: