Help modifying the code in the Elektor ethernet article?

General discussion on mikroPascal.
Post Reply
Author
Message
Ulf
Posts: 63
Joined: 30 Dec 2007 18:23
Location: Sweden

Help modifying the code in the Elektor ethernet article?

#1 Post by Ulf » 16 Apr 2009 14:44

I have tested the exampel code associated with the MikroElektronika ethernet article in Elektor http://www.mikroe.com/en/article/09/02/#pic. It works very nicely. I have also managed to modify the code so I have one more ON/OFF button. But I do not understand how I shall change the code so the background color of my added button changes with the state of the PORT pin.
I assume that it is this part of the example code that changes the color of the button in the exampel:

Code: Select all

    if (PORTB.0) then
      begin
        tmp := '#FFFF00'; memcpy(@indexPage+340, @tmp, 6);       // highlight (yellow) ON
        tmp := '#4974E2'; memcpy(@indexPage+431, @tmp, 6);       // clear OFF
      end
    else
      begin
        tmp := '#4974E2'; memcpy(@indexPage+340, @tmp, 6);       // clear ON
        tmp := '#FFFF00'; memcpy(@indexPage+431, @tmp, 6);       // highlight (yellow) OFF
      end;
I wonder if someone could tell me how to figure out what number should be added to @indexPage to change the color of my added button? I have tried with trial and error but it has always been wrong.

Regards

Ulf

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Re: Help modifying the code in the Elektor ethernet article?

#2 Post by srdjan » 21 Apr 2009 08:32

Hi,
Ulf wrote:

Code: Select all

    if (PORTB.0) then
      begin
        tmp := '#FFFF00'; memcpy(@indexPage+340, @tmp, 6);       // highlight (yellow) ON
        tmp := '#4974E2'; memcpy(@indexPage+431, @tmp, 6);       // clear OFF
      end
    else
      begin
        tmp := '#4974E2'; memcpy(@indexPage+340, @tmp, 6);       // clear ON
        tmp := '#FFFF00'; memcpy(@indexPage+431, @tmp, 6);       // highlight (yellow) OFF
      end;
I wonder if someone could tell me how to figure out what number should be added to @indexPage to change the color of my added button? I have tried with trial and error but it has always been wrong.

Regards

Ulf
For this approach you'll need to count characters in your html page preceding color section you need to replace. The easiest way is to start software debugger and see the locations of the color sections in the html page array.

Ulf
Posts: 63
Joined: 30 Dec 2007 18:23
Location: Sweden

#3 Post by Ulf » 21 Apr 2009 15:06

Hi, thank you very much for the response. I will see if I can do this.

Cheers

Ulf

Post Reply

Return to “mikroPascal General”