diff options
Diffstat (limited to '')
-rw-r--r-- | System_Python/encoder.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/System_Python/encoder.py b/System_Python/encoder.py index 4069a86..8b7053c 100644 --- a/System_Python/encoder.py +++ b/System_Python/encoder.py @@ -58,15 +58,15 @@ class Encoder: # Pull CS high after finish reading GPIO.output(self.cs_pin,1) # Format with offset, Max is 1024 - data=(data+offset)%1024 + data=(data-self.offset)%1024 # Data is linearly mapped if format=="Raw": return data elif format=="Degrees": - degrees=data/(1024/360) + degrees=(data/1024.0)*360.0 return degrees elif format=="Radian": - radians=data/(1024/(2*math.pi)) + radians=(data/1024.0)*(2.0*math.pi) return radians else: print("ERROR. Invalid format (Raw, Degrees, Radians)") |