Fix reading the PWM period on init and compilation with multiple files.

`fopen` mode `"a"` positions the stream at the end of the file, so it was always reading 0. `"a+"` would have fixed the problem as well, but since the file is only being read, it makes more sense to open it as read-only.

Also, move state declaration out of robotics_cape.h, because it causes linking problems when it's included in multiple files in the same project (symbol collision).