Skip to content

Update to the test file of the TCS34725 color sensor #37

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

Merged
merged 4 commits into from
Jun 30, 2021
Merged

Update to the test file of the TCS34725 color sensor #37

merged 4 commits into from
Jun 30, 2021

Conversation

snkYmkrct
Copy link
Contributor

Added more examples of how to read the data form the color sensor in tcs34725_simpletest.py.

Also added a comment explaining the gamma correction calculations that are done on the raw values from the sensor in color_rgb_bytes from adafruit_tcs34725.py.

@jposada202020 jposada202020 linked an issue Jun 30, 2021 that may be closed by this pull request
@jposada202020
Copy link
Contributor

@SilviaCC The CI is failing on Black and Pylint, could you make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code

Thanks :)

@jposada202020
Copy link
Contributor

jposada202020 commented Jun 30, 2021

@silviaCCI have just saw you comment in the discord channel, ping me if you need any help..

@snkYmkrct
Copy link
Contributor Author

@jposada202020 If you could message me in discord, I would really appreciate the help, thank you!

@jposada202020
Copy link
Contributor

@SilviaCC so right know the CI is only complaining about black, this is fairly easy to solve if we run black on the files. could you try it, also what I would do in the meantime is that I will grab your files and do the same..

@jposada202020
Copy link
Contributor

@SilviaCC according to the changes. you could change the tcs34725_simpletest.py file with this, and I think we will be good (I hope LOL)

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

# Simple demo of the TCS34725 color sensor.
# Will detect the color from the sensor and print it out every second.
import time
import board
import adafruit_tcs34725


# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = adafruit_tcs34725.TCS34725(i2c)

# Change sensor integration time to values between 2.4 and 614.4 milliseconds
# sensor.integration_time = 150

# Change sensor gain to 1, 4, 16, or 60
# sensor.gain = 4

# Main loop reading color and printing it every second.
while True:
    # Raw data from the sensor in a 4-tuple of red, green, blue, clear light component values
    # print(sensor.color_raw)

    color = sensor.color
    color_rgb = sensor.color_rgb_bytes
    print(
        "RGB color as 8 bits per channel int: #{0:02X} or as 3-tuple: {1}".format(
            color, color_rgb
        )
    )

    # Read the color temperature and lux of the sensor too.
    temp = sensor.color_temperature
    lux = sensor.lux
    print("Temperature: {0}K Lux: {1}\n".format(temp, lux))
    # Delay for a second and repeat.
    time.sleep(1.0)

@jposada202020
Copy link
Contributor

Thanks @SilviaCC
@caternuson Could you take a look. Thanks :)

@snkYmkrct
Copy link
Contributor Author

snkYmkrct commented Jun 30, 2021

Well, this was ... fun... :D
Thank you so much, @jposada202020 !

I hope all is good now, lol

@caternuson
Copy link
Contributor

Looks good! Thanks @SilviaCC ! Yes, isn't pleasing the CI bots a ton of fun.

@jposada202020 jposada202020 merged commit 1240746 into adafruit:main Jun 30, 2021
@jposada202020
Copy link
Contributor

@SilviaCC Thank you very much, if you need any help regarding any other PR let me know. Thanks Again for your contribution

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 2, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_OV2640 to 1.0.1 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_OV2640#3 from adafruit/ulab-example

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1306 to 2.12.0 from 2.11.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1306#66 from mcauser/patch

Updating https://github.com/adafruit/Adafruit_CircuitPython_TCS34725 to 3.3.8 from 3.3.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_TCS34725#37 from silviaCC/simpletest_and_color_rgb_update
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.18.6 from 2.18.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#153 from lesamouraipourpre/max-size

Updating https://github.com/adafruit/Adafruit_CircuitPython_Simple_Text_Display to 1.0.2 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Simple_Text_Display#2 from kattni/pypi

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_Simple_Text_Display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more examples to the test file of the TCS34725 color sensor
3 participants