-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniPlan51MDII_v100_20160118.ino
More file actions
1371 lines (1140 loc) · 81.1 KB
/
MiniPlan51MDII_v100_20160118.ino
File metadata and controls
1371 lines (1140 loc) · 81.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 最後編輯 2016-1-18
#include <Wire.h>
#include <Servo.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Adafruit_PWMServoDriver.h>
#include <EEPROM.h>
// I2C Address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// Servos Matrix
const int ALLMATRIX = 19; // 0 ~ 15 Servo + GPIO12 + GPIO14 + Run Time
const int ALLSERVOS = 18; // 0 ~ 15 Servo + GPIO12 + GPIO14
const int PWMRES_Min = 1; // PWM Resolution 1
const int PWMRES_Max = 120; // PWM Resolution 120
// ES08MDII Pulse Traveling 1500us to 1900us , 120度
const int SERVOMIN = 1100; // 1100
const int SERVOMAX = 2700; // 2600
// Servo Delay Base Time
const int BASEDELAYTIME = 10; // 10ms
// AP Password
const char WiFiAPPSK[] = "12345678";
int Servo_OE;
int Servo_PROGRAM;
int Servo_PROGRAM_Stack;
int GPIO_ID;
int GPIO12_PWM;
int GPIO14_PWM;
// Backup Servo Value
int Running_Servo_POS [ALLMATRIX];
ESP8266WebServer server(80);
Servo GPIO12SERVO;
Servo GPIO14SERVO;
/*============================================================================*/
// ES08MDII - 無修正
/////////////////////////////////////////////////////// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
int Servo_Act_Fix [ ] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/*============================================================================*/
// ES08MDII - 達文西姿勢
///////////////////////////////////////////////////// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
int Servo_Act_0 [ ] PROGMEM = { 65, 35, 80, 60, 80, 100, 20, 80, 40, 100, 20, 30, 55, 35, 75, 50, 90, 90, 0 };
/*============================================================================*/
// ES08MDII - 立正
///////////////////////////////////////////////////// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
int Servo_Act_1 [ ] PROGMEM = { 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 0 };
/*============================================================================*/
// 待機姿勢
int Servo_Prg_0_Step = 1;
int Servo_Prg_0 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 500 } // 立正
};
/*============================================================================*/
// 鞠躬動作
int Servo_Prg_1_Step = 4;
int Servo_Prg_1 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 35, 80, 60, 80, 120, 80, 40, 110, 25, 100, 30, 55, 35, 75, 50, 90, 90, 500 }, // 立正 右手前平舉內彎 左手後擺
{ 65, 20, 80, 10, 80, 120, 80, 40, 110, 25, 100, 30, 102, 35, 90, 50, 90, 90, 500 }, // 立正 右手前平舉內彎 左手後擺 鞠躬
{ 65, 20, 80, 10, 80, 120, 80, 40, 110, 25, 100, 30, 102, 35, 90, 50, 90, 90, 1000 }, // 鞠躬動作 等待
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 800 } // 立正
};
/*============================================================================*/
// 揮手動作
int Servo_Prg_2_Step = 9;
int Servo_Prg_2 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 35, 80, 60, 80, 100, 95, 80, 20, 70, 120, 30, 55, 35, 75, 50, 50, 90, 500 }, // 立正 右手上抬向外 頭右轉
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 30, 120, 30, 55, 35, 75, 50, 50, 90, 300 }, // 立正 右手上抬向內 頭右轉
{ 65, 35, 80, 60, 80, 100, 95, 80, 20, 70, 120, 30, 55, 35, 75, 50, 50, 90, 300 }, // 立正 右手上抬向外 頭右轉
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 30, 120, 30, 55, 35, 75, 50, 50, 90, 300 }, // 立正 右手上抬向內 頭右轉
{ 65, 35, 80, 60, 80, 0, 50, 100, 40, 30, 25, 30, 55, 35, 75, 50, 130, 90, 500 }, // 立正 左手上抬向外 頭左轉
{ 65, 35, 80, 60, 80, 0, 80, 80, 40, 30, 25, 30, 55, 35, 75, 50, 130, 90, 300 }, // 立正 左手上抬向內 頭左轉
{ 65, 35, 80, 60, 80, 0, 50, 100, 40, 30, 25, 30, 55, 35, 75, 50, 130, 90, 300 }, // 立正 左手上抬向外 頭左轉
{ 65, 35, 80, 60, 80, 0, 80, 80, 40, 30, 25, 30, 55, 35, 75, 50, 130, 90, 300 }, // 立正 左手上抬向內 頭左轉
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 500 } // 立正
};
/*============================================================================*/
// 鋼鐵人動作
int Servo_Prg_3_Step = 8;
int Servo_Prg_3 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 75, 35, 80, 60, 90, 120, 70, 120, 0, 100, 20, 40, 55, 35, 75, 60, 50, 90, 300 }, // 身體左傾斜 右手上抬 掌向外 頭右轉
{ 75, 35, 80, 60, 90, 120, 70, 120, 0, 100, 20, 40, 55, 35, 75, 60, 50, 90, 800 }, // 身體左傾斜 右手上抬 掌向外 頭右轉
{ 55, 35, 80, 60, 70, 100, 20, 120, 0, 50, 0, 20, 55, 35, 75, 40, 130, 90, 300 }, // 身體右傾斜 左手上抬 掌向外 頭左轉
{ 55, 35, 80, 60, 70, 100, 20, 120, 0, 50, 0, 20, 55, 35, 75, 40, 130, 90, 800 }, // 身體右傾斜 左手上抬 掌向外 頭左轉
{ 65, 35, 80, 60, 80, 20, 70, 120, 0, 50, 100, 30, 55, 35, 75, 50, 90, 90, 500 }, // 立正 雙手上抬 掌向外
{ 65, 20, 80, 45, 80, 20, 105, 120, 0, 10, 100, 30, 70, 35, 89, 50, 90, 90, 500 }, // 身體後傾斜 雙手上抬 掌向內
{ 65, 20, 80, 45, 80, 20, 105, 120, 0, 10, 100, 30, 70, 35, 89, 50, 90, 90, 800 }, // 身體後傾斜 雙手上抬 掌向內
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 500 } // 立正
};
/*============================================================================*/
// 阿帕契動作
int Servo_Prg_4_Step = 7;
int Servo_Prg_4 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 55, 35, 80, 60, 70, 100, 70, 30, 40, 80, 20, 20, 55, 35, 75, 40, 90, 90, 500 }, // 身體右傾斜
{ 55, 35, 80, 60, 70, 100, 70, 30, 40, 80, 20, 20, 55, 35, 75, 35, 130, 90, 300 }, // 身體右傾斜 左腳預抬 頭左轉
{ 55, 35, 80, 60, 70, 100, 70, 30, 100, 10, 100, 40, 55, 35, 75, 30, 130, 90, 500 }, // 身體右傾斜 右手敬禮 左腳上抬 頭左轉
{ 55, 35, 80, 60, 70, 100, 70, 30, 100, 10, 100, 40, 55, 35, 75, 30, 130, 90, 800 }, // 身體右傾斜 右手敬禮 左腳上抬 頭左轉
{ 55, 35, 80, 60, 70, 100, 70, 30, 40, 80, 20, 20, 55, 35, 75, 35, 130, 90, 600 }, // 身體右傾斜 左腳預抬 頭左轉
{ 55, 35, 80, 60, 70, 100, 70, 30, 40, 80, 20, 20, 55, 35, 75, 40, 90, 90, 500 }, // 身體右傾斜
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 500 } // 立正
};
/*============================================================================*/
// 單腳平衡動作 小
int Servo_Prg_5_Step = 12;
int Servo_Prg_5 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 75, 35, 80, 60, 90, 100, 20, 80, 40, 100, 20, 40, 55, 35, 75, 60, 90, 90, 500 }, // 身體左傾斜 雙手平舉上抬
{ 75, 35, 80, 60, 90, 50, 20, 80, 40, 100, 70, 40, 55, 35, 80, 60, 90, 90, 300 }, // 身體左傾斜 雙手平舉上抬旋轉 右腳預抬
{ 80, 35, 80, 60, 70, 50, 20, 80, 40, 100, 70, 40, 55, 35, 80, 60, 90, 90, 500 }, // 身體左傾斜 雙手平舉上抬旋轉 右腳上抬
{ 80, 35, 80, 60, 70, 50, 20, 80, 40, 100, 70, 40, 55, 35, 80, 60, 90, 90, 600 }, // 身體左傾斜 雙手平舉上抬旋轉 右腳上抬
{ 80, 15, 80, 0, 70, 50, 20, 80, 40, 100, 70, 40, 55, 35, 80, 60, 90, 90, 900 }, // 身體前傾斜 雙手平舉上抬旋轉 右腳上抬
{ 80, 15, 80, 0, 70, 50, 0, 80, 40, 120, 70, 40, 55, 35, 80, 60, 50, 90, 500 }, // 身體前傾斜 雙手平舉上抬旋轉 右腳上抬 上
{ 80, 15, 80, 0, 70, 50, 40, 80, 40, 80, 70, 40, 55, 35, 80, 60, 130, 90, 500 }, // 身體前傾斜 雙手平舉上抬旋轉 右腳上抬 下
{ 80, 15, 80, 0, 70, 50, 0, 80, 40, 120, 70, 40, 55, 35, 80, 60, 50, 90, 500 }, // 身體前傾斜 雙手平舉上抬旋轉 右腳上抬 上
{ 80, 15, 80, 0, 70, 50, 40, 80, 40, 80, 70, 40, 55, 35, 80, 60, 130, 90, 500 }, // 身體前傾斜 雙手平舉上抬旋轉 右腳上抬 下
{ 80, 15, 80, 0, 70, 50, 20, 80, 40, 100, 70, 40, 55, 35, 80, 60, 90, 90, 500 }, // 身體前傾斜 雙手平舉上抬旋轉 右腳上抬
{ 80, 35, 80, 60, 70, 50, 20, 80, 40, 100, 70, 40, 55, 35, 80, 60, 90, 90, 800 }, // 身體左傾斜 雙手平舉上抬旋轉 右腳上抬
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 500 } // 立正
};
/*============================================================================*/
// 暖身動作
int Servo_Prg_6_Step = 16;
int Servo_Prg_6 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 90, 90, 800 }, // 雙手插腰
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 50, 90, 500 }, // 雙手插腰 頭右轉
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 50, 90, 500 }, // 雙手插腰 頭右轉
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 130, 90, 500 }, // 雙手插腰 頭左轉
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 130, 90, 500 }, // 雙手插腰 頭左轉
{ 55, 35, 80, 60, 70, 100, 70, 20, 40, 100, 20, 20, 55, 35, 75, 40, 50, 90, 800 }, // 身體右傾斜 右手平舉 左手擺頭頂 頭右轉
{ 55, 35, 80, 60, 70, 100, 70, 20, 40, 100, 20, 20, 55, 35, 75, 40, 50, 90, 500 }, // 身體右傾斜 右手平舉 左手擺頭頂 頭右轉
{ 75, 35, 80, 60, 90, 100, 20, 80, 100, 50, 20, 40, 55, 35, 75, 60, 130, 90, 800 }, // 身體左傾斜 左手平舉 右手擺頭頂 頭左轉
{ 75, 35, 80, 60, 90, 100, 20, 80, 100, 50, 20, 40, 55, 35, 75, 60, 130, 90, 500 }, // 身體左傾斜 左手平舉 右手擺頭頂 頭左轉
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 90, 90, 500 }, // 雙手插腰
{ 65, 62, 15, 17, 80, 15, 95, 80, 40, 25, 100, 30, 95, 100, 48, 50, 90, 90, 800 }, // 蹲下 雙手向前平舉
{ 65, 62, 15, 17, 80, 15, 95, 80, 40, 25, 100, 30, 95, 100, 48, 50, 90, 90, 300 }, // 蹲下 雙手向前平舉
{ 65, 35, 80, 60, 80, 100, 70, 20, 100, 50, 20, 30, 55, 35, 75, 50, 90, 90, 500 }, // 雙手插腰
{ 65, 62, 15, 17, 80, 15, 95, 80, 40, 25, 100, 30, 95, 100, 48, 50, 90, 90, 800 }, // 蹲下 雙手向前平舉
{ 65, 62, 15, 17, 80, 15, 95, 80, 40, 25, 100, 30, 95, 100, 48, 50, 90, 90, 300 }, // 蹲下 雙手向前平舉
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 800 } // 立正
};
/*============================================================================*/
// 前進動作
int Servo_Prg_10_Step = 27;
int Servo_Prg_10 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 59, 36, 39, 80, 100, 95, 80, 40, 25, 20, 30, 75, 80, 50, 50, 90, 90, 500 }, // 淺蹲
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 500 }, // 淺蹲 右傾斜 左腳前移
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 40, 90, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 95, 100, 48, 60, 90, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 500 }, // 淺蹲 左傾斜 右腳前移
{ 75, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 500 }, // 淺蹲 右傾斜 左腳前移
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 40, 90, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 95, 100, 48, 60, 90, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 500 }, // 淺蹲 左傾斜 右腳前移
{ 75, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 500 }, // 淺蹲 右傾斜 左腳前移
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 40, 90, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 95, 100, 48, 60, 90, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 500 }, // 淺蹲 左傾斜 右腳前移
{ 75, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 300 } // 立正
};
/*============================================================================*/
// 後退動作
int Servo_Prg_11_Step = 19;
int Servo_Prg_11 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 59, 36, 39, 80, 100, 95, 80, 40, 25, 20, 30, 75, 80, 50, 50, 90, 90, 500 }, // 淺蹲
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 82, 48, 75, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 500 }, // 淺蹲 右傾斜 左腳後移
{ 55, 55, 80, 80, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 95, 100, 48, 60, 50, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 42, 70, 27, 60, 50, 90, 500 }, // 淺蹲 左傾斜 右腳後移
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 35, 35, 51, 60, 50, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 82, 48, 75, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 500 }, // 淺蹲 右傾斜 左腳後移
{ 55, 55, 80, 80, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 95, 100, 48, 60, 50, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 42, 70, 27, 60, 50, 90, 500 }, // 淺蹲 左傾斜 右腳後移
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 35, 35, 51, 60, 50, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 300 } // 立正
};
/*============================================================================*/
// 左轉動作
int Servo_Prg_12_Step = 27;
int Servo_Prg_12 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 59, 36, 39, 80, 100, 95, 80, 40, 25, 20, 30, 75, 80, 50, 50, 90, 90, 500 }, // 淺蹲
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 95, 100, 48, 60, 90, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 500 }, // 淺蹲 左傾斜 右腳前移
{ 75, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 82, 48, 75, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 500 }, // 淺蹲 右傾斜 左腳後移
{ 55, 55, 80, 80, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 95, 100, 48, 60, 90, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 500 }, // 淺蹲 左傾斜 右腳前移
{ 75, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 82, 48, 75, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 500 }, // 淺蹲 右傾斜 左腳後移
{ 55, 55, 80, 80, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 95, 100, 48, 60, 90, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 500 }, // 淺蹲 左傾斜 右腳前移
{ 75, 59, 36, 39, 90, 70, 95, 80, 40, 25, 0, 40, 82, 70, 70, 60, 90, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 82, 48, 75, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 500 }, // 淺蹲 右傾斜 左腳後移
{ 55, 55, 80, 80, 70, 70, 95, 80, 40, 25, 0, 20, 75, 80, 50, 35, 130, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 300 } // 立正
};
/*============================================================================*/
// 右轉動作
int Servo_Prg_13_Step = 27;
int Servo_Prg_13 [][ALLMATRIX] PROGMEM = {
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , G12 , G14 , ms
{ 65, 59, 36, 39, 80, 100, 95, 80, 40, 25, 20, 30, 75, 80, 50, 50, 90, 90, 500 }, // 淺蹲
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 500 }, // 淺蹲 右傾斜 左腳前移
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 40, 90, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 95, 100, 48, 60, 50, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 42, 70, 27, 60, 50, 90, 500 }, // 淺蹲 左傾斜 右腳後移
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 35, 35, 51, 60, 50, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 500 }, // 淺蹲 右傾斜 左腳前移
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 40, 90, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 95, 100, 48, 60, 50, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 42, 70, 27, 60, 50, 90, 500 }, // 淺蹲 左傾斜 右腳後移
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 35, 35, 51, 60, 50, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 55, 62, 15, 17, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 600 }, // 淺蹲 右傾斜 左腳上抬
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 35, 90, 90, 500 }, // 淺蹲 右傾斜 左腳前移
{ 55, 40, 45, 30, 70, 120, 95, 80, 40, 25, 50, 20, 75, 80, 50, 40, 90, 90, 300 }, // 淺蹲 右傾斜 左腳放下
{ 75, 40, 45, 30, 90, 100, 95, 80, 40, 25, 20, 40, 75, 80, 50, 60, 90, 90, 500 }, // 淺蹲 左傾斜
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 95, 100, 48, 60, 50, 90, 600 }, // 淺蹲 左傾斜 右腳上抬
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 42, 70, 27, 60, 50, 90, 500 }, // 淺蹲 左傾斜 右腳後移
{ 80, 59, 36, 39, 90, 120, 95, 80, 40, 25, 50, 40, 35, 35, 51, 60, 50, 90, 300 }, // 淺蹲 左傾斜 右腳放下
{ 55, 59, 36, 39, 70, 100, 95, 80, 40, 25, 20, 20, 75, 80, 50, 40, 90, 90, 500 }, // 淺蹲 右傾斜
{ 65, 35, 80, 60, 80, 100, 95, 80, 40, 25, 20, 30, 55, 35, 75, 50, 90, 90, 300 } // 立正
};
/*============================================================================*/
void Set_PWM_to_Servo(int iServo, int iValue)
{
int NewPWM = map(iValue, PWMRES_Min, PWMRES_Max, SERVOMIN, SERVOMAX);
if (iServo >= 17)
{
GPIO14SERVO.write(iValue);
}
else if (iServo >= 16)
{
GPIO12SERVO.write(iValue);
}
else
{
pwm.setPWM(iServo, 0, NewPWM);
}
}
/*============================================================================*/
void Servo_PROGRAM_Zero()
{
// 清除備份目前馬達數值
for ( int Index = 0; Index < ALLMATRIX; Index++)
{
Running_Servo_POS[Index] = Servo_Act_0[Index] + (int8_t)EEPROM.read(Index);
}
// 重新載入馬達預設數值
for (int iServo = 0; iServo < ALLSERVOS; iServo++)
{
Set_PWM_to_Servo(iServo, Running_Servo_POS[iServo]);
delay(10);
}
}
/*============================================================================*/
void Servo_PROGRAM_Center()
{
// 清除備份目前馬達數值
for ( int Index = 0; Index < ALLMATRIX; Index++)
{
Running_Servo_POS[Index] = Servo_Act_1[Index] + (int8_t)EEPROM.read(Index);
}
// 重新載入馬達預設數值
for (int iServo = 0; iServo < ALLSERVOS; iServo++)
{
Set_PWM_to_Servo(iServo, Running_Servo_POS[iServo]);
delay(10);
}
}
/*============================================================================*/
void Servo_PROGRAM_Run(int iMatrix[][19], int iSteps)
{
int INT_TEMP_A, INT_TEMP_B, INT_TEMP_C;
for ( int MainLoopIndex = 0; MainLoopIndex < iSteps; MainLoopIndex++) // iSteps 步驟主迴圈
{
// InterTotalTime 此步驟總時間
int InterTotalTime = iMatrix [ MainLoopIndex ] [ ALLMATRIX - 1 ] + (int8_t)EEPROM.read(ALLMATRIX - 1);
// InterDelayCounter 此步驟基本延遲次數
int InterDelayCounter = InterTotalTime / BASEDELAYTIME;
// 內差次數迴圈
for ( int InterStepLoop = 0; InterStepLoop < InterDelayCounter; InterStepLoop++)
{
for (int ServoIndex = 0; ServoIndex < ALLSERVOS; ServoIndex++) // 馬達主迴圈
{
INT_TEMP_A = Running_Servo_POS[ServoIndex]; // 馬達現在位置
INT_TEMP_B = iMatrix[MainLoopIndex][ServoIndex] + (int8_t)EEPROM.read(ServoIndex); // 馬達目標位置
if (INT_TEMP_A == INT_TEMP_B) // 馬達數值不變
{
INT_TEMP_C = INT_TEMP_B;
}
else if (INT_TEMP_A > INT_TEMP_B) // 馬達數值減少
{
// PWM內差值 = map( 執行次數時間累加, 開始時間, 結束時間, 內差起始值, 內差最大值 )
INT_TEMP_C = map(BASEDELAYTIME * InterStepLoop, 0, InterTotalTime, 0, INT_TEMP_A - INT_TEMP_B);
if (INT_TEMP_A - INT_TEMP_C >= INT_TEMP_B)
{
Set_PWM_to_Servo(ServoIndex, INT_TEMP_A - INT_TEMP_C);
}
}
else if (INT_TEMP_A < INT_TEMP_B) // 馬達數值增加
{
// PWM內差值 = map( 執行次數時間累加, 開始時間, 結束時間, 內差起始值, 內差最大值 )
INT_TEMP_C = map(BASEDELAYTIME * InterStepLoop, 0, InterTotalTime, 0, INT_TEMP_B - INT_TEMP_A);
if (INT_TEMP_A + INT_TEMP_C <= INT_TEMP_B)
{
Set_PWM_to_Servo(ServoIndex, INT_TEMP_A + INT_TEMP_C);
}
}
}
delay(BASEDELAYTIME);
}
// 備份目前馬達數值
for ( int Index = 0; Index < ALLMATRIX; Index++)
{
Running_Servo_POS[Index] = iMatrix[MainLoopIndex][Index] + (int8_t)EEPROM.read(Index);
}
}
}
/*============================================================================*/
void handleAction(WiFiClient client, String req, HTTPMethod method)
{
server.send(200, "text/plain", "Hello from MiniPlan !");
}
/*============================================================================*/
void handleController()
{
String pm = server.arg("pm");
String pms = server.arg("pms");
String gpid = server.arg("gpid");
String servo = server.arg("servo");
String setting = server.arg("setting");
if (pm != "")
{
Servo_PROGRAM = pm.toInt();
}
if (pms != "")
{
Servo_PROGRAM_Stack = pms.toInt();
}
if (servo != "")
{
int Servo_ID = servo.toInt();
String ival = server.arg("value");
int Servo_PWM = ival.toInt() + (int8_t)EEPROM.read(Servo_ID);
int pulselength = map(Servo_PWM, PWMRES_Min, PWMRES_Max, SERVOMIN, SERVOMAX);
pwm.setPWM(Servo_ID, 0, pulselength);
}
if (gpid != "")
{
GPIO_ID = gpid.toInt();
if (GPIO_ID == 12) {
String ival = server.arg("value");
GPIO12_PWM = ival.toInt() + (int8_t)EEPROM.read(16);
GPIO12SERVO.write(GPIO12_PWM);
}
if (GPIO_ID == 14) {
String ival = server.arg("value");
GPIO14_PWM = ival.toInt() + (int8_t)EEPROM.read(17);
GPIO14SERVO.write(GPIO14_PWM);
}
}
if (setting != "")
{
int Servo_ID = setting.toInt();
String ival = server.arg("value");
int8_t Servo_PWM = ival.toInt();
EEPROM.write(Servo_ID, Servo_PWM);
EEPROM.commit();
}
server.send(200, "text/html", "(pm, pms)=(" + pm + "," + pms + ")");
}
/*============================================================================
馬達歸零畫面
============================================================================*/
void handleZero()
{
String content = "";
content += "<html>";
content += "<head>";
content += "<title>MiniPlan Zero Check</title>";
content += " <style type=\"text/css\">";
content += " body {";
content += " color: white;";
content += " background-color: #000000 }";
content += " .pm_btn {";
content += " width: 160px;";
content += " -webkit-border-radius: 5;";
content += " -moz-border-radius: 5;";
content += " border-radius: 5px;";
content += " font-family: Arial;";
content += " color: #ffffff;";
content += " font-size: 24px;";
content += " background: #3498db;";
content += " padding: 10px 20px 10px 20px;";
content += " text-decoration: none;";
content += "}";
content += ".pm_text {";
content += "width: 160px;";
content += "-webkit-border-radius: 5;";
content += "-moz-border-radius: 5;";
content += "border-radius: 5px;";
content += "font-family: Arial;";
content += "font-size: 24px;";
content += "padding: 10px 20px 10px 20px;";
content += "text-decoration: none;";
content += "}";
content += ".pm_btn:hover {";
content += " background: #3cb0fd;";
content += " background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -o-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: linear-gradient(to bottom, #3cb0fd, #3498db);";
content += " text-decoration: none;";
content += "}";
content += ".pms_btn {";
content += "width: 240px;";
content += "-webkit-border-radius: 5;";
content += "-moz-border-radius: 5;";
content += "border-radius: 5px;";
content += "font-family: Arial;";
content += "color: #ffffff;";
content += "font-size: 24px;";
content += "background: #3498db;";
content += "padding: 10px 20px 10px 20px;";
content += "text-decoration: none;";
content += "}";
content += ".pms_btn:hover {";
content += "background: #3cb0fd;";
content += "background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -o-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: linear-gradient(to bottom, #3cb0fd, #3498db);";
content += "text-decoration: none;";
content += "}";
content += " </style>";
content += "</head>";
content += "<body>";
content += "<table>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #6e6e6e;\" type=\"button\" onclick=\"controlGpid(14, 90)\">GPIO 14</button></td>";
content += "<td><button class=\"pm_btn\" style=\"background: #6e6e6e;\" type=\"button\" onclick=\"controlGpid(12, 90)\">GPIO 12</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "<table>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(8,40)\">Servo 8</button></td>";
content += "<td><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(7,80)\">Servo 7</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(9,100)\">Servo 9</button></td>";
content += "<td><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(6,20)\">Servo 6</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(10,20)\">Servo 10</button></td>";
content += "<td><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(5, 100)\">Servo 5</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "<table>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(11,30)\">Servo 11</button></td>";
content += "<td><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(4,80)\">Servo 4</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(12,55)\">Servo 12</button></td>";
content += "<td><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(3,60)\">Servo 3</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(13,35)\">Servo 13</button></td>";
content += "<td><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(2,80)\">Servo 2</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(14,75)\">Servo 14</button></td>";
content += "<td><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(1,35)\">Servo 1</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(15,50)\">Servo 15</button></td>";
content += "<td><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(0,65)\">Servo 0</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "<table>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #ed3db5;\" type=\"button\" onclick=\"controlPm(100)\">ALL</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "</body>";
content += "<script>";
content += "function controlServo(id, value) {";
content += " var xhttp = new XMLHttpRequest();";
content += " xhttp.onreadystatechange = function() {";
content += " if (xhttp.readyState == 4 && xhttp.status == 200) {";
content += " document.getElementById(\"demo\").innerHTML = xhttp.responseText;";
content += " }";
content += " };";
content += " xhttp.open(\"GET\", \"controller?servo=\"+id+\"&value=\"+value, true);";
content += " xhttp.send();";
content += "}";
content += "function controlGpid(id, value) {";
content += " var xhttp = new XMLHttpRequest();";
content += " xhttp.onreadystatechange = function() {";
content += " if (xhttp.readyState == 4 && xhttp.status == 200) {";
content += " document.getElementById(\"demo\").innerHTML = xhttp.responseText;";
content += " }";
content += " };";
content += " xhttp.open(\"GET\", \"controller?gpid=\"+id+\"&value=\"+value, true);";
content += " xhttp.send();";
content += "}";
content += "function controlPm(value) {";
content += " var xhttp = new XMLHttpRequest();";
content += " xhttp.onreadystatechange = function() {";
content += " if (xhttp.readyState == 4 && xhttp.status == 200) {";
content += " document.getElementById(\"demo\").innerHTML = xhttp.responseText;";
content += " }";
content += " };";
content += " xhttp.open(\"GET\", \"controller?pm=\"+value, true);";
content += " xhttp.send();";
content += "}";
content += "</script>";
content += "</html>";
server.send(200, "text/html", content);
}
/*============================================================================
簡易動作編輯畫面
============================================================================*/
void handleEditor()
{
String content = "";
content += "<html>";
content += "<head>";
content += " <title>MiniPlan Motion Editor</title>";
content += " <style type=\"text/css\">";
content += " body {";
content += " color: white;";
content += " background-color: #000000 }";
content += " .pm_btn {";
content += " width: 160px;";
content += " -webkit-border-radius: 5;";
content += " -moz-border-radius: 5;";
content += " border-radius: 5px;";
content += " font-family: Arial;";
content += " color: #ffffff;";
content += " font-size: 24px;";
content += " background: #3498db;";
content += " padding: 10px 20px 10px 20px;";
content += " text-decoration: none;";
content += "}";
content += ".pm_text {";
content += "width: 160px;";
content += "-webkit-border-radius: 5;";
content += "-moz-border-radius: 5;";
content += "border-radius: 5px;";
content += "font-family: Arial;";
content += "font-size: 24px;";
content += "padding: 10px 20px 10px 20px;";
content += "text-decoration: none;";
content += "}";
content += ".pm_btn:hover {";
content += " background: #3cb0fd;";
content += " background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -o-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: linear-gradient(to bottom, #3cb0fd, #3498db);";
content += " text-decoration: none;";
content += "}";
content += ".pms_btn {";
content += "width: 240px;";
content += "-webkit-border-radius: 5;";
content += "-moz-border-radius: 5;";
content += "border-radius: 5px;";
content += "font-family: Arial;";
content += "color: #ffffff;";
content += "font-size: 24px;";
content += "background: #3498db;";
content += "padding: 10px 20px 10px 20px;";
content += "text-decoration: none;";
content += "}";
content += ".pms_btn:hover {";
content += "background: #3cb0fd;";
content += "background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -o-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: linear-gradient(to bottom, #3cb0fd, #3498db);";
content += "text-decoration: none;";
content += "}";
content += " </style>";
content += "</head>";
content += "<body>";
content += "<table>";
content += "<tr>";
content += "<td>GPIO 14 , Default value = 90<br/><input class=\"pm_text\" type=\"text\" id=\"gpid_14\" value=\"90\"><button class=\"pm_btn\" style=\"background: #6e6e6e;\" type=\"button\" onclick=\"controlGpid(14, 'gpid_14')\">SEND</button></td>";
content += "<td>GPIO 12 , Default value = 90<br/><input class=\"pm_text\" type=\"text\" id=\"gpid_12\" value=\"90\"><button class=\"pm_btn\" style=\"background: #6e6e6e;\" type=\"button\" onclick=\"controlGpid(12, 'gpid_12')\">SEND</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "<table>";
content += "<tr>";
content += "<td>Servo 8 , Default value = 40<br/><input class=\"pm_text\" type=\"text\" id=\"servo_8\" value=\"40\"><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(8,'servo_8')\">SEND</button></td>";
content += "<td>Servo 7 , Default value = 80<br/><input class=\"pm_text\" type=\"text\" id=\"servo_7\" value=\"80\"><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(7, 'servo_7')\">SEND</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 9 , Default value = 100<br/><input class=\"pm_text\" type=\"text\" id=\"servo_9\" value=\"100\"><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(9,'servo_9')\">SEND</button></td>";
content += "<td>Servo 6 , Default value = 20<br/><input class=\"pm_text\" type=\"text\" id=\"servo_6\" value=\"20\"><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(6,'servo_6')\">SEND</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 10 , Default value = 20<br/><input class=\"pm_text\" type=\"text\" id=\"servo_10\" value=\"20\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(10,'servo_10')\">SEND</button></td>";
content += "<td>Servo 5 , Default value = 100<br/><input class=\"pm_text\" type=\"text\" id=\"servo_5\" value=\"100\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(5,'servo_5')\">SEND</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "<table>";
content += "<tr>";
content += "<td>Servo 11 , Default value = 30<br/><input class=\"pm_text\" type=\"text\" id=\"servo_11\" value=\"30\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(11,'servo_11')\">SEND</button></td>";
content += "<td>Servo 4 , Default value = 80<br/><input class=\"pm_text\" type=\"text\" id=\"servo_4\" value=\"80\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(4,'servo_4')\">SEND</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 12 , Default value = 55<br/><input class=\"pm_text\" type=\"text\" id=\"servo_12\" value=\"55\"><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(12,'servo_12')\">SEND</button></td>";
content += "<td>Servo 3 , Default value = 60<br/><input class=\"pm_text\" type=\"text\" id=\"servo_3\" value=\"60\"><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(3,'servo_3')\">SEND</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 13 , Default value = 35<br/><input class=\"pm_text\" type=\"text\" id=\"servo_13\" value=\"35\"><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(13,'servo_13')\">SEND</button></td>";
content += "<td>Servo 2 , Default value = 80<br/><input class=\"pm_text\" type=\"text\" id=\"servo_2\" value=\"80\"><button class=\"pm_btn\" style=\"background: #f5da81;\" type=\"button\" onclick=\"controlServo(2,'servo_2')\">SEND</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 14 , Default value = 75<br/><input class=\"pm_text\" type=\"text\" id=\"servo_14\" value=\"75\"><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(14,'servo_14')\">SEND</button></td>";
content += "<td>Servo 1 , Default value = 35<br/><input class=\"pm_text\" type=\"text\" id=\"servo_1\" value=\"35\"><button class=\"pm_btn\" style=\"background: #bdbdbd;\" type=\"button\" onclick=\"controlServo(1,'servo_1')\">SEND</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 15 , Default value = 50<br/><input class=\"pm_text\" type=\"text\" id=\"servo_15\" value=\"50\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(15,'servo_15')\">SEND</button></td>";
content += "<td>Servo 0 , Default value = 65<br/><input class=\"pm_text\" type=\"text\" id=\"servo_0\" value=\"65\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(0,'servo_0')\">SEND</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "<table>";
content += "<tr>";
content += "<td><button class=\"pm_btn\" style=\"background: #ed3db5;\" type=\"button\" onclick=\"controlPm(99)\">STANDBY POSE</button></td>";
content += "</tr>";
content += "</table>";
content += "<br>";
content += "</body>";
content += "<script>";
content += "function controlServo(id, textId) {";
content += " var xhttp = new XMLHttpRequest();";
content += " var value = document.getElementById(textId).value;";
content += " xhttp.onreadystatechange = function() {";
content += " if (xhttp.readyState == 4 && xhttp.status == 200) {";
content += " document.getElementById(\"demo\").innerHTML = xhttp.responseText;";
content += " }";
content += " };";
content += " xhttp.open(\"GET\",\"controller?servo=\"+id+\"&value=\"+value, true);";
content += " xhttp.send();";
content += "}";
content += "function controlGpid(id, textId) {";
content += " var xhttp = new XMLHttpRequest();";
content += " var value = document.getElementById(textId).value;";
content += " xhttp.onreadystatechange = function() {";
content += " if (xhttp.readyState == 4 && xhttp.status == 200) {";
content += " document.getElementById(\"demo\").innerHTML = xhttp.responseText;";
content += " }";
content += " };";
content += " xhttp.open(\"GET\", \"controller?gpid=\"+id+\"&value=\"+value, true);";
content += " xhttp.send();";
content += "}";
content += "function controlPm(value) {";
content += " var xhttp = new XMLHttpRequest();";
content += " xhttp.onreadystatechange = function() {";
content += " if (xhttp.readyState == 4 && xhttp.status == 200) {";
content += " document.getElementById(\"demo\").innerHTML = xhttp.responseText;";
content += " }";
content += " };";
content += " xhttp.open(\"GET\", \"controller?pm=\"+value, true);";
content += " xhttp.send();";
content += "}";
content += "</script>";
content += "</html>";
server.send(200, "text/html", content);
}
/*============================================================================
馬達校正畫面
============================================================================*/
void handleSetting()
{
String content = "";
content += "<html>";
content += "<head>";
content += " <title>MiniPlan Setting</title>";
content += " <style type=\"text/css\">";
content += " body {";
content += " color: white;";
content += " background-color: #000000 }";
content += " .pm_btn {";
content += " width: 120px;";
content += " -webkit-border-radius: 5;";
content += " -moz-border-radius: 5;";
content += " border-radius: 5px;";
content += " font-family: Arial;";
content += " color: #ffffff;";
content += " font-size: 24px;";
content += " background: #3498db;";
content += " padding: 10px 20px 10px 20px;";
content += " text-decoration: none;";
content += "}";
content += ".pm_text {";
content += "width: 80px;";
content += "-webkit-border-radius: 5;";
content += "-moz-border-radius: 5;";
content += "border-radius: 5px;";
content += "font-family: Arial;";
content += "font-size: 24px;";
content += "padding: 10px 20px 10px 20px;";
content += "text-decoration: none;";
content += "}";
content += ".pm_btn:hover {";
content += " background: #3cb0fd;";
content += " background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: -o-linear-gradient(top, #3cb0fd, #3498db);";
content += " background-image: linear-gradient(to bottom, #3cb0fd, #3498db);";
content += " text-decoration: none;";
content += "}";
content += ".pms_btn {";
content += "width: 160px;";
content += "-webkit-border-radius: 5;";
content += "-moz-border-radius: 5;";
content += "border-radius: 5px;";
content += "font-family: Arial;";
content += "color: #ffffff;";
content += "font-size: 24px;";
content += "background: #3498db;";
content += "padding: 10px 20px 10px 20px;";
content += "text-decoration: none;";
content += "}";
content += ".pms_btn:hover {";
content += "background: #3cb0fd;";
content += "background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: -o-linear-gradient(top, #3cb0fd, #3498db);";
content += "background-image: linear-gradient(to bottom, #3cb0fd, #3498db);";
content += "text-decoration: none;";
content += "}";
content += " </style>";
content += "</head>";
content += "<body>";
content += "<table>";
content += "<tr>";
content += "<td>GPIO 14<br/><input class=\"pm_text\" type=\"text\" id=\"servo_17\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(17,'servo_17')\">SET</button></td>";
content += "<td>GPIO 12<br/><input class=\"pm_text\" type=\"text\" id=\"servo_16\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(16,'servo_16')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 8<br/><input class=\"pm_text\" type=\"text\" id=\"servo_8\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(8,'servo_8')\">SET</button></td>";
content += "<td>Servo 7<br/><input class=\"pm_text\" type=\"text\" id=\"servo_7\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(7,'servo_7')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 9<br/><input class=\"pm_text\" type=\"text\" id=\"servo_9\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(9,'servo_9')\">SET</button></td>";
content += "<td>Servo 6<br/><input class=\"pm_text\" type=\"text\" id=\"servo_6\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(6,'servo_6')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 10<br/><input class=\"pm_text\" type=\"text\" id=\"servo_10\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(10,'servo_10')\">SET</button></td>";
content += "<td>Servo 5<br/><input class=\"pm_text\" type=\"text\" id=\"servo_5\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(5,'servo_5')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 11<br/><input class=\"pm_text\" type=\"text\" id=\"servo_11\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(11,'servo_11')\">SET</button></td>";
content += "<td>Servo 4<br/><input class=\"pm_text\" type=\"text\" id=\"servo_4\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(4,'servo_4')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 12<br/><input class=\"pm_text\" type=\"text\" id=\"servo_12\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(12,'servo_12')\">SET</button></td>";
content += "<td>Servo 3<br/><input class=\"pm_text\" type=\"text\" id=\"servo_3\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(3,'servo_3')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 13<br/><input class=\"pm_text\" type=\"text\" id=\"servo_13\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(13,'servo_13')\">SET</button></td>";
content += "<td>Servo 2<br/><input class=\"pm_text\" type=\"text\" id=\"servo_2\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(2,'servo_2')\">SET</button></td>";
content += "</tr>";
content += "<tr>";
content += "<td>Servo 14<br/><input class=\"pm_text\" type=\"text\" id=\"servo_14\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(14,'servo_14')\">SET</button></td>";
content += "<td>Servo 1<br/><input class=\"pm_text\" type=\"text\" id=\"servo_1\" value=\"0\"><button class=\"pm_btn\" type=\"button\" onclick=\"controlServo(1,'servo_1')\">SET</button></td>";
content += "</tr>";