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

Can osDelay be emulated via getTimeStamp? #9

Open
puzrin opened this issue Jul 18, 2021 · 7 comments
Open

Can osDelay be emulated via getTimeStamp? #9

puzrin opened this issue Jul 18, 2021 · 7 comments

Comments

@puzrin
Copy link

puzrin commented Jul 18, 2021

PolicyEngine already has getTimeStamp, but still requires osDelay for rare cases. Can osDelay be emulated via getTimeStamp internally?

Reasons: simplify use without RTOS.

@Ralim
Copy link
Owner

Ralim commented Jul 18, 2021

Could it be implemented that way: yes
Why isn't it: Don't want to lock up the thread for that long when using an RTOS. Also harder to ensure timing match if using extra wait states and ensuring the outer object is called often enough. Both are rare cases, so odds of running into it is low.
Also, almost all HAL's provide this exact function already, so its literally one extra param.

@puzrin puzrin closed this as completed Jul 18, 2021
@puzrin
Copy link
Author

puzrin commented Jul 18, 2021

How about constructor variants? If osDelay not passed => emulate

@Ralim
Copy link
Owner

Ralim commented Jul 18, 2021

Why though 😂
Like, why should a library be responsible for this?
Given this is primarily going to be used on small devices, the duplicated code doesnt feel wise :)

@puzrin
Copy link
Author

puzrin commented Jul 18, 2021

Is library for "hardware first" or for "user first"? I can operate in any context :). But as OSS developper, wishing to make project popular, i'd prefer "user first" approach when possible.

the duplicated code doesn't feel wise :)

IMO such statements are discuss-able only when metrics/bounds available. Without clear criterias talk will tend to fall into holywar without constructive output :)

@Ralim
Copy link
Owner

Ralim commented Jul 18, 2021

Is library for "hardware first" or for "user first"? I can operate in any context :). But as OSS developper, wishing to make project popular, i'd prefer "user first" approach when possible.

Its user-first assuming user is at least competent in knowing roughly what they are setting up.
Its not user-first in the Arduino / PlatformIO way of usability>performance.

IMO such statements are discuss-able only when metrics/bounds available. Without clear criterias talk will tend to fall into holywar without constructive output :)

Naturally, and to prove this point ill just save that my preference is smaller code size and to leave it up to the user to handle at their discretion. Given how trivial of a function it is in the simplest case, and how complex it can be in complex cases; that is a wide enough span to prefer to encourage the user to use their available functions. :)

@puzrin
Copy link
Author

puzrin commented Jul 18, 2021

Its user-first assuming user is at least competent in knowing roughly what they are setting up.
Its not user-first in the Arduino / PlatformIO way of usability>performance.

  • Knowing how to install cmake / gcc / flash uploader is too much for beginners (especially on windows). It's more easy [for beginners] to install single vscode and let it organize the rest at project open.
  • There are cases when you can ask "please change this line, upload on your device and see if problem fixed". Then user may be "not programmer" at all (but still able to install vscode).

I have nothing against your personal preferences/expectations, but IMO possible use is more wide.

@Ralim
Copy link
Owner

Ralim commented Jul 18, 2021

I completely agree with your statements, but if you are using a framework that is integrating this code, its that framworks job to provide a good user experience for integrations.

The minimal required functions are relatively workable, while not abstracted away to the point of being useless for custom integrations.

I agree that example is quite long, but it could be shortened easily, but prefer the most verbose example possible.

No-one is going to download vscode + this library and be able to flash it to a board. There is at least a good 2 more steps in the middle there. A lot of the work on installing this code, or how to hook to i2c or how to hook to delay is partly on those frameworks more so than this library.

@Ralim Ralim reopened this Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants