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.
Diff: sensors/sensors.cpp
- Revision:
- 33:2dbbe198adaf
- Parent:
- 32:aee87dcaf7ca
- Child:
- 34:0a8ae7f92262
diff -r aee87dcaf7ca -r 2dbbe198adaf sensors/sensors.cpp
--- a/sensors/sensors.cpp Mon May 13 03:44:50 2019 +0000
+++ b/sensors/sensors.cpp Mon May 13 09:02:19 2019 +0000
@@ -2,6 +2,8 @@
#include "microinfinity.h"
#include "pinnames.h"
#include "moves.h"
+int RightOrLeft = 0;
+
//lowpass関係
const float kOldWeight = 0;
const float kOldWeightLight = 0.3; //filterの重み.軽いver
@@ -25,12 +27,11 @@
DigitalIn hand(pin_hand,PullUp);
DigitalIn switch_lo(pin_switch_lo,PullUp);
DigitalIn switch_li(pin_switch_li,PullUp);
-DigitalIn switch_LR(pin_switch_LR,PullUp);
-DigitalIn switch_modes[3]=
-{
- DigitalIn(pin_switch_modes[0],PullUp),
- DigitalIn(pin_switch_modes[1],PullUp),
- DigitalIn(pin_switch_modes[2],PullUp),
+InterruptIn switch_LR(pin_switch_LR,PullUp);
+DigitalIn switch_modes[3]= {
+ DigitalIn(pin_switch_modes[0],PullUp),
+ DigitalIn(pin_switch_modes[1],PullUp),
+ DigitalIn(pin_switch_modes[2],PullUp),
};
//InterruptIn mode4(pin_mode4,PullUp);
DigitalOut led4(LED4);
@@ -51,7 +52,7 @@
const char kFileName[] = "/local/sensors.csv";
Timer filetimer;
-/*int FileOpen() //1:異常終了
+int FileOpen() //1:異常終了
{
printf("file open\r\n");
if ((fp = fopen(kFileName, "w")) == NULL) {
@@ -61,7 +62,13 @@
fprintf(fp, "time[s], gyro[deg], hcsr04_forward[cm], hcsr04_back[cm], motor_lo[deg], motor_li[deg]\r\n");
filetimer.reset();
filetimer.start();
- mode4.rise(FileClose);//mode4ピンを上げげればfileclose
+ if(RightOrLeft) {
+ //rightなら
+ switch_LR.fall(FileClose);//left(0)にしたらclose
+ } else {
+ //left
+ switch_LR.rise(FileClose);//left(0)にしたらclose
+ }
return 0;
}
@@ -86,7 +93,8 @@
filetimer.stop();
if(fp != NULL)
fclose(fp);
-};*/
+};
+
void TickerSetUp()