[Legend General] mikereidis:
Version 1.

Go to the end of this post for the files.

I've only tested this in a month or so old version of CM7 on my Legend. It does not work on Blayo at this time. Besides daemon support, the only other reason root might be needed is to run the fix for audio routing on older CM ROMs.

The API requires Android 2.1-update1 at minimum, for Android Bluetooth support. I'm not sure about the App Inventor application but I'd guess 2.1 should be good for it also, and would also be need for BT support.

In theory, any device with a TI FM chip accessible via the hcitool command line utility should work in non-daemon mode. With the daemon, a working libbluetooth.so library needs to be available. Blayo has that library but I couldn't convince it to play nice with my code.

In the normal, non-daemon mode of operation, the API creates a directory named "sprt" in the "/sdcard" directory, so you'll need an SDCard. I could make this configurable in future. This is required because some place for the output of the hcitool commands is needed in order to read FM registers, such as RSSI. I'd like to avoid this requirement, but the only way I'm aware of at present requires "unusual" use of the message logs.

I renamed the app from SpiritFMRadio to aSpiritFMRadio, for now at least, because I got tired of scrolling down in the apps lists.

Currently, the best support is for North American FM standards. Setting even or other frequencies, such as for Australia, can be done with Config (floppy) -> Frequency or hit the "SEEK" mode button twice (puts it into "fine" tune mode) and move up or down 50 KHz from current frequency.

The development tool: Android App Inventor, has some serious quirks and limitations. I've worked around them the best I can, but expect this app will migrate towards a largely Java based app, or at least a service that can be used by Java or AI apps.

You need to download and install the API and the Application. The "sprt" daemon is optional and may be copied to /system/bin or anywhere else the path can find it. The daemon speeds up things like seeks nicely and uses fewer system resources. The "normal" way runs the command line hcitool utility under the covers.

When the app starts it takes around 12-14 seconds on my Legend to initialize the screen. At that point it will enable Bluetooth if needed and attempt to power up the FM. Enabling BT takes around 6 seconds for me. The power button at the upper left should go green and radio should be tuned to 91.5 Mhz on speaker with volume = 30%.

Clicking the power button should toggle the FM power state. To it's right is a bluetooth symbol that should follow the state of BT power. In middle is an old school floppy disk Icon representing Configuration. You may wish to/should avoid using it until I document the functions better. Some are bad news at this time.

The screen layout is designed mostly for landscape mode (power button up). It will switch and change some graphics to fit after a second or two of turning to a new orientation.

Horizontally, the leftmost column tends to feature a predominant button. The rightmost column is used only for information. It is the preferred place to grab if/when you need to scroll. In normal, non-debug mode, no scrolling should be needed in landscape mode. The largest middle section has buttons, displays etc.

The first row is for "Control" such as Power, BT state, Config, Info.

The second row is for "Audio". It starts with speaker or headset selection. Next is the volume slider and at right the volume percentage indication.

The last 3 rows are for "Tuner", ie RF radio stuff; mostly frequency but also RSSI (Signal strength). Button at 1st row left picks a random frequency and does an upward seek from there. Poking the frequency indicator in the middle should seek from your selection. At right is RSSI indicator. It will update if stats polling is on or when frequency is set or reset. Max I've seen is 51.

The 2nd Tuner row starts with the "Frequency Mode" button that affects how the middle up and down frequency buttons work. Default is "SEEK". Hit the mode button once and symbols change from "<<" and ">>" to "<" and ">" to indicate "TUNE" mode that moves 1 channel (0.2 MHz) at a time. Final mode, "-" and "+" is "FINE" tune mode that moves 50 KHz or 0.05 MHz.

The 3rd Tuner row starts with the Preset button. Only 3 presets are supported at this point. Press the Preset button when you are tuned to a frequency you like, and then press the button in the middle you want to program.

Seeking isn't perfect at this time. HTC app seems to do better so I'll have to study it. My algorithm attempts to avoid the problem where seeks stop at static or distortion, often from a powerful local station at the next or previous channel. So the hardware seek function is augmented with code that switches back to previous channel, and possibly next channel to see if RSSI on adjacent channels supports the current seek result.

The 3 config options starting with "Rssi" affect how seeks work. My development is done in a low signal area, so perhaps the Rssi options can be raised, but at present, no higher than 31. I'll document this better later.

Config option "DaemonEnable" should allow automatic starting and use of the daemon. If it works for you, I recommend it.

Config option "SUOutEnable" is normally enabled. If you don't need the audio fix it can be disabled. All the code for this does is "chmod o+r /dev/msm_snd" for setting the audio output.

If you hit a volume button, the sound may go off. Just hit the speaker/headset button once or twice to resolve. Config option "MediaVolumeHackEnable" works around this but I can't recommend it as it uses too much CPU time. (It continually plays a silent sound file.)

The color scheme and screen layout are subject to change of course. Let me know if there are things you like or don't like, and what features you'd like to see.

The stats polling can be interesting to monitor RSSI but I've just noted that it can have problems with the Config function, so I can't recommend enabling it at this point.

The configuration code was just added recently and can be a bit weird sometimes. Here's 2 walk-throughs:

For two-state config options ending in "Enable":

- Hit Config (floppy).

- Scroll/select option, such as "DaemonEnable".

- Dialog appears; select "Disable" or "Enable" as you need.

- That is all; option should be set in app and in config DB for next startup.

For numeric options such as Frequency:

- Hit Config (floppy).

- Scroll/select option, such as "Frequency".

- A new, temporary "Config" row appears as the 2nd row just under "Control". At right should be the current value.

- Click on white area to bring up numeric keypad.

- Enter number such as "89.1" and press "Done" to dismiss keypad. (Sometimes I've used "Back button" but multiple attempts were required.)

- Hit button to left of new value that says "SET" and variable name.

- Config row should disappear and value should now be set.

Note that Frequency and presets are the only config variables supporting non-integer numbers (ie those with a decimal point).

Please let me know how it went for you. I'll try to resolve just about any problem.

Screenshot:

https://docs.google.com/uc?id=0B7UP...U5YjE5&export=download&authkey=CPvPytcM&hl=en

http://cid-ce492c97f01d8fb0.office.live.com/self.aspx/Spirit FM Radio v1/spirit^_screen^_shot.png

API:

https://docs.google.com/uc?id=0B7UP...I0MWUw&export=download&authkey=CNOA67IE&hl=en

http://cid-ce492c97f01d8fb0.office.live.com/self.aspx/Spirit FM Radio v1/SpiritFMApi.apk

Application:

https://docs.google.com/uc?id=0B7UP...IwMzM1&export=download&authkey=CLm4kqEM&hl=en

http://cid-ce492c97f01d8fb0.office.live.com/self.aspx/Spirit FM Radio v1/aSpiritFMRadio.apk

Daemon:

https://docs.google.com/uc?id=0B7UP...djZTg5&export=download&authkey=CKWp-PAC&hl=en

http://cid-ce492c97f01d8fb0.office.live.com/self.aspx/Spirit FM Radio v1/sprt