Dangerous Prototypes

General Category => General discussion => Topic started by: honken on September 10, 2011, 01:38:30 pm

Title: QR in eagle
Post by: honken on September 10, 2011, 01:38:30 pm
Hi all,

As i was preparing some boards for manufacturing (perhaps a 7400 entry) I thought it would be fun to partake in Itead's OpenPCB program. But that requires me to have some identifying mark on my board and I thought a QR code would be perfect.

The bmp import in eagle as some room for improvement so I skipped that and wrote my own.
As I was writing I found out that the latest eagle (5.11.0) can do http get/post statements in ulp.
So here it is, dynamic pcb qr code generation with the help of Web 2.0...

Hope somebody will find it useful. No rights reserved. It's just a little midnight hack, so expect bugs.

unzip and rename to .ulp

[EDIT]Look futher down this thread[/EDIT]
Title: Re: QR in eagle
Post by: ian on September 12, 2011, 09:03:05 am
Very cool, I'll post this up.
Title: Re: QR in eagle
Post by: Sjaak on September 15, 2011, 05:47:21 pm
I fixed a couple of errors :)

Fixed:
- other sizes then 1
- a typo (unterminated string) on line5
- disabled selecting the qr code (only works when layer is specified)

things to consider:
- eagle ulp does have xml parser capabilities
- you can run the script on exit (i.e. exit (grid mm;); )

BTW nice hack :)
Title: Re: QR in eagle
Post by: honken on September 15, 2011, 07:22:04 pm
Great, I didn't know about the xml parser functions. I'll definitely look into those. It'll make it more robust, hopefully.

Update to come, now I'm off for dinner.
Title: Re: QR in eagle
Post by: Sjaak on September 15, 2011, 07:59:37 pm
It prolly does :) THere is no garantee the formatting stays exactly the same.
Title: Re: QR in eagle
Post by: honken on September 20, 2011, 09:01:47 pm
I've updated to the built-in XML decoding as suggested by Sjaak.
Another change is that it draws the QR at the mark instead of origo.
Title: Re: QR in eagle
Post by: honken on September 22, 2011, 06:33:44 am
Warning!
On my way to work this morning I realize this is probably wrong.
If you use this on a "dark" board and white stencil the colors will be inverted.

I'll have to investigate if it will still work with inverted colors, or if anybody knows please tell.
Title: Re: QR in eagle
Post by: alexwhittemore on October 18, 2011, 04:01:33 pm
Not sure what the deal is, but I'm trying to use honken's newest release and I'm not getting anything at all! I go through the dialog, select top/bottom silk, and hit generate, a progress bar runs up, then... nothing. No new objects, no visible anything, not sure what the deal is.

Also, it's unclear to me: What does 'current layer' mean? In order for there to be a 'current layer', I have to be in some tool, but the ULP doesn't run in the context of a tool.

EDIT: Hmmmm, it dumps a .scr into my project directory that makes the code. Makes more sense now, but still unintuitive.

EDIT 2: Here's a much bigger problem: Looks like characters don't get escaped correctly - my end URL reads as http%3A%2F%2F......

EDIT 3: Got a chance to look at the code, it turns out that the urlencode() is an unnecessary step. Not sure where it comes into play in the api calls, but I just made the change in the first line of the main make_gr_scr function:
Code: [Select]
  //string url_enc = urlencode( url );
  string url_enc = url;

tl;dr: made a quick modification, version attached below works for me with URLs.
Title: Re: QR in eagle
Post by: zivimo on June 03, 2013, 12:12:10 am
hey,

i got following problem:
Code: [Select]
../qr-code.ulp(49): XML-Error (1, 1): unexpectedd end of file
using eagle 6.1.0 pro. any solution?

thx a lot !
Title: Re: QR in eagle
Post by: honken on June 03, 2013, 06:33:57 pm
The old url redirects to http://http://www.esponce.com and they also have a new API version.

The new url in line 46 should be
Code: [Select]
http://www.esponce.com/api/v3/generate?content=
.
Title: Re: QR in eagle
Post by: honken on June 04, 2013, 09:20:56 am
OK,

I edited the file and reuploded.
[attachment=0]

I'll try to edit my previous posts.

It use the new API at esponce.com.

I have also changed from xml format to text, and then I can actually draw the QR non inverted with the most common case of white silkscreen on a "dark" board.

The urlencode part is very crude and "overdoes" things, ie encodes characters not necessary to encode, but without it it will break if you try to put an ampersand (&) or a space into the info you want in the QR-code.
Title: Re: QR in eagle
Post by: vld on January 24, 2015, 02:57:57 am
Hi, looks like the script is not working anymore (permission denied).
Can this be fixed again? Great script...
Title: Re: QR in eagle
Post by: Sjaak on January 26, 2015, 09:58:27 am
I think the website used for generating the qrcode is a paid service now.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01012089600session_write_close ( )...(null):0
20.01042221192ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01042221968Database_MySQL->query( ).../DatabaseHandler.php:119
40.05402360704Database_MySQL->error( ).../Db-mysql.class.php:273