Shallow Thoughts : : Sep

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Wed, 18 Sep 2013

Connecting an Arduino Pro Mini with an FTDI Friend

I found myself wanting to upload a sketch to an Arduino Pro Mini recently, using an FTDI Friend, and found that how to do it was surprisingly undocumented.

[Arduino Pro Mini] [Arduino Pro Mini]

First, the important thing is that the six FTDI pins do match up with the six pins at the edge of the Pro Mini, though obviously you have to figure out which way to rotate the two boards so you won't be 180 degrees off. I wasn't clear on that since the labels on the pins don't seem to match (see below).

Second, if you haven't soldered headers to your Pro Mini, you can stick a female-female header into the FTDI Friend's female header. then insert the other side of the header into the holes in the Pro Mini at an angle -- hold them with some tension so that the header pins are making contact with the copper-plated rims of the Pro Mini holes.

Okay, so the big question is which way to match the pins. It's complicated by the Pro Mini's having both outer holes unlabeled.

Usually when trying to match pins I start by looking for Ground, and make sure the two Grounds match. That doesn't work here -- the FTDI has the Gnd on one of the outer pins, while the Pro Mini has Gnd on the second pin in. The pin parked Gnd on the Pro Mini goes to CTS on the FTDI, while the pin parked Gnd on the FTDI corresponds to a pin on the Pro Mini that's unmarked. If you turned one of them 180 degrees, then you'd have Gnd (Pro Mini) - Rx (FTDI), and Gnd (FTDI) - unmarked (Pro Mini). No help there.

So ignore Ground and use VCC as your guide. It's on the third pin in -- so only in one orientation will VCC on both boards match. That's the orientation you want, and it works.

On some Pro Minis and some FTDI boards, you'll also have a label for "GREEN" or "GRN" on one side, and "BLACK" or "BLK" on the other. Match those if you have them, but you may not find that on all boards, particularly if you ever hook up to clone or third-party boards. So stick to VCC as a guide and you should be okay.

So what are those outer two holes on the Pro Mini? An image search for Arduino Pro Mini Pinout gives some pages showing GRN as TX and BLK as +9V (I assume that would be Vin, but actually those pages seem to be referring to the Arduino Mini, not the Pro Mini). But another shows GRN as RESET and BLK as Gnd. The official Pro Mini schematic shows the outer pins on JP1 as DTR and GND. So that seems most likely.

Tags: , ,
[ 16:28 Sep 18, 2013    More hardware | permalink to this entry | ]

Fri, 13 Sep 2013

GIMP menu placeholders

Someone on the gimp-developers list asked whether there was documentation of GIMP's menu hooks.

I wasn't sure what they meant by "hooks", but GIMP menus do have an interesting feature that plug-in writers should know about: placeholders.

Placeholders let you group similar types of actions together. For instance, iever notice that in the image window's File menu, all the things that Open images are grouped together? There's Open, Open as Layers..., Open Location... and Open Recent. And then there's a group of Save actions all grouped together -- Save, Save As..., Save a Copy... and so forth. That's because there's a placeholder for Open in the File menu, and another placeholder for Save.

When you write your own plug-ins, you can take advantage of these placeholders. For instance, I want my Save/Export clean plug-in to show up next to the other Save menu items, not somewhere else down near the bottom of the menu -- so when I register it, I pass menu = "<Image>/File/Save/" so GIMP knows to group it with the other Save actions, even though it's directly in the File menu, not a submenu called Save..

Pretty slick, huh? But how do you know what placeholders are available?

I took a look at the source. In the menus/ subdirectory are all the menu definitions in XML, and they're pretty straightforward. In image-menu.xml you'll see things like <placeholder name="Open">, <placeholder name="Save">

So to get a list of all the menu placeholders, you just need to find all the " grep '<placeholder' menus/*.xml

That's not actually so useful, though, because it doesn't tell you what submenu contains the placeholder. For instance, Acquire is a placeholder but you need to know that it's actually File->Create->Acquire. So let's be a little more clever.

We want to see <menu lines as well as <placeholders, but not <menuitem since those are just individual menu entries. egrep '<(placeholder|menu) will do that. Then pass it through some sed expressions to clean up the output, loop over all the XML files, and I ended up with:

for f in *.xml; do
  echo $f
  egrep '<(placeholder|menu) ' $f | sed -e 's_<placeholder *name="_** _' -e 's_<menu.*name="__' -e 's_"/*>__'
done

It isn't perfect: a few lines still show up that shouldn't -- but it'll get you the list you need. Fortunately the GIMP developers are very good about things like code formatting, so the identation of the file shows which placeholder is inside which submenu.

I only found placeholders in the image window menu, plus a single placeholder, "Outline", in the selection menu popup. I'm a little confused about that menu file: it seems to duplicate the existing Select menu in the image-menu.xml, except that the placeholder items in question -- feather, sharpen, shrink, grow, and border -- are in a placeholder called Outline in selection-menu.xml, but in a placeholder called Modify in image-menu.xml.

Anyway, here's the full list of placeholders, cleaned up for readability. Placeholders are in bold and followed with an asterisk *.

===== image-menu.xml =====
    File
      Create
        Acquire *
      Open *
      Open Recent
        Files *
      Debug
      Save *
      Export *
      Send *
      Info *
    Context
    Edit
      Undo *
      Cut *
      Copy *
      Paste *
      Paste as
      Buffer
      Clear *
      Fill *
      Stroke *
      Preferences *
    Select
      Modify *
    View
    Image
      New *
      Mode
        Color Profile *
      Precision
      Transform
        Flip *
        Rotate *
      Resize *
      Scale *
      Crop *
      Structure *
      Arrange *
      Guides
    Layer
      New *
      Structure *
      Text *
      Stack
        Select *
        Position *
      Mask
        Modify *
        Properties *
        Selection *
      Transparency
        Modify *
        Selection *
      Transform
        Flip *
        Rotate *
      Properties
        Opacity
        Layer Mode
      Resize *
      Scale *
      Crop *
    Colors
      Invert *
      Auto
      Components
      Desaturate
      Map
        Colormap *
      Info
      Modify *
    Tools
    Filters
      Recently Used
        Plug-Ins *
      Blur
        Motion *
      Enhance
      Distorts
      Light and Shadow
        Light *
        Shadow *
        Glass *
      Noise
      Edge-Detect
      Generic
      Combine
      Artistic
      Decor
      Map
      Render
        Clouds
        Nature
        Pattern
      Web
      Animation
        Animators *
      Menus *
      Languages *
      Extensions *
    Menus *
    Windows
      Recently Closed Docks
      Dockable Dialogs
      Images *
      Docks *
    Help
      Programming *

===== selection-menu.xml =====
    Outline *

Tags: ,
[ 19:06 Sep 13, 2013    More gimp | permalink to this entry | ]

Sat, 07 Sep 2013

Daytime Venus-Moon-Saturn conjunction

Tomorrow, Sunday September 8th, is an interesting astronomical event: a nice conjunction of a slim crescent moon and gibbous Venus, with Saturn hanging above and to the left of the pair.

That alone isn't anything unusual, though they'll be a lovely naked-eye sight just after nightfall. But here's the kicker: they'll be quite a bit closest during the daytime, best around 2-3 in the afternoon, Which makes for a fun exercise: can you find the crescent moon during daylight, then use it to guide you to Venus (right above it, about a degree away) and Saturn (about 10 degrees away, down and left)?

They'll be just a little east of due south, and about 40 degrees up. You'll definitely need binoculars to find Saturn, and they might help in finding the other two as well, depending on how bright and how hazy your afternoon sky is. Once you find them, a low powered telescope view should show Venus' phase and Saturn's rings. Venus is gibbous, alas; it would have been fun to see two crescents lined up one above the other.

If you have trouble finding them, wait until 3:30 pm, when they'll be transiting. At that point, you should be able to point due south, sweep your binoculars (or just your eyes) up just short of halfway to the zenith, and the moon should be there.

If you don't get a chance to watch the daylight conjunction, or don't have binoculars or a telescope handy, at least take a naked eye look at the trio at nightfall.

Mars and an early view of Comet ISON

As long as I'm reposting tips from my SJAA Ephemeris Shallow Sky column, there's another interesting thing in the sky this month: Comet C/2012 S1 ISON. Yes, that's the "super comet" that's supposed to become brighter than the moon. No, it won't be bright yet. It's still super wimpy, and worse, it's still in the morning sky, so it's not an easy or convenient target.

On the other hand, through September and October, Mars and Comet ISON will be within a few degrees of each other. So if you're willing to stay up (or get up) for early morning dark-sky observing, and you have a big telescope, this could be a nice view.

The comet won't be very impressive yet -- it's only expected to be 10th magnitude in September -- but such close proximity to Mars makes it easy to find and keep track of. In September, the pair don't rise until about 3:30am, and that won't change much for the next few months. The comet will probably stay below naked eye visibility at least for the next two months, brightening from 11th magnitude in early September to maybe 7th magnitude by Halloween.

As September opens, ISON makes a triangle with Mars and M44, the Beehive cluster. The comet stands about 2 degrees north of the Beehive and about 5 degrees east of Mars. But it closes with Mars as the month progresses: by the end of September you can find the comet about two degrees north of Mars, and by the middle of October they'll be down to only a degree apart (with ISON brightening to about ninth magnitude).

About that Beehive cluster: right now (September 7 through 9), Mars is passing right through the Beehive, like an angry red wasp among the smaller bees. Should be a nice view even if the comet isn't. It's a good binocular or even naked eye view (though great with a telescope, too). So if you find yourself up before dawn, definitely take a look.

Tags: ,
[ 19:34 Sep 07, 2013    More science/astro | permalink to this entry | ]

Mon, 02 Sep 2013

Waking up to Balloons

We recently returned from a quick whirlwind trip through a series of towns in the Four Corners area: the place where Arizona, New Mexico, Colorado and Utah come together.

[Hot-air balloon landing in the road in Cortez, CO] One highlight: watching hot-air balloons floating across the sky against the backdrop of Mesa Verde in Cortez, CO ... and watching one accidentally land in the middle of the highway in front of our motel (the White Eagle Inn, a charming little place with super nice owners).

Cars stopped on the highway while someone jumped out of the basket and pushed the balloon toward the side of the road. The truck on the left is the chase crew.

(And yes, that's a powerline in the foreground, very close to where the balloon came down.)

[Hot-air balloons in Cortez, CO] The sky was full of balloons, and the hotel was as good a place as any to watch them. Quite a way to start the morning!

Other highlights:

The view of the Rio Grande from the White Rock Overlook with lightning flashing in the background.

[Rio Grande panorama from White Rock, NM Overlook Park] (No lightning in the photo, just a 13-image panorama. Click for a bigger version.)

Dinner at Rancho de Chimayo. I had their famous carne adovada, Dave had a stuffed sopaipilla with green chile, and we shared. And sopaipillas with honey on the side, of course. They're just as good as they were the first time I was there ... was that really a quarter century ago?

All the motels that are using WPA passwords for their wi-fi, instead of stupid browser pages that you have to re-authenticate every time the connection drops. Things are looking up, gradually, for motel wi-fi.

[The working Ivanpah solar collector] Heading back into California, driving past Primm, NV, we checked out the progress on the new solar tower collector being built at old Ivanpah. It's changed a lot since we were there last. It looks like one tower is operational (though its mirror array doesn't appear to extend all the way around yet), while two more towers have mirror arrays but still have covers over the central tower. [All three Ivanpah solar collectors]

Tags: ,
[ 21:15 Sep 02, 2013    More travel | permalink to this entry | ]