Code: Select all
{r,g,b} = wheel(( (index*256/LEDS) + outer) & 255);
dvr.setPixelColorRGB(index, r, g, b);
Code: Select all
{r,g,b} = wheel(( (index*256/LEDS) + outer) & 255);
dvr.setPixelColorRGB(index, r, g, b);
Code: Select all
void myFunc(unsigned &var1, unsigned &var2){
var2 ++;
var1 += var2;
}
// In header file:
#ifdef __XC__
void myFunc(unsigned &var1, unsigned &var2);
#endif
Code: Select all
void otherFunc(){
s_vars miscVariables;
miscVariables.var1 = 0;
miscVariables.var2 = 0;
myFunc2(miscVariables);
// etc...
}
void myFunc2(s_vars &miscVariables){
miscVariables.var2 ++;
miscVariables.var1 += miscVariables.var2;
}
// In header file:
typedef struct s_vars {
unsigned var1;
unsigned var2;
}s_vars;
#ifdef __XC__
void myFunc2(s_vars &miscVariables);
#endif
Yes perhaps it is in xC, I am just learning, coming from decades of C. Have you ever programmed in Lua? Multiple results is a useful feature there.TSC wrote:I think multiple return values are messy.
Yes thanks, that is good advice. I have made use of references for return results in C++ at times.TSC wrote:Give return by reference a try.
Code: Select all
{r,g,b} = wheel(( (index*256/LEDS) + outer) & 255);
dvr.setPixelColorRGB(index, r, g, b);
Code: Select all
dvr.setPixelColorRGB(index, wheel(( (index*256/LEDS) + outer) & 255));
Thanks, I don't see how that answers the question though but I might be dense!infiniteimprobability wrote:you're in luck!!
Oh. If that term means calling from within the parameter list, it is common in other languages. Lua I am thinking. Functional languages. And Javascript lives there.segher wrote:function composition" is very bad style
in C (and XC).
Code: Select all
// xcc multiple-return.xc -target=XS1-L16A-128-QF124-C10 -o multiple-return.xe; xsim multiple-return.xe;
#include <print.h>
struct color
{
unsigned char r, g, b;
};
struct color
wheel(void)
{
struct color color = {255, 15, 22};
return color;
}
void
setPixelColorRGB(int index, struct color color)
{
printuintln(color.r);
printuintln(color.g);
printuintln(color.b);
}
int
main(void)
{
setPixelColorRGB(1, wheel());
return 0;
}