Skip to content

Instantly share code, notes, and snippets.

View kamiyaowl's full-sized avatar
🤔
:thinking_face:

Kamiya kamiyaowl

🤔
:thinking_face:
View GitHub Profile
/************************************************************************
M5StackFire I2C Scanner
The M5StackFire has a connector for I2C devices.
This program scans the addresses 1-127 continuosly and shows
the devices found on the TFT.
The M5Stack fire has two internal I2C devices at address 0x68 and 0x75.
@kamiyaowl
kamiyaowl / compressor_on_pynq_z2.py
Last active January 29, 2020 16:59
PYNQ-Z2のPython上でコンプレッサーを実装してみた https://twitter.com/kamiya_owl/status/1221425698029498368
from pynq.overlays.base import BaseOverlay
base = BaseOverlay("base.bit", download=False)
# あとでグラフに書きたい場合はtrue
is_debug_capture = True
l_src_arr = []
r_src_arr = []
l_dst_arr = []
r_dst_arr = []
// select_line_in()呼び出し時にTX Buffから音声出力できるようにレジスタ設定を書き込んでおく
/******************************************************************************
* Function to select LINE_IN as input.
* @param iic_index is the i2c index in /dev list.
* @return none.
*****************************************************************************/
extern "C" void select_line_in(int iic_index) {
int iic_fd;
iic_fd = setI2C(iic_index, IIC_SLAVE_ADDR);
# %matplotlib inline
import matplotlib.pyplot as plt
from ipywidgets import *
plt.rcParams['figure.figsize'] = (15.0, 10.0)
from pynq.overlays.base import BaseOverlay
base = BaseOverlay("base.bit")
# 2の補数の扱い辛い
def twos_complement(hexstr,bits):
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <stdint.h>
using namespace std;
int main() {
vector<uint8_t> mem(30000,0);
stack<int> branchStack;
@kamiyaowl
kamiyaowl / gke-cronjob.yml
Created July 18, 2018 13:41
Kubernetes cronjob
apiVersion: "batch/v1beta1"
kind: CronJob
metadata:
name: "<workload-name>"
namespace: "default"
labels:
app: "app-label"
spec:
schedule: "0 */4 * * *"
startingDeadlineSeconds: 120
@kamiyaowl
kamiyaowl / color_table.scala
Last active August 29, 2015 14:26
たまにこういうの欲しくなる
def loopSeq = ((0 to 0xff) ++ (0x0 to 0xff).reverse)
val arr = {loopSeq map{x => s"{ $x, 0, 0,}, "}} ++
{loopSeq map{x => s"{ 0, $x, 0,}, "}} ++
{loopSeq map{x => s"{ 0, 0, $x,}, "}} ++
{loopSeq map{x => s"{ $x, $x, 0,}, "}} ++
{loopSeq map{x => s"{ 0, $x, $x,}, "}} ++
{loopSeq map{x => s"{ $x, 0, $x,}, "}} ++
{loopSeq map{x => s"{ $x, $x, $x,}, "}}
@kamiyaowl
kamiyaowl / main.c
Created June 21, 2015 07:07
Number -> Hex for Embedded
#include <stdio.h>
typedef unsigned short uint16;
typedef unsigned char uint8;
const char numberTable[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
void itoa(uint16 src, char* buf){
uint8 i;
buf[0] = '0';
buf[1] = 'x';
@kamiyaowl
kamiyaowl / main.c
Created June 17, 2015 11:16
ガウスの消去法
#include <stdio.h>
// 未知数の数/方程式の数
#define N 2
int main(void){
// x + 2y = 5
//2x + 3y = 8
double matrix[N][N + 1] = {
{ 1, 2, 5 },
@kamiyaowl
kamiyaowl / ImageData.h
Last active August 29, 2015 14:23
ATMEGA328p LS027B4DH01
#ifndef IMAGEDATA_H_
#define IMAGEDATA_H_
#include <avr/pgmspace.h>
PROGMEM const uint8_t img_src[240][50] = {
{ 0x7, 0xf8, 0xff, 0xff, 0x3, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0xfe, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, },
{ 0xc0, 0xff, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, 0xff, 0xff, 0x8f, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, },
{ 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0xff, 0xc7, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff,