Hardware Reference
In-Depth Information
Finishing Touches
As usual, the source code here is functional but could do with a little bit of
tweaking. Remember those write functions that tell if the information was
written correctly? They all return true for the time being, but you can enhance
that by looking at the amount of bytes written to the I 2 C bus. Use that data to
give a more accurate response.
One thing is missing from this library: to perform a read, the user must i rst
make the output high. What would happen if that weren't done? The reading
would not be accurate. You could add this to the read functions; because the
outputs are known through a global variable, make sure that the output is high
before reading.
You have your shield, and you have your library, hopefully with your name
on both. Make this your project, and be creative with the applications you come
up with. Don't forget to tell me all about your projects!
Summa ry
In this chapter you have seen how to create your own library, and how to make
it easy to use by other users, by creating examples and other i les. You have seen
the importance of writing clear comments, how users will read your library,
as well as the importance of naming your functions. Now you have a working
library, ready to use with your own shield. All that is left to do is to imagine
new applications!
 
Search WWH ::




Custom Search