I am currently working on rewriting the driver suite to make them leaner. They won’t be backwards compatible with the old ones. Some of the changes will include:
- HiTechnic Sensor MUX support separated out from common.h. If you want to use it, you will need to include a a file for it. All subsequently included driver files will automatically have support for the sensor MUX. If you don’t include it, the sensor MUX specific functions will not be compiled in;
- Arrays are no longer structs but normal typedefs. The bug that necessitated the structs is no longer present and hasn’t been for some time, I just never got around to changing my code;
- Some sensors like the HT Infrared Seeker and Color Sensors have two versions; I’d like to merge these separate versions into one. The driver itself will determine what kind of sensor it’s dealing with and handle accordingly.
- Improve examples to have more comments;
- Add a HOWTO for using the drivers; it will deal with topics like including the right files, setting up the sensors in the wizard, etc;
- Merge certain functions by using pre-initialised arguments.
As you can see, plenty of things to be done. There are currently 44 sensors supported by my drivers, so it’s a fair bit of work. I’ve already converted some drivers and non-SMUX test programs. The results so far are quite promising. Here are some figures for the HiTechnic Accelerometer driver test programs, before and after.
|HTAC-test1.c (old)||HTAC-test1.c (new)||HTAC-SMUX-test1.c (old)||HTAC-SMUX-test1.c (new)|
|Total code bytes||4598||1643 (-64%)||4618||4319 (-6%)|
|Memory locations||716||420 (-41%)||716||652 (-9%)|
|Procedures||59||22 (-63%)||57||46 (-19%)|
Hopefully I’ll be able to shave some more fat off the suite here and there, we shall see.