Skip to content

Instantly share code, notes, and snippets.

View dvsseed's full-sized avatar
💭
I may be slow to respond.

曾令燊 dvsseed

💭
I may be slow to respond.
View GitHub Profile
@dvsseed
dvsseed / show_serial.py
Last active October 3, 2017 12:53
To detect the serial ports on windows 10 laptop
#coding:utf-8
"""
Written on a Windows 10 Laptop, Python 2.7.14 Version.
This program automatically detects and lists ports.
Written by Davis, Tseng 10/03/2017.
"""
# import serial
@dvsseed
dvsseed / show_serial.py
Created October 3, 2017 12:54
To detect the serial ports on windows 10 / MacOS Sierra laptop
#coding:utf-8
"""
Written on a Windows 10 / MacOS Sierra Laptop, Python 2.7.14 Version.
This program automatically detects and lists ports.
Written by Davis, Tseng 10/03/2017.
"""
# import serial
import serial.tools.list_ports
@dvsseed
dvsseed / find_syspath.py
Created October 9, 2017 06:55
To find the location(directory) of Python module sources
import sys
site_packages = next(p for p in sys.path if 'site-packages' in p)
print site_packages
@dvsseed
dvsseed / microbit_helper_zh_tw.s2e
Created October 11, 2017 23:02
scratch extension for microbit with Chinese
{
"extensionName": "BBC micro:bit Extension",
"extensionPort": 54321,
"url": "https://github.com/",
"blockSpecs": [
["r", "加速度感應值(mg) x", "acc_x"],
["r", "加速度感應值(mg) y", "acc_y"],
["r", "加速度感應值(mg) z", "acc_z"],
["", "", ""],
["r", "方位感應值(°) x", "comp_x"],
@dvsseed
dvsseed / microbit_hex.py
Created October 11, 2017 23:06
microbit hex from micropython
# micro:bit for Scratch Extension
from microbit import *
import music
REFRESH = 100
def get_sensor_data():
# Gestures/Accelerometer
ax, ay, az = accelerometer.get_x(), accelerometer.get_y(), accelerometer.get_z()
@dvsseed
dvsseed / microbit_helper.py
Created October 11, 2017 23:59
Scratch Extension helper for micro:bit
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 10 12:49:59 2017
@author: Davis, Tseng @Taiwan
Copyright (c) 2017-18 Davis Tseng All right reserved.
This program is free software;
@dvsseed
dvsseed / Excel_macro_for_microbit.vba
Created October 18, 2017 00:11
Excel and Micro:Bit through USB port
' Option Explicit
Dim StopReading As Boolean
Sub StartBtn_Click()
'
' StartBtn - Starts reading from the Micro:Bit into the grid
'
Dim COM_Byte As Byte
StopReading = False
@dvsseed
dvsseed / serial_write.py
Created October 18, 2017 07:09
Send micro:bit sensor's data to serial port
basic.forever(() => {
serial.writeString("D:")
serial.writeNumber(input.acceleration(Dimension.Strength))
serial.writeString(",")
serial.writeNumber(input.lightLevel())
serial.writeString(",")
serial.writeNumber(input.compassHeading())
serial.writeString(",")
serial.writeNumber(input.temperature())
serial.writeLine("")
@dvsseed
dvsseed / pulse.cpp
Created October 28, 2017 05:44
pulse cpp for micro:bit
#include "MicroBit.h"
MicroBit uBit;
int main() {
uBit.init();
uBit.display.scroll("NEW PROGRAM");
release_fiber();
}
@dvsseed
dvsseed / runyt.bat
Created November 1, 2017 00:56
uses yotta as an offline build system
@echo off
rem set the yotta build target
yt target bbc-microbit-classic-gcc
rem make sure cpp file goes into source dir
copy source\examples\bluetooth-eddystone-url\main.cpp source
rem and config.json in the microbit-samples dir
copy source\examples\bluetooth-eddystone-url\config.json .