electric baka
/
BLENano2_AD_Serial
for BLE Nano v2 INPUT : A/D, OUTPUT : USB Serial
Diff: main.cpp
- Revision:
- 2:2b070a0b5e17
- Parent:
- 1:0cf0e8648390
--- a/main.cpp Thu Sep 20 08:08:26 2018 +0000 +++ b/main.cpp Thu Sep 20 08:18:05 2018 +0000 @@ -17,21 +17,6 @@ //Definition //------------------------------------------------------------ #define ANALOG_IN_PIN1 P0_5 -#define TICKER_TIME 1000 //1000[us] = 1[ms] - -//HeartRate -int timer_num = 0; -int threshold_v = 650; -int threshold_t = 300; - - -//====================================================================== -//onTimeout -//====================================================================== -void m_status_check_handle(void) -{ - timer_num ++; -} //------------------------------------------------------------ @@ -44,29 +29,14 @@ { pc.baud(9600); char str[10]; - - //Timer Setting [us] - Ticker ticker; - ticker.attach_us(m_status_check_handle, TICKER_TIME); - - int timer_ms; - - while(1) - { + + while (true) { float s = ANALOG1; uint16_t value = s * 1024; - - //--------------------------------------------------------------------------------------------- - //Detect HeartRate Peak - //--------------------------------------------------------------------------------------------- - timer_ms = TICKER_TIME/1000 * timer_num; - if(value >= threshold_v && timer_ms > threshold_t) - { - //clear timer_num - timer_num = 0; - - sprintf(str, "%d\r\n", timer_ms); - pc.printf(str); - } + + sprintf(str, "%d\r\n", value); + pc.printf(str); + + wait_ms(1); } } \ No newline at end of file