Sketch with modified libraries?

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
bondolo
Posts: 14
Joined: Fri Nov 23, 2012 2:59 pm

Sketch with modified libraries?

Post 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);
    }
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Sketch with modified libraries?

Post 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.
Roberto.
Post Reply