-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Driver for TCS3772 Color Light-to-Digital Converter #3135
Conversation
* @return 0 on success | ||
* @return -1 on error | ||
*/ | ||
int tcs37727_read(tcs37727_t *dev, uint16_t *rawred, uint16_t *rawgreen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see this driver in a similar style as for the isl29125. This would mean to use the color_rgb_t
as output type. If you think you also need a higher resolution you could also introduce an own type in addition (just compare the isl29125 implementation)
*rawclear = ((uint16_t)buf[1] << 8) | buf[0]; | ||
*rawred = ((uint16_t)buf[3] << 8) | buf[2]; | ||
*rawgreen = ((uint16_t)buf[5] << 8) | buf[4]; | ||
*rawblue = ((uint16_t)buf[7] << 8) | buf[6]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in header file
Hm :-(. Any ideas why? <Do I have a different board revision or so?
|
You need PCB version 1426.1 (it is under the Phytec logo, left of micro USB). In the picture here is 1426.0 version and the sensor is not on it. |
I think you need more boards, right? |
I've got version 1426.0. Afaik the newer revision is available in the FU? Maybe some of them could test the driver. |
Just updated the photo on the wiki-page [1]. [1] - https://github.com/RIOT-OS/RIOT/wiki/Board:-Phytec-phyWAVE-KW22 |
My board is currently somewhere between Paris and Berlin... |
Is it with you :-) ? |
Apparently I outran it. ;-) |
updated and rebased on master, suitable, but still WIP |
Ok. Just give me a sign when it's not WIP any more! |
@PeterKietzmann I think I'm almost done, I do not want imlementieren the proximity measurement now, IR diode was not mounted at our Boards. |
@jfischer-phytec-iot I will have a deeper look inside in the next week, ok? In general: Do as much as you like and think is needed. Perhaps I will adapt small things afterwards which you need to test then. <- that was my thought when you opened this PR and said that this driver should just me a minimal implementation |
int cc; /**< IR compensated channels clear */ | ||
int lux; /**< Lux */ | ||
int ct; /**< Color temperature */ | ||
} tcs37727_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if you need all of this parameters for the device descriptor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PeterKietzmann once again:
The init function do not need any parameters, the sensor should be self adjusted by autogain function.
I am considering to divide the tcs37727_t in tcs37727_t and tcs37727_data_t, there also insert color_rgb_t. What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, do it! Maybe I just need to see this...
@jfischer-phytec-iot I'd suggest you adapt this PR with the discussed changes and shortly ping me then, so I can review and merge the minimal implementation. |
@PeterKietzmann ping |
@jfischer-phytec-iot there are some minor things that "may" be changed. I tend to merge this PR anyway, as it doesn't seem to have the highest priority ("basic functionality only"). I'll do a follow up PR to clean up some minor things, once I find more time. |
PS: Don't forget to use PCB version 1426.1 (can be found under the Phytec logo, left to the micro USB connector) |
@PeterKietzmann "basic functionality only" is not more up to date. We may like to discuss about "minor things" :-) I would try to make the autogain function independently of tcs37727_read. |
@jfischer-phytec-iot is it urgent? If so, just say it! Otherwise I'd like to delay this PR for some days.. |
@PeterKietzmann It is not urgent. A little time to mature will do the driver well :-) |
case 1: | ||
reg_again = TCS37727_CONTROL_AGAIN_4; | ||
val_again = 4; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the relation to https://github.com/RIOT-OS/RIOT/pull/3135/files#diff-c13e75366b4489aac1fd522db3c5b4a5R82. There you set TCS37727_CONTROL_AGAIN_4
and dev->again = 4;
. Here you read this value by val_again = dev->again;
and when the switch case is 4
(like you initialized) you set the parameters TCS37727_CONTROL_AGAIN_16
and val_again = 16;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function increments or decrements the gain value dev->again.
reg_again and val_again are temporary values.
dev->again is required for the calculations in tcs37727_read. reg_again will be a bitmap and should be written to register.
s/reg_again/tmp_reg_again and s/val_again/tmp_val_again ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, after comparing to the manual I got it.
@jfischer-phytec-iot except the question about the clipping of the gain value, are you willing to commit something else? Otherwise I think you can already squash you commits. |
@PeterKietzmann Yes, I will do the "TODO" :-) |
Just for the protocol: I talked with @jfischer-phytec-iot and he currently has some other projects with higher priority. He will adapt this PR once he finds time again. |
@jfischer-phytec-iot how is it going on your side? Any plans to spend further work on this PR? |
@PeterKietzmann It works well and provides useful results. I have removed WIP and would like to merge it (I am planning to extend it but it takes a few more weeks). |
|
||
#include <stdio.h> | ||
|
||
#include "vtimer.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to xtimer
@jfischer-phytec-iot fine with me. Could you please address my latest minor comments, check your code quickly, rebase and squash and give me a hint then?! |
The driver supports lux and ct calculation and autogain funktion.
@PeterKietzmann ping |
Fine with me. Let's wait for T |
ACK and go |
Driver for TCS3772 Color Light-to-Digital Converter
This PR adds the driver for TCS3772 Color Light-to-Digital Converter with Proximity Sensing.
Driver supports basic functionality only, no Proximity Sensing.
Can be tested with pba-d-01-kw2x Board.