Notifications
Clear all

A New Building Lighting for My HO Layout

23 Posts
5 Users
17 Likes
3,155 Views
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@wells5150

Posted by: @wells5150

I am still new to Arduino, but I 'm familiar with c++. I have a related question. I'm not sure if this should be a new topic or for another forum, but my queries concern timing. I am building something very similar. Would his code be more effective with millis? When would you use millis vs. chrono

Thanks in advance 🖖🏾

@photo-bud is correct.

There are many excellent functions in the full C++ Standard Library, but unfortunately only a portion of those are made available.

The Arduino reference page covers what's available to you: Arduino language reference

Note:- You can also access this reference from within your IDE help menu.

Note also:- That there are other language constructs available, such as namespaces, templeates, new, delete, etc... but they are not documented in the reference.

Cheers.


   
wells5150 and Photo Bud reacted
ReplyQuote
wells5150
(@wells5150)
Member
Joined: 4 years ago
Posts: 6
 

@photo-bud

OK - Seems straight forward.

LAW


   
ReplyQuote
wells5150
(@wells5150)
Member
Joined: 4 years ago
Posts: 6
 

@frogandtoad

@photo-bud - sorry for to include this: https://forum.arduino.cc/index.php?topic=570401.0

https://github.com/SofaPirate/Chrono

(Concurrently waiting a reply from developer(s))

I agree with @photo-bud & you - to stick with the Arduino reference when in doubt, but am I not seeing it? The 'chrono' function seems redundant, it includes 'millis' in its header file, it appears to do the same as 'millis'.

???

I will also try a few lines of C++ to experiment more regarding other constructs.

Thanks!

LAW


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 
Posted by: @wells5150

I agree with @photo-bud & you - to stick with the Arduino reference when in doubt, but am I not seeing it? The 'chrono' function seems redundant, it includes 'millis' in its header file, it appears to do the same as 'millis'.

Millis will be a count of how long the program is running. It looks like chrono is intended as a stopwatch. As far as I know, millis just counts and cannot be stopped. Chronos appears to use millis to count but has the ability to pause that time then add too it when restarted. It can also be started later.

 

Note that there could be some issues when using the value from millis. It does not play well with int and using math is an issue.


   
wells5150 reacted
ReplyQuote
wells5150
(@wells5150)
Member
Joined: 4 years ago
Posts: 6
 

@madmisha

That is a much better clarification than the one provided on Github!!! I appreciate the heads up re: int

I will at least give it a try.

Thanks a bunch! 👍🏾🖖🏾

LAW


   
Photo Bud reacted
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@wells5150

Posted by: @wells5150

@frogandtoad

@photo-bud - sorry for to include this: https://forum.arduino.cc/index.php?topic=570401.0

https://github.com/SofaPirate/Chrono

(Concurrently waiting a reply from developer(s))

I agree with @photo-bud & you - to stick with the Arduino reference when in doubt, but am I not seeing it? The 'chrono' function seems redundant, it includes 'millis' in its header file, it appears to do the same as 'millis'.

???

I will also try a few lines of C++ to experiment more regarding other constructs.

Thanks!

LOL... I've been misled! 😀

When you said:

I am still new to Arduino, but I 'm familiar with c++

... and then you followed up with:

When would you use millis vs. chrono

... I was fooled into thinking that you were talking about the C++11 version of the chrono class! 😀

But since you posted that link to the source, I now realise that it's a 3rd party library created for Arduino, but NOT a part of the C++ language per se - It's a library specifically created for Arduino, using the C and C++ language!

Now that I understand, and just to be clear for the readers... Chrono (capitol C), is a 3rd party library built for Arduino, and yes, it's not a bad wrapper library at all... I have downloaded it now and tried it out, but at the end of the day, the Chrono 3rd party library just uses millis and micros in the background, so C++ programmers should not  confuse it with the real "chrono" library provided by the ISO C++ standard.

Cheers.


   
Photo Bud and wells5150 reacted
ReplyQuote
wells5150
(@wells5150)
Member
Joined: 4 years ago
Posts: 6
 

@frogandtoad 

Learning both Arduino & different c++ IDEs seem a bit confusing, subtle differences, learning curves, 😵etc.  A lot of homework (= a lot of Yoo-Hoo), but still fun!! Pretty soon, I should be able to initially use better descriptive(s) in these forums.  I really appreciate everyone's assistance here!🖖🏾

LAW


   
ReplyQuote
Photo Bud
(@photo-bud)
Member
Joined: 5 years ago
Posts: 89
Topic starter  

@wells5150 and @frogandtoad - I've gotta admit I really enjoy how this topic has been "hijacked" and don't mind a bit, as I've learned some new things from it. The dynamics of thread evolution can sometimes be amazing and fruitful.

Photo Bud (aka John)
The Old Curmudgeon!


   
ReplyQuote
Page 2 / 2