Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Committer:
shimniok
Date:
Wed Jun 20 14:57:48 2012 +0000
Revision:
0:826c6171fc1b
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:826c6171fc1b 1 #include "mbed.h"
shimniok 0:826c6171fc1b 2 #include "Camera.h"
shimniok 0:826c6171fc1b 3
shimniok 0:826c6171fc1b 4 Camera::Camera(PinName tx, PinName rx):
shimniok 0:826c6171fc1b 5 serial(tx, rx)
shimniok 0:826c6171fc1b 6 {
shimniok 0:826c6171fc1b 7 serial.baud(115200);
shimniok 0:826c6171fc1b 8
shimniok 0:826c6171fc1b 9 return;
shimniok 0:826c6171fc1b 10 }
shimniok 0:826c6171fc1b 11
shimniok 0:826c6171fc1b 12 void Camera::start()
shimniok 0:826c6171fc1b 13 {
shimniok 0:826c6171fc1b 14 serial.attach(this, &Camera::receive, Serial::RxIrq);
shimniok 0:826c6171fc1b 15
shimniok 0:826c6171fc1b 16 // ping
shimniok 0:826c6171fc1b 17 // should now get ACK\r or NACK\r
shimniok 0:826c6171fc1b 18 // send colormap here
shimniok 0:826c6171fc1b 19 // should now get ACK\r or NACK\r
shimniok 0:826c6171fc1b 20 // disable white balance
shimniok 0:826c6171fc1b 21 // should now get ACK\r or NACK\r
shimniok 0:826c6171fc1b 22 serial.printf("ET\r\n");
shimniok 0:826c6171fc1b 23 // should now get ACK\r or NACK\r
shimniok 0:826c6171fc1b 24 return;
shimniok 0:826c6171fc1b 25 }
shimniok 0:826c6171fc1b 26
shimniok 0:826c6171fc1b 27
shimniok 0:826c6171fc1b 28 void Camera::receive()
shimniok 0:826c6171fc1b 29 {
shimniok 0:826c6171fc1b 30 while (serial.readable()) {
shimniok 0:826c6171fc1b 31 char c = serial.getc();
shimniok 0:826c6171fc1b 32 fprintf(stdout, "%c\n", c);
shimniok 0:826c6171fc1b 33 }
shimniok 0:826c6171fc1b 34 return;
shimniok 0:826c6171fc1b 35 }
shimniok 0:826c6171fc1b 36
shimniok 0:826c6171fc1b 37
shimniok 0:826c6171fc1b 38 /*
shimniok 0:826c6171fc1b 39 * (Byte 0: 0x0A – Indicating the start of a tracking packet
shimniok 0:826c6171fc1b 40 * Byte 1: Number of trac k ed objects (0x00 – 0x08 are valid)
shimniok 0:826c6171fc1b 41 * Byte 2: Color of object tracked in bounding box 1
shimniok 0:826c6171fc1b 42 * Byte 3: X upper left corner of bounding box 1
shimniok 0:826c6171fc1b 43 * Byte 4: Y upper left corner of bouding box 1
shimniok 0:826c6171fc1b 44 * Byte 5: X lower right corner of boudning box 1
shimniok 0:826c6171fc1b 45 * Byte 6: Y lower right corner of boudning box 1
shimniok 0:826c6171fc1b 46 * Byte 7: Color object tracked in bound box 2
shimniok 0:826c6171fc1b 47 * ...
shimniok 0:826c6171fc1b 48 * Byte x: 0xFF (indicates the end of line, and will be sent after all tracking info
shimniok 0:826c6171fc1b 49 * for the current frame has been sent)
shimniok 0:826c6171fc1b 50 */
shimniok 0:826c6171fc1b 51 void Camera::parse(char c)
shimniok 0:826c6171fc1b 52 {
shimniok 0:826c6171fc1b 53
shimniok 0:826c6171fc1b 54 return;
shimniok 0:826c6171fc1b 55 }
shimniok 0:826c6171fc1b 56