This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#11585 - New plugin: Resistor code calculator
Attached to Project:
Rockbox
Opened by Calvin Walden (clone4crw) - Monday, 30 August 2010, 22:07 GMT+2
Last edited by Frank Gevaerts (fg) - Saturday, 02 October 2010, 16:12 GMT+2
Opened by Calvin Walden (clone4crw) - Monday, 30 August 2010, 22:07 GMT+2
Last edited by Frank Gevaerts (fg) - Saturday, 02 October 2010, 16:12 GMT+2
|
DetailsThis is a calculator that will accept four band colors from menus, and graphically display a resistor corresponding to that, as well as the resistance in ohms. At the moment, its capability is limited to this.
It works on both the Sansa Fuze and e200, and will require someone else to help me port this to more players, because this plugin does NOT work in simulators. I hope in the future to finish the second part, which is accepting a keyed-in value and outputting the corresponding colored bands. More details are in the new resistor.c heading comments. (Should those be re/moved?) The zip file contains 3 files: resistor.diff, and the two bmp images used (one for the two supported Sansas) |
This task depends upon
Closed by Frank Gevaerts (fg)
Saturday, 02 October 2010, 16:12 GMT+2
Reason for closing: Accepted
Additional comments about closing: Committed as r28191 (with minor changes)
Saturday, 02 October 2010, 16:12 GMT+2
Reason for closing: Accepted
Additional comments about closing: Committed as r28191 (with minor changes)
"cleaned" == symmetry/colour correction in some places/smoothed some lines/general "prettying up"
[St.]
- You should really look at LCD_WIDTH and LCD_HEIGHT to decide on screen layout.
- int a=1/10; stores 0 in a. You'll want to handle fractional multipliers some other way. Unfortunately I think the obvious solution of using units of 1/100 ohm won't work as is, because then the largest multiplier is 100,000,000, and is I read the code correctly the largest value you ever multiply this with is 99, so the largest "full" value would be 9,900,000,000 which doesn't fit in an int anymore. You'll need to do some thinking here.
Things I would personally change, but which aren't bugs as such:
- I'd put the colour to value mapping in tables. The code right now looks very repetitive, and it can be shortened a lot by doing this.
- I'd change the variable and function names a bit, to "multiplier", "tens", ..., as soon as you're not dealing with real positioning any more. "first band" confuses me when you're actually calculating the final value.
- Do you really need functions like color_to_resistance_menu()? If you just call do_*_band_menu() directly, it doesn't make the code any harder to read, and it's a lot shorter.
- Maybe change some of those defines to enums. That doesn't change the generated code, but I think it looks nicer, and you can get compilers to warn you if you forget one in a switch statement.
Some nontechnical things:
- Won't people who use this plugin know what a resistor is? Do you need to explain that in the help?
- Rockbox uses UK english for UI texts and manual, so "colour" and friends. For variable and function names in the code this doesn't matter.
> - int a=1/10; stores 0 in a. You'll want to handle fractional multipliers some other way
Yes, I know, work needs to be done there.
> - I'd put the colour to value mapping in tables. The code right now looks very repetitive, and it can be shortened a lot by doing this.
If you could help me with that, that'd be great.
> - I'd change the variable and function names a bit, to "multiplier", "tens", ..., as soon as
It makes a bit more sense to me personally... a bit more consistency across everything, if you will.
> - Do you really need functions like color_to_resistance_menu()?
Was a way to isolate stupid early-on problems. I will consolidate that.
> - Maybe change some of those defines to enums.
I am not exactly interested in doing that myself, but if you are, go at it.
> - Won't people who use this plugin know what a resistor is? Do you need to explain that in the help?
Just threw that in for the heck of it. Does it pose a problem?/ could a helpfile have a better use?
> - Rockbox uses UK english for UI texts and manual, so "colour" and friends. For variable and function names in the code this doesn't matter.
Sure, I can do that.
Dominik:
Ok, I'll stop that.
Fixed: changed "color" to "colour", consolidated old color_to_resistance_menu()
Now broken: Fuze bitmap is all garbled. 99% sure it's a stupid typo of mine somewhere.
Feel free to pick the bits you like from this (or everything). As far as I can see, everything works the way it should. It compiles on non-colour targets and targets with smaller screens, but I haven't tested those.
There's one issue left (which it shares with *many* plugins): it ignores USB plugin events.
Works with e200, Fuze (although the BMP's still messed up), Clip, Nano, and m200. It requires all of the BMPs in the zip that will be in the next comment by me.
I'm guessing there's still a bunch of issues regarding the new resistance to codes routines, but it seems to work with the common resistances (I mainly tested 470, 47, 1K, 10K, 100, a couple of others).
Frank: I still need to look at your changes, haven't done that yet.
One issue: int get_power_ten(float in_val). Don't use float. On the one hand, the hardware doesn't support it, so it's *slow*, and on the other hand, the code that calls it passes an int anyway.
What's also still missing is a patch for the manual, or at least one or two paragraphs of text to include if you don't know LaTeX yourself. The in-plugin text is probably a good start.
Also, more (especially smaller) bitmaps would be nice. The smallest two colour screens we have are c200 and H10, with 132x80 and 128x128 respectively, so just adding a 128 pixel wide (or smaller) image would provide support for everything.