Skip to content

Add reset_motor_encoder #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2018
Merged
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
2 changes: 1 addition & 1 deletion Software/C/GoPiGo3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int GoPiGo3::get_version_hardware(char *str){
if(int error = spi_read_32(GPGSPI_MESSAGE_GET_HARDWARE_VERSION, value)){
return error;
}
sprintf(str, "%d.%d.%d", (value / 1000000), ((value / 1000) % 1000), (value % 1000));
sprintf(str, "%d.x.x", (value / 1000000));
}

int GoPiGo3::get_version_firmware(char *str){
Expand Down
6 changes: 3 additions & 3 deletions Software/C/GoPiGo3.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#ifndef GoPiGo3_h_
#define GoPiGo3_h_

#define FIRMWARE_VERSION_REQUIRED "0.3." // Firmware version needs to start with this
#define FIRMWARE_VERSION_REQUIRED "1.0." // Firmware version needs to start with this

#define LONGEST_I2C_TRANSFER 16 // longest possible I2C read/write
#define LONGEST_SPI_TRANSFER 24 // spi_read_string 20 chars (LONGEST_I2C_TRANSFER + 6) // longest possible message for configuring for an I2C sensor
#define LONGEST_I2C_TRANSFER 32 // longest possible I2C read/write
#define LONGEST_SPI_TRANSFER (LONGEST_I2C_TRANSFER + 6) // at least 24 for spi_read_string 20 chars, and at least LONGEST_I2C_TRANSFER + 6 for I2C transactions

#define SPI_TARGET_SPEED 500000 // SPI target speed of 500kbps

Expand Down
13 changes: 13 additions & 0 deletions Software/Python/gopigo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,19 @@ def offset_motor_encoder(self, port, offset):
((offset >> 24) & 0xFF), ((offset >> 16) & 0xFF), ((offset >> 8) & 0xFF), (offset & 0xFF)]
self.spi_transfer_array(outArray)

def reset_motor_encoder(self, port):
"""
Reset a motor encoder to 0

Keyword arguments:
port -- The motor port(s). MOTOR_LEFT and/or MOTOR_RIGHT.
"""
if port & self.MOTOR_LEFT:
self.offset_motor_encoder(self.MOTOR_LEFT, self.get_motor_encoder(self.MOTOR_LEFT))

if port & self.MOTOR_RIGHT:
self.offset_motor_encoder(self.MOTOR_RIGHT, self.get_motor_encoder(self.MOTOR_RIGHT))

def set_grove_type(self, port, type):
"""
Set grove type
Expand Down