Skip to content

Commit

Permalink
Bugfix for doy int size
Browse files Browse the repository at this point in the history
  • Loading branch information
Blue-Crescent committed Feb 26, 2024
1 parent 665ffb9 commit 5a9d3ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=JJYReceiver
version=0.7.4
version=0.8.3
author=BlueCrescent
maintainer=BlueCrescent <[email protected]>
sentence=JJY standard radio signal wave receiver library.
Expand Down
5 changes: 4 additions & 1 deletion src/JJYReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void JJYReceiver::stop(){
}

//timeinfo.tm_yday = // Day of the year is not implmented in Arduino time.h
void JJYReceiver::calculateDate(uint16_t year, uint8_t dayOfYear,volatile uint8_t *month,volatile uint8_t *day) {
void JJYReceiver::calculateDate(uint16_t year, uint16_t dayOfYear,volatile uint8_t *month,volatile uint8_t *day) {
uint8_t daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
// 閏年の場合、2月は29日
Expand Down Expand Up @@ -351,6 +351,9 @@ void JJYReceiver::debug(){
case TIMEVALID:
DEBUG_PRINT("TIMEVALID");
break;
case TIMETICK:
DEBUG_PRINT("TIMETICK");
break;
default:
break;
}
Expand Down
11 changes: 5 additions & 6 deletions src/JJYReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ class JJYReceiver {
volatile enum STATE state = INIT;
volatile enum JJYSTATE jjystate = JJY_INIT;
volatile uint8_t rcvcnt = 0;
volatile unsigned long fallingtime[2];
volatile const int8_t datapin,selpin,ponpin;
volatile const int8_t datapin,selpin,ponpin;
volatile int8_t monitorpin = -1;
volatile uint8_t frequency = 0;
volatile uint8_t markercount = 0;
Expand All @@ -103,8 +102,8 @@ 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,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_PM [N] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,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,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

volatile time_t globaltime = 0;
Expand All @@ -127,7 +126,7 @@ class JJYReceiver {
bool power();
uint8_t freq(uint8_t freq);
void monitor(int pin);
void calculateDate(uint16_t year, uint8_t dayOfYear,volatile uint8_t *month,volatile uint8_t *day);
void calculateDate(uint16_t year, uint16_t dayOfYear,volatile uint8_t *month,volatile uint8_t *day);
int distance(const volatile uint8_t* arr1,volatile uint8_t* arr2, int size);
int max_of_three(uint8_t a, uint8_t b, uint8_t c);
bool calculateParity(uint8_t value, uint8_t bitLength, uint8_t expectedParity);
Expand Down Expand Up @@ -161,7 +160,7 @@ class JJYReceiver {
return true;
}
time_t updateTimeInfo(JJYData* jjydata, int8_t index, int8_t offset) {
int year, yday;
uint16_t year, yday;
year = (((jjydata[index].bits.year & 0xf0) >> 4) * 10 + (jjydata[index].bits.year & 0x0f)) + 2000;
timeinfo.tm_year = year - 1900; //
yday = ((((jjydata[index].bits.doyh >> 5) & 0x0002)) * 100) + (((jjydata[index].bits.doyh & 0x000f)) * 10) + jjydata[index].bits.doyl;
Expand Down

0 comments on commit 5a9d3ed

Please sign in to comment.