Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openUC2/UC2-REST
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.0.25
Choose a base ref
...
head repository: openUC2/UC2-REST
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Apr 22, 2025

  1. cleanup, removing config

    beniroquai committed Apr 22, 2025
    Copy the full SHA
    1b1ddac View commit details
  2. fixing typo

    beniroquai committed Apr 22, 2025
    Copy the full SHA
    3e71951 View commit details
  3. Update UC2Client.py

    beniroquai committed Apr 22, 2025
    Copy the full SHA
    605940b View commit details
  4. Merge pull request #107 from openUC2/mergemaster

    Mergemaster
    beniroquai authored Apr 22, 2025
    Copy the full SHA
    a7a5cb2 View commit details

Commits on Apr 25, 2025

  1. Copy the full SHA
    a1cd02d View commit details

Commits on May 6, 2025

  1. Copy the full SHA
    5311053 View commit details
  2. Merge pull request #108 from openUC2/mergemaster

    Mergemaster
    beniroquai authored May 6, 2025
    Copy the full SHA
    26c5a63 View commit details

Commits on May 15, 2025

  1. adding cam module

    beniroquai committed May 15, 2025
    Copy the full SHA
    d2e3813 View commit details
  2. Merge pull request #109 from openUC2/mergemaster

    adding cam module
    beniroquai authored May 15, 2025
    Copy the full SHA
    bd7c372 View commit details

Commits on May 16, 2025

  1. fixing can interface

    beniroquai committed May 16, 2025
    Copy the full SHA
    5358e02 View commit details
  2. Merge pull request #110 from openUC2/mergemaster

    fixing can interface
    beniroquai authored May 16, 2025
    Copy the full SHA
    29df52e View commit details

Commits on May 19, 2025

  1. Copy the full SHA
    784582e View commit details
  2. Merge pull request #111 from openUC2/mergemaster

    running motor only when necessary
    beniroquai authored May 19, 2025
    Copy the full SHA
    0691cd6 View commit details
  3. fixing typo

    beniroquai committed May 19, 2025
    Copy the full SHA
    0c7ad90 View commit details
  4. fixing typo

    beniroquai committed May 19, 2025
    Copy the full SHA
    21092a3 View commit details
  5. Merge pull request #112 from openUC2/mergemaster

    fixing typo
    beniroquai authored May 19, 2025
    Copy the full SHA
    9cfb940 View commit details

Commits on May 25, 2025

  1. Copy the full SHA
    82e3520 View commit details
  2. Merge pull request #113 from openUC2/mergemaster

    adding stage scanning to motor
    beniroquai authored May 25, 2025
    Copy the full SHA
    9a17c45 View commit details
  3. minor fix in motor return

    beniroquai committed May 25, 2025
    Copy the full SHA
    29dc1e8 View commit details
  4. Merge remote-tracking branch 'origin/master'

    merge motor return
    beniroquai committed May 25, 2025
    Copy the full SHA
    e70451e View commit details

Commits on May 26, 2025

  1. Update motor.py

    beniroquai committed May 26, 2025
    Copy the full SHA
    221d46e View commit details
  2. Merge pull request #114 from openUC2/mergemaster

    Update motor.py
    beniroquai authored May 26, 2025
    Copy the full SHA
    4b906fb View commit details

Commits on May 28, 2025

  1. Copy the full SHA
    d91648b View commit details

Commits on May 30, 2025

  1. changing default values

    beniroquai committed May 30, 2025
    Copy the full SHA
    bad9867 View commit details

Commits on May 31, 2025

  1. adding focusscanning

    beniroquai committed May 31, 2025
    Copy the full SHA
    e4f936f View commit details
  2. Merge pull request #115 from openUC2/mergemaster

    adding focusscanning
    beniroquai authored May 31, 2025
    Copy the full SHA
    9e96afa View commit details

Commits on Jun 22, 2025

  1. Copy the full SHA
    e96890d View commit details
  2. Merge pull request #116 from openUC2/mergemaster

    fixing issue with current position
    beniroquai authored Jun 22, 2025
    Copy the full SHA
    1622f6b View commit details

Commits on Jul 8, 2025

  1. Copy the full SHA
    e819ddb View commit details
  2. quick fix

    beniroquai committed Jul 8, 2025
    Copy the full SHA
    ca2a5a2 View commit details
341 changes: 341 additions & 0 deletions DOCUMENTATION/2025_05_01_UC2_Example_DPC.ipynb

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions uc2rest/TEST/TEST_ESP32_LCD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#%%
import uc2rest
import numpy as np
import time

port = "unknown"
port = "/dev/cu.usbmodem101"

ESP32 = uc2rest.UC2Client(serialport=port, baudrate=115200, DEBUG=True, skipFirmwareCheck=False)
#ESP32.serial.sendMessage('{"task":"/home_act", "home": {"steppers": [{"stepperid":1, "timeout": 20000, "speed": 15000, "direction":1, "endposrelease":3000}]}}')

ESP_PANEL_LCD_H_RES = 800
ESP_PANEL_LCD_V_RES = 480


''' TEST LCD '''

# Create LedMatrix object, pass a reference to your “parent” that has post_json()
my_lcd = ESP32.lcd

my_lcd.set_timeout(.5)


for i in range(ESP_PANEL_LCD_H_RES//2):
# Turn off all LEDs
my_lcd.set_grating(i, r=255, g=255, b=255, horizontal=True)
#time.sleep(0.1)

for i in range(ESP_PANEL_LCD_V_RES//2):
# Turn off all LEDs
my_lcd.set_grating(i, r=255, g=255, b=255, horizontal=False)
#time.sleep(0.1)


# blacnk screen
my_lcd.clear(r=0, g=0, b=0)
my_lcd.set_color(r=255, g=255, b=255)

# have line moving vertically
dThickness = 10
for i in range(0, ESP_PANEL_LCD_H_RES, dThickness):
#
# {"task":"/lcd_act","action":"hline","x":0,"y":10,"len":800,"width":1,"r":255,"g":255,"b":0}
# {"task": "/lcd_act", "action": "vline", "x": 0, "y": 54, "len": 480, "width": 1, "r": 255, "g": 255, "b": 255, "qid": 156}
my_lcd.hline(0, i, ESP_PANEL_LCD_H_RES, width=dThickness)
#time.sleep(0.1)
my_lcd.clear(r=0, g=0, b=0)
for i in range(0, ESP_PANEL_LCD_V_RES, dThickness):
# Turn off all LEDs
my_lcd.vline(i, 0, ESP_PANEL_LCD_V_RES, width=dThickness)
#time.sleep(0.1)

71 changes: 46 additions & 25 deletions uc2rest/TEST/TEST_ESP32_LEDarray.py
Original file line number Diff line number Diff line change
@@ -4,33 +4,54 @@
import time

port = "unknown"
port = "/dev/cu.SLAB_USBtoUART"
ESP32 = uc2rest.UC2Client(serialport=port, baudrate=500000, DEBUG=True)
time.sleep(2)
#ESP32.serial.sendMessage('{"task":"/home_act", "home": {"steppers": [{"stepperid":1, "timeout": 20000, "speed": 15000, "direction":1, "endposrelease":3000}]}}')
# display random pattern
for i in range(10):
led_pattern = np.random.randint(0,55, (64,3))
ESP32.led.send_LEDMatrix_array(led_pattern=led_pattern, getReturn=True, timeout=4)

#
''' ################
LED
################'''
# test LED
ESP32.led.send_LEDMatrix_full(intensity=(255, 255, 255))
ESP32.led.send_LEDMatrix_full(intensity=(0, 0, 0))

# single LED
for iLED in range(5):
port = "/dev/cu.usbmodem101"
ESP32 = uc2rest.UC2Client(serialport=port, baudrate=115200, DEBUG=False, skipFirmwareCheck=True)

''' TEST LED '''

# Create LedMatrix object, pass a reference to your “parent” that has post_json()
my_led_matrix = ESP32.led



for i in range(1):
# Turn off all LEDs
my_led_matrix.send_LEDMatrix_off()
time.sleep(0.1)
# Fill entire matrix with red
my_led_matrix.send_LEDMatrix_full((255,0,0), getReturn=False)
time.sleep(0.1)



# Light only left half in bright white
mDirections = ["left", "right", "top", "bottom"]
for iDirection in mDirections:
my_led_matrix.send_LEDMatrix_halves(region=iDirection, intensity=(255,255,255), getReturn=False)
time.sleep(0.1)

# Draw a ring of radius 3 in purple
my_led_matrix.send_LEDMatrix_rings(radius=3, intensity=(128,0,128))

# Draw a filled circle of radius 5 in green
my_led_matrix.send_LEDMatrix_circles(radius=3, intensity=(0,255,0))




for iLED in range(64):
# timeout = 0 means no timeout => mResult will be rubish!
mResult = ESP32.led.send_LEDMatrix_single(indexled=iLED, intensity=(255, 255, 255))#, timeout=0.)
mResult = ESP32.led.send_LEDMatrix_single(indexled=iLED, intensity=(0, 0, 0))#, timeout=0.)
mResult = ESP32.led.send_LEDMatrix_single(indexled=iLED, intensity=(255, 255, 255), getReturn=0, timeout=0.1)
mResult = ESP32.led.send_LEDMatrix_single(indexled=iLED, intensity=(0, 0, 0), getReturn=0, timeout=0.1)

# display random pattern
for i in range(50):
led_pattern = np.random.randint(0,55, (48,3))
ESP32.led.send_LEDMatrix_array(led_pattern=led_pattern, getReturn=False)
for i in range(5):
led_pattern = np.random.randint(0,55, (25,3))
mResult = ESP32.led.send_LEDMatrix_array(led_pattern=led_pattern,getReturn=0,timeout=0)


ESP32.close()

# {"task":"/ledarr_act", "led":{"LEDArrMode":1, "led_array":[{"id":0, "r":255, "g":255, "b":255}]}}
mResult = ESP32.led.send_LEDMatrix_full(intensity=(255, 255, 255))
time.sleep(.1)
mResult = ESP32.led.send_LEDMatrix_full(intensity=(0, 0, 0), getReturn=False)
17 changes: 9 additions & 8 deletions uc2rest/TEST/TEST_ESP32_Serial.py
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
import time

port = "unknown"
port = "/dev/cu.SLAB_USBtoUART"
#port = "/dev/cu.SLAB_USBtoUART"
#port = "COM3"
port = "/dev/cu.usbmodem11101"
port = "/dev/cu.usbmodem101"
print("start")
ESP32 = uc2rest.UC2Client(serialport=port, baudrate=115200, DEBUG=True, skipFirmwareCheck=True)
#ESP32.serial.sendMessage('{"task":"/home_act", "home": {"steppers": [{"stepperid":1, "timeout": 20000, "speed": 15000, "direction":1, "endposrelease":3000}]}}')
@@ -18,12 +18,13 @@
# Create LedMatrix object, pass a reference to your “parent” that has post_json()
my_led_matrix = ESP32.led

# Turn off all LEDs
my_led_matrix.send_LEDMatrix_off()

# Fill entire matrix with red
my_led_matrix.send_LEDMatrix_full((255,0,0))

for i in range(5):
# Turn off all LEDs
my_led_matrix.send_LEDMatrix_off()
time.sleep(0.1)
# Fill entire matrix with red
my_led_matrix.send_LEDMatrix_full((255,0,0))
time.sleep(0.1)
# Light only left half in bright white
my_led_matrix.send_LEDMatrix_halves(region="left", intensity=(255,255,255))

37 changes: 14 additions & 23 deletions uc2rest/UC2Client.py
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
from .mserial import Serial
from .mserial import SerialManagerWrapper
from .galvo import Galvo
from .config import config
from .ledmatrix import LedMatrix
from .lcddisplay import LCDDisplay
from .motor import Motor
from .gripper import Gripper
from .home import Home
@@ -26,6 +26,7 @@
from .cmdrecorder import cmdRecorder
from .temperature import Temperature
from .message import Message
from .can import CAN
try:
import requests
except:
@@ -39,11 +40,11 @@ class UC2Client(object):

is_wifi = False
is_serial = False
BAUDRATE = 115200

# BAUDRATE = 500000
BAUDRATE = 500000

def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather", baudrate=BAUDRATE, NLeds=64, SerialManager=None, DEBUG=False, logger=None, skipFirmwareCheck=False):
def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather", baudrate=BAUDRATE,
NLeds=64, SerialManager=None, DEBUG=False, logger=None, skipFirmwareCheck=False,
isPyScript=False):
'''
This client connects to the UC2-REST microcontroller that can be found here
https://github.com/openUC2/UC2-REST
@@ -55,13 +56,13 @@ def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather
you can send commands through wifi/http or usb/serial
'''
if logger is None:
if True: #logger is None:
self.logger = Logger()
else:
self.logger = logger

# perhaps we are in the browser?
self.isPyScript = False
self.isPyScript = isPyScript

# initialize communication channel (# connect to wifi or usb)
if serialport is not None:
@@ -90,27 +91,24 @@ def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather
# import libraries depending on API version
self.logger.debug("Using API version 2")

#FIXME
#self.set_state(debug=False)

# initialize state
self.state = State(self)
if not self.isPyScript:
state = self.state.get_state()

# initialize config
if not self.isPyScript:
self.config = config(self)

# initialize cmdRecorder
self.cmdRecorder = cmdRecorder(self)

# initialize LED matrix
self.led = LedMatrix(self, NLeds=NLeds)

# initialize LCD display
self.lcd = LCDDisplay(self)

# initilize motor
self.motor = Motor(self)

# initialize CAN
self.can = CAN(self)

# initialize gripper
self.gripper = Gripper(self)

@@ -149,13 +147,6 @@ def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather

# initialize messaging
self.message = Message(self)

# initialize config
if False: # not self.isPyScript:
self.config = config(self)
try: self.pinConfig = self.config.loadConfigDevice()
except: self.pinConfig = None


# initialize module controller
self.modules = Modules(parent=self)
1 change: 0 additions & 1 deletion uc2rest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .config import *
from .UC2Client import *
33 changes: 33 additions & 0 deletions uc2rest/can.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class CAN(object):
def __init__(self, parent):
"""
CANController handles sending commands to a remote CAN device via the parent post_json interface.
:param parent: Parent object with post_json(path, payload, getReturn, timeout, nResponses)
"""
self._parent = parent

def reboot_remote(self, qid=1, can_address=0, isBlocking=False, timeout=2):
"""
Send a reboot signal to the remote CAN device.
:param qid: Query ID for the CAN command (default: 1)
:param isBlocking: If True, wait for response
:param timeout: Timeout for the command in seconds
:param can_address: Address of the CAN device to reboot (0 is master)
:return: Response from the device
"""
path = "/can_act"
payload = {
"task": path,
"restart": int(can_address)
}
nResponses = 1 if isBlocking else 0
# Send the payload to the parent, which handles the actual communication
return self._parent.post_json(
path,
payload,
getReturn=isBlocking,
timeout=timeout if isBlocking else 0,
nResponses=nResponses
)
Loading