Show Posts
Pages: 1 2 [3] 4 5
31  Using Arduino / Programming Questions / Re: a pointer to a multidimensional array on: September 20, 2011, 10:20:00 am
I'm puzzled. Its clear for me that changing the type doesn't change anything.
I don't get that I'm pointing to nowhere.

Let me explain how I think and what I want.

I've made a ColourBase object to store different variables and arrays.
I this case I have only the wheelHSBColor array and the baseHue integer, but I'd like to use more arrays and variables.

So I make 6 ColourBase objects in the constructor of the ColourPalette
Code:
ColourBase cArray[6]; // calling this I allocated the space for an array with 6 ColourBase objects?

for (int i=0;i<6; i++)
{ cArray[i] = ColourBase(); // here I will "fill up" the array with new created ColourBase objects.
}

By calling ColourBase(); I assume that I create 6 ColourBase() objects and also allocate memory space for the wheelHSBColor[] array since I create an array by doing this in the ColourBase constructor:
Code:
int wheelHSBColor[] = {0, 0, 0};

In the updatePalette() function called from the ColourPalette constructor I will set the value of each baseHue variable in each ColourBase object
Code:
  cArray[0].baseHue = mainHue;
  cArray[1].baseHue = mainHue - hueAngle;
  cArray[2].baseHue = mainHue + hueAngle;
  cArray[3].baseHue = mainHue + 180 + complementOffset;
  cArray[4].baseHue = cArray[3].baseHue - complementAngle;
  cArray[5].baseHue = cArray[3].baseHue + complementAngle;

Then I'll call the ColourAtRYBWheel function to fill the wheelHSBColor array in each ColourBase object (stored in the cArray)
Code:
for (int i=0; i<6;i++) {
   ColourAtRYBWheel(cArray[i].baseHue, cArray[i].wheelHSBColor);
}

In my assumption does c[0] point to index[0] of the wheelHSBColor array as index c[1] will point to wheelHSBColor[1].
Since I use a for-loop I think I'll fill each wheelHSBColor array for each ColorBase object.

I hope I cleared up my way of thinking. Hope you can point out what goes wrong. Thank you in advance.
32  Using Arduino / Programming Questions / Re: a pointer to a multidimensional array on: September 20, 2011, 09:25:19 am
Paul thanks for the great help you provide here in the forum helping to solve some problems.

I think I've solved part of the problem. Stupid indeed not to assign values to the arrays and the ColourBase object.

Although I have the idea that I did everything good now, there still goes something wrong with the c array in combination with the ColourAtRYBWheel function.

My .h file
Code:
#ifndef ColorLight_h
#define ColorLight_h

#include "WProgram.h"

class ColourBase
{
  public:
    ColourBase(); 
   
  int baseHue;           // hue value on the circle 
int *wheelHSBColor;
};

class ColourPalette
{
  public:
    ColourPalette();
 
int mainHue;
int complementOffset;
int hueAngle;
int complementAngle;

ColourBase *cArray;
void updatePalette();
void ColourAtRYBWheel(int, int*);

int lerpInt(int, int, int, int);
};
#endif

My .cpp file
Code:
##include "WProgram.h"
#include "ColorLight.h"

const int rybHueWheel[25] =
{ 0  , 12 , 24 , 30 , 36 , 42 , 48 , 54 , 60 , 72 , 84 , 108, 120, 154, 180, 206, 225, 240, 260, 265, 280, 300, 315, 333, 360 };

ColourBase::ColourBase()
{ int wheelHSBColor[] = {0, 0, 0};
}

ColourPalette::ColourPalette()
{
ColourBase cArray[6];

for (int i=0;i<6; i++)
    { cArray[i] = ColourBase();
    }

mainHue = 5;
complementOffset = 0;
hueAngle = 30;
complementAngle = 30;   

updatePalette();
}

void ColourPalette::updatePalette()
{
  Serial.println("update palette");
  cArray[0].baseHue = mainHue;
  cArray[1].baseHue = mainHue - hueAngle;
  cArray[2].baseHue = mainHue + hueAngle;
  cArray[3].baseHue = mainHue + 180 + complementOffset;
  cArray[4].baseHue = cArray[3].baseHue - complementAngle;
  cArray[5].baseHue = cArray[3].baseHue + complementAngle;

  // convert to new hue numbers with the new ColorWheel (HueToRYB)
  for (int i=0; i<6;i++)
  { ColourAtRYBWheel(cArray[i].baseHue, cArray[i].wheelHSBColor);
  }       
}

void ColourPalette::ColourAtRYBWheel(int hue, int c[3]) {
 
  if (hue<0)    hue = 360+hue;     
  hue = hue%360; // stick to 0 - 359

  int rybWheelIndex  = hue/15;      // colourWheel has 24 base colours
  int rybWheelAmount = hue%15;
 
  c[0] = lerpInt(rybHueWheel[rybWheelIndex], rybHueWheel[rybWheelIndex+1], rybWheelAmount,15);
 
  Serial.print("hue : ");
  Serial.println(hue, DEC);
 
  Serial.print("wheelindex: ");
  Serial.println(rybWheelIndex, DEC);
 
  Serial.print("val in wheelindex: ");
  Serial.println(rybHueWheel[rybWheelIndex], DEC); 
  Serial.print("val in wheelindex +1 : ");
  Serial.println(rybHueWheel[rybWheelIndex+1], DEC);
 
  Serial.print("wheelamount: ");
  Serial.println(rybWheelAmount,DEC);
 
  Serial.print("result in array: ");
 
  Serial.println(c[0],DEC); 
  Serial.print("result direct: ");
  Serial.println(lerpInt(rybHueWheel[rybWheelIndex], rybHueWheel[rybWheelIndex+1], rybWheelAmount,15));

  Serial.println("===================");
}

int ColourPalette::lerpInt(int a, int b, int f, int max)
{ // f is a number between 0 - max
return a + ( (b-a) * f/max );
}

I think something goes wrong with writing values to the c array in the function ColourAtRYBWheel. Probably its still not declared ok, but how can I solve that.

The results I print. In all cases the "result in array" should be the same as "result direct". I two cases thats not the case, so the number changes somewhere in between.
Code:
update palette
hue : 5
wheelindex: 0
val in wheelindex: 0
val in wheelindex +1 : 12
wheelamount: 5
result in array: 198
result direct: 4
===================
hue : 335
wheelindex: 22
val in wheelindex: 315
val in wheelindex +1 : 333
wheelamount: 5
result in array: 321
result direct: 321
===================
hue : 35
wheelindex: 2
val in wheelindex: 24
val in wheelindex +1 : 30
wheelamount: 5
result in array: 0
result direct: 26
===================
hue : 185
wheelindex: 12
val in wheelindex: 120
val in wheelindex +1 : 154
wheelamount: 5
result in array: 131
result direct: 131
===================
hue : 16
wheelindex: 1
val in wheelindex: 12
val in wheelindex +1 : 0
wheelamount: 1
result in array: 12
result direct: 12
===================
hue : 10
wheelindex: 0
val in wheelindex: 0
val in wheelindex +1 : 12
wheelamount: 10
result in array: 8
result direct: 8
===================†

I've implemented a lerp with only integers, so that part of the problem is solved.
33  Using Arduino / Programming Questions / Re: a pointer to a multidimensional array on: September 20, 2011, 05:43:33 am
I'm still struggling with strange values. However I don't know how to solve it. I thought its was related to the pointer and the array, but I'm not sure now.

I've updated my code and now use a normal global array (for this example I removed the multidimensional array that I used above).

My code:
header file:
Code:
#ifndef ColorLight_h
#define ColorLight_h

#include "WProgram.h"

class ColourBase
{
  public:
    ColourBase(); 
  int baseHue;           // hue value on the circle 
float *wheelHSBColor;
};

class ColourPalette
{
  public:
    ColourPalette();
 
int mainHue;
int complementOffset;
int hueAngle;
int complementAngle;

ColourBase cArray[6];
void updatePalette();
void ColourAtRYBWheel(int, float*);

float lerp(float, float, float);
};
#endif

.cpp file
Code:
#include "WProgram.h"
#include "ColorLight.h"

const int rybHueWheel[25] =
{ 0  , 12 , 24 , 30 , 36 , 42 , 48 , 54 , 60 , 72 , 84 , 108, 120, 154, 180, 206, 225, 240, 260, 265, 280, 300, 315, 333, 360 };

ColourBase::ColourBase()
{ float wheelHSBColor[3];
}

ColourPalette::ColourPalette()
{ mainHue = 5;
complementOffset = 0;
hueAngle = 30;
complementAngle = 30;   

updatePalette();
}

void ColourPalette::updatePalette()
{
  Serial.println("update palette");
  cArray[0].baseHue = mainHue;
  cArray[1].baseHue = mainHue - hueAngle;
  cArray[2].baseHue = mainHue + hueAngle;
  cArray[3].baseHue = mainHue + 180 + complementOffset;
  cArray[4].baseHue = cArray[3].baseHue - complementAngle;
  cArray[5].baseHue = cArray[3].baseHue + complementAngle;

  // convert to new hue numbers with the new ColorWheel (HueToRYB)
  for (int i=0; i<6;i++)
  { ColourAtRYBWheel(cArray[i].baseHue, cArray[i].wheelHSBColor);
  }       
}

void ColourPalette::ColourAtRYBWheel(int hue, float c[3]) {
 
  if (hue<0)    hue = 360+hue;     
  hue = hue%360; // stick to 0 - 359

  int   rybWheelIndex  = hue/15;      // colourWheel has 24 base colours
 
  float rybWheelAmount = (hue%15)/15.0; // interpolate amount

  c[0] = lerp(rybHueWheel[rybWheelIndex], rybHueWheel[rybWheelIndex+1], rybWheelAmount);
  c[1] = lerp(rybHueWheel[4], rybHueWheel[5], rybWheelAmount);
  c[2] = lerp(255, 255, rybWheelAmount); 
   
  Serial.print("hue : ");
  Serial.println(hue, DEC);
 
  Serial.print("wheelindex: ");
  Serial.println(rybWheelIndex, DEC);
 
  Serial.print("wheelamount: ");
  Serial.println(rybWheelAmount,DEC);
     
  Serial.println("===================");
}

float ColourPalette::lerp(float a, float b, float x)
{ return(a*(1-x) + b*x);
}

If I print this I'll get:
Code:
update palette
hue : -32704
wheelindex: 0
wheelamount: -30704688.0000000000
===================
hue : -24509
wheelindex: 0
wheelamount: -30704688.0000000000
===================
hue : -12223
wheelindex: 0
wheelamount: -30704688.0000000000
===================
hue : 835
wheelindex: 0
wheelamount: -30704688.0000000000
===================
hue : -18366
wheelindex: 0
wheelamount: -30704688.0000000000
===================
hue : 15427
wheelindex: 0
wheelamount: -30704688.0000000000
===================†

However when I comment the lines that start with c[1] and [c2] I get the right output.
Code:
  c[0] = lerp(rybHueWheel[rybWheelIndex], rybHueWheel[rybWheelIndex+1], rybWheelAmount);
  //c[1] = lerp(rybHueWheel[4], rybHueWheel[5], rybWheelAmount);
  //c[2] = lerp(255, 255, rybWheelAmount); 

Code:
update palette
hue : 5
wheelindex: 0
wheelamount: 0.3333333492
===================
hue : 335
wheelindex: 22
wheelamount: 0.3333333492
===================
hue : 35
wheelindex: 2
wheelamount: 0.3333333492
===================
hue : 185
wheelindex: 12
wheelamount: 0.3333333492
===================
hue : 155
wheelindex: 10
wheelamount: 0.3333333492
===================
hue : 215
wheelindex: 14
wheelamount: 0.3333333492
===================†

So repeatedly calling the lerp function gives this bug. Has it the do with a lack of memory?
 
I don't know if its smart to use floats (since I read about speed issues), but I cannot find good examples of fixed point or integer linair interpolation functions.

Also the question if its possible to use the Flash library like this (http://arduiniana.org/libraries/flash/) in my library. Is it just including the .h and files? Are there any examples on that?


34  Using Arduino / Programming Questions / Re: a pointer to a multidimensional array on: September 20, 2011, 01:52:33 am
Well, I think I don't really get what I'm doing. Declaring things in the .h file is new for me for example.

The problem was that I got back a lot of number that we're not in the array. So for sure the array didn't exist anymore and I got back some other data from the same memory address.

I now declared the array as a normal global array and not as a member variable (I suppose a member variable is a variable of an object). Is it right that I don't have to put those global variables in the header (.h) file? It works for now at least.

I'm trying to port some classes I wrote in Processing to Arduino, but that seems more difficult then I expected.
35  Using Arduino / Programming Questions / Re: a pointer to a multidimensional array on: September 19, 2011, 02:01:36 pm
Ok, sorry for not clearly documenting it. I've made a minimized version of the code, that gives me the error.

The Colorlight.h file
Code:
#ifndef ColorLight_h
#define ColorLight_h

#include "WProgram.h"

class ColourPalette
{
  public:
    ColourPalette();
   
    int** rybWheel;
};
#endif

The ColorLight.cpp file
Code:
#include "WProgram.h"
#include "ColorLight.h"

int _rybWheel[25][3] =
{ { 0  , 255, 255 }, // 0
{ 12 , 255, 255 }, // 15
{ 24 , 255, 255 }, // 30
{ 30 , 255, 255 }, // 45
{ 36 , 255, 255 }, // 60
{ 42 , 255, 255 }, // 75
{ 48 , 255, 255 }, // 90
{ 54 , 255, 255 }, // 105
{ 60 , 255, 255 }, // 120
{ 72 , 255, 255 }, // 135
{ 84 , 255, 255 }, // 150
{ 108, 255, 255 }, // 165
{ 120, 255, 255 }, // 180
{ 154, 255, 255 }, // 195
{ 180, 255, 255 }, // 210
{ 206, 255, 255 }, // 225
{ 225, 255, 255 }, // 240
{ 240, 255, 255 }, // 255
{ 260, 255, 255 }, // 270
{ 265, 255, 255 }, // 285
{ 280, 255, 255 }, // 300
{ 300, 255, 255 }, // 315
{ 315, 255, 255 }, // 330
{ 333, 255, 255 }, // 345
{ 360, 255, 255 }  // 360 
};


ColourPalette::ColourPalette()
{
rybWheel = _rybWheel;
}

This will give the error below:
Code:
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp: In constructor 'ColourPalette::ColourPalette()':
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp:37: error: cannot convert 'int [25][3]' to 'int**' in assignment

Line 37 is
Code:
rybWheel = _rybWheel;
36  Using Arduino / Programming Questions / Re: a pointer to a multidimensional array on: September 19, 2011, 12:37:01 pm
Yes, but if I try that then I get this error:

Code:
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp:55: error: cannot convert 'int [25][3]' to 'int**' in assignment

I tried this as well:
Code:
rybWheel = &_rybWheel;

error: /Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp:55: error: cannot convert 'int (*)[25][3]' to 'int**' in assignment

Pointer is still a hard subject to grab for me.
37  Using Arduino / Programming Questions / a pointer to a multidimensional array on: September 19, 2011, 11:23:28 am
I'm trying to make a pointer to a multidimensional array. Any idea how to do that?

In my old post I already found out how to do that with one array.
http://arduino.cc/forum/index.php/topic,53807.0.html

My code.
Code:
int _rybWheel[25][3] =
{ { 0  , 255, 255 }, // 0
{ 12 , 255, 255 }, // 15
{ 24 , 255, 255 }, // 30
{ 30 , 255, 255 }, // 45
{ 36 , 255, 255 }, // 60
{ 42 , 255, 255 }, // 75
{ 48 , 255, 255 }, // 90
{ 54 , 255, 255 }, // 105
{ 60 , 255, 255 }, // 120
{ 72 , 255, 255 }, // 135
{ 84 , 255, 255 }, // 150
{ 108, 255, 255 }, // 165
{ 120, 255, 255 }, // 180
{ 154, 255, 255 }, // 195
{ 180, 255, 255 }, // 210
{ 206, 255, 255 }, // 225
{ 225, 255, 255 }, // 240
{ 240, 255, 255 }, // 255
{ 260, 255, 255 }, // 270
{ 265, 255, 255 }, // 285
{ 280, 255, 255 }, // 300
{ 300, 255, 255 }, // 315
{ 315, 255, 255 }, // 330
{ 333, 255, 255 }, // 345
{ 360, 255, 255 }  // 360 
};


I declare the array in the .h file like this:
Code:
int* rybWheel;

And in the constructor I write.
Code:
rybWheel = _rybWheel;

And I do this in a function (thats the error on line 360)
Code:
Serial.println(rybWheel[rybWheelIndex+1][0],DEC);

I get these errors:
Code:
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp: In constructor 'ColourPalette::ColourPalette()':
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp:55: error: cannot convert 'int [25][3]' to 'int*' in assignment
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp: In member function 'void ColourPalette::ColourAtRYBWheel(int, int*)':
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight.cpp:360: error: invalid types 'int[int]' for array subscript

I've looked up some information on pointers, but I cannot find clear information about pointers to multidimensional arrays and how I can use that with Arduino.
38  Using Arduino / Programming Questions / Re: bit math problem - left and right shift rgb color on: September 18, 2011, 02:17:27 am
Thank you. That works! I forgot about intermediate result.
39  Using Arduino / Programming Questions / bit math problem - left and right shift rgb color on: September 17, 2011, 12:56:49 pm
I try to store RGB color in an unsigned long (I think thats 4 bytes on Arduino).

I've based my code on two examples from Processing:
http://processing.org/reference/rightshift.html
http://processing.org/reference/leftshift.html

If I do this 255 << 8 I get a a hex code #FFFF00, while I expect #00FF00.
It seems kind of strange to me, but maybe I miss something essential?

Below the code that I use to debug.

Code:
//http://processing.org/reference/rightshift.html
//http://processing.org/reference/leftshift.html

void setup()
{ Serial.begin(9600);
}

void loop()
{ byte inputr = 0;
  byte inputg = 255;
  byte inputb = 0;
 
  Serial.print("input r: ");
  Serial.print(inputr,DEC);
  Serial.print(" input g: ");
  Serial.print(inputg,DEC);
  Serial.print(" input b: ");
  Serial.println(inputb,DEC);
 
  unsigned long c = inputr << 16 | inputg << 8 | inputb;
 
  Serial.print("output HEX: ");
  Serial.println(c,HEX);
  //Serial.print("output BIN: ");
  //Serial.println(c,BIN);
   
  byte r = (c >> 16) & 0xFF; 
  byte g = (c >> 8) &  0xFF; 
  byte b = c & 0xFF;       
 
  Serial.print("r: ");
  Serial.print(r,DEC);
 
  Serial.print(" g: ");
  Serial.print(g,DEC);
 
  Serial.print(" b: ");
  Serial.println(b,DEC);
 
  Serial.println("====================");
  delay(500); 
}
40  Development / Other Software Development / Re: problem with array in library on: February 28, 2011, 01:02:51 pm
Clear. In my other examples i've used the byte type for this.

I've put the library online in my blog:
http://www.kasperkamperman.com/blog/arduino-moodlight-library/

If there are any issues please let my know.
41  Development / Other Software Development / Re: problem with array in library on: February 28, 2011, 11:32:25 am
Thanks this works. However I still wonder why I couldn't use the global array directly?

After you're example I tried it in my old way, and it works.

Probably this int dc[256] was the issue. I forgot to set the length of the array..

Whats the benefit to make the type in an unsigned int ? : uint8_t
42  Development / Other Software Development / Re: problem with array in library on: February 28, 2011, 07:11:13 am
Hi,

Here the library in the zip-file. In the example the debugging code :
http://dl.dropbox.com/u/1147392/MoodLight.zip

@Coding Badly

if I do this :
var test = ml._dim_curve[254];
Serial.println(test);

I expect to see: 248 (the value on index number 254).

I get back a lot of zero's or other strange numbers that aren't in the array.
Putting the array in my 'normal' code works perfectly.

@robtillaart.
I've made the array public (as you can see in the example) but I get the same broken value's.


43  Development / Other Software Development / problem with array in library on: February 28, 2011, 04:05:28 am
Hi,

I'm trying to make an Arduino library with the tutorial. http://www.arduino.cc/en/Hacking/LibraryTutorial. The only thing that doesn't work is to use an Array. I don't get compile errors, but the values that I get back don't seem to come from the array. Probably its something with a pointer, but I've no idea how to solve that.

The problem is in the _dim_curve[] array, that I'd like to use as a lookup table. That works perfect in a normal Arduino sketch (http://www.kasperkamperman.com/blog/arduino/arduino-programming-hsb-to-rgb/), but in the library that doesn't work.

My .cpp code:

Code:
#include "WProgram.h"
#include "MoodLight.h"

MoodLight::MoodLight()
{
 
}


int _dim_curve[] = {
    0,   1,   1,   2,   2,   2,   2,   2,   2,   3,   3,   3,   3,   3,   3,   3,
    3,   3,   3,   3,   3,   3,   3,   4,   4,   4,   4,   4,   4,   4,   4,   4,
    4,   4,   4,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   6,   6,   6,
    6,   6,   6,   6,   6,   7,   7,   7,   7,   7,   7,   7,   8,   8,   8,   8,
    8,   8,   9,   9,   9,   9,   9,   9,   10,  10,  10,  10,  10,  11,  11,  11,
    11,  11,  12,  12,  12,  12,  12,  13,  13,  13,  13,  14,  14,  14,  14,  15,
    15,  15,  16,  16,  16,  16,  17,  17,  17,  18,  18,  18,  19,  19,  19,  20,
    20,  20,  21,  21,  22,  22,  22,  23,  23,  24,  24,  25,  25,  25,  26,  26,
    27,  27,  28,  28,  29,  29,  30,  30,  31,  32,  32,  33,  33,  34,  35,  35,
    36,  36,  37,  38,  38,  39,  40,  40,  41,  42,  43,  43,  44,  45,  46,  47,
    48,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,
    63,  64,  65,  66,  68,  69,  70,  71,  73,  74,  75,  76,  78,  79,  81,  82,
    83,  85,  86,  88,  90,  91,  93,  94,  96,  98,  99,  101, 103, 105, 107, 109,
    110, 112, 114, 116, 118, 121, 123, 125, 127, 129, 132, 134, 136, 139, 141, 144,
    146, 149, 151, 154, 157, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 190,
    193, 196, 200, 203, 207, 211, 214, 218, 222, 226, 230, 234, 238, 242, 248, 255,
};

void MoodLight::setHSB(int hue, int sat, int val) {
  /* convert hue, saturation and brightness ( HSB/HSV ) to RGB
     The dim_curve is used only on brightness/value and on saturation (inverted).
     This looks the most natural.     
  */
 
  val = _dim_curve[val];
  Serial.println(val);
  //sat = 255-_dim_curve[255-sat];
 
  int r;
  int g;
  int b;
  int base;
 
  if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
 
    _red   = val;
    _green = val;
    _blue  = val;
   
  } else  {
   
    base = ((255 - sat) * val)>>8;
 
    switch(hue/60) {
case 0:
r = val;
g = (((val-base)*hue)/60)+base;
b = base;
break;

case 1:
r = (((val-base)*(60-(hue%60)))/60)+base;
g = val;
b = base;
break;

case 2:
r = base;
g = val;
b = (((val-base)*(hue%60))/60)+base;
break;

case 3:
r = base;
g = (((val-base)*(60-(hue%60)))/60)+base;
b = val;
break;

case 4:
r = (((val-base)*(hue%60))/60)+base;
g = base;
b = val;
break;

case 5:
r = val;
g = base;
b = (((val-base)*(60-(hue%60)))/60)+base;
break;
    }
     
    _red   = r;
    _green = g;
    _blue  = b;
  }   

}

int MoodLight::getRed(){

  return _red;

}

int MoodLight::getGreen(){

  return _green;

}

int MoodLight::getBlue(){

  return _blue;

}


And in the .h

Code:
#ifndef MoodLight_h
#define MoodLight_h

#include "WProgram.h"

class MoodLight
{
  public:
    MoodLight();
    void setHSB(int,int,int);
    int getRed();
    int getGreen();
    int getBlue();
   
  private:
    int _dim_curve[];
    //int _getCurve(int);
    int  _red;
    int  _green;
    int  _blue;
};

#endif
44  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Problem with 0017, Firmata 2.1 on Duemilanove on: September 24, 2009, 08:09:29 am
I use as3glue with Firmata 2.1 Changing the serialspeed ( in serproxy ) worked out good ( thanks for the tip ) and I have connection.

However I have also problems with the analog inputs. They don't give a range from 0-1023 anymore ( over a even range of 0-5V with a potmeter ). This is a software problem, because with Firmata 2.0 it works good.

Changing the firmata.cpp and firmata.h in the Arduino 17 library's folder didn't work either.

In the forum someone made his on changes :
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253735359/0

Those work, but the serialspeed is different.

Since I use it in an educational situation it would be good that a standard becomes kind of a standard. I hope Arduino 18 can come with a stable version.
45  Forum 2005-2010 (read only) / Syntax & Programs / Re: array of array variable names on: August 29, 2010, 03:39:35 am
Thanks to all for the tips. Thanks Dave for giving the idea of putting all the sizes in a separate array. In the end I did it without defining a struct.

Code:
int categorie1[]  = {1 };
int categorie2[]  = {1, 2 };
int categorie3[]  = {3, 4, 5 };
int categorie4[]  = {4, 8, 3, 11 };
int categorie5[]  = {2, 4, 8, 3, 15 , 11, 12, 13 };
int categorie6[]  = {1, 2, 8, 12, 6 };
int categorie7[]  = {20, 1, 15 };
int categorie8[]  = {2, 4, 8 };
int categorie9[]  = {2, 6 };
int categorie10[] = {2 };

int * categorieArray[10] = { categorie1, categorie2, categorie3,
                             categorie4, categorie5, categorie6,
                             categorie7, categorie8, categorie9,
                             categorie10 };

int categorieSizeArray[] =
{ sizeof(categorie1) / sizeof(int),
  sizeof(categorie2) / sizeof(int),
  sizeof(categorie3) / sizeof(int),
  sizeof(categorie4) / sizeof(int),
  sizeof(categorie5) / sizeof(int),
  sizeof(categorie6) / sizeof(int),
  sizeof(categorie7) / sizeof(int),
  sizeof(categorie8) / sizeof(int),
  sizeof(categorie9) / sizeof(int),
  sizeof(categorie10) / sizeof(int),
};

void setup()
{ Serial.begin(57600);
  
  for (int i=0; i < 10; i++)
  { // print category number
    Serial.print("category :");
    Serial.println(i+1);
    
    // print the contents of each category
    for (int j=0; j < categorieSizeArray[i]; j++)
    { Serial.println(categorieArray[i][j]);
    }  
  }
  
}


void loop()
{  
}


Pages: 1 2 [3] 4 5