delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2012/07/12/09:46:57

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Message-ID: <4FFED530.70503@estechnical.co.uk>
Date: Thu, 12 Jul 2012 14:46:24 +0100
From: Ed Simmons <ed AT estechnical DOT co DOT uk>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
MIME-Version: 1.0
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] pcb_(f)printf
References: <4FFDD696 DOT 3090509 AT estechnical DOT co DOT uk> <20120711211832 DOT GA9292 AT visitor2 DOT iram DOT es> <4FFDFD1F DOT 70704 AT estechnical DOT co DOT uk> <4FFE08B0 DOT 4060609 AT estechnical DOT co DOT uk> <20120712041809 DOT GA28342 AT malakian DOT lan>
In-Reply-To: <20120712041809.GA28342@malakian.lan>
X-Authenticated-As: ed AT estechnical DOT co DOT uk
Reply-To: geda-user AT delorie DOT com

On 12/07/12 05:18, Andrew Poelstra wrote:
> On Thu, Jul 12, 2012 at 12:13:52AM +0100, Ed Simmons wrote:
>> Sorry for the noise, I've figured it out. Dividing from the base
>> unit and printing an integer works fine for my purposes.
>>
>>     pcb_fprintf(fp, "3  : 230: 1: 3: 0:F 1X %iY %iA %iR %s %s %s\n",
>>             x/10000 , y/10000 , theta * 10, name, value, FRONT
>> (element) == 1 ? "top" : "bot");
>>
> Please don't use base units -- %i won't work on 64-bit systems, and
> isn't guaranteed to work on any systems in the future. Instead use
> the %mn specifier to output coordinates as nanometers. (Then you can
> use /10000 as you have.)
>   
>

Thanks, that's looking much better now. I did think it was a bit ugly to 
use the base unit, considering there's obviously been plenty of work to 
avoid using the base units directly.

I'm now finding another issue... I've made a fiducial symbol and 
footprint, and I'm successfully identifying fiducial 1 in the exporter, 
then trying to get it's location to use as the bias offset for all the 
location data that is subsequently output.

Using the same element loop and pin/pad loops to find the location of 
the fiducial seems to not work properly for me yet. I always get X axis 
location as 0, but Y looks as though it is working.

This is what I have:

   ELEMENT_LOOP (PCB->Data);
   {

       if (NSTRCMP ( NAMEONPCB_NAME (element), "FID1") == 0)
       { // hooray! fiducial 1 has been found
          pcb_fprintf (fp, "# Found fiducial 1\n");
          int count = 0;

           PAD_LOOP (element);
           {
             sumx += (pad->Point1.X + pad->Point2.X) / 2.0;
             sumy += (pad->Point1.Y + pad->Point2.Y) / 2.0;
             pcb_fprintf (fp, "# Sum X = %.2mm Sum y = %.2mm\n", 
sumx,sumy); //seems here that X is never getting a value other than 0
             count++;
           }
           END_LOOP;
           pcb_fprintf (fp, "# Found %i pads\n", count);
           if(count > 0 && count <= 2){ // the fiducial can have pads 
top and bottom!!
             offsetX = sumx;
             offsetY = sumy;
           }

       }

   }
   END_LOOP;

Any bright ideas would be greatly appreciated.

Thanks again.
Ed

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019