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 10:b50e4bb40571, committed 2016-06-06
- Comitter:
- aktk
- Date:
- Mon Jun 06 15:41:44 2016 +0000
- Parent:
- 9:ec1ee4a6b6a4
- Child:
- 11:d60fb729eacf
- Commit message:
- New Constructor TRP105FS(unsigned int, PinName) has implemented.
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 Mon Jun 06 15:38:23 2016 +0000
+++ b/TRP105F_Spline.cpp Mon Jun 06 15:41:44 2016 +0000
@@ -70,6 +70,25 @@
TRP105FS::TRP105FS(
unsigned int arg_num,
+ PinName pin
+)
+ :_ai(AnalogIn(pin))
+
+{
+ if(arg_num > _ENUM) _Sample_Num = _ENUM;
+ else _Sample_Num = arg_num;
+
+ _Sample_Set = (VDset *)malloc(_Sample_Num * sizeof(VDset));
+ _u_spline = (double*)malloc(_Sample_Num * sizeof(double));
+
+ for(int i = 0; i < _Sample_Num; i++) {
+ _Sample_Set[i].x = _Sample_Set[i].y = 0;
+ _u_spline[i] = 0.0;
+ }
+}
+
+TRP105FS::TRP105FS(
+ unsigned int arg_num,
UseType arg_type,
PinName pin
)
@@ -647,7 +666,7 @@
sprintf(filepath, "/local/%s", filename);
fp = fopen(filepath, "rb");
-
+
for(int i = 0; i < _ENUM; i++) {
fread(&_Set[i].x, sizeof(unsigned short), 1, fp);
@@ -704,7 +723,7 @@
sprintf(filepath, "/local/%s", filename);
fp = fopen(filepath, "w");
//fp = fopen("/local/log.txt", "w"); // open file in writing mode
-
+
fprintf(fp, "x, y,(threshold)\n");
for(int i = 0; i < _ENUM; i++) {
fprintf(fp, "%d,%d,(%d)\n", _Set[i].x, _Set[i].y, _Threshold[i]);
@@ -713,7 +732,7 @@
for(int i = 0; i < _Sample_Num; i++) {
fprintf(fp, "%d,%d\n", _Sample_Set[i].x, _Sample_Set[i].y);
}
-
+
free(filepath);
fclose(fp);
--- a/TRP105F_Spline.h Mon Jun 06 15:38:23 2016 +0000
+++ b/TRP105F_Spline.h Mon Jun 06 15:41:44 2016 +0000
@@ -56,6 +56,7 @@
TRP105FS();
TRP105FS(unsigned int);
TRP105FS(unsigned int, UseType);
+ TRP105FS(unsigned int, PinName);
TRP105FS(unsigned int, UseType, PinName);
//TRP105FS(unsigned int arg_num, DataInType arg_dit, unsigned int channel);
// Destraction
