Beispiel #1
0
 def __init__(self, greet, load):
     """ Initialise the interpreter session. """
     # true if a prompt is needed on next cycle
     self.prompt = True
     # input mode is AUTO (used by AUTO)
     state.basic_state.auto_mode = False
     # interpreter is executing a command
     state.basic_state.parse_mode = False
     # interpreter is waiting for INPUT or LINE INPUT
     state.basic_state.input_mode = False
     # previous interpreter mode
     self.last_mode = False, False
     # syntax error prompt and EDIT
     state.basic_state.edit_prompt = False
     # initialise the display
     display.init()
     # initialise the console
     console.init_mode()
     # set up event handlers
     state.basic_state.events = events.Events()
     # load initial program
     if load:
         # on load, accept capitalised versions and default extension
         with disk.open_native_or_dos_filename(load) as progfile:
             program.load(progfile)
     # set up interpreter and memory model state
     reset.clear()
     # greeting and keys
     if greet:
         console.clear()
         console.write_line(greeting.format(version=plat.version, free=var.fre()))
         console.show_keys(True)
Beispiel #2
0
 def __init__(self):
     self.diff = 0
     self.fcol = (50, 50, 50)
     self.fselcol = (50, 50, 200)
     self.relcontrol = True
     self.control_angle = 10
     self.sensible = 0
     self.speed = 7
     self.img = []
     self.text = []
     self.ptim = 0
     self.font = pygame.font.Font("DejaVuSans.ttf", 30)
     display.vars.font = self.font
     global gfx
     gfx = "gfx"
     pygame.init()
     self.size = (1024, 800)
     self.bounds = pygame.Rect(0, 0, self.size[0], self.size[1])
     display.init(self.size)
     self.menu_back = pygame.transform.smoothscale(
         pygame.image.load(path.join(gfx, 'menu.jpg')).convert(), self.size)
     self.gameback = pygame.transform.smoothscale(
         pygame.image.load(path.join(gfx, "background.jpg")), self.size)
     self.fpslimit = 40
     self.trace = display.trace()
     self.option = []
     self.sel = 0
     self.menu()
     self.loop()
Beispiel #3
0
    def _run_init(self):
        """Initialize the application before running.

        Returns: None
        """
        display.load('flamingo.backends.display.pygame_display',
                     'flamingo.backends.event.pygame_event')
        display.init(800, 600, self.data.screen_title)

        ## OpenGL
        gl.glShadeModel(gl.GL_SMOOTH)
        gl.glClearColor(0, 0, 0, 1)
        gl.glDisable(gl.GL_DEPTH_TEST)
        gl.glDisable(gl.GL_LIGHTING)
        
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        
        gl.glEnable(gl.GL_POINT_SMOOTH)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gl.glEnable(gl.GL_POLYGON_SMOOTH)

        # Flamingo
        self.data.eventlistener.bind(self.quit_all, constants.QUIT, constants.QUIT)

        audio.mixer.init()
        self.quit = False
Beispiel #4
0
 def __init__(self):
     self.diff=0
     self.fcol=(50,50,50)
     self.fselcol=(50,50,200)
     self.relcontrol=True
     self.control_angle=10
     self.sensible=0
     self.speed=7
     self.img=[]
     self.text=[]
     self.ptim=0
     self.font=pygame.font.Font("DejaVuSans.ttf", 30)
     display.vars.font=self.font
     global gfx;gfx="gfx"
     pygame.init()
     self.size=(1024,800)
     self.bounds=pygame.Rect(0,0,self.size[0],self.size[1])
     display.init(self.size)
     self.menu_back=pygame.transform.smoothscale(pygame.image.load(path.join(gfx,'menu.jpg')).convert(),self.size)
     self.gameback = pygame.transform.smoothscale(pygame.image.load(path.join(gfx,"background.jpg")),self.size)
     self.fpslimit=40
     self.trace=display.trace()    
     self.option=[]
     self.sel=0
     self.menu()
     self.loop()
Beispiel #5
0
def main():
    logger.debug('IPPhone')
    logger.debug('開始')

    server_address = os.environ['SERVER_ADDRESS']
    config = {
        'server_address': (server_address, 5060),
        'local_uri': ('6002', server_address, 5061),
        'password': '******',
        'expires': 3600,
    }

    event.init()

    com.init()
    drv.init(config)
    reg.init(config)
    dialog.init(config)
    display.init()

    threading.Thread(target=drv.recv, daemon=True).start()
    threading.Thread(target=event.main, daemon=True).start()

    while cmd():
        pass

    logger.debug('終了')
Beispiel #6
0
def init(blocking=True):
    display.init(not blocking)

    # Initialize the styles
    init_styles()

    scr = lv.obj()
    lv.scr_load(scr)
    update()
Beispiel #7
0
def start():
    try:
        display.init()
        control.init()
        gameloop.start()
    finally:
        control.finish()
        display.exit()
        print("Game over! Score - ", Game.GameState().score)
Beispiel #8
0
 def __init__(self):
     terrain.loadimg("testlevel")
     #terrain.loadimg("clev")
     self.name = "damnidontcare"
     display.init()
     self.gamestate = gameStateClass()
     self.walkers = self.gamestate.walkers
     self.clients = self. walkers
     simplenet.clients = self.clients
     terrain.walkers = self.walkers
     display.lookat(0, 0)
     self.mx = 100
     self.my = 100
     self.mywalker = self.walkers[0]
     self.menu = menu.Menu()
Beispiel #9
0
def main():
    pygame.init()
    display.init()
    controller = Controller()
    scene = Title()
    while True:
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        if not controller.poll():
            if hasattr(scene, 'server'):
                print 'shutdown'
                scene.server.shutdown()
            return
        scene.draw()
        pygame.display.flip()
        scene = scene.action(controller)
Beispiel #10
0
def run(server_class=HTTPServer, handler_class=handler, port=8080):
    display.init()
    for c in '987654321 ':
        display.write_char(c)
        sleep(0.25)
    logging.basicConfig(level=logging.INFO)
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    logging.info('listening on port ...\n')
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    logging.info('stopping...\n')
Beispiel #11
0
def prepare_console():
    """ Initialise backend and console. """
    import state
    import backend
    import display
    import sound
    import console
    # we need this prepared for input to work,
    # even if we don't use any function from it
    import inputs
    interface = config.get('interface') or 'graphical'
    display.init(interface)
    sound.init('none' if config.get('nosound') else interface)
    if not state.loaded:
        console.init_mode()
    return backend, console
Beispiel #12
0
def prepare_console():
    """ Initialise backend and console. """
    import state
    import backend
    import display
    import sound
    import console
    # we need this prepared for input to work,
    # even if we don't use any function from it
    import inputs
    interface = config.get('interface') or 'graphical'
    display.init(interface)
    sound.init('none' if config.get('nosound') else interface)
    if not state.loaded:
        console.init_mode()
    return backend, console
Beispiel #13
0
 def connect(self) -> bool:
     notified = False
     while True:
         if self.checkInstallationMode() and not self.is_bm3:
             return False
         self.dspi = dsp.init()
         if not self.dspi:
             if not notified:
                 dprint("Vayve LCD Display not detected")
                 notified = True
             time.sleep(10)
         else:
             if (self.dspi.vid, self.dspi.pid) == (0x2047, 0xf003):
                 max_count = 150
                 timer = 0.1
                 print(f"Waiting for {max_count*timer} sec ...")
                 count = 0
                 while count < max_count:
                     if self.checkInstallationMode() and not self.is_bm3:
                         self.close()
                         return False
                     time.sleep(timer)
                     count += 1
             self.displayOnTime = None
             break
         if (self.is_remote_associated() and self.getTvStatus()
             ) and self.viewersRegistered and not self.viewersDeclared:
             self.buzz()
     dprint(f"Clearing display")
     self.dspi.Clear()
     return True
Beispiel #14
0
def init():
    display.init()

    # Set up material theme
    # First argument (210) is a hue - theme color shift,
    # Second - default font to use. Builtin: roboto_16, roboto_28
    th = lv.theme_material_init(210, lv.font_roboto_22)
    lv.theme_set_current(th)

    # Create a screen and load it
    # To access active screen use lv.scr_act()
    scr = lv.obj()
    lv.scr_load(scr)

    # Initialize the styles
    styles["title"] = lv.style_t()
    # Title style - just a default style with larger font
    lv.style_copy(styles["title"], lv.style_plain)
    styles["title"].text.font = lv.font_roboto_28
Beispiel #15
0
def main():
    GPIO.cleanup()
    try:
        initGpio()
        display.init()
        while True:
            display.lcdWriteSecondLine("Choose an action...")
            global displayTime
            displayTime = true
            #Start new thread to show curent datetime on display
            # and wait for user input on keyboard
            thr = thread.start_new_thread(printDateToDisplay, ())
            a = getOneKey()
            displayTime = False
            if 47 < a < 58:
                readNfc(a)
    except KeyboardInterrupt:
        GPIO.cleanup()
        pass
    GPIO.cleanup()
Beispiel #16
0
def main():
    GPIO.cleanup()
    try:
        initGpio()
        display.init()
        while True:
            display.lcdWriteSecondLine("Choose an action...")
            global displayTime
            displayTime=true
            #Start new thread to show curent datetime on display
            # and wait for user input on keyboard
            thr = thread.start_new_thread(printDateToDisplay, ())
            a = getOneKey()
            displayTime=False
            if 47 < a < 58:
                readNfc(a)
    except KeyboardInterrupt:
        GPIO.cleanup()
        pass
    GPIO.cleanup()
Beispiel #17
0
def main():
    try:
        initGpio()
        mysqlite.init()
        display.init()
        display.lcdWriteSecondLine("Willkommen")

        global displayTime
        displayTime = True
        
        while 1:
            while displayTime:
                printTimeToDisplay()
                time.sleep(1)

            #Start new thread to show curent datetime on display
            # and wait for user input on keyboard
            #thr = thread.start_new_thread(printDateToDisplay, ())
            #a = getOneKey()
            #displayTime=False
            #if 47 < a < 58:
            #    readNfc(a)

    except KeyboardInterrupt:
        print "Good-bye!"
        logging.info("Keyboard interrupt")
        display.lcdWriteFirstLine("Good-bye!")
        display.lcdWriteSecondLine("")
        time.sleep(1)
        display.lcdWriteFirstLine("")

    except:
        print "Fatal Error!"
        logging.info("Fatal Error")
        display.lcdWriteFirstLine("Fatal Error!")
        display.lcdWriteSecondLine("")
        time.sleep(1)
        display.lcdWriteFirstLine("")

    finally:
        GPIO.cleanup()
Beispiel #18
0
def initialize(width, height, title):
    '''
    Starts pygame, initializes the display, makes the mouse invisible, and registers quit events.
    '''
    global LEVEL
    
    num_successes, num_fails = pygame.init()

    logger.debug("Number of modules initialized: " + str(num_successes))
    logger.debug("Number of modules failed: " + str(num_fails))

    # Initialize display
    display.init(width, height, title)
    
    physics.PHYSICS_SYSTEM.width = width
    physics.PHYSICS_SYSTEM.height = height

    event_handler.register("QUIT", quit)
    event_handler.register("KEYDOWN", key_quit)
    
    pygame.mouse.set_visible(False)
    def __init__(self, slide_seconds, width=None, height=None, crop_threshold=10, shuffle=True):
        self.screen, self.width, self.height = display.init(width, height)

        self.provider = providers.Provider(self.width, self.height, CACHE_PATH, CACHE_SIZE_MB, shuffle=shuffle)
        self.theme = themes.Theme(self.width, self.height)

        self.frame = RaspberryFrame((self.width, self.height), crop_threshold)
        self.frame.add(fade=False)

        self.clock = pygame.time.Clock()
        self.slide_seconds = slide_seconds
        self.timer = None

        self.overlay = overlay.Overlay(self.theme)
Beispiel #20
0
i2c = busio.I2C(board.SCL, board.SDA, frequency=800000)
if LOAD_PMSA003I:
    # PMSA003I needs its own i2c bus because it seems to mess with other i2c devices
    # it also needs a much lower i2c clock frequency per adafruit docs
    # fortunately the feathers2 has 2 i2c controllers and we can instantiate the 2nd one
    # on pins IO17 and IO18 which are very close to 3V and GND pins so
    # you can solder a JST-EH connector with 5 or more positions to [3V, 0, GND, 17, 18]
    # also, @unexpectedmaker warned on discord not to use IO0 for i2c
    i2c1 = busio.I2C(board.IO17, board.IO18, frequency=100000)

if LOAD_WATCHDOG:
    w.feed()

if LOAD_DISPLAY:
    print("init display")
    display.init(i2c)

    if LOAD_WATCHDOG:
        w.feed()

print("init net")
display.show(0, "init net")

from net import requests, geo

if LOAD_WATCHDOG:
    w.feed()

if LOAD_FREEDOM:
    print("init link")
    display.show(0, "init link")
Beispiel #21
0
 def __init__(self):
     self.display = display.init()
     self.scr = lv.scr_act()
Beispiel #22
0
# 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")


    




Beispiel #23
0
 def init_ui(self):
     display.init()
     theme = lv.theme_material_init(210, lv.font_roboto_mono_28)
     lv.theme_set_current(theme)
Beispiel #24
0
def init():
    display.init()
Beispiel #25
0
 def init_display(self):
     d.init()
     return
Beispiel #26
0
import pygame
import config
import display
from display import Display, MenuDisplay
from sprites import Goal, Lights
from levels import Level, levels
from camera import Camera

clock = pygame.time.Clock()


def move((x, y), (dx, dy)):
    return x + dx, y + dy


display.init()

objReader.load_models()


class Game:
    def menu(self):
        items = [(level.name, lambda x=level: self.play(x()))
                 for level in levels] + [('quit', lambda: exit(0))]

        menu = MenuDisplay(items)
        self._quitMenu = False

        tm = pygame.time.Clock()
        while not self._quitMenu:
            for event in pygame.event.get():
Beispiel #27
0
import objects
import map

WIDTH = 384
HEIGHT = 384

# Event handlers
def quit(e):
    """Event hander for quit events"""
    # Any shutdown code should go here
    sys.exit()


pygame.display.init()

display.init(WIDTH, HEIGHT)
display.register(map.sample_map())
display.register(objects.sample_statue())

minotaur = objects.sample_minotaur()
display.register(minotaur)

ehandler.register("quit", quit)

while True:
    minotaur.update()
    display.render()
    ehandler.run()


pygame.quit()
Beispiel #28
0
def main(apps=None, network="main", keystore_cls=None):
    """
    apps: list of apps to load
    network: default network to operate
    keystores: list of KeyStore classes that can be used
    """
    # Init display first as it also inits the SDRAM
    display.init(False)
    # create virtual file system /sdram
    # for temp untrusted data storage
    rampath = platform.mount_sdram()

    # set working path to empty folder in sdram
    if not platform.simulator:
        cwd = rampath + "/cwd"
        platform.maybe_mkdir(cwd)
        os.chdir(cwd)

    # define hosts - USB, QR, SDCard
    # each hosts gets it's own RAM folder for data
    Host.SETTINGS_DIR = platform.fpath("/qspi/hosts")
    Specter.SETTINGS_DIR = platform.fpath("/qspi/global")
    hosts = [
        USBHost(rampath + "/usb"),
        QRHost(rampath + "/qr"),
        SDHost(rampath + "/sd"),
    ]
    # temp storage in RAM for host commands processing
    BaseApp.TEMPDIR = rampath + "/tmp"

    # define GUI
    if not platform.simulator:
        gui = SpecterGUI()
    else:
        # this GUI can simulate user actions for automated testing
        from gui.tcp_gui import TCPGUI
        gui = TCPGUI()

    # inject the folder where keystore stores it's data
    KeyStore.path = platform.fpath("/flash/keystore")
    # detect keystore to use
    if keystore_cls is not None:
        keystores = [keystore_cls]
    else:
        keystores = [
            MemoryCard,
            SDKeyStore,
        ]

    # loading apps
    if apps is None:
        apps = load_apps()

    # make Specter instance
    settings_path = platform.fpath("/flash")
    specter = Specter(
        gui=gui,
        keystores=keystores,
        hosts=hosts,
        apps=apps,
        settings_path=settings_path,
        network=network,
    )
    specter.start()
Beispiel #29
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")
Beispiel #30
0
        print label_to_num
        print num_to_label
        print 'Loading training data...'
        model.load(config.TRAINING_FILE)
        print 'loaded.'

    pi2kf.init()
    #call("aplay -q /home/pi/pi2kf/bla.wav", shell=True)
    if not options.fast:
        speak("System gestartet!,")
        speak("Warten auf Netzwerk!")
    httpThread = threading.Thread(target=httpThreadFunc)
    httpThread.daemon = True
    httpThread.start()

    image = display.init()

    width = display.width
    height = display.width

    # Get drawing object to draw on image.
    draw = ImageDraw.Draw(image)

    # Draw a black filled box to clear the image.
    draw.rectangle((0,0,width,height), outline=0, fill=0)

    #padding = 0
    font22 = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 22)
    font9  = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 9)
    font25 = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 25)
    #Draw Mot2Bot
Beispiel #31
0
addcontext.create_machine("machines/arithmetic/adders/compbinadd.tm")

# A Decimal Subtractor in Two Dimensions and with Many Working Parts
# This machine is more of a complex, working in concert.\nThe parent spawns workers whenever it needs them for subtasks.
subcontext = m.MachineContext(m.parse_tape("machines/arithmetic/subtract-composite/subtract.tp"))
subcontext.create_machine("machines/arithmetic/subtract-composite/subtract.tm")

# Conway's Life, Turingified.
concontext = m.MachineContext(m.parse_tape("machines/automata/conway/conway.tp"))
concontext.create_machine("machines/automata/conway/conway.tm", lifespan=100000)

# A dumb tail-chaser.
chacontext = m.MachineContext(m.parse_tape("machines/misc/snailchase.tp"))
chacontext.create_machine("machines/misc/snailchase.tm")
"""
# Langton's ant, in quadruplicate.
lancontext = m.MachineContext(m.Plane())
lancontext.create_machine("machines/automata/langton.tm", (0,0), "quad", 1000000)
"""
# Random Walker
rancontext = m.MachineContext(m.Plane())
rancontext.create_machine("machines/misc/randwalk.tm")

# Tree Grower
treecontext = m.MachineContext(m.Plane())
treecontext.create_machine("machines/misc/tree.tm")
"""

d.init(lancontext)
d.running = False
d.run()
Beispiel #32
0
            if contour.attrib['{http://slic3r.org/namespaces/slic3r}type'] == 'contour':
                contuple=contuple+(1,)
            elif contour.attrib['{http://slic3r.org/namespaces/slic3r}type'] == 'hole':
                contuple=contuple+(0,)
            coordinates=contour.attrib['points'].split()

            Xlist=[]
            Ylist=[]

            for coordinate in coordinates:
                Xlist.append(float(coordinate.split(',')[0]))
                Ylist.append(float(coordinate.split(',')[1]))

    	#HARDCODE a resize for 40 micron pixels
            XlistCorr=[640+25*(x-size[0]/2) for x in Xlist]
            YlistCorr=[400+25*(x-size[1]/2) for x in Ylist]

            contuple = contuple + (XlistCorr,)
            contuple = contuple + (YlistCorr,)
            print(len(Xlist))
            laytuple = laytuple + (contuple,)
        model = model + (laytuple,)

d.init()

for layer in model:
    print(len(layer[0]))
    d.expose(layer)

d.finish()
Beispiel #33
0
# Node ID
node_id = ubinascii.hexlify(machine.unique_id()).decode('utf-8')
print('\nDevice ID:' + node_id)
print('LCD initializing...', end='')

# pin Analog and digital

# LCD
lcd = lcd.TFT()
lcd.init(lcd.M5STACK,
         width=240,
         height=320,
         speed=40000000,
         rst_pin=33,
         miso=19,
         mosi=23,
         clk=18,
         cs=14,
         dc=27,
         bgr=True,
         invrot=3,
         expwm=machine.PWM(32, duty=0, timer=1))
lcd.setBrightness(30)
lcd.clear()
lcd.setColor(0xCCCCCC)
print('Done!')

#BUTTON
m5button = Button()
buttonA = m5button.register(_BUTTON_A_PIN)
buttonB = m5button.register(_BUTTON_B_PIN)
Beispiel #34
0
def start():
    display.init()
    MainMenu().push(modal=True)
Beispiel #35
0
# ------------------ M5Stack -------------------

# Node ID
node_id = ubinascii.hexlify(machine.unique_id()).decode('utf-8')
print('\nDevice ID:' + node_id)
print('LCD initializing...', end='')

# LCD
lcd = lcd.TFT()
lcd.init(lcd.M5STACK,
         width=240,
         height=320,
         speed=40000000,
         rst_pin=33,
         backl_pin=32,
         miso=19,
         mosi=23,
         clk=18,
         cs=14,
         dc=27,
         bgr=True,
         backl_on=1,
         invrot=3)
lcd.setBrightness(10)
lcd.clear()
lcd.setColor(0xCCCCCC)
print('Done!')
# lcd.println('M5Stack MicroPython '+VERSION, 0, 0)
# lcd.println('Device ID:'+node_id)
# lcd.println('Boot Mode:')
# lcd.println('Hold button A to boot into SAFE mode.')
# lcd.println('Hold button B to boot into OFFLINE mode.')
Beispiel #36
0
def main():
    # Initialization..
    logAndScreen("service init..")
    initGPio()
    display.init()
    try:
        #Main loop
        while True:
            #input readings.
            readLoopInputs()
            #TODO: Check if machine available(active low pin signal.)
            #checkMaytagAvailable()
            #print "luego del chequeo",maytag_available_signal
            #If PASS, then machine is available, and wait until a valid card is passing throug.
            logAndScreen("Machine available, asking for card")
            display.print_lcd_message("passCard")
            uid_read = nfc.readNfc()
            logAndScreen("Card Read: " + uid_read)
            #check Maytag Available when user ask for washing.
            #checkMaytagAvailable()
            if (isMaytagAvailable()):
                logAndScreen("Verifying..")
                display.print_lcd_message("verifying")
                ws_response = httpPostQuery(uid_read, urlFundsQuery)
                response = int(float(ws_response))
                ##Depending on web response..
                if (response == 4):
                    display.print_lcd_message("netwokError")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response == 2):
                    display.print_lcd_message("unasociatedCard")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response == 1):
                    display.print_lcd_message("invalidCard")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response == 3):
                    display.print_lcd_message("noFounds")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response >= 0):  #When founds are enogh
                    display.print_verification_message(response)
                    sendBeep()
                    logAndScreen("Waiting for confirmation..")
                    uuid2 = nfc.readNfcTOut()
                    logAndScreen("UUID2 Read: " + uuid2)
                    if (uuid2 == uid_read):
                        display.print_lcd_message("authorizing")
                        ws_response = httpPostQuery(uid_read, urlWashPayment)
                        response = int(float(ws_response))
                        ##Depending on web response, the results to the machine.
                        if (response == 2):
                            display.print_lcd_message("unasociatedCard")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response == 4):
                            display.print_lcd_message("networkError")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response == 1):
                            display.print_lcd_message("invalidCard")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response == 3):
                            display.print_lcd_message("noFounds")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response >= 0):
                            sendEnablePulse()
                            display.print_auth_message(response)
                            sendBeep()
                            time.sleep(180)
                        else:
                            display.print_lcd_message("internalError")
                            sendWrongBeep()
                            time.sleep(5)
                else:
                    display.print_lcd_message("internalError")
                    sendWrongBeep()
                    time.sleep(5)
            else:
                #Maytag unavailable
                logAndScreen("Maytag Unavailable")
                display.print_lcd_message("maytagUnavailable")
                sendWrongBeep()
                time.sleep(5)

    except KeyboardInterrupt:
        logAndScreen("ctrl plus c pressed, service down..")
        GPIO.cleanup()

    #except :
    #       logAndScreen("Main loop exception")
    #       GPIO.cleanup()

    GPIO.cleanup()
Beispiel #37
0
            display.clear()
            time.sleep(0.5)
            display.set_display(int(delta.seconds / 3600), True, blink_color)
            time.sleep(0.5)
            display.set_display(16, False, blink_color)
            time.sleep(0.5)
            display.clear()
        else:
            display.set_display_manual({0: blink_color})
            time.sleep(0.5)
            display.set_display_manual({0: 0})
        time.sleep(0.5)


# main
display.init()
# display.clear()
g_calendar.init()
tcpserver.init()
while True:
    try:
        if not tcpserver.connected:
            if time.time() > next_update_calendar:
                next_update_calendar = time.time() + 5
                new = g_calendar.update()
                if new:
                    next_calendar_notification = time.clock()

            if time.time() > next_calendar_notification:
                next_calendar_notification = time.time() + 30
                if len(g_calendar.events):
Beispiel #38
0
            elif contour.attrib[
                    '{http://slic3r.org/namespaces/slic3r}type'] == 'hole':
                contuple = contuple + (0, )
            coordinates = contour.attrib['points'].split()

            Xlist = []
            Ylist = []

            for coordinate in coordinates:
                Xlist.append(float(coordinate.split(',')[0]))
                Ylist.append(float(coordinate.split(',')[1]))

    #HARDCODE a resize for 40 micron pixels
            XlistCorr = [640 + 25 * (x - size[0] / 2) for x in Xlist]
            YlistCorr = [400 + 25 * (x - size[1] / 2) for x in Ylist]

            contuple = contuple + (XlistCorr, )
            contuple = contuple + (YlistCorr, )
            print(len(Xlist))
            laytuple = laytuple + (contuple, )
        model = model + (laytuple, )


d.init()

for layer in model:
    print(len(layer[0]))
    d.expose(layer)

d.finish()
Beispiel #39
0
import web
import thermometer
import display
import knob
import weather
import relay

HIST_LEN = 100
DB_WRITE_PERIOD = 60

# We're on /dev/i2c-1
bus = SMBus(1)

GPIO.setmode(GPIO.BOARD)
thermometer.init(bus)
display.init(bus)
knob.init()
conn = db.init()
web.init()
relay.init()

TIMEZONE = dateutil.tz.gettz('US/Pacific')


def get_is_day():
    now = datetime.datetime.now(TIMEZONE)
    return now.hour >= 8 and now.hour < 20


is_day = None
db_write_time = 0
Beispiel #40
0
big_font = pygame.font.SysFont('Century Gothic', 22)

game_speed = 50
screen_width = 800
screen_height = 600
cell_size = 40
menu_item_height = cell_size / 2
menu_item_v_offset = cell_size / 2 + 5
menu_tower_v_offset = menu_item_height * 7 + menu_item_v_offset + 7
tower_spacing = 45
menu_width = 200
playfield_w = int((screen_width - menu_width) / cell_size)
playfield_h = int(screen_height / cell_size)
background_line_width = 1

display.init(screen_width, screen_height, cell_size, menu_width, playfield_w, playfield_h, background_line_width)
events.init()

# TODO: iterate for every level
current_level = levels.level_1
current_waves_list = levels.level_1_waves

level_number = 1
wave_number = 0
heart_number = 20
kill_counter = 0
heart_max = heart_number
money = Resource()
money.gain(350)
victorious = False