d

Dependencies:   mbed

Revision:
0:ee4e3ab4db45
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sshape.h	Wed Nov 16 08:37:38 2022 +0000
@@ -0,0 +1,68 @@
+#ifndef SSHAPE_H
+#define SSHAPE_H
+
+#include "stdio.h"
+#include "math.h"
+#include "time.h"
+#include "mbed.h"
+/*  samplecode
+#include "stdio.h"
+#include "sshape.h"
+#include "mbed.h"
+#include "time.h"
+#include "stdlib.h"
+
+#define time 10
+
+shape sshape(time);
+
+ Serial pc(USBTX, USBRX, 115200);
+double pm(double num);
+
+int main(void){
+    double stickpoints = 10.0;
+    double add = 0;
+    while(1){
+        sshape.start();
+        double start = sshape.start();
+        
+        while(1){
+        pc.printf("spend time  :  %4.2f  ",sshape.shapeTime(start));
+        pc.printf("shape : %.2f  Target : %.2f add : %.2f\r\n",sshape.compute(stickpoints,start,add),stickpoints,add);
+        if(pm(stickpoints-add)*sshape.compute(stickpoints,start,add) >= pm(stickpoints-add)*stickpoints){
+            add = sshape.compute(stickpoints,start,add);
+            pc.printf("aaaaaaaaaaaaaaddddddddddddd   %f",add);
+        break;}
+        }
+        for(int i=0; i<10; i++){
+            pc.printf("%f",add);
+        }
+        stickpoints = rand() % 257- 128;;
+    }
+}
+double pm(double num){
+    return (num>0)-(num<0);
+}
+
+        
+*/
+
+class shape {
+public:
+    shape(double time);
+    double compute(double stickpoints,double starttime,double add);
+    double start();
+    double shapeTime(double starttime);
+    double kasokudo(double time_s,double start_s,double points_s,double add_s);
+    int pm(double num);
+private:
+    double shapeS_m;
+    double add_m;
+    double time_tmp;
+    double tmp;
+    double time_c;
+    double shapeSpeed;
+    double time;
+    clock_t start_m;
+};
+#endif