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
9 changes: 5 additions & 4 deletions picar/SunFounder_PCA9685/PCA9685.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _debug_(self,message):

def setup(self):
'''Init the class with bus_number and address'''
self._debug_('Reseting PCA9685 MODE1 (without SLEEP) and MODE2')
self._debug_('Resetting PCA9685 MODE1 (without SLEEP) and MODE2')
self.write_all_value(0, 0)
self._write_byte_data(self._MODE2, self._OUTDRV)
self._write_byte_data(self._MODE1, self._ALLCALL)
Expand Down Expand Up @@ -119,14 +119,14 @@ def _check_i2c(self):
for address in tmp_addresses:
if address != '--':
addresses.append(address)
print("Conneceted i2c device:")
print("Connected i2c device:")
if addresses == []:
print("None")
else:
for address in addresses:
print(" 0x%s" % address)
if "%02X" % self.address in addresses:
print("Wierd, I2C device is connected, Try to run the program again, If problem stills, email this information to support@sunfounder.com")
print("Weird, I2C device is connected, Try to run the program again, If problem persists, email this information to support@sunfounder.com")
else:
print("Device is missing.")
print("Check the address or wiring of PCA9685 Server driver, or email this information to support@sunfounder.com")
Expand Down Expand Up @@ -176,7 +176,8 @@ def write_all_value(self, on, off):

def map(self, x, in_min, in_max, out_min, out_max):
'''To map the value from arange to another'''
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
# need to map to int to avoid returning float with Python3 division operator
return int((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)

@property
def debug(self):
Expand Down
2 changes: 1 addition & 1 deletion picar/SunFounder_PCA9685/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SunFounder is a technology company focused on Raspberry Pi and Arduino open sour
This is the code for SunFounder PCA9685.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied wa rranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Expand Down