Purchased a m5StickV - Fixed in recent firmware update.
-
@ajb2k3 said in Purchased a m5StickV:
@xeon have you contacted M5Stack support about this? They should be available now
They verified the problem and will release a fix soon.
-
@xeon said in Purchased a m5StickV:
@ajb2k3 said in Purchased a m5StickV:
@xeon have you contacted M5Stack support about this? They should be available now
They verified the problem and will release a fix soon.
Glad to hear it.
-
@ajb2k3 So far i managed to program a demo with all the source lying around thanks to our great friends here sharing.
But there are a few source examples i'm looking for.
i'm trying to make a program that tests as many functions and features as possible.import audio
import gc
import image
import lcd
import sensor
import sys
import time
import utime
import uos
import _thread
import pmu
import KPU as kpu
from fpioa_manager import *
from machine import I2C
from Maix import I2S, GPIO
time.sleep(2)Initialize
Lcd setup
lcd.init()
lcd.rotation(2)
i2c = I2C(I2C.I2C0, freq=400000, scl=28, sda=29)Speaker setup
fm.register(board_info.SPK_SD, fm.fpioa.GPIO0)
spk_sd=GPIO(GPIO.GPIO0, GPIO.OUT)
spk_sd.value(1) #Enable the SPK outputfm.register(board_info.SPK_DIN,fm.fpioa.I2S0_OUT_D1)
fm.register(board_info.SPK_BCLK,fm.fpioa.I2S0_SCLK)
fm.register(board_info.SPK_LRCLK,fm.fpioa.I2S0_WS)wav_dev = I2S(I2S.DEVICE_0)
Init battery monitor axp192
axp = pmu.axp192()
axp.enableADCs(True)Setup A and B buttons
fm.register(board_info.BUTTON_A, fm.fpioa.GPIO1)
but_a=GPIO(GPIO.GPIO1, GPIO.IN, GPIO.PULL_UP) #PULL_UP is required here!fm.register(board_info.BUTTON_B, fm.fpioa.GPIO2)
but_b = GPIO(GPIO.GPIO2, GPIO.IN, GPIO.PULL_UP) #PULL_UP is required here!but_a_pressed = 0
but_b_pressed = 0
but_stu = 1
cnt_f = 0Setup LED's
fm.register(board_info.LED_W, fm.fpioa.GPIO3)
led_w = GPIO(GPIO.GPIO3, GPIO.OUT) #RGBW "White" LED
led_w.value(1) #RGBW "White" LED is Active Lowfm.register(board_info.LED_R, fm.fpioa.GPIO4)
led_r = GPIO(GPIO.GPIO4, GPIO.OUT) #RGBW "Red" LED
led_r.value(1) #RGBW "Red" LED is Active Lowfm.register(board_info.LED_G, fm.fpioa.GPIO5)
led_g = GPIO(GPIO.GPIO5, GPIO.OUT) #RGBW "Green" LED
led_g.value(1) #RGBW "Green" LED is Active Lowfm.register(board_info.LED_B, fm.fpioa.GPIO6)
led_b = GPIO(GPIO.GPIO6, GPIO.OUT) #RGBW "Blue" LED
led_b.value(1) #RGBW #RGBW "Blue" LED is Active LowDefine image filters
origin = (0,0,0, 0,1,0, 0,0,0)
edge = (-1,-1,-1,-1,8,-1,-1,-1,-1)
sharp = (-1,-1,-1,-1,9,-1,-1,-1,-1)
relievo = (2,0,0,0,-1,0,0,0,-1)Subs
def fade_scrn(fspd,dirr): # Use backlight to fade screen dirr = dirrection 0 = in 1 = out
for i in range(9):
if dirr == 0:
set_backlight(i)
if dirr == 1:
ti = 9 - i
set_backlight(ti)
time.sleep(fspd)def play_sound(filename,vol):
try:
player = audio.Audio(path = filename)
player.volume(vol)
wav_info = player.play_process(wav_dev)
wav_dev.channel_config(wav_dev.CHANNEL_1, I2S.TRANSMITTER,resolution = I2S.RESOLUTION_16_BIT, align_mode = I2S.STANDARD_MODE)
wav_dev.set_sample_rate(wav_info[1])
while True:
ret = player.play()
if ret == None:
break
elif ret==0:
break
player.finish()
except:
passdef set_backlight(level): # Set backlight brightness ranges from 0 to 8
if level > 8:
level = 8
if level < 0:
level = 0
val = (level+7) << 4
i2c.writeto_mem(0x34, 0x91,int(val))def show_logo():
led_r.value(0)
img = image.Image("/sd/startup1.jpg")
time.sleep(0.15)
led_r.value(1)
set_backlight(0)
lcd.display(img)
fade_scrn(0.02,0)
led_w.value(0)
led_b.value(0)
play_sound("/sd/logo.wav",70)
led_b.value(1)
fade_scrn(0.02,1)
img = image.Image("/sd/startup2.jpg")
lcd.display(img)
fade_scrn(0.02,0)
play_sound("/sd/ding1.wav",70)
time.sleep(2)
led_w.value(1)def init_camera(): #initialize sensor
led_b.value(0)
led_r.value(0)
err_counter = 0
while 1:
try:
sensor.reset() # Reset sensor.
break
except:
err_counter = err_counter + 1
if err_counter == 20:
led_r.value(0) # Led stays red if sensor failed to initialize.
lcd.draw_string(lcd.width()//2-100,lcd.height()//2-4, "Error: Sensor Init Failed", lcd.WHITE, lcd.RED)
time.sleep(0.1)
continue
led_b.value(1)
led_r.value(1)
led_g.value(0) # Led turns Green meaning all good.
play_sound("/sd/ding2.wav",70)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA) #QVGA=320x240
sensor.run(1)
time.sleep(0.5)
led_g.value(1)def show_batt_stats():
val = axp.getVbatVoltage()
img.draw_string(52, 60, "Bat V:" + str(val), color=(230,0,0))
val = axp.getBatteryDischargeCurrent()
img.draw_string(52, 72, "Bat I:" + str(val), color=(230,0,0))
val = axp.getUSBVoltage()
img.draw_string(52, 84, "USB V:" + str(val), color=(230,0,0))
val = axp.getUSBInputCurrent()
img.draw_string(52, 96, "USB I:" + str(val), color=(230,0,0))
val = axp.getBatteryInstantWatts()
img.draw_string(52, 108, "I W:" + str(val), color=(230,0,0))
val = axp.getTemperature()
img.draw_string(52, 120, "Temp*:" + str(val), color=(230,0,0))def apply_filter(cnt_f):
if cnt_f==1: #cycle filters 1=edge, 2=sharp, 3=relievo, 4=origin, 0 = skip filter
img.conv3(edge)
img.draw_string(52,60, "edge",color=(255,0,0))
elif cnt_f==2:
img.conv3(sharp)
img.draw_string(52,60, "sharp",color=(255,0,0))
elif cnt_f==3:
img.conv3(relievo)
img.draw_string(52,60, "relievo",color=(255,0,0))
elif cnt_f==4:
img.conv3(origin) #reset filter
img.draw_string(52,60, "origin",color=(255,0,0))
else :
cnt_f=0Main
show_logo()
if but_a.value() == 0: #If dont want to run the demo
img = image.Image("/sd/startup3.jpg")
lcd.display(img)
print('[info]: Exit by user operation')
fade_scrn(0.02,1)
time.sleep(0.02)
set_backlight(0)
sys.exit()init_camera()
Define list of classes
classes = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor']
task = kpu.load("/sd/model/20class.kmodel")
task_face = kpu.load(0x300000) # default face detection model on flash memorytask_face = kpu.load("/sd/model/facedetect.kmodel") # you can extract the model from default .kfpkg
anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658, 5.155437, 6.92275, 6.718375, 9.01025)
Anchor data is for bbox, extracted from the training sets.
kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
kpu.init_yolo2(task_face, 0.5, 0.3, 5, anchor)print('[info]: Started.')
fade_scrn(0.02,1)
img = sensor.snapshot()
lcd.display(img)
fade_scrn(0.02,0)
led_g.value(1)
green_threshold = (0, 80, -70, -10, -0, 30)try:
while(True):img=sensor.snapshot() # Take Snapshot # Press B and A to cycle thru filters if but_b.value() == 0 and but_a.value() == 0 and but_b_pressed == 0: cnt_f=cnt_f+1 but_b_pressed=1 #play_sound("/sd/ding2.wav",70) if but_b.value() == 1 and but_a.value() == 0 and but_b_pressed == 1: but_b_pressed=0 #play_sound("/sd/ding2.wav",70) if cnt_f==5: cnt_f=0 apply_filter(cnt_f) gc.collect() code_obj = kpu.run_yolo2(task, img) code_face = kpu.run_yolo2(task_face, img) if code_obj: # object detected max_id = 0 max_rect = 0 for i in code_obj: img.draw_rectangle(i.rect()) text = ' ' + classes[i.classid()] + ' (' + str(int(i.value()*100)) + '%) ' for x in range(-1,2): for y in range(-1,2): img.draw_string(x+i.x(), y+i.y()+(i.h()>>1), text, color=(255,255,255), scale=1.5,mono_space=False) img.draw_string(i.x(), i.y()+(i.h()>>1), text, color=(255,25,25), scale=1.5,mono_space=False) #display detected object name id = i.classid() rect_size = i.w() * i.h() if rect_size > max_rect: max_rect = rect_size max_id = id if but_a.value() == 0 and but_b.value() == 1: led_w.value(0) play_sound("/sd/voice/en/"+str(max_id)+".wav",70) led_w.value(1) if code_face: # face detected max_id = 0 max_rect = 0 for i in code_face: img.draw_rectangle(i.rect(),color=(230,0,0)) if but_b.value() == 0 and but_a.value() == 1: # press B for battery stats overlay show_batt_stats() #gc.collect() #blobs = img.find_blobs([green_threshold]) #if blobs: #for b in blobs: #tmp=img.draw_rectangle(b[0:4]) #tmp=img.draw_cross(b[5], b[6]) #c=img.get_pixel(b[5], b[6]) lcd.display(img)
except KeyboardInterrupt:
kpu.deinit(task)
kpu.deinit(task_face)
sys.exit() -
Xeon, I've noticed pretty same problem on my stick-v today.
Whenever I press and hold turn-off button stick reboots instead of turning off.
In my case this happens whenever SD card is plugged in. I've removed it and everything works as intended now -
@thrasher
latest Firmware fixes this.http://forum.m5stack.com/topic/1403/m5stickv-firmware_1017-upgrade