Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**.DS_Store
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ Either `[block1, block2, ..., blockN]` or `[arrow1, arrow2, ..., arrowN]`
> "ALGORITHM_OBJECT_CLASSIFICATION"
> ```
>
> **Return:**
> "Knock Received" on success
> As of firmware 0.5.1b, no return value is sent.

#### learn(id)
> **Description:**
Expand All @@ -227,15 +226,13 @@ Either `[block1, block2, ..., blockN]` or `[arrow1, arrow2, ..., arrowN]`
> **Arguments:**
> - id: (`int`) The desired ID of the object (1 - 1023 range).
>
> **Return:**
> "Knock Received" on success
> As of firmware 0.5.1b, no return value is sent.

#### forget()
> **Description:**
> Forget learned objects for the current running algorithm.
>
> **Return:**
> "Knock Received" on success
> As of firmware 0.5.1b, no return value is sent.

## UI Related Functions
#### setCustomName(name, id)
Expand All @@ -246,8 +243,7 @@ Either `[block1, block2, ..., blockN]` or `[arrow1, arrow2, ..., arrowN]`
> - name: (`str`) value for the desired name.
> - id: (`int`) the object ID you wish to change.
>
> **Return:**
> "Knock Received" on success
> As of firmware 0.5.1b, no return value is sent.

#### customText(name, x, y)
> **Description:**
Expand All @@ -260,15 +256,13 @@ Either `[block1, block2, ..., blockN]` or `[arrow1, arrow2, ..., arrowN]`
> - x: (`int`) x coordinate of the top left corner of the text
> - y: (`int`) y coordinate of the top left corner of the text
>
> **Return:**
> "Knock Received" on success
> As of firmware 0.5.1b, no return value is sent.

#### clearText()
> **Description:**
> Clear and remove all custom UI texts from the screen.
>
> **Return:**
> "Knock Received" on success
> As of firmware 0.5.1b, no return value is sent.

## Utility Functions
#### saveModelToSDCard(idVal)
Expand Down
28 changes: 21 additions & 7 deletions circuitPyHuskyLib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HUSKYLENS CircuitPython Library
# 09 JUN 2023
# 08 OCT 2025
#
# Credit:
# Code base (reference) for Raspberry Pi:
Expand All @@ -8,6 +8,8 @@
# Code base (reference) for Raspberry Pi Pico (MicroPython):
# https://community.dfrobot.com/makelog-310469.html
#
# OCT 2025 - Updated by Brogan M. Pratt for HuskyLens Firmware v0.5.1b
#
# You need to include these libraries in your CIRCUITPY/lib folder. You can download it from https://circuitpython.org/libraries
# - adafruit_bus_device
#
Expand All @@ -29,6 +31,7 @@
import binascii
import busio
import adafruit_bus_device.i2c_device as i2c_device
from time import sleep

commandHeaderAndAddress = "55AA11"
algorthimsByteID = {
Expand Down Expand Up @@ -146,6 +149,10 @@ def processReturnData(self, numIdLearnFlag=False, frameFlag=False):
with self.huskylensSer:
self.huskylensSer.readinto(byteString, start=5, end=len(byteString))

# TODO: remove debug line
#print("RAW RESPONSE:", ''.join(['%02x' % b for b in byteString]))


# Convert byteString to hex first before splitCommandToParts
commandSplit = self.splitCommandToParts(''.join(['%02x' % b for b in byteString]))
if(commandSplit[3] == "2e"):
Expand Down Expand Up @@ -205,6 +212,7 @@ def convert_to_class_object(self,data,isBlock):
def knock(self):
cmd = self.cmdToBytes(commandHeaderAndAddress+"002c3c")
self.writeToHuskyLens(cmd)
sleep(0.1)
return self.processReturnData()

def learn(self, id):
Expand All @@ -220,12 +228,14 @@ def learn(self, id):
cmd += self.calculateChecksum(cmd)
cmd = self.cmdToBytes(cmd)
self.writeToHuskyLens(cmd)
return self.processReturnData()
sleep(0.1)
return # depreciated on firmware > 0.5.1, no return self.processReturnData()

def forget(self):
cmd = self.cmdToBytes(commandHeaderAndAddress+"003747")
self.writeToHuskyLens(cmd)
return self.processReturnData()
sleep(0.1)
return # depreciated on firmware > 0.5.1, no return self.processReturnData()

def setCustomName(self, name, id):
localId = "{:02x}".format(id)
Expand All @@ -243,7 +253,9 @@ def setCustomName(self, name, id):
cmd += self.calculateChecksum(cmd)
cmd = self.cmdToBytes(cmd)
self.writeToHuskyLens(cmd)
return self.processReturnData()
sleep(0.1)
# add a small 0.1s sleep here if renaming multiple tags in quick succession
return # depreciated on firmware > 0.5.1, no return self.processReturnData()

def customText(self, name, x, y):
name_=""
Expand All @@ -268,12 +280,13 @@ def customText(self, name, x, y):
cmd += self.calculateChecksum(cmd)
cmd = self.cmdToBytes(cmd)
self.writeToHuskyLens(cmd)
return self.processReturnData()
sleep(0.1)
return # depreciated on firmware > 0.5.1, no return self.processReturnData()

def clearText(self):
cmd = self.cmdToBytes(commandHeaderAndAddress+"003545")
self.writeToHuskyLens(cmd)
return self.processReturnData()
return # depreciated on firmware > 0.5.1, no return self.processReturnData()

def requestAll(self):
cmd = self.cmdToBytes(commandHeaderAndAddress+"002030")
Expand Down Expand Up @@ -368,7 +381,8 @@ def algorithm(self, alg):
cmd += self.calculateChecksum(cmd)
cmd = self.cmdToBytes(cmd)
self.writeToHuskyLens(cmd)
return self.processReturnData()
sleep(0.1)
return # depreciated on firmware > 0.5.1, no return self.processReturnData()
else:
print("INCORRECT ALGORITHIM NAME")

Expand Down