Feedback: Correct Fixed Point conversion & take mod of angle send value

This commit is contained in:
Zachy committed 2019-05-17 21:31:33 +01:00
1 parent a60b513e74
commit 0b127da0ca
3 files changed
+9 -8

No files matched your search

+3 -2
View File
@@ -122,12 +122,13 @@ class Angle(Type):
@staticmethod
def read(file_object):
# Linearly transform angle in steps of 1/256 into steps of 1/360
return 360 * UnsignedByte.read(file_object) / 255
return 360 * UnsignedByte.read(file_object) / 256
@staticmethod
def send(value, socket):
# Normalize angle between 0 and 255 and convert to int.
UnsignedByte.send(round(255 * (value / 360)), socket)
UnsignedByte.send(round(256 * ((value % 360) / 360)), socket)
class VarInt(Type):