per1234 / PalatisSoftPWM

Software PWM library for Arduino
BSD 3-Clause "New" or "Revised" License
18 stars 5 forks source link

got time to cherry-pick some of your commits :-D #6

Open Palatis opened 8 years ago

Palatis commented 8 years ago

I finally got time to cherry-pick some of your commits into my repository.

Thanks for your great effort :-D

Palatis commented 8 years ago

and BTW for the SoftPWM -> PalatisSoftPWM rename thing,

you actually put lots of effort into this, so I wouldn't consider it as "hijacking reputation" by any means. yes, you started from the point I left over, and did a great job, you absolutely have the right to share the reputation.

Palatis commented 8 years ago

I think I'll support those SOFTPWM_DEFINE_PINn_CHANNEL macros if they're inside their own file (say, platform_atmega328p.h), and included on-demand with preprocessor guards.

making the already-monster SoftPWM.h even longer is just not my taste.

per1234 commented 8 years ago

Way cool! I'm very glad you found some of my work worth merging.

you absolutely have the right to share the reputation.

Thanks! That was the name I had been using for it personally for a while since I had multiple libraries of practically the same name installed for a little while. This was one of the first 3rd party Arduino libraries I ever installed and I think the first from GitHub because I remember trying to figure out "what does this -master thing mean?"

I think I'll support those SOFTPWM_DEFINE_PINn_CHANNEL macros if they're inside their own file (say, platform_atmega328p.h), and included on-demand with preprocessor guards.

That's a great idea to put it in a separate file! I don't know why I didn't think to do it that way. That is super annoying to have to scroll down forever just to get to the actual code.

I'm not sure if I understand what you mean by platform_atmega328p.h. Do you want the macros for each part in a separate file? I think the automatic detection of the part is useful because some Arduino users don't know which microcontroller they're using, just that it's an "Uno" or whatever. How about just putting all the Arduino pin definitions in a single file, maybe ArduinoPins.h?

Palatis commented 8 years ago

i mean:

platform_attinyX5.h

#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#define SOFTPWM_DEFINE_PIN0_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRB, PORTB, PORTB0)
#define SOFTPWM_DEFINE_PIN0_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRB, PORTB, PORTB0)
#define SOFTPWM_DEFINE_PIN1_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRB, PORTB, PORTB1)
#define SOFTPWM_DEFINE_PIN1_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRB, PORTB, PORTB1)
#define SOFTPWM_DEFINE_PIN2_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRB, PORTB, PORTB2)
#define SOFTPWM_DEFINE_PIN2_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRB, PORTB, PORTB2)
#define SOFTPWM_DEFINE_PIN3_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRB, PORTB, PORTB3)
#define SOFTPWM_DEFINE_PIN3_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRB, PORTB, PORTB3)
#define SOFTPWM_DEFINE_PIN4_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRB, PORTB, PORTB4)
#define SOFTPWM_DEFINE_PIN4_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRB, PORTB, PORTB4)
#define SOFTPWM_DEFINE_PIN5_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRB, PORTB, PORTB5)
#define SOFTPWM_DEFINE_PIN5_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRB, PORTB, PORTB5)
#endif

platform_atmegaX8.h

#if defined(__AVR_ATmega48__) || defined(__AVR_ATmega48A__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega48PA__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega88A__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega88PA__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168PA__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
#define SOFTPWM_DEFINE_PIN0_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRD, PORTD, PORTD0)
#define SOFTPWM_DEFINE_PIN0_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRD, PORTD, PORTD0)
#define SOFTPWM_DEFINE_PIN1_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRD, PORTD, PORTD1)
#define SOFTPWM_DEFINE_PIN1_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRD, PORTD, PORTD1)
#define SOFTPWM_DEFINE_PIN2_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRD, PORTD, PORTD2)
#define SOFTPWM_DEFINE_PIN2_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRD, PORTD, PORTD2)
#define SOFTPWM_DEFINE_PIN3_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRD, PORTD, PORTD3)
#define SOFTPWM_DEFINE_PIN3_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRD, PORTD, PORTD3)
#define SOFTPWM_DEFINE_PIN4_CHANNEL(CHANNEL) SOFTPWM_DEFINE_CHANNEL(CHANNEL, DDRD, PORTD, PORTD4)
#define SOFTPWM_DEFINE_PIN4_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_CHANNEL_INVERT(CHANNEL, DDRD, PORTD, PORTD4)

...

#define SOFTPWM_DEFINE_PINA5_CHANNEL(CHANNEL) SOFTPWM_DEFINE_PIN19_CHANNEL(CHANNEL)
#define SOFTPWM_DEFINE_PINA5_CHANNEL_INVERT(CHANNEL) SOFTPWM_DEFINE_PIN19_CHANNEL_INVERT(CHANNEL)
#endif

and do

// support for SOFTPWM_DEFINE_PINn_CHANNEL on different Arduino variants
#include <platform_attinyX5.h> // arduino:gemma variants
#include <platform_atmegaX8.h> // arduino:standard or arduino:eightanalogoutputs variants
#include <platform_foo.h> // arduino:foo variants
#include <platform_bar.h> // arduino:bar variants
#include <platform_baz.h> // arduino:baz variants

inside the main SoftPWM.h.

or something like that... just don't make SoftPWM.h a monster header...

per1234 commented 8 years ago

Ok, that makes sense. Will do!

Palatis commented 8 years ago

dunno if names like platform_attinyx5.h would be too much conflict-possible in the whole arduino environment...

maybe have to think of a different name.