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.
Fork of TRP105F_Spline by
Revision 13:16fc61b41eff, committed 2016-06-07
- Comitter:
- aktk
- Date:
- Tue Jun 07 16:23:19 2016 +0000
- Parent:
- 12:db5110d9d494
- Child:
- 14:a99bf22b919d
- Commit message:
- type of _Sample_Num was modified: int -> unsigned short.; in saveSetting(any), size of _Sample_num to write into savedata file was modified: int -> unsigned short.
Changed in this revision
| TRP105F_Spline.cpp | Show annotated file Show diff for this revision Revisions of this file |
| TRP105F_Spline.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/TRP105F_Spline.cpp Tue Jun 07 04:35:15 2016 +0000
+++ b/TRP105F_Spline.cpp Tue Jun 07 16:23:19 2016 +0000
@@ -577,7 +577,7 @@
fwrite(&_Threshold[i], sizeof(unsigned short), 1, fp);
fputc(0x3b, fp);
}
- fwrite(&_Sample_Num, sizeof(int), 1, fp);
+ fwrite(&_Sample_Num, sizeof(unsigned short), 1, fp);
fputc(0x3b, fp);
for(int i = 0; i < _Sample_Num; i++) {
fwrite(&_Sample_Set[i].x, sizeof(unsigned short), 1, fp);
@@ -661,7 +661,7 @@
fwrite(&_Threshold[i], sizeof(unsigned short), 1, fp);
fputc(0x3b, fp);
}
- fwrite(&_Sample_Num, sizeof(int), 1, fp);
+ fwrite(&_Sample_Num, sizeof(unsigned short), 1, fp);
fputc(0x3b, fp);
for(int i = 0; i < _Sample_Num; i++) {
fwrite(&_Sample_Set[i].x, sizeof(unsigned short), 1, fp);
@@ -739,50 +739,52 @@
char buffer[3];
for(int i = 0; i < _ENUM; i++) {
+ //Set X
for(int j = 0; j < 3; j++) {
- while(!com->readable());
- buffer[j]
- = (*com).getc();
- }
- _Set[i].x = static_cast<unsigned short>(0xFFFF & (buffer[0] << 8 | buffer[1]));
- //tmp = static_cast< char >(0xFF & (buffer[2]));
-
- for(int j = 0; j < 3; j++) {
- while(!com->readable());
buffer[j] = com->getc();
}
- _Set[i].y = static_cast<unsigned short>(0xFFFF & (buffer[0] << 8 | buffer[1]));
- //tmp = static_cast< char >(0xFF & (buffer[2]));
+ com->putc(0x06); //return ACK
+ _Set[i].x = static_cast<unsigned short>(0xFFFF & (buffer[1] << 8 | buffer[0]));
+ //Set Y
for(int j = 0; j < 3; j++) {
- while(!com->readable());
+ buffer[j] = com->getc();
+ }
+ com->putc(0x06); //return ACK
+ _Set[i].y = static_cast<unsigned short>(0xFFFF & (buffer[1] << 8 | buffer[0]));
+
+ //Threshold
+ for(int j = 0; j < 3; j++) {
buffer[j] = com->getc();
}
- _Threshold[i] = static_cast<unsigned short>(0xFFFF & (buffer[0] << 8 | buffer[1]));
- //tmp = static_cast< char >(0xFF & (buffer[2]));
+ com->putc(0x06); //return ACK
+ _Threshold[i] = static_cast<unsigned short>(0xFFFF & (buffer[1] << 8 | buffer[0]));
}
+ //Sample Num
for(int j = 0; j < 3; j++) {
- while(!com->readable());
buffer[j] = com->getc();
}
- _Sample_Num = static_cast<unsigned short>(0xFFFF & (buffer[0] << 8 | buffer[1]));
- //tmp = static_cast< char >(0xFF & (buffer[2]));
+ com->putc(0x06); //return ACK
+ _Sample_Num = static_cast<unsigned short>(0xFFFF & (buffer[1] << 8 | buffer[0]));
for(int i = 0; i < _Sample_Num; i++) {
+ //Sample Set X
for(int j = 0; j < 3; j++) {
- while(!com->readable());
buffer[j] = com->getc();
}
- _Sample_Set[i].x= static_cast<unsigned short>(0xFFFF & (buffer[0] << 8 | buffer[1]));
- //tmp = static_cast< char >(0xFF & (buffer[2]));
-
+ com->putc(0x06); //return ACK
+ _Sample_Set[i].x= static_cast<unsigned short>(0xFFFF & (buffer[1] << 8 | buffer[0]));
+
+ //Sample Set Y
for(int j = 0; j < 3; j++) {
- while(!com->readable());
buffer[j] = com->getc();
}
- _Sample_Set[i].y= static_cast<unsigned short>(0xFFFF & (buffer[0] << 8 | buffer[1]));
- //tmp = static_cast< char >(0xFF & (buffer[2]));
+ if(i != _Sample_Num - 1)
+ com->putc(0x06); //return ACK
+ else
+ com->putc(0x04); //return EOT
+ _Sample_Set[i].y= static_cast<unsigned short>(0xFFFF & (buffer[1] << 8 | buffer[0]));
}
}
--- a/TRP105F_Spline.h Tue Jun 07 04:35:15 2016 +0000
+++ b/TRP105F_Spline.h Tue Jun 07 16:23:19 2016 +0000
@@ -82,7 +82,7 @@
//
// Defining Constants
//
- enum _SetConstant {
+ enum {
_LIDX = 0,
_RIDX = 255,
_ENUM = _RIDX - _LIDX + 1
@@ -93,7 +93,7 @@
// Debug or Module
UseType _useType;
// For data sampling and making spline model
- unsigned int _Sample_Num; // the number of samples for derive spline
+ unsigned short _Sample_Num; // the number of samples for derive spline
VDset* _Sample_Set;
double* _u_spline;
// For comvert voltage -> physical quantity e.g. distance
