Skip to content

Instantly share code, notes, and snippets.

@ti-nspire
ti-nspire / MAX31855_Example.cpp
Last active January 13, 2020 20:09
MAX31855_Example_for_ATmega328P
#include <avr/io.h>
#include <util/delay.h>
extern "C" {
#include "USART.h"
}
#include "mySPI.h"
#include "MAX31855.h"
int main(){
initUSART();
@ti-nspire
ti-nspire / MAX31855.cpp
Last active January 12, 2020 21:23
MAX31855_library_for_ATmega328P
#include <avr/io.h>
#include "MAX31855.h"
#include "mySPI.h"
void MAX31855::getData(){
selectSlave(_port, _pin);
tradeByte(0); hi16bits = SPDR << 8;
tradeByte(0); hi16bits |= SPDR ;
tradeByte(0); lo16bits = SPDR << 8;
tradeByte(0); lo16bits |= SPDR ;
@ti-nspire
ti-nspire / mySPI.cpp
Last active January 12, 2020 21:22
SPI_library_for_ATmega328P
#include <avr/io.h>
#include "mySPI.h"
void selectSlave(uint8_t port, uint8_t pin){
switch(port){
case 'B': PORTB &= ~(1 << pin); break;
case 'C': PORTC &= ~(1 << pin); break;
case 'D': PORTD &= ~(1 << pin); break;
default : PORTB &= ~(1 << PB2); break;
}
103AT
温度(℃) 抵抗(kΩ)
-50 329.5
-40 188.5
-30 111.3
-20 67.77
-10 42.47
0 27.28
10 17.96
20 12.09
@ti-nspire
ti-nspire / printByteAsBin.c
Created February 20, 2019 01:27
a function to print a one-byte value as a binary number.
#include <stdio.h>
// a function to print a one-byte value as a binary number.
void printByteAsBin(unsigned char oneByte){
unsigned char binStr[8];
unsigned char mask = 128; // 0b 1000 0000;
for(int i=0; i<8; i++){
binStr[i] = (oneByte & mask) ? '1' : '0' ;
mask >>= 1;
}
@ti-nspire
ti-nspire / AM2302.cpp
Last active December 2, 2018 21:22
A library for AM2302/DHT22 connected to the micro:bit on the Mbed platform
#include "MicroBit.h"
#include "AM2302.h"
extern MicroBit uBit;
int AM2302::bits2bytes(int *buf, int pos){
int Pos = (8 * pos) - 7;
int sute = 0;
for(int i=Pos ; i<(Pos+8); i++){
sute |= buf[i] << (Pos+7-i);
}
@ti-nspire
ti-nspire / lifegame.py
Created October 22, 2018 02:39
a Conway's Game of Life
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import convolve2d
from matplotlib.animation import FuncAnimation
class LifeGame: # 引数は左から(2次元排列, (表示領域の幅, 高さ), 更新ミリ秒)
def __init__(self, mat, figsize=None, interval=1):
self.mat = np.asarray(mat, dtype=np.uint8)
self.Rules = np.array([[0,0,0,1,0,0,0,0,0], [0,0,1,1,0,0,0,0,0]], dtype=np.uint8)
self.Weight = np.array([[1,1,1], [1,0,1], [1,1,1]], dtype=np.uint8)
self.anim = FuncAnimation(plt.figure(figsize=figsize), self.__update, interval=interval)
@ti-nspire
ti-nspire / PILImage.py
Last active August 8, 2018 06:40
PIL.Imageの使いかた
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
class IMAGE:
def __init__(self, imgPath):
self.srcImg = Image.open(imgPath)
self.__initialize()
@ti-nspire
ti-nspire / MCP3008.c
Created July 6, 2018 23:43
AD Converter MCP3008.c for PC-G850VS
unsigned int read(unsigned char CH){
unsigned char mosi[36] = {3,4,6,4,6,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,1};
unsigned char ch[8][6] = {{0,2,0,2,0,2}, /*CH0*/
{0,2,0,2,4,6}, /*CH1*/
{0,2,4,6,0,2}, /*CH2*/
{0,2,4,6,4,6}, /*CH3*/
{4,6,0,2,0,2}, /*CH4*/
{4,6,0,2,4,6}, /*CH5*/
{4,6,4,6,0,2}, /*CH6*/
{4,6,4,6,4,6}}; /*CH7*/
@ti-nspire
ti-nspire / さきがけて.md
Last active May 29, 2018 00:35
さきがけて

青空文庫を
"さき駈けて" OR "先駈けて" OR "さきがけて" OR "さき駆けて" OR "先がけて" OR "先駆けて" site:www.aozora.gr.jp/cards
で検索してみる。

見つかったうち、「ほかの何かよりも先に」「ほかの誰かよりも先に」の意味で使われているのはおそらく徳永直 光をかかぐる人々だけである。それ以外はすべて「ほかの何よりも先に」「ほかの誰よりも先に」「まっさきに」の意味で使われている。「さきがけ」の反対は「しんがり」である。「先驅者」は「誰かよりも先に何かをした者」ではなく「誰よりも先に何かをした者」である。

したがって
「その会社は他社に先駆けて量子コンピューターを商品化した」とは言えるが
「その会社は日立に先駆けて量子コンピューターを商品化した」とは多分言えない。