Skip to content

Instantly share code, notes, and snippets.

View xiongyihui's full-sized avatar

Yihui Xiong xiongyihui

View GitHub Profile
@xiongyihui
xiongyihui / hotplug2.rules
Created January 11, 2013 11:12
OpenWRT中Hotplug服务的配置文件
$include /etc/hotplug2-common.rules
SUBSYSTEM ~~ (^net$|input$|^button$|^usb$|^ieee1394$|^block$|^atm$|^zaptel$|tty$) {
exec /sbin/hotplug-call %SUBSYSTEM%
}
DEVICENAME == watchdog {
exec /sbin/watchdog -t 5 /dev/watchdog
next-event
}
@xiongyihui
xiongyihui / wifly_change_baud.ino
Created March 25, 2013 09:29
test WiFly 171, change it's default baud of WiFly's UART. Arduino will get incorrect response from WiFly since Arduino's SoftwareSerial is not stable enough.
#include <SoftwareSerial.h>
// Pins' connection
// Arduino WiFly
// 2 <----> TX
// 3 <----> RX
SoftwareSerial wifly(2, 3);
void readWiFlyOutput()
{
/**
* led_breath.ino
* Use PWM to change LED's brightness
* Mode:
* Quadratic curve
* Linearity
*/
#define NOT_USE_LINEARITY 1
@xiongyihui
xiongyihui / usb_keyboard.cpp
Created July 31, 2013 04:20
Use Arch as an USB keyboard
#include "mbed.h"
#include "USBKeyboard.h"
BusOut leds(LED1, LED2, LED3); //LED1: NUM_LOCK, LED2: CAPS_LOCK, LED3: SCROLL_LOCK
USBKeyboard keyboard;
int main(void) {
while (!keyboard.configured()) { // wait until keyboard is ready
}
@xiongyihui
xiongyihui / custom_adapter.py
Created March 6, 2014 10:03
Use custom CMSIS DAP debug adapter with pyOCD
'''
Use custom CMSIS DAP debug adapter with pyOCD
'''
from time import sleep
from random import randrange
from pyOCD.interface import INTERFACE, usb_backend
from pyOCD.board import MbedBoard
GCC_BIN =
LIBRARY = ble_api
SRC_DIR := common public services
BUILD_DIR := $(addprefix build/,$(SRC_DIR))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
OBJ := $(patsubst %.cpp,build/%.o,$(SRC))
@xiongyihui
xiongyihui / CMakeLists.txt
Created November 27, 2014 10:19
CMakeLists.txt for mbed
#
# CMake configuration
#
# Please refer to http://www.cmake.org/cmake/help/documentation.html
# You may also refer to http://www.cmake.org/cmake/help/syntax.html for a quick
# introduction to CMake's syntax.
cmake_minimum_required (VERSION 2.8)
# The name of our project is "NODE". CMakeLists files in this project can
#!/usr/bin/env python
import sys, serial
import numpy as np
from collections import deque
from matplotlib import pyplot as plt
# class that holds data for N samples
class DataPoll:
# constr
@xiongyihui
xiongyihui / k_type_tc_table.c
Created March 3, 2015 07:11
K type thermocouple conversion table - Celsius
// K type thermocouple conversion table - Celsius
// from -270 to 1372
const float k_type_tc_table[] = {
/* ˚C -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 ˚C */
/* -260 */ -6.458, -6.457, -6.456, -6.455, -6.453, -6.452, -6.45, -6.448, -6.446, -6.444,
/* -250 */ -6.441, -6.438, -6.435, -6.432, -6.429, -6.425, -6.421, -6.417, -6.413, -6.408,
/* -240 */ -6.404, -6.399, -6.393, -6.388, -6.382, -6.377, -6.37, -6.364, -6.358, -6.351,
/* -230 */ -6.344, -6.337, -6.329, -6.322, -6.314, -6.306, -6.297, -6.289, -6.28, -6.271,
/* -220 */ -6.262, -6.252, -6.243, -6.233, -6.223, -6.213, -6.202, -6.192, -6.181, -6.17,
/* -210 */ -6.158, -6.147, -6.135, -6.123, -6.111, -6.099, -6.087, -6.074, -6.061, -6.048,
@xiongyihui
xiongyihui / beaglebone_green_test.py
Created March 31, 2015 06:53
To test BeagleBone Green
'''
BeagleBone Green Test
apt-get install build-essential python-dev python-setuptools python-pip python-smbus -y
pip install Adafruit_BBIO
'''
import Adafruit_BBIO.GPIO as GPIO