Beispiel #1
0
    def __init__(self):
        from Maix import utils
        import machine

        if utils.gc_heap_size() != 1024 * 1024:
            utils.gc_heap_size(1024 * 1024)  # 1MiB
            machine.reset()
        lcd.init(freq=15000000)
        lcd.clear()
        self.__w = lcd.width()
        self.__h = lcd.height()
        self.canvas = image.Image(size=(self.__w, self.__h))
        self.__bg_img = None
        self.__bg_color = (255, 255, 255)
        self.canvas.draw_rectangle(0,
                                   0,
                                   self.__w,
                                   self.__h,
                                   self.__bg_color,
                                   fill=True)  # background color
Beispiel #2
0

def u_send(d):
    data_packet = bytearray([0xFF, 0xAA])
    data_packet.append(d % 256)
    uart_Port.write(data_packet)
    print("send " + str(d))


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!

utils.gc_heap_size(300000)


def initialize_camera():
    err_counter = 0
    while 1:
        try:
            sensor.reset()  #Reset sensor may failed, let's try some times
            break
        except:
            err_counter = err_counter + 1
            if err_counter == 20:
                lcd.draw_string(lcd.width() // 2 - 100,
                                lcd.height() // 2 - 4,
                                "Error: Sensor Init Failed", lcd.WHITE,
                                lcd.RED)
Beispiel #3
0
            while True:
                try:
                    # print((int)(1000 / (time.ticks_ms() - last)), 'fps')
                    # last = time.ticks_ms()
                    # print_mem_free()
                    gc.collect()
                    app.ctrl.cycle()
                    protect.keep()
                    #time.sleep(0.1)
                except KeyboardInterrupt:
                    protect.stop()
                    raise KeyboardInterrupt()
                except Exception as e:
                    # gc.collect()
                    print(e)


#'''
if __name__ == "__main__":
    import lcd

    from Maix import utils
    import machine

    if utils.gc_heap_size() != 1024 * 1024:
        utils.gc_heap_size(1024 * 1024)  # 1MiB
        machine.reset()

    lcd.init()
    print_mem_free()
    app.run()
Beispiel #4
0
import image
import lcd
import sensor
import sys
import time
import uos
import KPU as kpu
from fpioa_manager import *
from machine import I2C
from Maix import I2S, GPIO
from Maix import utils

#
# initialize
#
utils.gc_heap_size(250000)

lcd.init()
lcd.rotation(2)
i2c = I2C(I2C.I2C0, freq=400000, scl=28, sda=29)

fm.register(board_info.SPK_SD, fm.fpioa.GPIO0)
spk_sd=GPIO(GPIO.GPIO0, GPIO.OUT)
spk_sd.value(1) #Enable the SPK output

fm.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)
Beispiel #5
0
import KPU as kpu
import sensor
import lcd
import image
import time
import uos
import audio
import gc
import ulab as np
from fpioa_manager import *
from Maix import utils, I2S, GPIO
from machine import Timer,PWM,I2C
#import _thread

#utils.gc_heap_size(400000)      # 287
utils.gc_heap_size(450000)      # 287

# LCD初期化
lcd.init()
lcd.rotation(2)

i2c = I2C(I2C.I2C0, freq=400000, scl=28, sda=29)
def set_backlight(level):
    if level > 8:
        level = 8
    if level < 0:
        level = 0
    val = (level+7) << 4
    i2c.writeto_mem(0x34, 0x91,int(val))

try:
Beispiel #6
0
import gc
import audio
import re
from fpioa_manager import *
from machine import I2C
from Maix import utils, I2S, GPIO
import sensor, image, time
import lcd

gc.collect()
utils.gc_heap_size(400000)

lcd.init()
lcd.rotation(2)

fm.register(board_info.SPK_SD, fm.fpioa.GPIO0)
spk_sd = GPIO(GPIO.GPIO0, GPIO.OUT)
spk_sd.value(1)  #Enable the SPK output

fm.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)

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!