Esempio n. 1
0
def Main():
  Screen.WakeScreen()
  Timer.SetTimeOut('sleep_screen', 7, Screen.SleepScreen, permanent=True)
  RefreshDesktop()
Esempio n. 2
0
def Thread():
    serial_port = SystemState.PhoneState.serial_port

    # Infinite loop to pass found messages to InterruptSystem() in cobblr.
    while True:
        # Looks for incomming serial messages (calls, texts, etc).
        try:
            serial_data = serial_port.readlines()
        except serial.SerialException:
            serial_data = []  # Evil.

        serial_data = ParseSerialData(serial_data)
        if len(serial_data) > 0:
            print 'serial data: ', serial_data

        # Call related interrupts
        if len(serial_data) > 0:
            message_type = serial_data[0]
            if message_type == 'RING':
                serial_data = serial_data[1].strip()
                stripped_number = serial_data.split('"')[1].strip('"')
                Screen.WakeScreen()

                # Setting RING timeout timer to hang up if NO CARRIER is not received.
                callback = Menu.Back
                callback_args = {'change_application': True}
                Timer.DeleteTimeOut('ring_timeout')
                Timer.SetTimeOut('ring_timeout', 6, callback, callback_args)

                # Changes menu
                callback_args = {
                    'screen_mode': 3,
                    'application': 'phone',
                    'change_application': True,
                    'store_history': False
                }
                message = {
                    'callback': Menu.JumpTo,
                    'callback_args': callback_args
                }
                SystemState.interrupt_queue.put(message)

                # Print's 'Incomming Call' on the screen.
                callback_args = {
                    'permatext': True,
                    'text': 'Incomming Call',
                    'text_type': 'message'
                }
                message = {
                    'callback': TextWriter.Write,
                    'callback_args': callback_args
                }
                SystemState.interrupt_queue.put(message)

                # Print's the phone number on the screen.
                callback_args = {
                    'permatext': True,
                    'text': stripped_number,
                    'text_type': 'subtext'
                }
                message = {
                    'callback': TextWriter.Write,
                    'callback_args': callback_args
                }
                SystemState.interrupt_queue.put(message)

            if message_type == 'ATA':
                Timer.DeleteTimeOut('ring_timeout')

            # If someone hang's up, go back to the lass application.
            if message_type == 'NO CARRIER':
                Timer.DeleteTimeOut('ring_timeout')
                callback_args = {'change_application': True}
                message = {
                    'callback': Menu.Back,
                    'callback_args': callback_args
                }
                SystemState.interrupt_queue.put(message)