Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: simonmicro <[email protected]>
  • Loading branch information
simonmicro committed Jan 13, 2025
1 parent 6531f79 commit c323002
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion include/apps/watchfaces/OswAppWatchfaceDigital.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OswAppWatchfaceDigital: public OswAppV2 {
static void drawSteps();
static void digitalWatch(short timeZone, uint8_t fontSize, uint8_t dateCoordY, uint8_t timeCoordY);
static void timeOutput(uint8_t hour, uint8_t minute, uint8_t second, bool showSecond = true);
static void dateOutput(uint16_t yearInt, uint8_t monthInt, uint8_t dayInt);
static void dateOutput(uint16_t year, uint8_t month, uint8_t day);
static void displayWeekDay3(const char* weekday);

private:
Expand Down
12 changes: 6 additions & 6 deletions include/services/OswServiceTaskBLEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OswServiceTaskBLEServer : public OswServiceTask {
};
class CurrentTimeCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
uint8_t bytesCurrentTime[9+1]; // will be read from (9 exact-time-256, 1 reason)
uint8_t bytes[9+1]; // will be read from (9 exact-time-256, 1 reason)
};
class FirmwareRevisionCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
Expand All @@ -69,23 +69,23 @@ class OswServiceTaskBLEServer : public OswServiceTask {
};
class StepsTodayCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
uint8_t bytesStepsToday[4]; // this is a 4-byte array of a uint_32_t number
uint8_t bytes[4]; // this is a 4-byte array of a uint_32_t number
};
class StepsTotalWeekCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
uint8_t bytesStepsTotalWeek[4]; // this is a 4-byte array of a uint_32_t number
uint8_t bytes[4]; // this is a 4-byte array of a uint_32_t number
};
class StepsTotalCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
uint8_t bytesStepsTotal[4]; // this is a 4-byte array of a uint_32_t number
uint8_t bytes[4]; // this is a 4-byte array of a uint_32_t number
};
class StepsAverageCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
uint8_t bytesStepsAverage[4]; // this is a 4-byte array of a uint_32_t number
uint8_t bytes[4]; // this is a 4-byte array of a uint_32_t number
};
class StepsDayHistoryCharacteristicCallbacks: public NimBLECharacteristicCallbacks {
void onRead(NimBLECharacteristic* pCharacteristic);
uint8_t bytesStepsDayHistory[4 * 7]; // this is a 28-byte array of a seven uint_32_t number
uint8_t bytes[4 * 7]; // this is a 28-byte array of seven uint_32_t numbers
};


Expand Down
26 changes: 13 additions & 13 deletions src/apps/watchfaces/OswAppWatchfaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,36 @@ void OswAppWatchfaceDigital::displayWeekDay3(const char* weekday) {
hal->gfx()->print(weekday3);
}

void OswAppWatchfaceDigital::dateOutput(uint16_t yearInt, uint8_t monthInt, uint8_t dayInt) {
void OswAppWatchfaceDigital::dateOutput(uint16_t year, uint8_t month, uint8_t day) {
OswHal* hal = OswHal::getInstance();
switch (OswAppWatchfaceDigital::getDateFormat()) {
case 0:
hal->gfx()->printDecimal(monthInt, 2);
hal->gfx()->printDecimal(month, 2);
hal->gfx()->print("/");
hal->gfx()->printDecimal(dayInt, 2);
hal->gfx()->printDecimal(day, 2);
hal->gfx()->print("/");
hal->gfx()->print(yearInt);
hal->gfx()->print(year);
break;
case 1:
hal->gfx()->printDecimal(dayInt, 2);
hal->gfx()->printDecimal(day, 2);
hal->gfx()->print(".");
hal->gfx()->printDecimal(monthInt, 2);
hal->gfx()->printDecimal(month, 2);
hal->gfx()->print(".");
hal->gfx()->print(yearInt);
hal->gfx()->print(year);
break;
case 2:
hal->gfx()->print(yearInt);
hal->gfx()->print(year);
hal->gfx()->print(".");
hal->gfx()->printDecimal(monthInt, 2);
hal->gfx()->printDecimal(month, 2);
hal->gfx()->print("/");
hal->gfx()->printDecimal(dayInt, 2);
hal->gfx()->printDecimal(day, 2);
break;
case 3:
hal->gfx()->printDecimal(dayInt, 2);
hal->gfx()->printDecimal(day, 2);
hal->gfx()->print("/");
hal->gfx()->printDecimal(monthInt, 2);
hal->gfx()->printDecimal(month, 2);
hal->gfx()->print("/");
hal->gfx()->print(yearInt);
hal->gfx()->print(year);
break;
}
}
Expand Down
72 changes: 36 additions & 36 deletions src/services/OswServiceTaskBLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,17 @@ void OswServiceTaskBLEServer::CurrentTimeCharacteristicCallbacks::onRead(NimBLEC
OswTime oswTime;
OswHal::getInstance()->getTime(offset, oswTime);

this->bytesCurrentTime[0] = (uint8_t) oswDate.year; // Exact Time 256 -> Day Date Time -> Date Time -> Year #1
this->bytesCurrentTime[1] = (uint8_t) (oswDate.year >> 8); // Exact Time 256 -> Day Date Time -> Date Time -> Year #2
this->bytesCurrentTime[2] = (uint8_t) oswDate.month; // Exact Time 256 -> Day Date Time -> Date Time -> Month
this->bytesCurrentTime[3] = (uint8_t) oswDate.day; // Exact Time 256 -> Day Date Time -> Date Time -> Day
this->bytesCurrentTime[4] = (uint8_t) oswTime.hour; // Exact Time 256 -> Day Date Time -> Date Time -> Hours
this->bytesCurrentTime[5] = (uint8_t) oswTime.minute; // Exact Time 256 -> Day Date Time -> Date Time -> Minutes
this->bytesCurrentTime[6] = (uint8_t) oswTime.second; // Exact Time 256 -> Day Date Time -> Date Time -> Seconds
this->bytesCurrentTime[7] = (uint8_t) (oswDate.weekDay == 0 ? 7 : oswDate.weekDay); // Exact Time 256 -> Day Date Time -> Day of Week
this->bytesCurrentTime[8] = 0b00000000; // Exact Time 256 -> Fractions256
this->bytesCurrentTime[9] = 0b00000001; // Adjust Reason: External Reference Time Update
pCharacteristic->setValue(this->bytesCurrentTime, sizeof(this->bytesCurrentTime));
this->bytes[0] = (uint8_t) oswDate.year; // Exact Time 256 -> Day Date Time -> Date Time -> Year #1
this->bytes[1] = (uint8_t) (oswDate.year >> 8); // Exact Time 256 -> Day Date Time -> Date Time -> Year #2
this->bytes[2] = (uint8_t) oswDate.month; // Exact Time 256 -> Day Date Time -> Date Time -> Month
this->bytes[3] = (uint8_t) oswDate.day; // Exact Time 256 -> Day Date Time -> Date Time -> Day
this->bytes[4] = (uint8_t) oswTime.hour; // Exact Time 256 -> Day Date Time -> Date Time -> Hours
this->bytes[5] = (uint8_t) oswTime.minute; // Exact Time 256 -> Day Date Time -> Date Time -> Minutes
this->bytes[6] = (uint8_t) oswTime.second; // Exact Time 256 -> Day Date Time -> Date Time -> Seconds
this->bytes[7] = (uint8_t) (oswDate.weekDay == 0 ? 7 : oswDate.weekDay); // Exact Time 256 -> Day Date Time -> Day of Week
this->bytes[8] = 0b00000000; // Exact Time 256 -> Fractions256
this->bytes[9] = 0b00000001; // Adjust Reason: External Reference Time Update
pCharacteristic->setValue(this->bytes, sizeof(this->bytes));
}

void OswServiceTaskBLEServer::FirmwareRevisionCharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic) {
Expand All @@ -331,58 +331,58 @@ void OswServiceTaskBLEServer::HardwareRevisionCharacteristicCallbacks::onRead(Ni
void OswServiceTaskBLEServer::StepsTodayCharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic) {
uint32_t stepsToday = OswHal::getInstance()->environment()->getStepsToday();

this->bytesStepsToday[0] = (uint8_t) stepsToday;
this->bytesStepsToday[1] = (uint8_t) (stepsToday >> 8);
this->bytesStepsToday[2] = (uint8_t) (stepsToday >> 16);
this->bytesStepsToday[3] = (uint8_t) (stepsToday >> 24);
this->bytes[0] = (uint8_t) stepsToday;
this->bytes[1] = (uint8_t) (stepsToday >> 8);
this->bytes[2] = (uint8_t) (stepsToday >> 16);
this->bytes[3] = (uint8_t) (stepsToday >> 24);

pCharacteristic->setValue(this->bytesStepsToday, sizeof(this->bytesStepsToday));
pCharacteristic->setValue(this->bytes, sizeof(this->bytes));
}

void OswServiceTaskBLEServer::StepsTotalCharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic) {
uint32_t stepsTotal = OswHal::getInstance()->environment()->getStepsTotal();

this->bytesStepsTotal[0] = (uint8_t) stepsTotal;
this->bytesStepsTotal[1] = (uint8_t) (stepsTotal >> 8);
this->bytesStepsTotal[2] = (uint8_t) (stepsTotal >> 16);
this->bytesStepsTotal[3] = (uint8_t) (stepsTotal >> 24);
this->bytes[0] = (uint8_t) stepsTotal;
this->bytes[1] = (uint8_t) (stepsTotal >> 8);
this->bytes[2] = (uint8_t) (stepsTotal >> 16);
this->bytes[3] = (uint8_t) (stepsTotal >> 24);

pCharacteristic->setValue(this->bytesStepsTotal, sizeof(this->bytesStepsTotal));
pCharacteristic->setValue(this->bytes, sizeof(this->bytes));
}

void OswServiceTaskBLEServer::StepsTotalWeekCharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic) {
uint32_t stepsTotalWeek = OswHal::getInstance()->environment()->getStepsTotalWeek();

this->bytesStepsTotalWeek[0] = (uint8_t) stepsTotalWeek;
this->bytesStepsTotalWeek[1] = (uint8_t) (stepsTotalWeek >> 8);
this->bytesStepsTotalWeek[2] = (uint8_t) (stepsTotalWeek >> 16);
this->bytesStepsTotalWeek[3] = (uint8_t) (stepsTotalWeek >> 24);
this->bytes[0] = (uint8_t) stepsTotalWeek;
this->bytes[1] = (uint8_t) (stepsTotalWeek >> 8);
this->bytes[2] = (uint8_t) (stepsTotalWeek >> 16);
this->bytes[3] = (uint8_t) (stepsTotalWeek >> 24);

pCharacteristic->setValue(this->bytesStepsTotalWeek, sizeof(this->bytesStepsTotalWeek));
pCharacteristic->setValue(this->bytes, sizeof(this->bytes));
}
#ifdef OSW_FEATURE_STATS_STEPS
void OswServiceTaskBLEServer::StepsAverageCharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic) {
uint32_t stepsAverage = OswHal::getInstance()->environment()->getStepsAverage();

this->bytesStepsAverage[0] = (uint8_t) stepsAverage;
this->bytesStepsAverage[1] = (uint8_t) (stepsAverage >> 8);
this->bytesStepsAverage[2] = (uint8_t) (stepsAverage >> 16);
this->bytesStepsAverage[3] = (uint8_t) (stepsAverage >> 24);
this->bytes[0] = (uint8_t) stepsAverage;
this->bytes[1] = (uint8_t) (stepsAverage >> 8);
this->bytes[2] = (uint8_t) (stepsAverage >> 16);
this->bytes[3] = (uint8_t) (stepsAverage >> 24);

pCharacteristic->setValue(this->bytesStepsAverage, sizeof(this->bytesStepsAverage));
pCharacteristic->setValue(this->bytes, sizeof(this->bytes));
}

void OswServiceTaskBLEServer::StepsDayHistoryCharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic) {

for (uint8_t indexOfWeek = 0; indexOfWeek < 7; indexOfWeek++) {
uint32_t value = OswHal::getInstance()->environment()->getStepsOnDay(indexOfWeek, false);
this->bytesStepsDayHistory[0 + indexOfWeek * 4] = (uint8_t) value;
this->bytesStepsDayHistory[1 + indexOfWeek * 4] = (uint8_t) (value >> 8);
this->bytesStepsDayHistory[2 + indexOfWeek * 4] = (uint8_t) (value >> 16);
this->bytesStepsDayHistory[3 + indexOfWeek * 4] = (uint8_t) (value >> 24);
this->bytes[0 + indexOfWeek * 4] = (uint8_t) value;
this->bytes[1 + indexOfWeek * 4] = (uint8_t) (value >> 8);
this->bytes[2 + indexOfWeek * 4] = (uint8_t) (value >> 16);
this->bytes[3 + indexOfWeek * 4] = (uint8_t) (value >> 24);
}

pCharacteristic->setValue(this->bytesStepsDayHistory, sizeof(this->bytesStepsDayHistory));
pCharacteristic->setValue(this->bytes, sizeof(this->bytes));
}
#endif
#endif
Expand Down

0 comments on commit c323002

Please sign in to comment.