Add pinmapping functionality.

This is more or less what I was thinking about for pin mapping functionality.

I only modified the gpio function for now, but if this gets merge, then it can be used in other places as well.