Skip to content

Commit

Permalink
Hasty update
Browse files Browse the repository at this point in the history
  • Loading branch information
Blue-Crescent committed Feb 15, 2024
1 parent 5177d76 commit 2396c8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/JJYReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ time_t JJYReceiver::getTime() {
switch(state){
case RECEIVE: // Intermediate update (1st receive update)
if(timeavailable == -1) return -1;
if(mode == HASTYUPDATE){
hastyupdate();
if(mode == JJY_HASTYUPDATE){
//JJY_HASTYUPDATE();
globaltime = updateTimeInfo(jjydata,rcvcnt,1);
}
timeavailable = -1;
return -1;
Expand Down Expand Up @@ -134,9 +135,9 @@ void JJYReceiver::delta_tick(){
rcvcnt = (rcvcnt + 1) % VERIFYLOOP;
if(lencheck(jjypayloadlen)){ // Payload Length check
timeinfo.tm_sec = 1; //
settime(rcvcnt);
if(!minCheck(rcvcnt)) break;
if(!hourCheck(rcvcnt)) break;
settime(rcvcnt);
timeCheck();
timeavailable = rcvcnt;
}
Expand Down Expand Up @@ -243,11 +244,11 @@ void JJYReceiver::monitor(int pin){
}

void JJYReceiver::begin(enum MODE updatemode){
mode = updatemode;
mode = static_cast<MODE>(updatemode);
init();
}
void JJYReceiver::begin(){
begin(ONETIME);
begin(JJY_ONETIME);
}

void JJYReceiver::stop(){
Expand Down
8 changes: 4 additions & 4 deletions src/JJYReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ typedef union {
} bits;
} JJYData;

enum MODE {JJY_HASTYUPDATE=1,JJY_ONETIME=0,JJY_CONSERVATIVE=2};
class JJYReceiver {
enum MODE {HASTYUPDATE,ONETIME,CONSERVATIVE};
enum STATE {INIT,RECEIVE,TIMEVALID,TIMETICK};
enum RELIABILITY {NONFIRST=-2,UNKNOWN=0x0,MINPARITYOK=0x1,HOURPARITYOK=0x2,LENGTHOK=0x4}; // UNKNOWN = 1st reception, NONFIRST = twice~ reception
enum JJYSTATE {JJY_INIT=-1,JJY_MIN=0,JJY_HOUR=1,JJY_DOYH=2,JJY_DOYL=3,JJY_YEAR=4,JJY_WEEK=5};
Expand All @@ -88,7 +88,7 @@ class JJYReceiver {
JJYData jjydata[VERIFYLOOP];
JJYData last_jjydata[1];
volatile enum STATE state = INIT;
volatile enum MODE mode = HASTYUPDATE;
volatile enum MODE mode = JJY_HASTYUPDATE;

volatile enum JJYSTATE jjystate = JJY_INIT;
volatile uint8_t jjyposition= 0;
Expand Down Expand Up @@ -261,13 +261,13 @@ class JJYReceiver {
switch(jjystate){
case JJY_YEAR:
globaltime = updateTimeInfo(jjydata,rcvcnt,1);
DEBUG_PRINTLN("HASTY UPDATE");
DEBUG_PRINTLN("HASTY UPDATE:TIME");
break;
}
}
if(jjystate == JJY_WEEK && jjypayloadlen[JJY_YEAR] == 9){ // Yearの反映
globaltime = updateTimeInfo(jjydata,rcvcnt,1);
DEBUG_PRINTLN("HASTY UPDATE");
DEBUG_PRINTLN("HASTY UPDATE:YEAR");
}
}
};
Expand Down

0 comments on commit 2396c8e

Please sign in to comment.