Page 1 of 1

Sketch with modified libraries?

Posted: Sun Dec 30, 2012 10:25 pm
by bondolo
I've just started playing with programming my ReefAngel and have been able to modify a sketch created by the wizard. I wanted to make some library changes but I can't figure out how to correctly add them. If I try to add the RA_NokiaLCD.cpp and RA_NokiaLCD.h to my sketch then the compile fails with messages about "sketch_dec30b:72: error: 'class ReefAngelClass' has no member named 'PWM'"

If I just modify the files in libararies/ReefAngel/RA_NokiaLCD/ then it appears to have no effect--the original libraries are used.

There seems to be some gap in my understanding of the Arduino compilation/library model.

The code in question is intended to replace the DrawOutletBox with a version that allows the outlets to be labelled. A wrapper for the old behaviour is provided that prints the usual 1-8. In my sketch I would use the new DrawLabelledOutletBox with a label set that labels my outlets "HFLR KR" (or something else that helps me remember which is which).

Cheers!

Code: Select all

void RA_NokiaLCD::DrawOutletBox(byte x, byte y,byte RelayData)
{
    DrawLabelledOutletBox(x, y, RelayData, "12345678");
}

void RA_NokiaLCD::DrawLabelledOutletBox(byte x, byte y,byte RelayData, char* labels)
{
    Clear(OutletBorderColor,x,y,x+104,y);  //94
    Clear(OutletBorderColor,x,y+12,x+104,y+12);
    for (byte a=0;a<8;a++)
    {
        byte bcolor = OutletOffBGColor;
        byte fcolor = OutletOffFGColor;
        char temp[]="  ";
        if ((RelayData&(1<<a))==1<<a)
        {
            bcolor = OutletOnBGColor;
            fcolor = OutletOnFGColor;
        }
        Clear(bcolor,x+(a*13),y+1,x+13+(a*13),y+11);
        temp[0] = labels[a];
        DrawText(fcolor,bcolor,x+4+(a*13),y+3,temp);
    }
}

Re: Sketch with modified libraries?

Posted: Mon Dec 31, 2012 9:30 am
by rimai
If you change the library itself, you will loose the changes next time the system updates the libraries.
So, the best option is to just create a function of your own.
Like this:

Code: Select all

void DrawLabelledOutletBox(byte x, byte y,byte RelayData, char* labels)
{
    ReefAngel.LCD.Clear(OutletBorderColor,x,y,x+104,y);  //94
    ReefAngel.LCD.Clear(OutletBorderColor,x,y+12,x+104,y+12);
    for (byte a=0;a<8;a++)
    {
        byte bcolor = OutletOffBGColor;
        byte fcolor = OutletOffFGColor;
        char temp[]="  ";
        if ((RelayData&(1<<a))==1<<a)
        {
            bcolor = OutletOnBGColor;
            fcolor = OutletOnFGColor;
        }
        ReefAngel.LCD.Clear(bcolor,x+(a*13),y+1,x+13+(a*13),y+11);
        temp[0] = labels[a];
        ReefAngel.LCD.DrawText(fcolor,bcolor,x+4+(a*13),y+3,temp);
    }
}
Add this to the very end of your code and use the function just like this:

Code: Select all

DrawLabelledOutletBox(10,120,ReefAngel.Relay.RelayData,"Test");
Let me know if this works.