![](/media/cache/profiles/90a82bf94b4c5981e7e68ff425e519f3.50x50_q85.jpg)
LEDの点滅や、ブザーのOn,Offの周期測定をおこなう。 搬送波の周期は測定できない(10ms周期以上のON,OFF)
Dependencies: AQM0802A DigitalSw mbed
Diff: priodMsurement.cpp
- Revision:
- 4:001603e48dc8
- Parent:
- 3:2a8fdcc54c95
- Child:
- 5:f137bb7eeda6
--- a/priodMsurement.cpp Mon Jun 05 12:31:15 2017 +0000 +++ b/priodMsurement.cpp Tue Jun 06 13:15:07 2017 +0000 @@ -14,8 +14,9 @@ int32_t hiCompleteTime; // 1/1 [ms]/count int32_t loCompleteTime; + int32_t D_surement[50][2]; // LCD表示用測定値保管 -uint8_t P_surement = 0; // D_surement[ここ][] のポインタ +int8_t P_surement = 0; // D_surement[ここ][] のポインタ #define Z_nonSurement (-1) // D_surementの最終位置(不定値) int8_t beforeLevel = -1; // 0:Lo 1:Hi -1:timeOut(non Pluse) @@ -32,25 +33,26 @@ } else { D_surement[P_surement][hilo] = surement; D_surement[P_surement + 1][hilo] = (int32_t)Z_initialSurement; - - if(hilo == Z_loSurement){ + + if(hilo == Z_loSurement) { P_surement++; - } + } } } InterruptIn lightIn(p22); DigitalOut monitor(LED4); - -bool surementData(uint8_t p, int32_t *hiPriod, int32_t *loPriod) +bool surementData(int8_t *p, int32_t *hiPriod, int32_t *loPriod) { bool ans = beforeLevel == -1 ? true : false; - - *hiPriod = D_surement[p][Z_hiSurement]; - *loPriod = D_surement[p][Z_loSurement]; - + if(ans == false) { + *p = P_surement; + } + *hiPriod = D_surement[*p][Z_hiSurement]; + *loPriod = D_surement[*p][Z_loSurement]; + return (ans); - } +} void priodMsurementMain(void) { @@ -63,14 +65,16 @@ hiTimer.reset(); if(beforeLevel == 0) { loCompleteTime = loTimer.read_ms(); - surementPut(Z_loSurement, loCompleteTime); + surementPut(Z_loSurement, loCompleteTime); + beforeLevel = 1; printf("hi = %d, lo = %d\r\n",hiCompleteTime, loCompleteTime); } if(beforeLevel == -1) { +// if((beforeLevel == -1) && (F_start == true)) { printf("start\r\n"); - surementPut(Z_initialSurement, (int32_t)Z_initialSurement); + surementPut(Z_initialSurement, (int32_t)Z_initialSurement); + beforeLevel = 1; } - beforeLevel = 1; monitor = 1; } @@ -79,7 +83,7 @@ loTimer.reset(); if(beforeLevel == 1) { hiCompleteTime = hiTimer.read_ms(); - surementPut(Z_hiSurement, hiCompleteTime); + surementPut(Z_hiSurement, hiCompleteTime); } beforeLevel = 0; monitor = 0;