Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifies API usage #405

Merged
merged 9 commits into from
Oct 22, 2024
Merged

Simplifies API usage #405

merged 9 commits into from
Oct 22, 2024

Conversation

RuffaloLavoisier
Copy link
Member

@RuffaloLavoisier RuffaloLavoisier commented Sep 29, 2024

Update getDate, getTime API with #403

How to use

OswTime oswTime = {  };
hal->getLocalTime(oswTime);

Each element can be referred to as a sub-element. It returns data for a time or date and can be used by selecting the necessary elements.

Summary

internal getUTCTime API

void getUTCTime(uint32_t* hour, uint32_t* minute, uint32_t* second);

to

void getUTCTime(OswTime& oswTime); // New API

internal getTime API

void getTime(time_t& offset, uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon = nullptr);

to

void getTime(time_t& offset, OswTime& oswTime); // New API

merge internal getDate API

void getDate(time_t& offset, uint32_t* day, uint32_t* weekDay);
void getDate(time_t& offset, uint32_t* day, uint32_t* month, uint32_t* year);

to

void getDate(time_t& offset, OswDate& oswDate); // New API

update getLocalTime API

inline void getLocalTime(uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon = nullptr) {
    this->getTime(this->timezoneOffsetPrimary, hour, minute, second, afterNoon);
}

to

inline void getLocalTime(OswTime& oswTime) {
    this->getTime(this->timezoneOffsetPrimary, oswTime);
}

merge getLocalDate API

inline void getLocalDate(uint32_t* day, uint32_t* weekDay) {
    this->getDate(this->timezoneOffsetPrimary, day, weekDay);
};
inline void getLocalDate(uint32_t* day, uint32_t* month, uint32_t* year) {
    this->getDate(this->timezoneOffsetPrimary, day, month, year);
};

to

inline void getLocalDate(OswDate& oswDate) {
    this->getDate(this->timezoneOffsetPrimary, oswDate);
};

update getDualTime API

inline void getDualTime(uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon = nullptr) {
    this->getTime(this->timezoneOffsetSecondary, hour, minute, second, afterNoon);
}

to

inline void getDualTime(OswTime& oswTime) {
    this->getTime(this->timezoneOffsetSecondary, oswTime);
}

merge getDualDate API

inline void getDualDate(uint32_t* day, uint32_t* weekDay) {
    this->getDate(this->timezoneOffsetSecondary, day, weekDay);
};
inline void getDualDate(uint32_t* day, uint32_t* month, uint32_t* year) {
    this->getDate(this->timezoneOffsetSecondary, day, month, year);
};

to

inline void getDualDate(OswDate& oswDate) {
    this->getDate(this->timezoneOffsetPrimary, oswDate);
};

update getWeekDay API

const char* weekDay = OswHal::getInstance()->getWeekDay.at(day);

- update getDate, getTime API
@RuffaloLavoisier
Copy link
Member Author

Emulator is working !

@RuffaloLavoisier RuffaloLavoisier added ⭐ enhancement New feature or request src/osw-app This PR / issue impacts the current release of the OS src/core src/osw-watchface labels Sep 29, 2024
@simonmicro
Copy link
Member

Some thoughts of mine:

  • You use OSW_TIME* oswTime in the function signatures a lot. I think, as this is mostly the only parameter, it should be required and not optional - so use OSW_TIME& oswTime instead.
  • Class naming convention. OSW_TIME implies a pre-processor define or global constant. Maybe use OswTime for the struct/class you are adding.

include/osw_hal.h Outdated Show resolved Hide resolved
include/osw_hal.h Outdated Show resolved Hide resolved
include/osw_hal.h Outdated Show resolved Hide resolved
src/apps/tools/OswAppDistStats.cpp Outdated Show resolved Hide resolved
src/apps/tools/OswAppDistStats.cpp Outdated Show resolved Hide resolved
src/apps/watchfaces/OswAppWatchface.cpp Outdated Show resolved Hide resolved
src/hal/time.cpp Outdated Show resolved Hide resolved
src/hal/time.cpp Outdated Show resolved Hide resolved
include/osw_hal.h Outdated Show resolved Hide resolved
src/apps/tools/OswAppStepStats.cpp Outdated Show resolved Hide resolved
src/hal/time.cpp Outdated Show resolved Hide resolved
@simonmicro simonmicro mentioned this pull request Oct 14, 2024
@simonmicro
Copy link
Member

Hey, the changes to the code itself look fine - but, as expected, LUA is still not compatible with the deprecation attribute. I would recommend you to revert that commit for now and move it into #366, as that PR also aims to fix that.

RuffaloLavoisier added a commit that referenced this pull request Oct 18, 2024
RuffaloLavoisier added a commit that referenced this pull request Oct 18, 2024
- Gets the name of the day of the week that the cursor points to
@RuffaloLavoisier
Copy link
Member Author

@simonmicro Ready to merge.

@RuffaloLavoisier RuffaloLavoisier merged commit 59c0fc7 into develop Oct 22, 2024
133 checks passed
@RuffaloLavoisier RuffaloLavoisier deleted the feature/DateTimeAPI branch October 22, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src/core src/osw-app This PR / issue impacts the current release of the OS src/osw-watchface ⭐ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants