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: XYZ_sensor_Platform_SPI mbed
Diff: ui.cpp
- Branch:
- envelope
- Revision:
- 10:a49cdab3810f
- Parent:
- 9:c4f7257dee47
- Child:
- 11:bb86ffb378f4
--- a/ui.cpp Tue Dec 12 09:37:33 2017 +0000 +++ b/ui.cpp Fri Jan 05 06:52:00 2018 +0000 @@ -6,7 +6,7 @@ #define I2C_FREQUENCY 400000 typedef unsigned char byte; -uint8_t** dataToSend; +uint8_t* dataToSend; int sendArrayIndex = 0; int sendBufferMax = 10000; const int BAUD = 921600; @@ -42,7 +42,6 @@ int main() { - dataToSend = new uint8_t*[sendBufferMax]; led=1; command = new Envelope; command->enableHeader(std::string("H"));// 48 H @@ -69,11 +68,6 @@ isRecording = false; echo('S',0,0,0); }// end recording if - if(!isRecording && n != 0) { - n = 0; - for(int i = 0; i < sendBufferMax; i++) - if(dataToSend[i]) delete dataToSend[i]; - } if(getMag>0) { int16_t mag[3]; if(platform.get_mag_raw(mag)==0) echo('M',mag); @@ -127,11 +121,10 @@ { char tmp[] = {typ, p_data[0]>>8, p_data[0], p_data[1]>>8, p_data[1], p_data[2]>>8, p_data[2]}; command->setEnvelopeData(tmp,7); - dataToSend[sendArrayIndex] = (uint8_t*)(command->getEnvelopeArray()); + dataToSend = (uint8_t*)(command->getEnvelopeArray()); for(int i = 0; i < command->length(); i++) { - pc.putc(dataToSend[sendArrayIndex][i]); + pc.putc(dataToSend[i]); } - sendArrayIndex = (sendArrayIndex+1)%sendBufferMax; } void Rx_interrupt() @@ -164,7 +157,7 @@ break; case 'Y': if(dataArray[1]&0x80) forwardCount++; - else forwardCount++; + else backwardCount++; break; case 'Z': if(dataArray[1]&0x80) upCount++; @@ -172,14 +165,13 @@ break; case 'M': // magnet getMag++; -// pc.putc(dataArray[0]); -// echo('O',mag); mag_test=!mag_test; break; case 'R': // record recordTime = dataArray[1]; recordTime *= Fs; - waitTime = 1.0/Fs-0.0005-1/(BAUD/8/10); + waitTime = 1.0/Fs-0.00048-1/(BAUD/8/10); + n = 0; if(waitTime < 0) waitTime = 0; isRecording = true; break; @@ -189,8 +181,7 @@ default: break; } // end switch -// delete result; - delete dataArray; +// delete dataArray; result = NULL; dataArray = NULL; } // end result if