jjcarrier/Si4735 — pull request #1 by csdexter (2012-03-18 22:36:30+00:00)
Title: Si4735 Refactor, as discussed on the blog

For some unknown reason, my reply to your comment on your blog disappeared today, in spite of being initially published without issue. This gave me enough determination and time to set up a proper github account, do the paperwork which brings us to this message and also write a proper ChangeLog entry :-)

- added keywords file for syntax highlighting support in Arduino IDE
- added Si4735-private.h, containing library-private constants
- switched to using the official SPI library
- moved translation (table-driven) code to a separate class, thus
allowing gcc's -Os to magically do the right thing if you're not using
that class
- added translation of PTY codes between locales
- made Si4735 connection configurable at constructor, as is the case
with many other libraries. Used default parameters to keep the change
transparent.
- made powering Si4735 off a digital pin optional
- adjusted code behavior to match data sheet timing specs to the letter
-- this includes obvious things such as making sure SPI speed is under
2.5MHz at all times and not so obvious things such as signal-to-signal
sequencing and timing restrictions
- used default arguments to factor a nicer interface for sendCommand()
- added chip communication debugging (with pretty print!), controlled
by compile-time #define
- added constants for all data sheet flags and numbers, making the code
more readable
- added varactor (varicap) bits when tuning on SW
- ensured "silence on the bus!" during tuning, as recommended in the
data sheet
- RDS configuration isn't a global state, configured per power up, but
a local one, configured *after* successful tune in -- changed to match
- made returning only parts of the chip revision data possible
- getFrequency() now ACKs STCINT
- made use of built-in constrain() to streamline code
- updateRDS() now only runs if in FM mode *and* RDSINT was triggered,
SPI traffic per call reduced from 3+17 bytes to 2 bytes for inactive
runs
- now also extracting DI, M/S, PTYN from RDS
- added endianness awareness where necessary throughout the code (AVRs
are little-endian, Si4735 is big-endian)
- used integer arithmetic (fixed point) for group 4A date/time
calculations as AVRs lack a FPU and emulation is not only slow, but
also big
- string sanitization now uses "?" as placeholder character, as is
customary
- added isRDSCapable(), for high-level code to be able to decide not to
call updateRDS() after a set timeout for trying to acquire the RDS
stream
- getRDSTime() now returns false if no CT is being transmitted
- getRSQ() now ACKs RSQINT, also now extracts PILOT too
- the chip knows its current volume level, no need to store it locally
too, also enhanced volumeDown() to mute when reaching the bottom
- made extensive use of the word() constructor to enforce proper
alignment of values at all times
- since all class functions that call getResponse() live within the
class, it made perfect sense to add private byte response[16]
- end() can now optionally hard power off the chip
- removed locale stuff from class Si4735, left only setDeemphasis()
- setMode() now allows switching modes on the fly, including the whole
dance of getting the chip ready again
- resetRDS() now gracefully resets RDS strings (space-fill instead of
truncate)
- used built-in constant for SPI pins doing away with the #if
defined(MEGA) block
- refactored Si4735_Example and Si4735_SerialExample to work with the
current version of the library, also extended their functionality to
make them more useful for quickly getting a feel of what (and how) the
library does
- added a command to flush the current command string buffer contents
to Si4735_SerialExample
- added the "?" (help) command to both examples