diff --git a/library.properties b/library.properties index 3729fda..ff02053 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=JJYReceiver -version=0.7.5 +version=0.8.0 author=BlueCrescent maintainer=BlueCrescent sentence=JJY standard radio signal wave receiver library. paragraph=This library returns UTC date time of time_t type. Negative logic output type JJY receiver supported. Tested with JJY receiver IC MAS6181B with lgt8f328p/esp32. category=Communication url=https://github.com/Blue-Crescent/JJYReceiver.git -architectures=* +architectures=* \ No newline at end of file diff --git a/src/JJYReceiver.cpp b/src/JJYReceiver.cpp index 626491a..0d19658 100644 --- a/src/JJYReceiver.cpp +++ b/src/JJYReceiver.cpp @@ -160,10 +160,10 @@ void JJYReceiver::delta_tick(){ data = digitalRead(datapin)==HIGH ? 1 : 0; shift_in(data, sampling, N); sampleindex++; - if(sampleindex == 100){ + if(95 < sampleindex){ sampleindex = 0; clear(sampling, N); - }else if(sampleindex == 90){ // クロックが揺らぐので100sampleしっかりないため少し間引く + }else if(sampleindex == 95){ #ifdef DEBUG_BUILD debug2(); #endif @@ -224,22 +224,16 @@ void JJYReceiver::delta_tick(){ } void JJYReceiver::jjy_receive(){ - unsigned long time = millis(); - unsigned long window; if(state == TIMEVALID) return; bool data = digitalRead(datapin); // ピンの状態を読み取る if (data == LOW) { if(monitorpin != -1) digitalWrite(monitorpin,LOW); - window = time - fallingtime[0]; - if(990 < window){ + if(sampleindex < 20){ sampleindex = 0; clear(sampling,N); } - fallingtime[1] = fallingtime[0]; - fallingtime[0] = time; }else{ if(monitorpin != -1) digitalWrite(monitorpin,HIGH); - } } uint8_t JJYReceiver::freq(uint8_t freq){ @@ -289,7 +283,7 @@ void JJYReceiver::monitor(int pin){ } void JJYReceiver::begin(){ - init(); + init(); } void JJYReceiver::stop(){ @@ -357,6 +351,8 @@ void JJYReceiver::debug(){ case TIMEVALID: DEBUG_PRINT("TIMEVALID"); break; + default: + break; } DEBUG_PRINT(" "); DEBUG_PRINT((int)jjypayloadlen[jjystate]); diff --git a/src/JJYReceiver.h b/src/JJYReceiver.h index 80be122..286dc6d 100644 --- a/src/JJYReceiver.h +++ b/src/JJYReceiver.h @@ -103,9 +103,9 @@ class JJYReceiver { volatile uint8_t sampleindex = 0; volatile uint8_t sampling [N]; volatile int8_t timeavailable = -1; - volatile const uint8_t CONST_PM [N] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00}; - volatile const uint8_t CONST_H [N] = {0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - volatile const uint8_t CONST_L [N] = {0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + volatile const uint8_t CONST_PM [N] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00}; + volatile const uint8_t CONST_H [N] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00}; + volatile const uint8_t CONST_L [N] = {0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; volatile time_t globaltime = 0; volatile time_t received_time = -1;