Пример #1
0
def main():
    lights = lc.LEDString(count=50)

    print("Red")
    lights.light_up(0, Color(255, 0, 0))
    time.sleep(2)

    print("Green")
    lights.light_up(0, Color(0, 255, 0))

    time.sleep(2)

    print("Blue")
    lights.light_up(0, Color(0, 0, 255))

    time.sleep(2)

    lights.turn_all_off()
Пример #2
0
    def __init__(self):

        self.init_time = int(time.time())
        self.queued_words = queue.Queue()
        self.running = True
        self.inputs_required = True
        self.MAX_WORD_LENGTH = 60
        self.ALLOWED_CHARACTERS = set("ABCDEFGHIJKLMNOPQRSTUVWXYZ ")
        self.letters = [
            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
            "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
        ]

        white = np.Color(255, 255, 255)
        dark_blue = np.Color(0, 0, 170)
        purple = np.Color(100, 0, 100)
        cyan = np.Color(50, 220, 220)
        light_blue = np.Color(0, 150, 200)
        yellow = np.Color(255, 200, 0)
        pink = np.Color(255, 50, 255)

        self.LETTER_COLOUR = {
            "A": white,
            "B": dark_blue,
            "C": purple,
            "D": cyan,
            "E": light_blue,
            "F": yellow,
            "G": pink,
            "H": cyan,
            "I": cyan,
            "J": pink,
            "K": light_blue,
            "L": cyan,
            "M": yellow,
            "N": pink,
            "O": purple,
            "P": cyan,
            "Q": pink,
            "R": cyan,
            "S": white,
            "T": yellow,
            "U": light_blue,
            "V": pink,
            "W": light_blue,
            "X": yellow,
            "Y": pink,
            "Z": pink
        }

        config = configparser.ConfigParser()
        config.read("wall.ini")

        self.animations = [
            self.flicker, self.trail_letters, self.twinkle,
            self.fade_in_and_out
        ]

        self.LETTER_LED = {}
        self.pin18 = lc.LEDString(
            count=config.getint("Strip Lengths", "pin18"))
        self.pin12 = lc.LEDString(count=config.getint("Strip Lengths",
                                                      "pin12"),
                                  pin=12)

        options = config.options("LED Pin and Numbers")
        for option in options:
            letter = option.upper().rstrip()
            numbers = config.get("LED Pin and Numbers", option).split(",")
            pin = int(numbers[0])
            number = int(numbers[1])
            #print(letter, number, type(letter), type(number))
            strip = None
            if pin == 18:
                strip = self.pin18
            elif pin == 12:
                strip = self.pin12
            self.LETTER_LED[letter] = LED.LED(letter, strip, number,
                                              self.LETTER_COLOUR.get(letter))

        #q = self.LETTER_LED.get("Q")
        #i = self.LETTER_LED.get("I")
        #strip = i.strip
        #self.top_row = [x for x in range(0, q)]
        #self.middle_row = [x for x in range(i, q - 1, -1)]
        #self.bottom_row = [x for x in range(i + 1, strip.numPixels + 1)]

        self.blacklist = []

        try:
            blacklist = config.get("Words", "blacklist").split(",")
            for word in blacklist:
                #print("blacklist word", word)
                word = word.upper().rstrip()
                # print(line)
                # print(self.word_is_ok(line))
                # print(word)
                self.blacklist.append(word)
        except configparser.NoOptionError:
            self.blacklist = []

        self.words = []

        words = config.get("Words", "words").split(",")
        for word in words:
            word = word.upper().rstrip()
            #print(line)
            #print(self.word_is_ok(line))
            #print(word)
            if self.word_is_ok(word):
                self.words.append(word)

        self.hashtags = []
        hashtags = config.get("Words", "hashtags").split(",")
        for hashtag in hashtags:
            hashtag = hashtag.rstrip()
            self.hashtags.append(twitter.Hashtag(text=hashtag))

        #Twitter setup
        consumer_key = config.get("Twitter", "consumer_key")
        consumer_secret = config.get("Twitter", "consumer_secret")
        access_token = config.get("Twitter", "access_token")
        access_token_secret = config.get("Twitter", "access_token_secret")
        self.api = twitter.Api(consumer_key=consumer_key,
                               consumer_secret=consumer_secret,
                               access_token_key=access_token,
                               access_token_secret=access_token_secret,
                               sleep_on_rate_limit=True)