<commit_before>from tamproxy import Sketch, SyncedSketch, Timer
from tamproxy.devices import Color

# Prints RGB, clear(C), colorTemp, and lux values read and
# computed from the device. For more details, see the Adafruit_TCS34725
# Arduino library, from which the colorTemp and lux computations are
# used.

# Color sensor should be connected to the I2C ports (SDA and SCL)

class ColorRead(SyncedSketch):

    def setup(self):
        self.color = Color(self.tamp,
                           integrationTime=Color.INTEGRATION_TIME_101MS,
                           gain=Color.GAIN_1X)
        self.timer = Timer()

    def loop(self):
        if self.timer.millis() > 100:
            self.timer.reset()
            print "~~~~~~~~~"
            print self.color.r, self.color.g, self.color.b, self.color.c
            print self.calibrate_colors(self.color.r, self.color.g, self.color.b)
            print self.color.colorTemp, self.color.lux

    def calibrate_colors(self, r, g, b):
        return (int(r / 0.90), int(g / 0.45), int(b / 0.40))


if __name__ == "__main__":
    sketch = ColorRead(1, -0.00001, 100)
    sketch.run()
<commit_msg>test_color now prints the color of the block<commit_after>from tamproxy import Sketch, SyncedSketch, Timer
from tamproxy.devices import Color

# Prints RGB, clear(C), colorTemp, and lux values read and
# computed from the device. For more details, see the Adafruit_TCS34725
# Arduino library, from which the colorTemp and lux computations are
# used.

# Color sensor should be connected to the I2C ports (SDA and SCL)

class ColorRead(SyncedSketch):

    def setup(self):
        self.color = Color(self.tamp,
                           integrationTime=Color.INTEGRATION_TIME_101MS,
                           gain=Color.GAIN_1X)
        self.timer = Timer()

    def loop(self):
        if self.timer.millis() > 100:
            self.timer.reset()
            print "~~~~~~~~~"
            print self.color.r, self.color.g, self.color.b, self.color.c
            #print self.calibrate_colors(self.color.r, self.color.g, self.color.b)
            #print self.color.colorTemp, self.color.lux
            print self.whatColorIsThis(self.color.r, self.color.g, self.color.b)

    def calibrate_colors(self, r, g, b):
        return (int(r / 0.90), int(g / 0.45), int(b / 0.40))

    def whatColorIsThis(self, r, g, b):
        if r > 1.5*g and r > 1.5*b:
            return "Red"
        elif g > r and g > b:
            return "Green"
        else:
            return "No Block"


if __name__ == "__main__":
    sketch = ColorRead(1, -0.00001, 100)
    sketch.run()

{'fraction_non_alphanumeric': 0.11404515882127822, 'fraction_numerical': 0.02602372751626483, 'mean_word_length': 2.3299363057324842, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5734253', 'n_tokens_mistral': 902, 'n_tokens_neox': 838, 'n_words': 238}