Skip to content

Instantly share code, notes, and snippets.

@anoken
anoken / 003_imu_SH200Q.py
Last active August 25, 2019 14:11
003_imu_SH200Q_m5stickv.py
## M5StickV SH200Q maixpy
## Referred to the following
## https://github.com/m5stack/M5StickC/blob/master/src/utility/SH200Q.cpp
## https://github.com/m5stack/M5-Schematic/blob/master/Core/SH200Q.pdf
## https://bbs.sipeed.com/t/topic/863
from machine import I2C
i2c = I2C(I2C.I2C0, freq=100000, scl=28, sda=29)
devices = i2c.scan()
## M5StickV MPU6886 maixpy
## Referred to the following
## https://github.com/m5stack/M5StickC/blob/master/src/utility/MPU6886.cpp
##https://github.com/m5stack/M5-Schematic/blob/master/datasheet/MPU-6886-000193%2Bv1.1_GHIC.PDF.pdf
from machine import I2C
MPU6886_ADDRESS=0x68
MPU6886_WHOAMI=0x75
MPU6886_ACCEL_INTEL_CTRL= 0x69
@anoken
anoken / 005_image_filter.py
Last active September 2, 2019 22:00
005_image_filter.py
## M5StickV MaixPy
## Referred to the following
## http://docs.openmv.io/library/omv.image.html#functions
import sensor,image,lcd,gc,time,uos
from fpioa_manager import *
from Maix import GPIO
fm.register(board_info.BUTTON_A, fm.fpioa.GPIO1)
but_a=GPIO(GPIO.GPIO1, GPIO.IN, GPIO.PULL_UP)
@anoken
anoken / 006_LED.py
Created September 2, 2019 23:06
006_LED.py
import time,cmath,math
from machine import Timer,PWM
from fpioa_manager import *
tim = Timer(Timer.TIMER0, Timer.CHANNEL0, mode=Timer.MODE_PWM)
ch = PWM(tim, freq=500000, duty=0, pin=board_info.LED_R)
cnt=0
while(True):
duty=0
@anoken
anoken / convert_tfline_kmodel_nncase_v0.2.0.sh
Last active September 5, 2019 20:25
convert_tfline_kmodel_nncase_v0.2.0.sh
#!/bin/bash
echo "Usage: ./convert.sh modelxxx.tflite"
name=`echo $1 | cut -d '.' -f 1`
tflite_out=$name.tflite
kmodel_out=$name.kmodel
#nncase
# https://github.com/kendryte/nncase
# wget https://github.com/kendryte/nncase/releases/download/v0.2.0-alpha1/ncc-linux-x86_64.tar.xz
ncc_exe=~/nncase/ncc
@anoken
anoken / 010_camera_image_conv_filter.py
Created September 5, 2019 21:10
010_camera_image_conv_filter.py
import sensor, image, lcd, time
from fpioa_manager import *
from Maix import I2S, GPIO
lcd.init()
lcd.rotation(2)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
origin = (0,0,0, 0,1,0, 0,0,0)
@anoken
anoken / 190917_cnn_test.py
Created September 16, 2019 15:47
190917_cnn_test.py
from keras.models import Sequential
from keras.layers import Activation, Dense, Dropout,Conv2D,MaxPooling2D,Flatten
from keras.utils.np_utils import to_categorical
from keras.optimizers import Adagrad
from keras.optimizers import Adam
import numpy as np
from PIL import Image
import os
from sklearn.model_selection import train_test_split
@anoken
anoken / 190917_imu_test.py
Created September 16, 2019 15:49
190917_imu_test.py
from machine import I2C
i2c = I2C(I2C.I2C0, freq=100000, scl=28, sda=29)
devices = i2c.scan()
print(devices)
import sensor, image, time,lcd,machine
from machine import I2C
MPU6886_ADDRESS=0x68
MPU6886_WHOAMI=0x75
@anoken
anoken / 190919_imu_test2.py
Created September 18, 2019 16:50
190919_imu_test2.py
from machine import I2C
i2c = I2C(I2C.I2C0, freq=100000, scl=28, sda=29)
devices = i2c.scan()
print(devices)
import lcd #for test
AXP192_ADDR=0x34
Backlight_ADDR=0x91
level=50
val = (level+7) << 4
@anoken
anoken / 190919_har_test_train.py
Created September 18, 2019 16:51
190919_har_test_train.py
from keras.models import Sequential
from keras.layers import Activation, Dense, Dropout,Conv2D,MaxPooling2D,Flatten,ZeroPadding2D
from keras.utils.np_utils import to_categorical
from keras.optimizers import Adagrad
from keras.optimizers import Adam
import numpy as np
from PIL import Image
import os
from sklearn.model_selection import train_test_split
import tensorflow as tf