# data[].attributes.attachment_link.readable_text
from m5stack import *
import unit

servo_motor = unit.get(unit.SERVO, unit.PORTA)

def buttonA_wasPressed():
  lcd.clear(lcd.BLACK)
  lcd.print('Servo Demo on Port A', 12, 38)  
  lcd.print('Rotation Degree: 0',13,81,lcd.WHITE)
  servo_motor.write_angle(0)
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  lcd.clear(lcd.BLACK)
  lcd.print('Servo Demo on Port A', 12, 38)  
  lcd.print('Rotation Degree: 90',13,81,lcd.WHITE)  
  servo_motor.write_angle(90)
  pass
btnB.wasPressed(buttonB_wasPressed)

def buttonC_wasPressed():
  lcd.clear(lcd.BLACK)
  lcd.print('Servo Demo on Port A', 12, 38)  
  lcd.print('Rotation Degree: 180',13,81,lcd.WHITE)  
  servo_motor.write_angle(180)
  pass
btnC.wasPressed(buttonC_wasPressed)

servo_motor.write_angle(0)
lcd.clear(lcd.BLACK)
lcd.font(lcd.FONT_DejaVu18)
lcd.print('Servo Demo on Port A', 12, 38)
lcd.print('Rotation Degree: ',13,81,lcd.WHITE)


# data[].attributes.body
Remember to change the file name to "hkylen" before downloading

# data[].attributes.attachment_link.readable_text
from machine import Pin, I2C
import os

ADDRESS = 0x32

machine = os.uname().machine
i2c1 = I2C(-1, scl=Pin(22), sda=Pin(21), freq=100000) #SDA = TX, SCL = RX

# Command List
START_CMD = b'\x55\xAA\x11'
COMMAND_REQUEST_KNOCK = START_CMD + b'\x00\x2C\x3C'
COMMAND_REQUEST = START_CMD + b'\x00\x20\x30'
COMMAND_REQUEST_ALGORITHM = START_CMD + b'\x02\x2D'

FACE_RECOGNITION = 0
OBJECT_TRACKING = 1
OBJECT_RECOGNITION = 2
COLOR_RECOGNITION = 4
TAG_RECOGNITION = 5
CLASSIFICATION = 6

COMMAND_RETURN_OK = START_CMD + b'\x00\x2E\x3E'

def isReady():
    try:
        i2c1.writeto(ADDRESS, COMMAND_REQUEST_KNOCK, len(COMMAND_REQUEST_KNOCK))
        res = i2c1.readfrom(ADDRESS, len(COMMAND_RETURN_OK))
    except OSError:
        return False
    return res == COMMAND_RETURN_OK

def setAlgorithm(index):
    cmd = COMMAND_REQUEST_ALGORITHM + bytes([ index, 0, 0x3F + index ])
    try:
        i2c1.writeto(ADDRESS, cmd, 8)
        res = i2c1.readfrom(ADDRESS, len(COMMAND_RETURN_OK))
    except OSError:
        return False
    return res == COMMAND_RETURN_OK

blocks = { }
arrow = { }

def b2i(x, y):
    return (x << 8) | y

def readBlockInfo():
    global blocks, arrow
    try:
        data = i2c1.readfrom(ADDRESS, 16)
    except OSError:
        print("I2C error")
        return False
    if data[:5] == (START_CMD + b'\x0A\x2A'): # Block ?
        data = data[5:]
        index = b2i(data[9], data[8])
        blocks[index] = {
            "x": b2i(data[1], data[0]),
            "y": b2i(data[3], data[2]),
            "w": b2i(data[5], data[4]),
            "h": b2i(data[7], data[6])
        }
        return True
    elif data[:5] == (START_CMD + b'\x0A\x2B'): # Arrow ?
        data = data[5:]
        index = b2i(data[9], data[8])
        arrow[index] = {
            "xs": b2i(data[1], data[0]),
            "ys": b2i(data[3], data[2]),
            "xe": b2i(data[5], data[4]),
            "ye": b2i(data[7], data[6])
        }
        return True
    print("DATA ERROR")
    return False

def update():
    global blocks, arrow
    try:
        i2c1.writeto(ADDRESS, COMMAND_REQUEST, len(COMMAND_REQUEST))
        data = i2c1.readfrom(ADDRESS, 16)
    except OSError:
        print("I2C error")
        return False
    # print(data[:5])
    if data[:5] == (START_CMD + b'\x0A\x29'):
        data = data[5:]
        blocksLen = int(data[0])
        learnedLen = int(data[2])
        blocks = { }
        arrow = { }
        for i in range(blocksLen):
            readBlockInfo()
    else:
        print("DATA ERROR")

def blockIsReady(index):
    return index in blocks

def blockGetPos(index):
    if not blockIsReady(index):
        return ( 0, 0 )
    return (blocks[index]["x"], blocks[index]["y"])
    
def blockGetPosX(index):
    if not blockIsReady(index):
        return ( 0 )
    return (blocks[index]["x"])    

def blockGetPosY(index):
    if not blockIsReady(index):
        return ( 0 )
    return (blocks[index]["y"])    

# data[].attributes.attachment_link.readable_text
import sys
sys.path.append('/flash/apps')
import hkylen
import unit
from m5stack import *
from m5ui import *
from time import sleep

#===== Declarations =====#
servo_0 = unit.get(unit.SERVO, unit.PORTC)

#===== User-Defined Functions =====#
def displayResult(faceID):
    if (faceID == 1):
        lbl.setColor(lcd.RED)
        rgb.setColorAll(lcd.RED)
        lbl.setText('FACE ID: 1')
        servo_0_90_0()
    elif (faceID == 2):
        lbl.setColor(lcd.GREEN)
        rgb.setColorAll(lcd.GREEN)
        lbl.setText('FACE ID: 2')
        servo_0_90_0()
    elif (faceID == 3):
        lbl.setColor(lcd.BLUE)
        rgb.setColorAll(lcd.BLUE)
        lbl.setText('FACE ID: 3')
        servo_0_90_0()
    elif (faceID == 4):
        lbl.setColor(lcd.YELLOW)
        rgb.setColorAll(lcd.YELLOW)
        lbl.setText('FACE ID: 4')   
        servo_0_90_0()
    else:
        lbl.setColor(lcd.WHITE)
        rgb.setColorAll(lcd.BLACK)
        lbl.setText('No Face ID')

def servo_0_90_0():
    servo_0.write_angle(90)
    sleep (2)
    servo_0.write_angle(0)
    

#===== Main =====#
lcd.clear(lcd.BLACK)
lcd.font(lcd.FONT_DejaVu24)
servo_0.write_angle(0) 
hkylen.setAlgorithm(hkylen.FACE_RECOGNITION)

while not (hkylen.isReady()):
    lcd.print('Huskylens Not Ready!', 10, 0, lcd.CYAN)

lcd.clear(lcd.BLACK)
lcd.print('Face Security Demo', 10, 0, lcd.CYAN)
lbl = M5TextBox(15, 90, '', lcd.FONT_DejaVu56, lcd.WHITE)

displayResult(0)
while True:
    hkylen.update()
    if hkylen.blockIsReady(1):
        displayResult(1)
    elif hkylen.blockIsReady(2):
        displayResult(2)
    elif hkylen.blockIsReady(3):
        displayResult(3)
    elif hkylen.blockIsReady(4):
        displayResult(4)
    else:    
        displayResult(0)       
    sleep(2)

# data[].attributes.attachment_link.readable_text
import sys
sys.path.append('/flash/apps')
import hkylen
import unit
from m5stack import *
from m5ui import *
from time import sleep

#===== Declarations =====#
servo_0 = unit.get(unit.SERVO, unit.PORTC)


#===== User-Defined Functions =====#
def displayResult(objectID):
    if (objectID == 2):
        lbl.setColor(lcd.WHITE)
        rgb.setColorAll(lcd.WHITE)
        lbl.setText('Pass')
        servo_0_90_0()
    else:
        lbl.setColor(lcd.RED)
        rgb.setColorAll(lcd.RED)
        lbl.setText('Fail')

def servo_0_90_0():
    servo_0.write_angle(90)
    sleep (2)
    servo_0.write_angle(0)

#===== Main =====#
lcd.clear(lcd.BLACK)
lcd.font(lcd.FONT_DejaVu24)    
hkylen.setAlgorithm(hkylen.CLASSIFICATION)

while not (hkylen.isReady()):
    lcd.print('HuskyLens Not Ready!', 10, 0, lcd.CYAN)
    
lcd.clear(lcd.BLACK)
lcd.print('Object Classify Demo', 10, 0, lcd.CYAN)
lbl = M5TextBox(15, 90, '', lcd.FONT_DejaVu56, lcd.WHITE)

displayResult(0)
while True:
    hkylen.update()
    if hkylen.blockIsReady(2):
        displayResult(2)
    else:    
        displayResult(0)       
    sleep(2)

# data[].attributes.body
The wire connection is wrong in this image*

# data[].attributes.body
import sys

sys.path.append('/flash/apps')

import hkylen

import unit

from m5stack import *

from m5ui import *

from time import sleep

#===== Declarations =====#

servo_0 = unit.get(unit.SERVO, unit.PORTC)

#===== User-Defined Functions =====#

def displayResult(faceID):

if (faceID == 1):

lbl.setColor(lcd.RED)

rgb.setColorAll(lcd.RED)

lbl.setText('FACE ID: 1')

servo_0_90_0()

elif (faceID == 2):

lbl.setColor(lcd.GREEN)

rgb.setColorAll(lcd.GREEN)

lbl.setText('FACE ID: 2')

servo_0_90_0()

elif (faceID == 3):

lbl.setColor(lcd.BLUE)

rgb.setColorAll(lcd.BLUE)

lbl.setText('FACE ID: 3')

servo_0_90_0()

elif (faceID == 4):

lbl.setColor(lcd.YELLOW)

rgb.setColorAll(lcd.YELLOW)

lbl.setText('FACE ID: 4')

servo_0_90_0()

else:

lbl.setColor(lcd.WHITE)

rgb.setColorAll(lcd.BLACK)

lbl.setText('No Face ID')

def servo_0_90_0():

servo_0.write_angle(90)

sleep (2)

servo_0.write_angle(0)

#===== Main =====#

lcd.clear(lcd.BLACK)

lcd.font(lcd.FONT_DejaVu24)

servo_0.write_angle(0)

hkylen.setAlgorithm(hkylen.FACE_RECOGNITION)

while not (hkylen.isReady()):

lcd.print('Huskylens Not Ready!', 10, 0, lcd.CYAN)

lcd.clear(lcd.BLACK)

lcd.print('Face Security Demo', 10, 0, lcd.CYAN)

lbl = M5TextBox(15, 90, '', lcd.FONT_DejaVu56, lcd.WHITE)

displayResult(0)

while True:

hkylen.update()

if hkylen.blockIsReady(1):

displayResult(1)

elif hkylen.blockIsReady(2):

displayResult(2)

elif hkylen.blockIsReady(3):

displayResult(3)

elif hkylen.blockIsReady(4):

displayResult(4)

else:

displayResult(0)

sleep(2)