Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SerialMultiByte QEI TFmini IRsensor
Diff: main.cpp
- Revision:
- 1:6ae7ff29d054
- Parent:
- 0:d789af71fbc6
diff -r d789af71fbc6 -r 6ae7ff29d054 main.cpp
--- a/main.cpp Mon Aug 26 08:44:58 2019 +0000
+++ b/main.cpp Thu Sep 05 16:15:26 2019 +0900
@@ -8,8 +8,8 @@
union UnionBytes{
uint8_t bytes[28];
float IRdistance[7]; //0~1
- uint32_t TFdistance[7]; //2~3
- uint32_t pulses[7]; //4~6
+ int32_t TFdistance[7]; //2~3
+ int32_t pulses[7]; //4~6
};
IRsensor ir[] = {
@@ -19,37 +19,47 @@
TFmini tf[] = {
TFmini(TF0_TX, TF0_RX),
- TFmini(TF1_TX, TF0_RX)
+ TFmini(TF1_TX, TF1_RX)
};
QEI loli[] = {
- QEI(encoder_0A, encoder_0B, NC, 100, QEI::X4_ENCODING),
QEI(encoder_1A, encoder_1B, NC, 100, QEI::X4_ENCODING),
- QEI(encoder_2A, encoder_2B, NC, 100, QEI::X4_ENCODING)
+ QEI(encoder_4A, encoder_4B, NC, 100, QEI::X4_ENCODING),
+ QEI(encoder_3A, encoder_3B, NC, 100, QEI::X4_ENCODING)
};
SerialMultiByte serial(mainTX, mainRX);
+Serial pc(USBTX, USBRX, 115200);
+
int main()
{
+ //pc.printf("hello\r\n");
UnionBytes bytedata;
+ uint8_t sendbytes[28];
for(int i=0; i<28; i++){
bytedata.bytes[i] = 0;
}
for(int i=0; i<2; i++){
ir[i].startAveraging(10);
}
- while (true) {
+ while (1) {
for(int i=0; i<2; i++){
bytedata.IRdistance[i] = ir[i].get_Averagingdistance();
+ pc.printf("%f ", bytedata.IRdistance[i]);
}
for(int i=0; i<2; i++){
- bytedata.TFdistance[i+2] = tf[i].getDistance();
+ bytedata.TFdistance[i+2] = (int32_t)tf[i].getDistance();
+ pc.printf("%d ", bytedata.TFdistance[i+2]);
}
for(int i=0; i<3; i++){
- bytedata.pulses[i+4] = loli[i].getPulses();
+ bytedata.pulses[i+4] = (int32_t)loli[i].getPulses();
+ pc.printf("%d ", bytedata.pulses[i+4]);
}
- serial.sendData(bytedata.bytes, 28);
+ for(int i=0; i<28; i++){
+ sendbytes[i] = bytedata.bytes[i];
+ }
+ serial.sendData(sendbytes, 28);
+ pc.printf("a\r\n");
}
}
-