If you have several crates of 100 apples each and have one partly filled crate with only 15 apples in it, but want to sell 20 apples to a customer, how would you do that?
The crates stand for your days and the apples are the seconds, just the numbers are a bit bigger and not as nice to look at
Yup, thatās it.
(Actually 0:15 was meant as 12:15am, but still the same answer)
So if you check for end < start and then add 86400 if thatās the case, you have managed the rolling over day.
Another way would be to do the calculation first without the āborrowingā and only if the result is negative ānormalizeā the result by adding 86400.
There are multiple other solutions you should add to your mental repository in order to be able to tackle such problems.
e.g.
You need to see times and dates as one thing and not two seperate, as minutes and seconds are actually the same thing just in a different scale.
You need to understand the difference between signed and unsigned maths and what happens if you mix.
You might also want to look at the modulus operation (88200 % 86400 = 1800) as well as integer vs. floating point division.
These basics will help you a lot when dealing with numbers and range checks.
I actually read a bit about modulus, but didnāt want to get lost in another world for the moment. So now that I get the math, Iām trying to understand how this will fit into this code.
Maybe Iām reading this wrong. But I see this as telling the functions to run every 3600 seconds. Do I need to tell photon earlier in the loop to compensate for the time or do I do it within each of these statements?
I was seeing something like this for the time check:
Any time greater than 86399 is never going to be <= to "now" right? So, that's not going to work. Your math needs to give an answer that's always less then 86400, or the pumps won't ever turn off.
Just wanted to pop in here to to comment that this sounds like an awesome product, and that I'm blown away by the time and help that @Ric, @ScruffR, @Moors7, and @peekay123 have contributed over the last couple of months.
I want to echo the sentiment that the forums are a really great place for getting tips, but isn't necessarily intended as a place to do continued product development. @Ric has been very generous with his time and expertise, which is fantastic, but if you're building a commercial product we highly recommend you also reach out to Particle.
We have a bunch of great resources specifically built to support product creators, including access to a network of paid contractors for developmental services (like you requested in your post at the beginning in the thread!).
Yes, they have been incredibly generous. I have ideas and never know how to implement them. I just want to be clear that this is not a project I intend to profit from, its a project to help out a community of coral reef enthusiasts. I do a lot of work to help support others as well. I donāt expect anything from anyone and honestly Iām surprised they havenāt given up yet (but I know they are incredibly frustrated by me), Iām guessing Iām going to need to find additional resources soon.
I appreciate you chiming in, and Iāll check out the resources for paid contractors. Iām happy to pay. Iād rather pay than frustrate othersā¦that is not my intention.
Iāll let it be @Ric, lifeās too short for me to create frustrations in the lives of others why Iām the one lacking knowledge. I appreciate your help and patienceā¦I mean that sincerely, Thank you.
Hey @james211āI want to thank you for your enthusiasm! I donāt believe that you have offended or frustrated anyone. I would be very glad if all of our community members were as ambitious as youā¦many of the individuals on the Particle team learned about electronics and firmware development with the help of open source communities like this one, so I sincerely hope you continue your process of learning!
I would love to see you continue to post updates on the progress of your project! Best of luck!