Commits

Alex Hixon  committed ed3fd90

Added simulate mode, make sure GUI sends between 0 and 180 deg.

  • Participants
  • Parent commits 273976f

Comments (0)

Files changed (1)

 SMOOTHING = True
 
 COM_PORT = "/dev/ttyUSB0"
+SIMULATE = True
 
 class Interface ():
     def __init__ (self, resolution, colors, aspect=45, title="flymote"):
         self.pitchroll = [0.0, 0.0]         # smoothed pitch and roll
         self.pitchroll_a = [0.0, 0.0]       # absolute (unsmoothed) pitch and roll values
         self.alpha = 0.07                   # smoothing constant
-        
-        print "Connecting to USB..."
-        self.wireless = wireless.WirelessConnection (COM_PORT)
-        print "Connected!"
+
+        if not SIMULATE:
+            print "Connecting to USB..."
+            self.wireless = wireless.WirelessConnection (COM_PORT)
+            print "Connected!"
         
         glutInit()
         
             self.cube.axes[0] = self.pitchroll[0] * PITCH_FACTOR
             self.cube.axes[1] = yaw * YAW_FACTOR
             self.cube.axes[2] = self.pitchroll[1] * ROLL_FACTOR
-            
-            # and send that stuff to the controller
-            self.wireless.send ((wireless.MessageType.MOVE_ELEVATOR, 180 - self.cube.axes[0]))
-            self.wireless.send ((wireless.MessageType.MOVE_RUDDER, 180 - self.cube.axes[2]))
+
+            if not SIMULATE:
+                # and send that stuff to the controller
+                elevator_deg = (self.cube.axes[0] + 360) / 4
+                self.wireless.send ((wireless.MessageType.MOVE_ELEVATOR, elevator_deg)
+                rudder_deg = (self/cube.axes[2] + 360) / 4
+                self.wireless.send ((wireless.MessageType.MOVE_RUDDER, rudder_deg)
         else:
             pass
             # FIXME: send noop polls to the controller every x seconds