<commit_before>import RPi.GPIO as GPIO
from time import sleep 
from multiprocessing import Process
import os

class Breathe(object):

    def __init__(self):
        GPIO.setmode(GPIO.BCM) # We can also choose a BOARD numbering schemes.
        GPIO.setup(21, GPIO.OUT) # set GPIO 21 as output
        self.light = GPIO.PWM(21, 100) # create object for PWM on port 21 at 100 Hertz
        self.p = Process(target=calm, args=(self.light,))

    def shutdown(self):
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        GPIO.cleanup()
        print("breathing shut down.")
        
    def restart(self):
        print("restarting breathing!")
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        GPIO.cleanup()
        
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(21, GPIO.OUT)
        self.light = GPIO.PWM(21, 100)
        self.light.start(0)
        self.p = Process(target=calm, args=(self.light,))
        self.p.start()

    def calm(self):
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        self.p = Process(target=calm, args=(self.light,))
        self.p.start()
        
    def erratic(self):
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        self.p = Process(target=erratic, args=(self.light,))
        self.p.start()
        
def calm(light):
    print("starting calm breathing...")
    light.start(0)
    pause_time = 0.02<commit_msg>Add CALM,ERRATIC, and OFF breathe state to breather<commit_after>import RPi.GPIO as GPIO
from time import sleep 
from multiprocessing import Process
import os

class Breathe(object):

    def __init__(self):
        GPIO.setmode(GPIO.BCM) # We can also choose a BOARD numbering schemes.
        GPIO.setup(21, GPIO.OUT) # set GPIO 21 as output
        self.light = GPIO.PWM(21, 100) # create object for PWM on port 21 at 100 Hertz
        self.p = Process(target=calm, args=(self.light,))
        self.state = breathe_state(('CALM', 'ERRATIC', 'OFF'))
        self.restart_state = self.state.CALM

    def shutdown(self):
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        GPIO.cleanup()
        print("breathing shut down.")
        
    def restart(self):
        print("restarting breathing!")
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        GPIO.cleanup()
        
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(21, GPIO.OUT)
        self.light = GPIO.PWM(21, 100)
        self.light.start(0)
        if (self.restart_state == self.state.CALM):
            self.p = Process(target=calm, args=(self.light,))
            self.p.start()
        elif (self.restart_state == self.state.ERRATIC):
            self.p = Process(target=erratic, args=(self.light,))
            self.p.start()
        else:
            self.shutdown()

    def calm(self):
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        self.p = Process(target=calm, args=(self.light,))
        self.p.start()
        
    def erratic(self):
        if (self.p.is_alive()):
            self.p.terminate()
        self.light.stop()
        self.p = Process(target=erratic, args=(self.light,))
        self.p.start()

    def set(self, state):
        self.restart_state = state
        print("state has been set:", self.restart_state)

class breathe_state(object): 
    def __init__(self, tupleList):
        self.tupleList = tupleList

    def __getattr__(self, name):
        return self.tupleList.index(name)       
        
def calm(light):
    print("starting calm breathing...")
    light.start(0)
    pause_time = 0.02
{'fraction_non_alphanumeric': 0.13257173219978746, 'fraction_numerical': 0.01381509032943677, 'mean_word_length': 2.0609756097560976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '40734', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1207, 'n_words': 262}