Skip to content

Commit

Permalink
Curved-stats : fix for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RuffaloLavoisier committed May 26, 2022
1 parent c84d7af commit b11ae0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/apps/tools/OswAppKcalStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OswAppKcalStats : public OswApp {
uint8_t cursorPos = 6; // WeekDay position
void drawCurvedChart();
void showCurvedChart();
void readyValue(int type = 0, uint8_t cursor = 7, uint32_t* cursorValue = nullptr);
void readyValue(int type = 0, uint8_t cursor = 6, uint32_t* cursorValue = nullptr);
uint16_t weekValue[7] = {};
OswUI* ui;
};
Expand Down
15 changes: 2 additions & 13 deletions src/apps/tools/OswAppKcalStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ void OswAppKcalStats::readyValue(int type, uint8_t cursor, uint32_t* cursorValue
int curvedIdx = 0;
uint8_t graphRange = MIN_VALUE - MAX_VALUE;
uint16_t kcalGoal = OswConfigAllKeys::kcalPerDay.get();
for (int Index = ((weekday + 1 > 6) ? 0 : weekday + 1); Index != weekday; Index++, curvedIdx++) {
for (int Index = ((weekday + 1 > 6) ? 0 : weekday + 1); curvedIdx<7; Index++, curvedIdx++) {
if (Index > 6) Index = 0;

uint32_t weekDayValue = 0;
if (type == 0) {
weekDayValue = OswAppWatchfaceFitness::calculateKcalorie(hal->environment->getStepsOnDay(Index));
Expand All @@ -38,21 +37,11 @@ void OswAppKcalStats::readyValue(int type, uint8_t cursor, uint32_t* cursorValue
} else if (type == 3) {
weekDayValue = OswAppWatchfaceFitness::calculateKcalorie(hal->environment->getStepsOnDay(Index));
}
weekValue[curvedIdx] = weekDayValue;
weekValue[curvedIdx] = weekDayValue;
}
Serial.print(String(__FILE__) + ": Current weekValue - ");
for(size_t i = 0; i < 7; i++) {
Serial.print(weekValue[i]);
if(i!=6){
Serial.print(",");
}
else {
Serial.println(" -");
}
if (cursorValue != nullptr){
*cursorValue = weekValue[cursor];
}
}
}

void OswAppKcalStats::drawCurvedChart() {
Expand Down

0 comments on commit b11ae0e

Please sign in to comment.