Skip to content

Commit ac6029d

Browse files
authored
Bug fixes
1 parent 25e353e commit ac6029d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/servo/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ def __init__(self,pin_id,min_us=544.0,max_us=2400.0,min_deg=0.0,max_deg=180.0,fr
77
self.pwm.freq(freq)
88
self.current_us = 0.0
99
self._slope = (min_us-max_us)/(math.radians(min_deg)-math.radians(max_deg))
10-
self._offset = math.radians(min_deg)
10+
self._offset = min_us
1111

1212
def write(self,deg):
1313
self.write_rad(math.radians(deg))
1414

15-
def read(sefl):
15+
def read(self):
1616
return math.degrees(self.read_rad())
1717

1818
def write_rad(self,rad):
19-
self.write_us((rad-self._offset)*self._slope)
19+
self.write_us(rad*self._slope+self._offset)
2020

2121
def read_rad(self):
22-
return (self.current_us/self._slope)+self._offset
22+
return (self.current_us-self._offset)/self._slope
2323

2424
def write_us(self,us):
2525
self.current_us=us

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy