-
Notifications
You must be signed in to change notification settings - Fork 89
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
DueTimer Library v2.0 #20
Comments
Sounds great the only thing I'd do is not to have the class name as DueTime but actually have a namespace Due and keep the Class Name As Timer so the include would look like #include <timer.h> // whatever , this is where the base class is define
namespace Due{
class Time : public virtual BaseTimer{
public:
.
};
} When I use that timer i make use i sue the correct namepsace. #include <due/Timer.h>
Due::Timer* ptr_myTiler; or What do you think? On 9 Jun 2013, at 21:55, Ivan Seidel [email protected] wrote:
Diego Colombo PhD |
The only problem is that the Library should be "easy" to use. Implementing Because Arduino is made to be simple, it wouldn't be the simplest way of doing. I like to use namespaces as you said, but not for this kind of library... |
Not sure about arduino being simple to use. The IDE is quite naive and anything else is quite complicated because involves being familiar with make files and the underlying tool chain. The current state of tools and education of the arduino user base encourage to one of the practices that scares me the most : copy paste of code between projects. I do not see any harm or too high complexity into using namespace to minimise the risk of name collision, which is pretty serious problem in languages as c and cpp due to no real type system at runtime. Python is also a great example of how having namespace is useful to keep all thing tidy. And python user base goes from hobbyist to research passing for financial institution. But I will be happy with the guidelines you want to take since this is your project and I am happy to be a contributor here. Just if we could avoid that name for the concrete arduino due class:) I am really looking forward for the new start to I can also integrate your new designed library in the project I am doing for mUBreeze. Ready to start when you are ! On 9 Jun 2013, at 22:34, Ivan Seidel [email protected] wrote:
|
@ivanseidel Your The thing is: From the hardware point of view, the Timer Counter blocks as described in the datasheet are built around a 32-bit counter. This is the central piece of hardware that you have to use in order to create a timer or to measure frequency, or to create a hardware PWM, etc. The requirements of your use case define how to configure this counter and the multiplexers around it. For example, to create a timer, you have to configure the clock input of the counter to be one of the predefined system clocks. Or to create an event counter you would connect it the counter's clock input to an external pin signal. I'm convinced that having classes that really represent the underlying hardware will enable developers to easily derive classes with new application specific behaviour. I propose the following: @colombod |
The diagram looks great. Don't worry about my point of view. But you put Due in front of every class :) sounds like a call for namespaces to me but I am fine whatever naming convention you want to go for. Can you imagine all classes in stl being stdstring etc :) Let's get this started and it is going to be great ! Apple teaches it : educate your user base :) Looking forward to the next version of this great library. On 11 Jun 2013, at 11:33, Philipp Klaus [email protected] wrote:
|
In OO, sometimes we just leave a method not being used, however, changing a public method to private or protected (a more restrict type than the father) is not possible. But, what I tought about, when inheriting methods So the logic is:
It will not be That fast, since we are using a Software timer. However, Servo library from atmega328 use exacly this: creating a simple timer and changing the output via software. In that way, we would require a attachInterrupt and an detachInterrupt on the father, to register those callbacks. I'm even thinking about implementing setDutyCycle on BaseTimer, since it can be helpfull on others classes. My core idea is: Make a FULL interface, with all posible methods of configuring the PWM form of the Timer, Interrupts. Even we NOT using all of those methods our childs, we will be able to do it. Implementing interfaces for each of the main "things" (Servo, PWM, TimerInterrupt, Counter...) is essential for extensions and others developers/coders to make use of our library. Usualy, I name interfaces with the Also, we should keep in mind that: This Library MUST work with others plataforms. To do so, interfaces are perfect for us. If we are using the word "Due" in front of the class, is JUST to show that we are mplementing the Due part of the library. But, i belive that would be fine to drop that name, and use only In that way, on compilation time we check the plataform, and include the correct code, and NOTHING will change. |
Makes sense On 11 Jun 2013, at 12:26, Ivan Seidel [email protected] wrote:
|
Off course you can: See this C++ OOP tutorial and scroll through to Hiding functionality.
OK, so we need to attach callbacks in the PWM class. that's fine. But we still don't need them in the Counter class.
Yes, this is also how it's done by cmaglie's Servo2 lib. It only uses callback functions for the PWM (to support any pin).
True.
I think that any interface should have a clean and well defined API. See it as a contract between you and your users.
Does this not contradict your previous statement about avoiding "a class with thousands of methods"?
True. And in order to let them quickly understand what's going on in our code, its structure should be logical.
As I read it this library was initially called ARMtimer. I see the chance that this library could be adopted to newer boards that may follow the Arduino Due (also based on the ARM SAM platform). If we want to go on and use the library format 1.5, we should move the implementation files to the subfolder So from my point of view I think it's fine to drop the |
But is not cool to do that (it's a workaround). Imagine: you pass an object of class Hiding/removing/encapsulating a method or atribute on another class would result on a crash in runtime (witch is not cool, and that's why Java doesen't allows it, only permiting you to make the method/atribute less restrict, but not more restrict than the father...) Attaching a callback to a counter might be needed, to create a software counter (in case of exceeding all the counters, or for example: you have to counters with the same Timer, with the same frequency. Perhaps, what we really should do, is to make all methods private, and make it public acordingly to what the class does. Eg.: One other thing, why shouldn't we attach an interrupt on a I understand your point, about keeping it clean. I belive that the fewer the methods, the better. But key things such as: Set frequency and duty cycle and callbacks is the base of the Timer. What do you think? |
How about multiple inheritance done safe ? It is like the categories in objective c. That way we can partition the functionalities on block of interface and the time we inherit more than one class we implement them. If course on this scenario base classes needs to put all pure virtual. Dr Diego Colombo PhD On 11 Jun 2013, at 20:19, Ivan Seidel [email protected] wrote:
|
Yes still interested ! Dr Diego Colombo PhD On 5 Sep 2013, at 01:01, Ivan Seidel [email protected] wrote:
|
I'm interested too , in TimerCounter |
Is it possible to integrate ADC functionality? I.e. trigger ADC readings using the TC (this is supported by the ADC/timer hardware) |
Hi ammoniak, It is possible, but in the moment I'm not thinking about implementing those But fell free to do it, and send to us the updated version =) Ivan Ivan Seidel Gomes 2014-08-26 8:18 GMT-03:00 ammoniak [email protected]:
|
Hi Ivan |
hello @Oegtsgeest, |
Thx for yr quick reply. Yes indeed it had to to with priorities. Thanks to your lead i solved the issue. |
Hi , can you help me with a simple sketch for the library. I intoduced it in my code and it has display poblem. Thanks |
Hi. I have fixed the problem. Thanks |
Hi Ivan. I am using your Timer library for the Due. But when I have a complex code running within the Timer Interrupt Service Routine and I try print data serially I do not get it printed when I use the Serial.print within the ISR. But when I print the data in the loop function I get data but still all the processes are running within the Timer's ISR. Do you understand why I am facing this ?? Please suggest |
Here is the place to discuss the enchancements of the library for the v2.0
Key things that will be created/changed:
Interface
PWM
Servo
CounterTimer
The text was updated successfully, but these errors were encountered: