|
楼主 |
发表于 2015-5-4 17:39:56
|
显示全部楼层
对于楼主的回复:
first issue, well, not sure it would do any good or bad to the size of binary (although, i might check that) otherwise there is no reason to change
这位网友说:
Agree, but especially on the UNO all bytes saved (even a few) add up and frees memory for other functionality.
Please let me know the diff in size (esp for the color lib)
对于楼主的回复:
as nobody looks at the code of libraries most of the time
这位网友说:
I do if the sensors / topic interests me
All that said, I must say you delivered well written code and again thanks for sharing.
那位网友又说到:
The TCS3471 lib looks also like some decent work, but I have a more serious remark here.
In the color library I would remove detect() and all tests to _detected. The _detected constructs makes the library definitely more robust I know.
But more importantly (imho) you cannot have two of these sensors on the bus any more. Most libs give the address as parameter to the constructor.
The footprint of the lib would be smaller (to be tested how much) too.
Still good work!
楼主回复说:
The library was written with this board in mind - 无效链接,which has TXS0104 level converter chip on it, outputs of which can be put in high impedance state, so in theory (not tested yet), one could attach more than one chip to i2c, make multiple instances of TCS3471 object and take care of addressing specific instance in sketch, or one could use i2c multiplexer like TCA9548A and again use multiple instances of TCS3471. Besides, each instance tries to determine correct address on it's own, since different versions of chip can have either address 0x29 or 0x39. If Arduino environment follows regular c++ rules, which I hope it does, since compiler is based on gcc, each instance will have it's own copy of member variables, since none of them is declared as static.
Nevertheless, I might consider reviewing the code if there is enough interest in this, besides this is version 1. Much more footprint could be saved if I got rid of float arguments to some functions, but I decided to leave those in for ease of use
对于楼主的回复:Besides, each instance tries to determine correct address on it's own, since different versions of chip can have either address 0x29 or 0x39.
网友回复到:
But I foresee this scenario:
object1 will test address1 first and find it on the I2C bus => happy
object2 will test address1 first and find it on the I2C bus => happy (oops)
I saw the floating point and yes you can save quite a bit there.
You could use an uint16_t and set the timing in milliseconds to get the 1/10 of second behavior identical.
That would allow for periods up to 65 seconds (if it indicates millis).
If you use an uint16_t for 1/10 of second you can even do longer timings.
Eager to see the size improvements you will get!
楼主说:
User sketch has to take care of defining different sets of communication functions for each of instances, that way one can ensure that right chip is addressed in case of multiplexer or right chip is enabled in case of level shifter.
I left those floats in because milliseconds are less confusing than 10x milliseconds. Allowed values are limited by chip itself, for one of timing functions it is 2.4ms-614.4ms, but for another one it is 2.4-7372.8ms, which translates to uint32_t if 10x the value is used. Anyway, if that becomes a problem, I will re-consider these things.
|
|