Page 1 of 1

Help modifying the code in the Elektor ethernet article?

Posted: 16 Apr 2009 14:44
by Ulf
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

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

Posted: 21 Apr 2009 08:32
by srdjan
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.

Posted: 21 Apr 2009 15:06
by Ulf
Hi, thank you very much for the response. I will see if I can do this.

Cheers

Ulf