git.haldean.org droidcopter / 04a37ac
Firmware finished (hypthetically) Will Brown 11 years ago
3 changed file(s) with 26 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
1919 };
2020
2121 struct motor motors[MOTOR_COUNT] = {
22 {6, 0, 0, NULL}, {9, 0, 0, NULL},
23 {10, 0, 0, NULL}, {11, 0, 0, NULL}
22 {6, 0, 0, SoftwareServo()}, {9, 0, 0, SoftwareServo()},
23 {10, 0, 0, SoftwareServo()}, {11, 0, 0, SoftwareServo()}
2424 };
2525
2626 char buffer[WORD_BUFFER_LENGTH];
2727 unsigned int led_cycles = 0;
28
2928
3029 /**
3130 * Updates the speeds of the motors.
99 import android.util.Log;
1010
1111 public class BluetoothOutput {
12 private static String btAddress = "00:06:66:04:B1:BE";
13 private BluetoothSocket btSocket;
14 private PrintStream outputStream;
12 private static String btAddress = "00:06:66:04:B1:BE";
13 private static UUID btUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
14
15 private BluetoothSocket btSocket;
16 private PrintStream outputStream;
1517
16 public BluetoothOutput() throws IOException {
17 Log.e("ChopperBluetooth", "Starting Bluetooth");
18 BluetoothDevice btDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(btAddress);
19 Log.e("ChopperBluetooth", "Device Acquired");
20 btSocket = btDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
21 Log.e("ChopperBluetooth", "Socket Created");
22 outputStream = new PrintStream(btSocket.getOutputStream());
23 Log.e("ChopperBluetooth", "Output Stream Created");
24 }
18 public BluetoothOutput() throws IOException {
19 Log.e("ChopperBluetooth", "Starting Bluetooth");
20 BluetoothDevice btDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(btAddress);
21 Log.e("ChopperBluetooth", "Device Acquired");
22 btSocket = btDevice.createRfcommSocketToServiceRecord(btUuid);
23 Log.e("ChopperBluetooth", "Socket Created");
24 btSocket.connect();
25 Log.e("ChopperBluetooth", "And we're connected!");
26 outputStream = new PrintStream(btSocket.getOutputStream());
27 Log.e("ChopperBluetooth", "Output Stream Created");
28 outputStream.print("Hello there, good sir");
29 Log.e("ChopperBluetooth", "Wrote string to output.");
30 setMotorSpeeds(1d, 1d, 1d, 1d);
31 }
2532
26 public void setMotorSpeeds(int m1, int m2, int m3, int m4) {
27 Log.e("ChopperBluetooth", "Writing " + m1 + " " + m2 + " " + m3 + " " + m4);
28 outputStream.print(m1 + " " + m2 + " " + m3 + " " + m4 + "\r");
29 }
33 public void setMotorSpeeds(double m1, double m2, double m3, double m4) {
34 String message = String.format("%03d%03d%03d%03d", m1, m2, m3, m4);
35 Log.e("ChopperBluetooth", "Writing " + message);
36 outputStream.print(message);
37 }
3038 }
+0
-1
text/.#essay-121220.tex less more
0 haldean@alux.2598:1292553063