diff --git a/src/JJYReceiver.cpp b/src/JJYReceiver.cpp index f143269..7e979a3 100644 --- a/src/JJYReceiver.cpp +++ b/src/JJYReceiver.cpp @@ -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; @@ -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; } @@ -243,11 +244,11 @@ void JJYReceiver::monitor(int pin){ } void JJYReceiver::begin(enum MODE updatemode){ - mode = updatemode; + mode = static_cast(updatemode); init(); } void JJYReceiver::begin(){ - begin(ONETIME); + begin(JJY_ONETIME); } void JJYReceiver::stop(){ diff --git a/src/JJYReceiver.h b/src/JJYReceiver.h index 921c23d..4faa27f 100644 --- a/src/JJYReceiver.h +++ b/src/JJYReceiver.h @@ -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}; @@ -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; @@ -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"); } } };