Skip to content

Commit d5d66b5

Browse files
author
Matthew Richardson
authored
Merge pull request #161 from mattallen37/master
Add reset_motor_encoder
2 parents 05165bc + eeddd8f commit d5d66b5

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Software/C/GoPiGo3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int GoPiGo3::get_version_hardware(char *str){
163163
if(int error = spi_read_32(GPGSPI_MESSAGE_GET_HARDWARE_VERSION, value)){
164164
return error;
165165
}
166-
sprintf(str, "%d.%d.%d", (value / 1000000), ((value / 1000) % 1000), (value % 1000));
166+
sprintf(str, "%d.x.x", (value / 1000000));
167167
}
168168

169169
int GoPiGo3::get_version_firmware(char *str){

Software/C/GoPiGo3.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#ifndef GoPiGo3_h_
1313
#define GoPiGo3_h_
1414

15-
#define FIRMWARE_VERSION_REQUIRED "0.3." // Firmware version needs to start with this
15+
#define FIRMWARE_VERSION_REQUIRED "1.0." // Firmware version needs to start with this
1616

17-
#define LONGEST_I2C_TRANSFER 16 // longest possible I2C read/write
18-
#define LONGEST_SPI_TRANSFER 24 // spi_read_string 20 chars (LONGEST_I2C_TRANSFER + 6) // longest possible message for configuring for an I2C sensor
17+
#define LONGEST_I2C_TRANSFER 32 // longest possible I2C read/write
18+
#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
1919

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

Software/Python/gopigo3.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,19 @@ def offset_motor_encoder(self, port, offset):
583583
((offset >> 24) & 0xFF), ((offset >> 16) & 0xFF), ((offset >> 8) & 0xFF), (offset & 0xFF)]
584584
self.spi_transfer_array(outArray)
585585

586+
def reset_motor_encoder(self, port):
587+
"""
588+
Reset a motor encoder to 0
589+
590+
Keyword arguments:
591+
port -- The motor port(s). MOTOR_LEFT and/or MOTOR_RIGHT.
592+
"""
593+
if port & self.MOTOR_LEFT:
594+
self.offset_motor_encoder(self.MOTOR_LEFT, self.get_motor_encoder(self.MOTOR_LEFT))
595+
596+
if port & self.MOTOR_RIGHT:
597+
self.offset_motor_encoder(self.MOTOR_RIGHT, self.get_motor_encoder(self.MOTOR_RIGHT))
598+
586599
def set_grove_type(self, port, type):
587600
"""
588601
Set grove type

0 commit comments

Comments
 (0)