風速計用プログラムです。動きません……
Dependencies: mbed
Fork of mbed_fuusoku by
やっぱり動きます(InterruptInをp30に設定すると読まなくなるボードがあります……)。最新のは校正済みです。
Diff: main.cpp
- Revision:
- 0:51b2d6484a7d
- Child:
- 1:d802daeec8f6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 19 03:49:07 2016 +0000 @@ -0,0 +1,55 @@ +//計器プログラム +#include "mbed.h" +#include "Fusokukei.h" + +#define AIR_LOOP_TIME 0.01 + +Serial pc(USBTX,USBRX); + +InterruptIn FusokukeiPin(p21); +Ticker FusokukeiTicker; +Fusokukei air; +volatile int air_kaitensu= 0; + +DigitalOut led(LED1); +DigitalOut led4(LED4); +int time_counter; + +void air_countUp(); +void call_calcAirSpeed(); +void init(); +void FusokukeiInit(); + +void air_countUp(){ + air_kaitensu++; +} + +void call_calcAirSpeed(){ + air.calcAirSpeed(air_kaitensu); + air_kaitensu = 0; +} + +void init(){ + FusokukeiInit(); + led4 = 0; + time_counter = 0; +} + +void FusokukeiInit(){ + FusokukeiPin.rise(air_countUp); + FusokukeiTicker.attach(&call_calcAirSpeed, AIR_LOOP_TIME); +} + +int main(){ + init(); + while(1){ + pc.printf("test %d\n\r",time_counter); + pc.printf("air_kaitensu: %d\n\r",air_kaitensu); + pc.printf("%f\n\r",airSpeed); + led4 = 1; + wait(0.2); + led4 = 0; + wait(0.2); + time_counter++; + } +} \ No newline at end of file