Skip to content

Instantly share code, notes, and snippets.

View mipsparc's full-sized avatar

mipsparc mipsparc

View GitHub Profile
@mipsparc
mipsparc / serialrx.c
Created April 13, 2018 14:53
PIC16F1579向け UARTで受信するテスト。RCREGbits.RCREGって書き方、完全に思いつかなかった
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / meter_increment.c
Created April 11, 2018 16:44
ソフトウェアPWMでちょっとずつメーターが進んでいくテスト
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / serialtx.c
Created April 11, 2018 15:46
USARTで送信するテスト PIC16F1579向け
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / door_led_indicator.c
Last active April 10, 2018 02:03
E233系ドア上ランプをイメージして、接点状態が変化すると0.3秒点滅を5回繰り返すPIC16F677向けCプログラム
// CONFIG
#pragma config FOSC = INTRCCLK // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
@mipsparc
mipsparc / renamedirs.sh
Created August 5, 2017 03:59
renamedirs.txtにあるディレクトリのそれぞれ1番最初にあるJPEGファイルの撮影年をディレクトリ名に付加する
#!/bin/bash
cat renamedirs.txt | while read DIRN
do
FILENAME=`ls -1 $DIRN | sed -n '1p'`
YEAR=`echo ${DIRN}/${FILENAME} | python3 photodir_year.py`
echo "renaming ${DIRN}"
mv $DIRN ${DIRN}_${YEAR}
done
@mipsparc
mipsparc / exif_year.py
Created August 5, 2017 03:56
標準入力で与えられたファイル名のJPEGファイルのEXIF情報を読み込み、撮影された年を標準出力で返す
#/usr/bin/env python3
from PIL import Image
from datetime import datetime
imgname = input();
img = Image.open(imgname)
#DateTimeOriginal のExif tag ID
taken_datetime_exif = img._getexif()[0x9003]
@mipsparc
mipsparc / isdbt_clock.py
Last active August 23, 2016 15:50
チューナーから標準入力されたストリームを読み込んで時刻情報パケット(TDT)から時刻を取得し、GUIの時計を表示します
#!/usr/bin/env python3
#coding:utf-8
import json
import random
import time
try:
from gi import pygtkcompat
except ImportError:
pygtkcompat = None
@mipsparc
mipsparc / totts_stream.py
Last active July 22, 2023 18:31
totts.py(MPEG2-TSの中のTDTパケットを取り出して、中に入ってる時刻情報を表示するやつ)のリアルタイムストリーム入力可能にしたバージョン。
#! /usr/bin/env python3
#coding:utf-8
#require bitstring
import bitstring
from sys import argv
import math
import sys
import io
import time
@mipsparc
mipsparc / totts.py
Last active September 9, 2023 12:48
MPEG2-TSの中のTDTパケットを取り出して、中に入ってる時刻情報を表示するやつ
#! /usr/bin/env python3
#coding:utf-8
#require bitstring
import bitstring
import math
import sys
filename = sys.argv[1]
packet_length = 188
@mipsparc
mipsparc / pidcount.py
Last active January 16, 2023 01:01
MPEG2-TSファイルを解析して、含まれているPIDと数を列挙する
#! /usr/bin/env python3
#coding:utf-8
#require bitstring
import bitstring
import math
import sys
filename = sys.argv[1]
packet_length = 188