Newbie questionnaire
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
Before I unhook everything to upload the test code, can I double check that the custom function should be using 0x42 instead of 0x41 (based on 0x41 being the primary 16-channel PWM, that should be operable via the standard code)?
Also, forgive my asking again, but what is the syntax for the first 16-channel PWM, if this CustomExpansion() function is what I need for the second 16-channel PWM?
Also, forgive my asking again, but what is the syntax for the first 16-channel PWM, if this CustomExpansion() function is what I need for the second 16-channel PWM?
Re: Newbie questionnaire
You can copy the function and call it CustomExpansion1 and change the address to 0x42.
Roberto.
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
So use the custom code for both, instead of custom code for one and the library support for the other?
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
Should I want to use the library version, what would the function name and syntax be?
And do I need to change the name of the function if I only include one copy in my code?
Sorry for all the serial questions.
And do I need to change the name of the function if I only include one copy in my code?
Sorry for all the serial questions.
Re: Newbie questionnaire
You need to add this to setup to enable the feature:
Then you can use a function like:
Code: Select all
ReefAngel.Add16ChPWM();
Code: Select all
ReefAngel.PWM.Set16Channel(0,PWMSlope(9,0,20,0,15,100,60,15));
Roberto.
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
Thanks much! This is enough to get me started, but I have a feeling I'll want to replicate the Set16ChannelRaw functionality from RA_PWM.h eventually. Hopefully by the time I'm ready to try that, I'll understand how to do it without so much hand-holding.
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
On further consideration, is it necessary to have two copies of the named function? Since the CustomExpansion() function takes the address of the expansion board as its first variable (byte id), doesn't this mean I could simply pass 0x41 when I wanted to access the first expansion module, and 0x42 when I wanted to access the second?
Re: Newbie questionnaire
Yes, that is the best solution
I just didn't want to confuse too much, but it seems you are on top of things
I just didn't want to confuse too much, but it seems you are on top of things
Roberto.
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
And if I wanted to rely on my custom function, I could change it up a bit:
To allow the function to accept a 12-bit integer, instead of a percentage. That way I could pass a high-definition value from one of the smooth slope functions, yes? (Assuming I haven't broken some variable naming rule with "level")
Code: Select all
void CustomExpansion1(byte id, byte channel, int level)
{
Wire.beginTransmission(id);
Wire.write(0);
Wire.write(0xa1);
Wire.endTransmission();
Wire.beginTransmission(id);
Wire.write(0x8+(4*channel));
Wire.write(level&0xff);
Wire.write(level>>8);
Wire.endTransmission();
}
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
Since I've taken out the line that maps the percentage byte onto a 12-bit number, do I still need to have lines four and five in my CustomExpansion function:
It seems like there's no need to end then immediately start the transmission, but I don't know the Wire functions at all.
Code: Select all
Wire.endTransmission();
Wire.beginTransmission(id);
- joshlawless
- Posts: 138
- Joined: Thu May 23, 2013 2:52 pm
Re: Newbie questionnaire
Living dangerously! Will let you know what happens when I get it connected.