Skip to content

Instantly share code, notes, and snippets.

View yswallow's full-sized avatar

Sanagi yswallow

View GitHub Profile
@yswallow
yswallow / ihex_checksum.rb
Created November 5, 2021 01:37
Intel Hexファイルの行のチェックサムを求めるやつ
line = ARGV[0]
max = 0x2000
sum = 0
(line.length/2).times do |i|
sum += (line[i*2]+line[i*2+1]).to_i(16)
end
puts "%02X" % ( (max-sum) & 0x00FF )
@yswallow
yswallow / nrf_digitizer_main.c
Created August 9, 2021 05:41
Androidから認識されるデジタイザをnRF52で作る
/**
* Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@yswallow
yswallow / dual-role.py
Created January 19, 2021 16:19
CircuitPythonでBLE UARTの通信を別のPeripheralから受信してBLE HIDでCentralに送る
"""
Demonstration of a Bluefruit BLE Central for Circuit Playground Bluefruit. Connects to the first BLE
UART peripheral it finds. Sends Bluefruit ColorPackets, read from three accelerometer axis, to the
peripheral.
"""
import time
import board
import digitalio
@yswallow
yswallow / threadtest.py
Created October 26, 2020 23:20
Pythonのスレッド完全に理解した
import threading
import time
def thread1():
while True:
time.sleep(1)
print("Thread1 running")
if not threading.main_thread().is_alive():
print("Thread1 exit")
break
@yswallow
yswallow / boot.py
Created September 8, 2020 19:45
CircuitPythonでエラーメッセージをテキストファイルに出力する
import board
import digitalio
import storage
import os
storage.remount("/", False)
force_writable_button = digitalio.DigitalInOut(board.D2)
force_writable_button.direction = digitalio.Direction.INPUT
force_writable_button.pull = digitalio.Pull.UP
@yswallow
yswallow / darknet-test.py
Created September 5, 2020 10:13
darknetで処理して枠を付けた画像を保存するやつ
from ctypes import *
import random
import os
import argparse
import shutil
from pathlib import Path
global DARKNET_FORCE_CPU
DARKNET_FORCE_CPU = True
@yswallow
yswallow / file-preview.html
Created August 27, 2020 20:40
選択したファイルをCanvasとimgでプレビューするスクリプト
<html>
<body>
<canvas id="draw-area" width="480" height="320"></canvas>
<input id="select-image" type="file" accept="image/*">
<div id="filename"></div>
<img id="imagePreview">
<script>
drawingArea = document.getElementById("draw-area");
imageSelection = document.getElementById("select-image");
filenameOutput = document.getElementById("filename");
@yswallow
yswallow / KeyActionList.html
Last active August 27, 2020 19:43
KeyActionListをカテゴリー分けするツールとその結果 https://www.aerotap.com/Help/aeroTAP/aeroTAP/jp/What_is_KeyActionList.htm
<html>
<head>
<script src="./KeyActionList.js" defer></script>
<meta charset="UTF-8">
<title>KeyActionList</title>
</head>
<body>
<select id="category"></select>
<select id="action"></select>
</body>
@yswallow
yswallow / canvas.html
Created August 26, 2020 19:36
長方形 グリグリやって 遊ぶやつ (575)
<html>
<body>
<canvas id="drawing" width="480" height="270" ></canvas>
<li id="areas"></li>
<script>
const CanvasArea = {
elements: {
canvas: document.getElementById("drawing"),
},
<html>
<head>
<meta charset="UTF-8">
<title>Mouse.ini generator</title>
</head>
<body>
<div class="wrapper">
<div id="left-column">