Exemplo n.º 1
0
def print_thread():
    global text
    while True:
        display.show(text, 1)
        if text == 'done' or text == 'FAIL':
            display.show(text, 5)
            break
Exemplo n.º 2
0
def game(first_player):
    """
    A game of tic tac toe
    """
    grid = empty()
    player = first_player
    list_turns_played = {
        lettre: [range(SIZE, 27)]
        for lettre in ALPHABET if ALPHABET.index(lettre) < SIZE
    }
    win = False
    while is_playable(grid):
        show(grid)
        current_turn = ""
        while len(current_turn) != 2 or current_turn[0] not in list_turns_played \
              or int(current_turn[1]) in list_turns_played[current_turn[0]]:
            current_turn = input(
                "It's {} turn. Please enter a valid combination to play.\n".
                format(PLAYER[player])).upper()
        list_turns_played[current_turn[0]].append(int(current_turn[1]))
        grid[ALPHABET.index(current_turn[0])][int(current_turn[1])] = player
        if is_won(grid):
            print("Well played ! {} wins ;-)".format(PLAYER[player]))
            win = True
            break
        player = not player
    if not win:
        print("Oh... That's a draw!")
    show(grid)
Exemplo n.º 3
0
def classify():
    warnings.filterwarnings('ignore')

    # get the training labels
    train_labels = utly.getTrainLabels()

    # import the feature vector and trained labels
    print('\nReading from dataset')
    global_features = h5h.readH5_data()
    global_labels = h5h.readH5_label()

    print('\nTraining model...')
    # create the model - Random Forests
    clf = RandomForestClassifier(n_estimators=tp.num_trees,
                                 random_state=tp.seed)
    # fit the training data to the model
    clf.fit(global_features, global_labels)
    print('\nModel trained.')

    print('\nRunning test...')
    # loop through the test images
    for file in glob.glob(tp.test_path + "/*.jpg"):
        image = utly.read_im(file)
        global_feature = utly.fextract(image)
        rgf = global_feature.reshape(-1, 1)
        rescaled_feature = utly.transf(rgf)
        prediction = clf.predict(rescaled_feature.reshape(1, -1))[0]
        display.show(image, prediction)
    print('\nTest completed.')
Exemplo n.º 4
0
 def get_str(self, index=0):
     finite = False
     x = ''
     while finite == False:
         if pygame.time.get_ticks() - self.ptim > 200:
             if self.option[index].text == [x]:
                 self.option[index].text = ['_']
             else:
                 self.option[index].text = [x]
             self.option[index].select()
             self.option[index].centerh(), self.option[index].render()
             self.ptim = pygame.time.get_ticks()
         for e in pygame.event.get():
             if e.type == pygame.QUIT: sys.exit()
             elif e.type == pygame.KEYDOWN:
                 if e.key == pygame.K_RETURN and len(x) != 0:
                     pygame.event.clear()
                     finite = True
                 elif e.key == pygame.K_BACKSPACE:
                     x = x[0:len(x) - 1]
                 elif len(x) < 10:
                     x += e.unicode
         display.show()
     self.option[index].text = [x]
     return x
Exemplo n.º 5
0
def drawPage(header, entries, duration):
  now = datetime.now()
  display.clear()
  y = display.drawHeader(20, header)
  display.drawEntries(entries, y, 15, 1)
  display.show()
  time.sleep(duration - (datetime.now() - now).seconds)
  return
Exemplo n.º 6
0
def showInfoDisplay():

    while True:
        sleep(6)
        display.show(
            ("Estado: " + str(firebase_connection.readDB("Estado"))),
            ("T:" + str(firebase_connection.readDB("Temperatura")) + " C"))
        sleep(10)
Exemplo n.º 7
0
def drawPage(duration):
    now = datetime.now()
    duration = timedelta(seconds=duration)
    while (datetime.now() - now).seconds < duration.seconds:
        display.clear()
        y = display.drawHeader(15, "CCU")
        drawEntries(y)
        display.show()
    return
Exemplo n.º 8
0
def drawPage(duration):
  now = datetime.now()
  duration = timedelta(seconds=duration)
  while (datetime.now() - now).seconds < duration.seconds:
    display.clear()
    y = display.drawHeader(15, getIP())
    display.drawEntries((getCpuLoad(), getMemUsage(), getDiskUsage(), getCpuTemp()), y, 12, 2)
    display.show()
    time.sleep(0.250)
  return
Exemplo n.º 9
0
def drawPage(duration):
    now = datetime.now()
    duration = timedelta(seconds=duration)
    while (datetime.now() - now).seconds < duration.seconds:
        display.clear()
        y = display.drawHeader(15, "USV")
        display.drawEntries((getAkku(), getRuntime(), getVoltage(), getLoad()),
                            y, 12, 2)
        #    display.DRAW.bitmap((0,0), Image.open('ac.png').convert("RGBA"))
        display.show()
    return
Exemplo n.º 10
0
def drawPage(duration):
    now = datetime.now()
    duration = timedelta(seconds=duration)
    MQTT.loop_start()
    while (datetime.now() - now).seconds < duration.seconds:
        display.clear()
        y = display.drawHeader(15, "Mosquitto")
        drawEntries(y)
        display.show()
        time.sleep(.1)
    MQTT.loop_stop()
    return
Exemplo n.º 11
0
def onCamStart():
    print("Camera started")

    # For now, returns a random picture from the pictures folder
    img = camera.takePicture()

    # Gets the items on the image (format: [{"label": "apple", box: [0.11, 0.14, 0.01, 0.012], confidence: 0.32}, ...]
    items = ml.processImage(img)

    # Get more information from the info module
    # TODO

    # Call the display module
    display.show(img, items)
Exemplo n.º 12
0
def scan():
    cap = cv2.VideoCapture(0)
    cap.set(3, 960)
    cap.set(4, 540)
    flag, frame = cap.read()
    rects = []
    result = []
    # hsv1_colors = (50, 180, 0)
    hsv1_colors = (60, 70, 20)
    # hsv2_colors = (180, 255, 200)
    hsv2_colors = (89, 145, 255)
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    zeros = np.zeros(hsv.shape)

    h_min = np.array(hsv1_colors, np.uint8)
    h_max = np.array(hsv2_colors, np.uint8)

    mask = cv2.inRange(hsv, h_min, h_max)
    contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    max_rects = 0, 0, 0, 0
    for c in contours:
        x, y, w, h = cv2.boundingRect(c)
        if w * h > max_rects[2] * max_rects[3]:
            max_rects = x, y, w, h
        if w > 5 and h > 10:
            rects.append((w, h, x))
            cv2.putText(zeros, text=f'({w}, {h})', org=(x, y),
                        fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(0, 255, 0),
                        thickness=1, lineType=cv2.LINE_AA)
            cv2.rectangle(zeros, (x, y), (x + w, y + h), (155, 155, 0), 1)
    rects.sort(key=lambda _: _[2])
    for num, (w, h, x) in enumerate(rects):
        # print(num, (w, h))
        # print(w)
        # print(h)
        if 15 < w < 70:
            if h > 300:
                typ = 3
            elif h > 150:
                typ = 2
            elif h > 70:
                typ = 1
            else:
                typ = -1
            if typ > 0:
                result.append(str(typ))
        if len(result) > 5:
            pass
    print(' '.join(result))
    show(' '.join(result))
Exemplo n.º 13
0
 def loop(self):
     self.option[self.sel].select()
     maxlen=len(self.option)-1
     while True:
         for e in pygame.event.get():
             if e.type==pygame.QUIT:sys.exit()
             elif e.type==pygame.KEYDOWN:
                 self.option[self.sel].deselect()
                 if e.key==pygame.K_RETURN:exec(self.option[self.sel].meta);maxlen=len(self.option)-1
                 if e.key==pygame.K_UP:self.sel-=1
                 if e.key==pygame.K_DOWN:self.sel+=1
                 if self.sel < 0:self.sel=maxlen
                 if self.sel > maxlen:self.sel=0
                 self.option[self.sel].select()
         display.show()
Exemplo n.º 14
0
 def loop(self):
     self.option[self.sel].select()
     maxlen=len(self.option)-1
     while True:
         for e in pygame.event.get():
             if e.type==pygame.QUIT:sys.exit()
             elif e.type==pygame.KEYDOWN:
                 self.option[self.sel].deselect()
                 if e.key==pygame.K_RETURN:exec(self.option[self.sel].meta);maxlen=len(self.option)-1
                 if e.key==pygame.K_UP:self.sel-=1
                 if e.key==pygame.K_DOWN:self.sel+=1
                 if self.sel < 0:self.sel=maxlen
                 if self.sel > maxlen:self.sel=0
                 self.option[self.sel].select()
         display.show()
Exemplo n.º 15
0
 def pysnake(self):
     self.purge()
     display.fps_init(self.fpslimit)
     self.snake = snake_new(self, self.diff, self.speed)
     black = 0, 0, 0
     self.back = display.object(self.gameback, layer=0)
     self.snake.add()
     while 1:
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 pygame.display.quit()
                 sys.exit()
             if event.type == pygame.KEYDOWN:
                 if event.key == pygame.K_ESCAPE: self.snake.gameover = 1
                 elif event.key == pygame.K_SPACE:
                     self.relcontrol = not self.relcontrol
                 if self.relcontrol == False:
                     for c in self.snake.plcontrol:
                         if event.key == pygame.K_UP:
                             c.speed_rot(setangle=270)
                         elif event.key == pygame.K_DOWN:
                             c.speed_rot(setangle=90)
                         elif event.key == pygame.K_LEFT:
                             c.speed_rot(setangle=180)
                         elif event.key == pygame.K_RIGHT:
                             c.speed_rot(setangle=0)
         kp = pygame.key.get_pressed()
         if pygame.time.get_ticks(
         ) - self.ptim > self.sensible and self.relcontrol == True:
             self.ptim = pygame.time.get_ticks()
             for c in self.snake.plcontrol:
                 if kp[275] > 0: c.speed_rot(self.control_angle * 1)
                 elif kp[276] > 0: c.speed_rot(self.control_angle * -1)
         if self.snake.gameover == 1:
             self.trace.reset()
             self.get_high()
             self.purge()
             self.menu()
             self.loop()
         else:
             self.snake.grow()
             self.snake.speed()
             self.snake.score()
             self.snake.collcheck()
             self.trace.update_track()
             self.trace.update_trace()
             display.tick(self.fpslimit, 1)
             display.show()
Exemplo n.º 16
0
def test_differential():
    RECOMP = True
    MDS_DIR = "../motif_displacement_files/"
    f1, f2 = "SRR1015583", "SRR1015587"
    OUT = MDS_DIR + "differential_" + f1 + "_" + f2 + ".csv"
    if RECOMP:
        mds = mds_frame()
        mds.load_MD_score_file(MDS_DIR + f1 + "_MDS.csv", "WT")
        mds.load_MD_score_file(MDS_DIR + f2 + "_MDS.csv", "KO")
        df = mds.differential("WT", "KO", h=150)
        df.to_csv(OUT, index=False)

    df = pd.read_csv(OUT)
    sns.set(font_scale=2)
    sns.set_style("ticks")
    F = plt.figure(tight_layout=True, figsize=(12, 10))

    ax1, ax2 = F.add_subplot(1, 2, 1), F.add_subplot(1, 2, 2)
    S = show(df=df, ax=ax2, FDR=pow(10, -5))
    ax1.hist(df.pval_mds,
             bins=60,
             color="steelblue",
             edgecolor="white",
             label="N=" + str(df.shape[0]))
    ax1.set_xlabel("p-value")
    ax1.set_ylabel("frequency")
    ax1.legend(loc="best")
    sns.despine()
    plt.show()
Exemplo n.º 17
0
 def setvar(self,index=0,int=0):
     finite=False
     x=int
     while finite==False:
         if pygame.time.get_ticks()-self.ptim>250:
             if self.option[index].text==[str(x)]:self.option[index].text=['_']
             else:self.option[index].text=[str(x)]
             self.option[index].select();self.option[index].render();self.ptim=pygame.time.get_ticks()
         for e in pygame.event.get():
             if e.type==pygame.QUIT:sys.exit()
             elif e.type==pygame.KEYDOWN:
                 if e.key==pygame.K_UP:x+=1
                 elif e.key==pygame.K_DOWN:x-=1
                 elif e.key==pygame.K_RETURN:pygame.event.clear();finite=True
         display.show()
     self.option[index].text=[str(x)]
     return x
Exemplo n.º 18
0
 def get_str(self,index=0):
     finite=False
     x=''
     while finite==False:
         if pygame.time.get_ticks()-self.ptim>200:
             if self.option[index].text==[x]:self.option[index].text=['_']
             else:self.option[index].text=[x]
             self.option[index].select();self.option[index].centerh(),self.option[index].render();self.ptim=pygame.time.get_ticks()
         for e in pygame.event.get():
             if e.type==pygame.QUIT:sys.exit()
             elif e.type==pygame.KEYDOWN:
                 if e.key==pygame.K_RETURN and len(x)!=0:pygame.event.clear();finite=True
                 elif e.key==pygame.K_BACKSPACE:x=x[0:len(x)-1] 
                 elif len(x)<10: x+=e.unicode
         display.show()
     self.option[index].text=[x]
     return x
Exemplo n.º 19
0
 def setvar(self,index=0,int=0):
     finite=False
     x=int
     while finite==False:
         if pygame.time.get_ticks()-self.ptim>250:
             if self.option[index].text==[str(x)]:self.option[index].text=['_']
             else:self.option[index].text=[str(x)]
             self.option[index].select();self.option[index].render();self.ptim=pygame.time.get_ticks()
         for e in pygame.event.get():
             if e.type==pygame.QUIT:sys.exit()
             elif e.type==pygame.KEYDOWN:
                 if e.key==pygame.K_UP:x+=1
                 elif e.key==pygame.K_DOWN:x-=1
                 elif e.key==pygame.K_RETURN:pygame.event.clear();finite=True
         display.show()
     self.option[index].text=[str(x)]
     return x
Exemplo n.º 20
0
 def pysnake(self):
     self.purge()
     display.fps_init(self.fpslimit)
     self.snake=snake_new(self,self.diff,self.speed)
     black =  0, 0, 0
     self.back = display.object(self.gameback,layer=0)
     self.snake.add()
     while 1:
         for event in pygame.event.get():
             if event.type==pygame.QUIT:
                 pygame.display.quit()
                 sys.exit()
             if event.type==pygame.KEYDOWN: 
                 if event.key==pygame.K_ESCAPE:self.snake.gameover=1
                 elif event.key==pygame.K_SPACE:self.relcontrol=not self.relcontrol
                 if self.relcontrol==False:
                     for c in self.snake.plcontrol:
                         if event.key==pygame.K_UP:c.speed_rot(setangle=270)
                         elif event.key==pygame.K_DOWN:c.speed_rot(setangle=90)
                         elif event.key==pygame.K_LEFT:c.speed_rot(setangle=180)
                         elif event.key==pygame.K_RIGHT:c.speed_rot(setangle=0)            
         kp=pygame.key.get_pressed()
         if pygame.time.get_ticks()-self.ptim> self.sensible and self.relcontrol==True:
             self.ptim=pygame.time.get_ticks()
             for c in self.snake.plcontrol:
                 if kp[275]>0:c.speed_rot(self.control_angle*1)
                 elif kp[276]>0:c.speed_rot(self.control_angle*-1)
         if self.snake.gameover==1:
             self.trace.reset()
             self.get_high()
             self.purge()
             self.menu()
             self.loop()
         else:
             self.snake.grow()
             self.snake.speed()
             self.snake.score()
             self.snake.collcheck()
             self.trace.update_track()
             self.trace.update_trace()
             display.tick(self.fpslimit,1)
             display.show()
Exemplo n.º 21
0
def main():
    args = parse.set()
    config = Config()

    address = parse.read(args, config)

    if not config.api_key:
        if not config.api_key:
            print("API key not found, run again with --key apikey")
            return

    if (address):
        location = Location(address, config.location_url)
        if (location.address):
            weather = Weather(location, config)
            display.show(location, weather)
        return

    if not args.key:
        print('No address supplied')
Exemplo n.º 22
0
def main():
  cam.init()
  #dis.init(1920, 1080)

  while(True):
    # capture frame-by-frame
    img = cam.read()

    # our operations on the frame come here
    gray = vis.gray(img)

    # display the resulting frame
    dis.show(gray)

    # handle key input
    if cv2.waitKey(1) & 0xFF == ord('q'): # quit
        break
    if cv2.waitKey(1) & 0xFF == ord('c'): # calibrate
        calibrate()

  # clean up camera
  cam.destroy()
Exemplo n.º 23
0
def run():
    """
    complete assembled workflow
    - > open and store data set
    - > perform interpolation on data set
    - > find coldest/hottest temperatures of each year
    - > find coldest/hottest days of each year
    - > store the coldest/hottest temperatures of each year
    - > plot coldest/hottest days
    - > perform gauss process future prediction
    - > plot future prediction
    """
    Dataset = DataSet()
    Temp = Temperature()
    Tempdata = TempData()

    Dataset.open_file()
    complete_file = Dataset.get_data_set()
    finer_file = perform_interpolation(complete_data=complete_file)

    years = Temp.separate_into_years(finer_file)
    hottest_days = []
    coldest_days = []
    for year in years:
        Temp.find_coldest_temp_in_year(year)
        Temp.find_hottest_temp_in_year(year)
        days = Temp.separate_into_days(year)
        hottest_days.append(Temp.find_hottest_day(days))
        coldest_days.append(Temp.find_coldest_day(days))
    hottest_temp_year = Temp.get_hottest_temp_each_year()
    coldest_temp_year = Temp.get_coldest_temp_each_year()
    legend = Dataset.get_legend()
    Tempdata.store_extrema(legend, hottest_temp_year, coldest_temp_year)
    plot_hottest_and_coldest_days(hottest_days, coldest_days)

    x, y, x_unknown, y_unknown, sigma = gauss_process(complete_file[1:])
    plot_trend_prediction(x, y, x_unknown, y_unknown, sigma)
    show()
Exemplo n.º 24
0
import time

from ble_temperature import setup as setup_ble
from display import setup as setup_display, show
from sensors import setup as setup_sensors

ble_temp = setup_ble()
displays = setup_display()
sensors, roms = setup_sensors()

while True:
    sensors.convert_temp()
    time.sleep_ms(750)  # wait for values
    values = []
    for i, rom in enumerate(roms):
        value = sensors.read_temp(rom)
        print(i, "rom:", rom, "=>", value)
        show(i, displays, value)
        values.append(value)
    ble_temp.set_temperature(values, notify=True)
    time.sleep(5)
Exemplo n.º 25
0
# Opening the 'Words.txt' file
try:
    word_list = open("Words.txt", "r")
except IOError:
    error.file_error()
finally:
    print "Opening Operation done!"

# Basic modifications code
data = storer.store_data(word_list)
storer.remove_slashn(data)
storer.to_lower(data)

# Closing the file
word_list.close()

# Getting input from the user
word = raw_input("Enter an item to be searched (Type \'exit\' to exit) :  ")

input.checker(word)

display.init("Intializing check")

# Checking
if search.letter(word, data):
    display.show("PASS")

else:
    display.show("EVERYTHING FALIED")
Exemplo n.º 26
0
    instruction = instruction_queue.exe(
    )  #IF/ID (instruction fetch and decode)

    memory.exe(
        instruction
    )  #Memory block, if the instruction is a load or store, it will be processed here

    for i in range(
            system.add_number
    ):  ##Adder reservation stations, send the instruction to the adder reservations stations
        reservation_station.add_exe(i, instruction)
        adder.exe(i, 0, 0, 0, 0)

    for i in range(
            system.mul_number
    ):  ##Multiplier reservation stations, send the instruction to the multiplier reservations stations
        reservation_station.mul_exe(i, instruction)
        multiplier.exe(i, 0, 0, 0, 0)

    cdb.exe(
    )  ##Common Data Bus, which will broadcast the result back to the registers and reservation stations

    display.show()  ##Will print the state of the machine

    ## Next clock cycle
    time.sleep(system.sleep_duration)

for i in range(len(system.mem)):
    print("Memory slot", i, ": ", system.mem[i], sep='')
Exemplo n.º 27
0
    print(data[i])

responses = {}
clients = []

# TODO :
# Display the data


print("#### Starting clients : ####")
for target in data:
    responses[target] = [] #A bit unordered
    for toPing in data[target]:
        if toPing['protocole'] == 'TCP':
            clients.append(threading.Thread(target=ClientTCP, args = [responses, target, toPing["ipType"], toPing['address'], toPing['port']]))
        elif toPing['protocole'] == 'UDP':
            clients.append(threading.Thread(target=ClientUDP, args = [responses, target, toPing["ipType"], toPing['address'], toPing['port']]))
        elif toPing['protocole'] == 'ICMP':
            clients.append(threading.Thread(target=ClientICMP, args=[responses, target, toPing['address']]))
        else:
            print('Unsupported protocole' + ' - ' + toPing['address'] + ' - ' + toPing['protocole'])

for client in clients:
    client.start()

#Managing the end of the thread exec (That should never happened)
for client in clients:
    client.join()
print('#### Over ####')
display.show(responses)
Exemplo n.º 28
0
          "00000:"
          "11111:"
          "11111"),
    Image("00000:"
          "00000:"
          "00000:"
          "00000:"
          "11111"),
    Image("00000:"
          "00000:"
          "00000:"
          "00000:"
          "00000"),
]

display.show(all_boats, color=(10, 10, 10), delay=150)

music.play(music.JUMP_UP)
display.show('A', color=(20, 0, 0))
while 0 == button_a.was_pressed():
    time.sleep(0.1)
time.sleep(0.5)
display.show('O', color=(0, 20, 0))

music.play(music.JUMP_UP)
display.show('B', color=(20, 0, 0))
while 0 == button_b.was_pressed():
    time.sleep(0.1)
time.sleep(0.5)
display.show('O', color=(0, 20, 0))
Exemplo n.º 29
0
data = storer.store_data(word_list)
storer.remove_slashn(data)
storer.to_lower(data)

# Closing the file
word_list.close()


# Getting input from the user
word = raw_input("Enter an item to be searched (Type \'exit\' to exit) :  ")

input.checker(word)

display.init("Intializing check")

# Checking
if search.letter(word,data):
    display.show("PASS")
    
else:
    display.show("EVERYTHING FALIED")


    






Exemplo n.º 30
0
#import WiFiMqtt as network
import gamer
import time
import display

# Setup
# network.setupConnections()
# mqtt = network.MyMqtt()
# device = gamer.MyPyGamer(mqtt)
# gamer.initialize()
print("Setup complete.")
display.show(False, False, False, False, "Percy", "Motors", True, "Servos",
             False)

# Main Loop
interval = 1 / 10
counter = 0
while True:
    """
    if counter > interval:
        mqtt.checkMessages()
        counter = 0
    else:
        counter = counter + 1
    """
    gamer.check_buttons()
    time.sleep(interval)
Exemplo n.º 31
0
#!/usr/bin/env python3
import display
import sys
display.init()
display.show(sys.argv[1].rjust(4), 2)
Exemplo n.º 32
0
def refresh():
    display.show(device.button.up, device.button.down, device.button.left,
                 device.button.right, robot.name, "motors",
                 robot.mode == "motor", "servos", robot.mode == "servo")
Exemplo n.º 33
0
def select(cmd):
    cmd = cmd.strip().split(" ")
    #  LOAD AND STORE COMMANDS
    if cmd[0] == "LDA" and len(cmd) > 1:
        functions.LDA(cmd[1])

    elif cmd[0] == "MOV" and len(cmd) > 1:
        regs = cmd[1].strip().split(",")
        functions.MOV(regs[0], regs[1])

    elif cmd[0] == "STA" and len(cmd) > 1:
        functions.STA(cmd[1])

    elif cmd[0] == "MVI" and len(cmd) > 1:
        operand = cmd[1].strip().split(",")
        functions.MVI(operand[0], operand[1])

    elif cmd[0] == "LXI" and len(cmd) > 1:
        operand = cmd[1].strip().split(",")
        functions.LXI(operand[0], operand[1].strip())

    elif cmd[0] == "LHLD" and len(cmd) > 1:
        functions.LHLD(cmd[1])

    elif cmd[0] == "SHLD" and len(cmd) > 1:
        functions.SHLD(cmd[1])

    elif cmd[0] == "XCHG":
        functions.XCHG()

    elif cmd[0] == "STAX" and len(cmd) > 1:
        functions.STAX(cmd[1])

        # ARITHMETIC COMMANDS

    elif cmd[0] == "ADD" and len(cmd) > 1:
        functions.ADD(cmd[1])

    elif cmd[0] == "SUB" and len(cmd) > 1:
        functions.SUB(cmd[1])

    elif cmd[0] == "ADI" and len(cmd) > 1:
        functions.ADI(cmd[1])

    elif cmd[0] == "INR" and len(cmd) > 1:
        functions.INR(cmd[1])

    elif cmd[0] == "DCR" and len(cmd) > 1:
        functions.DCR(cmd[1])

    elif cmd[0] == "INX" and len(cmd) > 1:
        functions.INX(cmd[1])

    elif cmd[0] == "DCX" and len(cmd) > 1:
        functions.DCX(cmd[1])

    elif cmd[0] == "DAD" and len(cmd) > 1:
        functions.DAD(cmd[1])

    elif cmd[0] == "SUI" and len(cmd) > 1:
        functions.SUI(cmd[1])

        # LOGICAL COMMANDS

    elif cmd[0] == 'CMP' and len(cmd) > 1:
        functions.CMP(cmd[1])

    elif cmd[0] == 'CMA':
        functions.CMA()

        # BRANCHING COMMANDS

    elif cmd[0] == 'JMP' and len(cmd) > 1:
        return functions.JMP(cmd[1])

    elif cmd[0] == 'JC' and len(cmd) > 1:
        return functions.JC(cmd[1])

    elif cmd[0] == 'JNC' and len(cmd) > 1:
        return functions.JNC(cmd[1])

    elif cmd[0] == 'JZ' and len(cmd) > 1:
        return functions.JZ(cmd[1])

    elif cmd[0] == 'JNZ' and len(cmd) > 1:
        return functions.JNZ(cmd[1])

        # EXTRA COMMANDS

    elif cmd[0] == "SET" and len(cmd) > 1:
        operand = cmd[1].strip().split(",")
        functions.SET(operand[0], operand[1])

    elif cmd[0] == "HLT":
        display.show()
        if registers.dBugOn == True:
            return
        exit(1)
    else:
        print "operand missing:", cmd
        exit(1)
Exemplo n.º 34
0
# The default delay value.
default_delay = 0.2
# The amount of time to delay the program.
to_delay = 0

while running:
    tries += 1
    if to_delay > 0:
        # Delays the program execution.
        time.sleep(to_delay)
        to_delay = 0
    try:
        if state["state"] == -1:
            if state["status"] == 0:
                display.show([title, "Initializing"])
                # Clean data
                if os.path.isdir(url_data_dir):
                    for filename in os.listdir(url_data_dir):
                        file_path = os.path.join(url_data_dir, filename)
                        try:
                            if os.path.isfile(file_path):
                                os.unlink(file_path)
                            elif os.path.isdir(file_path):
                                shutil.rmtree(file_path)
                        except:
                            pass
                # Initialize Directories
                os.makedirs(url_data_dir, exist_ok=True)
                os.makedirs(url_raw_dir, exist_ok=True)
                os.makedirs(url_raw_heroes_dir, exist_ok=True)
Exemplo n.º 35
0
#!/usr/bin/env python3
import subprocess
import display

data = subprocess.run(['df', '-h', '/mnt/backup'],
                      stdout=subprocess.PIPE).stdout.decode('utf-8')

display.init()
display.show(data.split('\n')[1].split()[3].rjust(4), 2)
Exemplo n.º 36
0
import pins

led1 = pins.Pins(12)
led2 = pins.Pins(14)

led1.write_digital(1)
led2.write_digital(1)

import display
Image = display.Image
display = display.Display()

time.sleep(0.5)
music.play(music.JUMP_UP)
display.show('A', color=(20, 0, 0))
while 0 == button_a.was_pressed():
    time.sleep(0.1)
time.sleep(0.5)
display.show('O', color=(0, 20, 0))

time.sleep(0.5)
music.play(music.JUMP_UP)
display.show('D', color=(20, 0, 0))
display.clear()
time.sleep(1)
display.show(Image("33333:"
                   "33333:"
                   "33333:"
                   "33333:"
                   "33333"),