Skip to content

Commit

Permalink
Merge pull request #8 from Blue-Crescent/receive
Browse files Browse the repository at this point in the history
Receive
  • Loading branch information
Blue-Crescent authored Feb 19, 2024
2 parents fafa3c6 + f80381d commit 3896603
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=JJYReceiver
version=0.7.5
version=0.8.0
author=BlueCrescent
maintainer=BlueCrescent <[email protected]>
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=*
16 changes: 6 additions & 10 deletions src/JJYReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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){
Expand Down Expand Up @@ -289,7 +283,7 @@ void JJYReceiver::monitor(int pin){
}

void JJYReceiver::begin(){
init();
init();
}

void JJYReceiver::stop(){
Expand Down Expand Up @@ -357,6 +351,8 @@ void JJYReceiver::debug(){
case TIMEVALID:
DEBUG_PRINT("TIMEVALID");
break;
default:
break;
}
DEBUG_PRINT(" ");
DEBUG_PRINT((int)jjypayloadlen[jjystate]);
Expand Down
6 changes: 3 additions & 3 deletions src/JJYReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3896603

Please sign in to comment.