d
Embed:
(wiki syntax)
Show/hide line numbers
sshape.h
00001 #ifndef SSHAPE_H 00002 #define SSHAPE_H 00003 00004 #include "stdio.h" 00005 #include "math.h" 00006 #include "time.h" 00007 #include "mbed.h" 00008 /* samplecode 00009 #include "stdio.h" 00010 #include "sshape.h" 00011 #include "mbed.h" 00012 #include "time.h" 00013 #include "stdlib.h" 00014 00015 #define time 10 00016 00017 shape sshape(time); 00018 00019 Serial pc(USBTX, USBRX, 115200); 00020 double pm(double num); 00021 00022 int main(void){ 00023 double stickpoints = 10.0; 00024 double add = 0; 00025 while(1){ 00026 sshape.start(); 00027 double start = sshape.start(); 00028 00029 while(1){ 00030 pc.printf("spend time : %4.2f ",sshape.shapeTime(start)); 00031 pc.printf("shape : %.2f Target : %.2f add : %.2f\r\n",sshape.compute(stickpoints,start,add),stickpoints,add); 00032 if(pm(stickpoints-add)*sshape.compute(stickpoints,start,add) >= pm(stickpoints-add)*stickpoints){ 00033 add = sshape.compute(stickpoints,start,add); 00034 pc.printf("aaaaaaaaaaaaaaddddddddddddd %f",add); 00035 break;} 00036 } 00037 for(int i=0; i<10; i++){ 00038 pc.printf("%f",add); 00039 } 00040 stickpoints = rand() % 257- 128;; 00041 } 00042 } 00043 double pm(double num){ 00044 return (num>0)-(num<0); 00045 } 00046 00047 00048 */ 00049 00050 class shape { 00051 public: 00052 shape(double time); 00053 double compute(double stickpoints,double starttime,double add); 00054 double start(); 00055 double shapeTime(double starttime); 00056 double kasokudo(double time_s,double start_s,double points_s,double add_s); 00057 int pm(double num); 00058 private: 00059 double shapeS_m; 00060 double add_m; 00061 double time_tmp; 00062 double tmp; 00063 double time_c; 00064 double shapeSpeed; 00065 double time; 00066 clock_t start_m; 00067 }; 00068 #endif
Generated on Wed Nov 16 2022 08:38:09 by
1.7.2