Colors shield v1.1 (RGB shield)

Arduino specifieke Software
Berichten: 7
Geregistreerd: 30 Okt 2013, 13:05

Colors shield v1.1 (RGB shield)

Berichtdoor Arduinonieuw » 30 Okt 2013, 13:17

Hallo,

Ik heb een Colors Shield v1.1 van iteadstudio gekocht.Nu probeer ik dat al dagen aan de gang te krijgen maar zonder succes.
Alle voorbeeldcodes geven errors aan bij het compileren (ik heb wel de benodigde libraries geïnstalleerd). Mijn board is een Arduino Mega.
Men stelt dat de colors shield gebruikt kan worden als een colorduino. Maar welke voorbeeld software ik ook laad er zijn altijd errors. Meestal zijn dat dingen die niet gedeclareerd zijn in software. Ik heb echter het vermoeden dat die dingen juist in de libraries te vinden zouden moeten zijn. Die heb ik trouwens op de officiële manier in Arduino geïmporteerd. Ik gebruik de software Arduino 1.0.5 en daar werken alle andere probeersels wel op (b.v. de samples bij Arduino). Wat doe ik fout? Ik ben echt een beginner!

Ik hoop dat jullie mij helpen kunnen.

Groet,

Emil

Advertisement

Berichten: 108
Geregistreerd: 07 Aug 2013, 21:34

Re: Colors shield v1.1 (RGB shield)

Berichtdoor KrisG » 30 Okt 2013, 13:23

Ik heb eens snel gekeken:

deze pinnen staan op een andere plek bij de Mega:
D13 / SCK
D12 / MISO RESET
D11 / MOSI ~

Die zal je dus anders moeten aansluiten en bijgevolg kan je deze shield niet zomaar in de Mega prikken.

Kris
Als je het probleem gedetailleerd genoeg omschrijft, heb je meestal al de oplossing.

Berichten: 7
Geregistreerd: 30 Okt 2013, 13:05

Re: Colors shield v1.1 (RGB shield)

Berichtdoor Arduinonieuw » 30 Okt 2013, 13:26

Dank je Kris, ik ga direct aan de slag.

Berichten: 7
Geregistreerd: 30 Okt 2013, 13:05

Re: Colors shield v1.1 (RGB shield)

Berichtdoor Arduinonieuw » 30 Okt 2013, 20:15

Hey ben ik weer,

Dat met die hardware gaat me we lukken. Simpel kijken wat er bedraad moet worden en op breadboard zetten. Maar waarom lukt het toch niet om al die sketches te runnen? Ik laad de libraries maar toch blijft het programma maar roepen dat er errors zijn. Het volgende programma zou moeten draaien voor mijn rgb board. Echter tijdens het compileren krijg ik de volgende foutmeldingen. Wat is dat toch met die declares. Als ik een programma van het net haal hoort dat toch te werken? om gek van te worden. En dat doen alle demo programma's.

sketch_oct30a:44: error: 'ColorduinoScreenWidth' was not declared in this scope
sketch_oct30a:44: error: 'ColorduinoScreenHeight' was not declared in this scope
sketch_oct30a.ino: In function 'void plasma_morph()':
sketch_oct30a:109: error: 'ColorduinoScreenHeight' was not declared in this scope
sketch_oct30a:110: error: 'ColorduinoScreenWidth' was not declared in this scope
sketch_oct30a:121: error: 'Colorduino' was not declared in this scope
sketch_oct30a:126: error: 'Colorduino' was not declared in this scope
sketch_oct30a.ino: In function 'void ColorFill(unsigned char, unsigned char, unsigned char)':
sketch_oct30a:138: error: 'PixelRGB' was not declared in this scope
sketch_oct30a:138: error: 'p' was not declared in this scope
sketch_oct30a:138: error: 'Colorduino' was not declared in this scope
sketch_oct30a:139: error: 'ColorduinoScreenWidth' was not declared in this scope
sketch_oct30a:140: error: 'ColorduinoScreenHeight' was not declared in this scope
sketch_oct30a.ino: In function 'void setup()':
sketch_oct30a:153: error: 'Colorduino' was not declared in this scope
sketch_oct30a:169: error: 'ColorduinoScreenHeight' was not declared in this scope
sketch_oct30a:170: error: 'ColorduinoScreenWidth' was not declared in this scope
sketch_oct30a:178: error: 'plasma' was not declared in this scope



/*
ColorduinoPlasma - Plasma demo using Colorduino Library for Arduino
Copyright (c) 2011 Sam C. Lin lincomatic@hotmail.com ALL RIGHTS RESERVED

based on Color cycling plasma
Version 0.1 - 8 July 2009
Copyright (c) 2009 Ben Combee. All right reserved.
Copyright (c) 2009 Ken Corey. All right reserved.
Copyright (c) 2008 Windell H. Oskay. All right reserved.
Copyright (c) 2011 Sam C. Lin All Rights Reserved

This demo is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This demo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <Colorduino.h>

typedef struct
{
unsigned char r;
unsigned char g;
unsigned char b;
} ColorRGB;

//a color with 3 components: h, s and v
typedef struct
{
unsigned char h;
unsigned char s;
unsigned char v;
} ColorHSV;

unsigned char plasma[ColorduinoScreenWidth][ColorduinoScreenHeight];
long paletteShift;


//Converts an HSV color to RGB color
void HSVtoRGB(void *vRGB, void *vHSV)
{
float r, g, b, h, s, v; //this function works with floats between 0 and 1
float f, p, q, t;
int i;
ColorRGB *colorRGB=(ColorRGB *)vRGB;
ColorHSV *colorHSV=(ColorHSV *)vHSV;

h = (float)(colorHSV->h / 256.0);
s = (float)(colorHSV->s / 256.0);
v = (float)(colorHSV->v / 256.0);

//if saturation is 0, the color is a shade of grey
if(s == 0.0) {
b = v;
g = b;
r = g;
}
//if saturation > 0, more complex calculations are needed
else
{
h *= 6.0; //to bring hue to a number between 0 and 6, better for the calculations
i = (int)(floor(h)); //e.g. 2.7 becomes 2 and 3.01 becomes 3 or 4.9999 becomes 4
f = h - i;//the fractional part of h

p = (float)(v * (1.0 - s));
q = (float)(v * (1.0 - (s * f)));
t = (float)(v * (1.0 - (s * (1.0 - f))));

switch(i)
{
case 0: r=v; g=t; b=p; break;
case 1: r=q; g=v; b=p; break;
case 2: r=p; g=v; b=t; break;
case 3: r=p; g=q; b=v; break;
case 4: r=t; g=p; b=v; break;
case 5: r=v; g=p; b=q; break;
default: r = g = b = 0; break;
}
}
colorRGB->r = (int)(r * 255.0);
colorRGB->g = (int)(g * 255.0);
colorRGB->b = (int)(b * 255.0);
}

float
dist(float a, float b, float c, float d)
{
return sqrt((c-a)*(c-a)+(d-b)*(d-b));
}


void
plasma_morph()
{
unsigned char x,y;
float value;
ColorRGB colorRGB;
ColorHSV colorHSV;

for(y = 0; y < ColorduinoScreenHeight; y++)
for(x = 0; x < ColorduinoScreenWidth; x++) {
{
value = sin(dist(x + paletteShift, y, 128.0, 128.0) / 8.0)
+ sin(dist(x, y, 64.0, 64.0) / 8.0)
+ sin(dist(x, y + paletteShift / 7, 192.0, 64) / 7.0)
+ sin(dist(x, y, 192.0, 100.0) / 8.0);
colorHSV.h=(unsigned char)((value) * 128)&0xff;
colorHSV.s=255;
colorHSV.v=255;
HSVtoRGB(&colorRGB, &colorHSV);

Colorduino.SetPixel(x, y, colorRGB.r, colorRGB.g, colorRGB.b);
}
}
paletteShift++;

Colorduino.FlipPage(); // swap screen buffers to show it
}

/********************************************************
Name: ColorFill
Function: Fill the frame with a color
Parameter:R: the value of RED. Range:RED 0~255
G: the value of GREEN. Range:RED 0~255
B: the value of BLUE. Range:RED 0~255
********************************************************/
void ColorFill(unsigned char R,unsigned char G,unsigned char B)
{
PixelRGB *p = Colorduino.GetPixel(0,0);
for (unsigned char y=0;y<ColorduinoScreenWidth;y++) {
for(unsigned char x=0;x<ColorduinoScreenHeight;x++) {
p->r = R;
p->g = G;
p->b = B;
p++;
}
}

Colorduino.FlipPage();
}

void setup()
{
Colorduino.Init(); // initialize the board

// compensate for relative intensity differences in R/G/B brightness
// array of 6-bit base values for RGB (0~63)
// whiteBalVal[0]=red
// whiteBalVal[1]=green
// whiteBalVal[2]=blue
unsigned char whiteBalVal[3] = {36,63,63}; // for LEDSEE 6x6cm round matrix
Colorduino.SetWhiteBal(whiteBalVal);


// start with morphing plasma, but allow going to color cycling if desired.
paletteShift=128000;
unsigned char bcolor;

//generate the plasma once
for(unsigned char y = 0; y < ColorduinoScreenHeight; y++)
for(unsigned char x = 0; x < ColorduinoScreenWidth; x++)
{
//the plasma buffer is a sum of sines
bcolor = (unsigned char)
(
128.0 + (128.0 * sin(x*8.0 / 16.0))
+ 128.0 + (128.0 * sin(y*8.0 / 16.0))
) / 2;
plasma[x][y] = bcolor;
}

// to adjust white balance you can uncomment this line
// and comment out the plasma_morph() in loop()
// and then experiment with whiteBalVal above
// ColorFill(255,255,255);
}

void loop()
{
plasma_morph();
}

Gebruikers-avatar
Berichten: 270
Geregistreerd: 30 Dec 2012, 11:42

Re: Colors shield v1.1 (RGB shield)

Berichtdoor Rudi » 30 Okt 2013, 20:49

De laatste specifieke versie voor de Mega al geprobeerd? Te vinden op https://github.com/lincomatic/Colorduino/downloads

Ik heb geen Mega noch Colorduino of Color Shield maar wanneer ik de versie hier van gebruik (Colorduino library en het voorbeeldprogramma Colorduinoplasma) dan compileert hij zonder warnings.
Arduinows!
Why do computer programmers confuse Halloween with Christmas? Because Oct 31 = Dec 25
I got 01100011 problems but a bit ain't 00000001

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: Colors shield v1.1 (RGB shield)

Berichtdoor nicoverduin » 30 Okt 2013, 21:02

heb die library ook geïmporteerd?
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 7
Geregistreerd: 30 Okt 2013, 13:05

Re: Colors shield v1.1 (RGB shield)

Berichtdoor Arduinonieuw » 04 Dec 2013, 20:27

Hallo, hier ben ik weer,

Colors shield nog steeds niet aan de gang. Ik heb zelfs een Uno gekocht. Alle versie van iTEAD gedownload met libraries. Kan iemand mij vertellen wat ik precies moet doen om er iets uit te krijgen, ik word er gek van!!! Welke software moet ik nu in mijn arduino laden om dat shield ook maar iets te laten doen. Jullie schrijven steeds waar ik moet zijn en als ik die Software download en flash blijft dat ding errors geven. Het is altijd wat, maar niets werkt. Is er een stappenplan?????

Thnx........

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: Colors shield v1.1 (RGB shield)

Berichtdoor nicoverduin » 05 Dec 2013, 00:16

Ja er is een stappenplan voor Arduino...... Dat heet een tutorial.....
De boodschappen die jij krijgt worden veroorzaakt doordat je importeren van de library niet goed gaat.
Ik heb net jouw programma hierboven door de compiler gehaald voor zowel de Uno als de Atmega.
compileren prima.

Ik vermoed dat jij als eerste fout boodschap de regel in de trend van "Colorduino.h not found".

En dan ben ik toch wel nieuwsgierig wat jij waar hebt geïnstalleerd.
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 108
Geregistreerd: 07 Aug 2013, 21:34

Re: Colors shield v1.1 (RGB shield)

Berichtdoor KrisG » 05 Dec 2013, 11:40

Dit lijkt op: ik heb een auto en een vat benzine gekocht, maar de auto rijdt nog steeds niet... :)

Kris
Als je het probleem gedetailleerd genoeg omschrijft, heb je meestal al de oplossing.

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: Colors shield v1.1 (RGB shield)

Berichtdoor nicoverduin » 05 Dec 2013, 17:21

Ach hij heeft ofwel de libraries niet goed geinstalleerd of iets anders. De boodschappen onstaan omdat de compiler de include niet kan vervullen. Daarom bestaan al die datatypes niet. Daarom is het ook veel beter als je hiermee begint om gewoon een zooi tutorials door te lopen, beetje klooien met C++ om het in den vingers te krijgen. Nu krijgt men allerlei frustraties die onnodig zijn. De fout ligt immers nooit bij jezelf :)
Pas als je voor jezelf die laatste zin kan omdraaien namelijk "de fout ligt altijd bij jezelf". ben je zover om het echt te leren :)
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Volgende

Terug naar Arduino software

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 37 gasten