color shield bi color display

Hardware geleverd door Arduino
Berichten: 203
Geregistreerd: 11 Mei 2014, 11:22

color shield bi color display

Berichtdoor vanschagen » 27 Aug 2014, 14:20

exact het zelfde probleem hier ,met compilen dezelfde fouten,als poster "arduinonieuw"
libraries voeg ik zo toe, http://arduino.cc/en/Guide/Libraries
ik heb nu 3 versies,libraries erop staan ,allemaal het zelfde compile probleem als de poster arduinonieuw
wat doe ik dan nou weer fout.
display heb ik in bezit maar nog niet de printplaat ervoor :oops:

librarys staan hier
C:\users\medion\documents\arduino\librariers\libraries

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

ik gebruik de arduino MEGA

deze code gebruik ik

Code: Alles selecteren
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();
}

Advertisement

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

Re: color shield bi color display

Berichtdoor nicoverduin » 27 Aug 2014, 16:23

welke library heb je gebruikt bij deze compilatie?
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 203
Geregistreerd: 11 Mei 2014, 11:22

Re: color shield bi color display

Berichtdoor vanschagen » 27 Aug 2014, 16:45

ik begrijp dus dat ik nog een librarie toe moet voegen
ik gebruik de colorduinoplasma voorbeeld
die librarie heb ik toegevoegd en daar zat dat voorbeeld bij.
dus ik begrijp dat ik weer wat verkeerd doe
verdorie ,maar ik snap niet wat
deze heb ik geinstalleerd , http://blog.lincomatic.com/?p=148
ik heb ver 1.2 en v 1.2.4 geprobeerd ,maar alles geeft de zelfde compile fouten

sorry hoor Nico


hier staan de libraries ,normaal werkt alles

http://www.mijnbestand.nl/Bestand-FVXCT6N4FZFY.png

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

Re: color shield bi color display

Berichtdoor nicoverduin » 27 Aug 2014, 17:47

De oorzaak zo lijkt het is dat de library (versie 1.2) nog gericht is op de voude pre versie 1.0 van arduino IDE is gericht. Dit ga je denk ik nog wel meer meemaken. Mensen die enthousiast een library creëren en het beschikbaar stellen. Maar als het goed is staat er nog een foutboodschap voor de boodschappen die je laat zien. Bij C en C++ is het niet ondenkbaar dat een enkele Eerste fout leidt tot een hele batterij ander fouten. Dus altijd goed kijken naar de foutboodschappen en in ieder geval vanaf de eerste. Daar zei de compilper dat hij "WProgram.h" niet kon vinden

In colorduino.h er bovenaan:
cpp code
#ifndef _COLORDUINO_H_
#define _COLORDUINO_H_
#include "WProgam.h"


Dat moet zijn:
cpp code
#ifndef _COLORDUINO_H_
#define _COLORDUINO_H_
#include "Arduino.h"


Ik kon jouw sketch zo compileren :
cpp code
#include "Arduino.h"
/*
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();
}


compilatie resultaten:
cpp code
Building target: test
Printing size:
"D:/Arduino/hardware/tools/avr/bin/avr-size" --format=avr --mcu=atmega2560 "D:/workspace/test/Release/test.elf"
AVR Memory Usage
----------------
Device: atmega2560

Program: 5112 bytes (2.0% Full)
(.text + .data + .bootloader)

Data: 470 bytes (5.7% Full)
(.data + .bss + .noinit)
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 203
Geregistreerd: 11 Mei 2014, 11:22

Re: color shield bi color display

Berichtdoor vanschagen » 27 Aug 2014, 20:36

ik heb het over genomen wat je neer gezet hebt
maar zelfde fouten
zo staat het nu

Code: Alles selecteren
#ifndef _COLORDUINO_H_
#define _COLORDUINO_H_
#include "Arduino.h"


#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: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: color shield bi color display

Berichtdoor nicoverduin » 27 Aug 2014, 22:56

Je moet natuurlijk wel doen wat ik vraag.....

Je moet colorduino.h aanpassen. Die is nog gebaseerd op de Arduino IDE < 1.0
De code die ik heb neer gezet is goed dus daar moet je vanaf blijven. De code die je nu hebt gemaakt gaat zeker niet werken
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 203
Geregistreerd: 11 Mei 2014, 11:22

Re: color shield bi color display

Berichtdoor vanschagen » 28 Aug 2014, 07:42

sorry nico
colorduino.h aanpassen gaat mij dus niet lukken,dat weet je zelf ook wel.
maar als jij het werkend hebt,kun je me de werkende versie dan niet geven???
ik red het zo toch niet.

waar heb jij je librarier staan???
de mijne staan hier,en dat klopt volgens mij ook niet.
C:\users\medion\documents\arduino\libraries\libraries

en compileer jij met de arduino UNO of met de MEGA???
en welk ide gebruik jij de 1.0.5 of de beta 1.5.7????

deze heb ik ook geprobeerd ,dezelfde fouten
https://github.com/lincomatic/Colorduino/downloads

Berichten: 203
Geregistreerd: 11 Mei 2014, 11:22

Re: color shield bi color display

Berichtdoor vanschagen » 28 Aug 2014, 08:55

heb nu dit gevonden ,maar daar vind hij colorduino.h blijkbaar niet
ben al wel wat verder nu.
maar colorduino heb ik al wel toegevoegd ,maar hij vind hem niet dus.

Code: Alles selecteren
#ifndef _COLORDUINO_H_
#define _COLORDUINO_H_
#include "Arduino.h"
#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <colorduino.h>
#define ColorduinoBitsPerColor 8

#define ColorduinoScreenWidth 8
#define ColorduinoScreenHeight 8






   /*
  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
*/




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: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: color shield bi color display

Berichtdoor nicoverduin » 28 Aug 2014, 09:19

Je hebt toch die library geïmporteerd?

Laatste keer en dan geef ik het op.......

a) gebruik mijn programma zoals ik hem heb laten zien. Niet meer en niet minder
b) Importeer de colorduino library en pas colorduino.h aan. Niet meer en niet minder.
c) compileren
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 203
Geregistreerd: 11 Mei 2014, 11:22

Re: color shield bi color display

Berichtdoor vanschagen » 28 Aug 2014, 09:29

ja maarzo als ik aan gaf die colorduino.h ziet hij blijkbaar niet dat is het probleem en ik snap er niks van
ik voeg die toe volgens de orginele regels ,maar hij zet het ergens neer ,waar hij blijkbaar niet gevonden word.
en een library aanpassen gaat mij echt niet lukken

kun je me eigenlijk niet even helpen ,via Teamviewer?????

Volgende

Terug naar Arduino hardware

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 50 gasten