Skip to content

Instantly share code, notes, and snippets.

@ksasao
ksasao / adctest.ino
Last active February 24, 2019 16:29
M5Stack analog read and noise suppression
#include <driver/adc.h>
#include <M5Stack.h>
void setup() {
Serial.begin(115200);
M5.begin();
M5.Speaker.setVolume(0);
M5.Lcd.setBrightness(200);
adc1_config_width(ADC_WIDTH_12Bit);
@ksasao
ksasao / analog_mic_draw.ino
Last active May 17, 2018 04:11
[M5Stack] mic input test (speaker noise suppressed) refer to https://gist.github.com/ksasao/485ffbccbf3c47ea9cb814d3484e85e0
#include <driver/adc.h>
#include <M5Stack.h>
const int _bufSize = 128;
int _buf[_bufSize]; // adc buffer for suppress speaker noise
int _pos = 0;
int _old = 0;
int _count = 0;
int _offset = 0;
@ksasao
ksasao / camera.ino
Last active August 21, 2018 07:54
Grove Serial Camera Kit demo for M5Stack
//
// Grove Serial Camera Kit demo for M5Stack
//
// !! CAUTION !!
// This code uses M5Stack Grove I2C as Grove UART (serial port).
// REMOVE all I2C devices.
//
// original code:
// https://github.com/Seeed-Studio/Grove_Serial_Camera_Kit/blob/master/SerialCameral_DemoCode_CJ_OV528_SoftSer/SerialCameral_DemoCode_CJ_OV528_SoftSer.ino
// File SerialCamera_DemoCode_CJ-OV528.ino
// M5Stack Text-to-Speech demo using AquesTalk pico for ESP32
// see: http://blog-yama.a-quest.com/?eid=970188
#include <M5Stack.h>
#include "driver/i2s.h"
#include "aquestalk.h"
#define LEN_FRAME 32
uint32_t workbuf[AQ_SIZE_WORKBUF];
void setup() {
@ksasao
ksasao / drawNumber.ino
Last active April 1, 2018 00:24
Drawing test for M5Stack. see https://twitter.com/ksasao/status/970196248836755456 To see the whole source code, click RAW or Download ZIP button. License: public domain.
This file has been truncated, but you can view the full file.
#include <M5Stack.h>
#include "M5StackUpdater.h"
const unsigned char _buf[] ={
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
@ksasao
ksasao / 0_talking_watch.ino
Last active July 18, 2019 11:13
Talking wrist watch for M5Stack
// Talking wrist watch for M5Stack
// 2018/4/8 @ksasao
//
// see:
// https://twitter.com/meganetaaan/status/982258576361078784
// http://blog-yama.a-quest.com/?eid=970191
// prerequisite: AquesTalk pico for ESP32
// https://www.a-quest.com/download.html#a-etc
#include <M5Stack.h>
#include "avator.h"
@ksasao
ksasao / echo_server.py
Created April 15, 2018 06:13
Python3 asynchronous UDP Server for Windows (asyncio does not support 'create_datagram_endpoint()')
import socket
import threading
HOST = '0.0.0.0'
PORT = 24081
BUFFER_SIZE = 1024
def udpServer():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((HOST, PORT))
@ksasao
ksasao / findmarker.py
Last active February 20, 2022 09:12
某スーツの水玉をみつけるやつ
import numpy as np
import random
import math
import cv2
from PIL import Image
def recognize(im):
# 輪郭線抽出のための二値化
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_blur = cv2.GaussianBlur(im_gray, (3, 3), 0)
@ksasao
ksasao / detect_marker.py
Last active December 10, 2023 02:38
ZOZOSUITのマーカーのIDを読み取るコードです。公開されている画像を元に独自に解析しているので、公式ではこのように処理しているかどうかは不明です。仕様等については https://twitter.com/ksasao/status/990779583682170881 のスレッドも参照してください。全身を読み取るコード https://twitter.com/ksasao/status/989842844243279872 ライセンスは Apache License 2.0 です。
import numpy as np
import random
import math
import cv2
from PIL import Image
import sys
def detect_markers(im):
markers = []
# 輪郭線抽出のための二値化
@ksasao
ksasao / acc.py
Last active September 12, 2018 14:08
iPhoneで心拍を取るテスト。Pythonista 用。実行すると5秒後から5秒間測定を行います。仰向けになってiPhoneを胸の上に置き、息を止めてじっとしていてください。
'''This script records your device's orientation (accelerometer data) for 5 seconds, and then renders a simple plot of the gravity vector, using matplotlib.'''
import motion
import matplotlib.pyplot as plt
from time import sleep
import console
def main():