From 6716c9ffb0db801223e17e94dc99fdb297e728cf Mon Sep 17 00:00:00 2001 From: Anton Tetov <anton@tetov.se> Date: Sun, 12 Jun 2022 13:00:54 +0200 Subject: [PATCH] replace gripper functions with ones using farmbot_os --- src/gripper.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/gripper.py b/src/gripper.py index d53b714..845315d 100755 --- a/src/gripper.py +++ b/src/gripper.py @@ -1,11 +1,21 @@ -#!/usr/bin/env python3 -import serial +"""Functions to manipulate gripper. + +TODO: Integrate with FarmbotClient or FarmbotYoloClient +""" +from client import FarmbotClient +from creds import device_id +from creds import token + + def gripper_open(): - ser = serial.Serial('/dev/ttyUSB0') - ser.write(str.encode("o")) - ser.close + """Manipulate gripper by setting pin to 1.""" + client = FarmbotClient(device_id, token) + client.write_pin(1, 1, pin_mode="digital") + client.shutdown() + def gripper_close(): - ser = serial.Serial('/dev/ttyUSB0') - ser.write(str.encode("c")) - ser.close \ No newline at end of file + """Manipulate gripper by setting pin to 0.""" + client = FarmbotClient(device_id, token) + client.write_pin(1, 1, pin_mode="digital") + client.shutdown() -- GitLab