arduino-2020-06-12-0711.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673








12201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260











                            <----SKIPPED LINES---->




      *SERVO_CONNECTION, read_timeout=7,
      error_pin=messageboard.GPIO_ERROR_ARDUINO_SERVO_CONNECTION, to_parent_q=to_parent_q,
      read_format='l', write_format='ff???', name='Servo')
  link.Open()

  last_flight = {}
  last_angles = (0, 0)
  flight, json_desc_dict, configuration, additional_attr = InitialMessageValues(
      to_arduino_q)
  next_read = 0
  next_write = 0
  now = GetNow(json_desc_dict, additional_attr)

  while not shutdown.value:
    if not to_arduino_q.empty():
      flight, json_desc_dict, configuration, additional_attr = to_arduino_q.get(
          block=False)

      if 'test_servos' in configuration:
        messageboard.RemoveSetting(configuration, 'test_servos')
        configuration.pop('test_servos')  # ensure that this is triggered only once
        link.Write((0, 0, *LASER_RGB_OFF))
        time.sleep(1)
        link.Write((90, 0, *LASER_RED))
        time.sleep(1)
        link.Write((180, 0, *LASER_GREEN))
        time.sleep(1)
        link.Write((270, 0, *LASER_BLUE))
        time.sleep(1)

      new_flight = DifferentFlights(flight, last_flight)
      if new_flight:
        Log('Flight changed from %s to %s' % (
            messageboard.DisplayFlightNumber(last_flight),
            messageboard.DisplayFlightNumber(flight)
        ), ser=link)

        # Turn off laser so that line isn't traced while it moves to new position
        link.Write((*last_angles, *LASER_RGB_OFF))

      last_flight = flight




                            <----SKIPPED LINES---->





  # Read in the saved display mode, if it exists
  display_mode = messageboard.ReadFile(REMOTE_DISPLAY_MODE, log_exception=False)
  if not display_mode:
    display_mode = DISP_LAST_FLIGHT_NUMB_ORIG_DEST
  else:
    display_mode = int(display_mode)

  flight, json_desc_dict, configuration, additional_attr = InitialMessageValues(
      to_arduino_q)
  next_read = 0
  next_write = 0

  while not shutdown.value:
    if not to_arduino_q.empty():
      to_arduino_message = to_arduino_q.get(block=False)
      flight, json_desc_dict, configuration, additional_attr = to_arduino_message

      if 'test_remote' in configuration:
        messageboard.RemoveSetting(configuration, 'test_remote')
        configuration.pop('test_remote')  # ensure that this is triggered only once

        def TestDisplayMode(m):
          SendRemoteMessage(
              flight, json_desc_dict, configuration, additional_attr,
              m, write_keys, write_format_tuple, link)
          time.sleep(1)

        TestDisplayMode(DISP_LAST_FLIGHT_NUMB_ORIG_DEST)
        TestDisplayMode(DISP_LAST_FLIGHT_AZIMUTH_ELEVATION)
        TestDisplayMode(DISP_FLIGHT_COUNT_LAST_SEEN)
        TestDisplayMode(DISP_RADIO_RANGE)

    if time.time() >= next_write:
      next_write = SendRemoteMessage(
          flight, json_desc_dict, configuration, additional_attr,
          display_mode, write_keys, write_format_tuple, link)

    if time.time() >= next_read:
      bytes_read = []
      values_t = link.Read(bytes_read=bytes_read)




                            <----SKIPPED LINES---->





01234567890123456789012345678901234567890123456789012345678901234567890123456789









633634635636637638639640641642643644645646647648649650651652 653654655656657658659660661662663664665666667668669670671672








12191220122112221223122412251226122712281229123012311232123312341235123612371238 12391240124112421243124412451246124712481249125012511252125312541255125612571258











                            <----SKIPPED LINES---->




      *SERVO_CONNECTION, read_timeout=7,
      error_pin=messageboard.GPIO_ERROR_ARDUINO_SERVO_CONNECTION, to_parent_q=to_parent_q,
      read_format='l', write_format='ff???', name='Servo')
  link.Open()

  last_flight = {}
  last_angles = (0, 0)
  flight, json_desc_dict, configuration, additional_attr = InitialMessageValues(
      to_arduino_q)
  next_read = 0
  next_write = 0
  now = GetNow(json_desc_dict, additional_attr)

  while not shutdown.value:
    if not to_arduino_q.empty():
      flight, json_desc_dict, configuration, additional_attr = to_arduino_q.get(
          block=False)

      if 'test_servos' in configuration:
        messageboard.RemoveSetting(configuration, 'test_servos')

        link.Write((0, 0, *LASER_RGB_OFF))
        time.sleep(1)
        link.Write((90, 0, *LASER_RED))
        time.sleep(1)
        link.Write((180, 0, *LASER_GREEN))
        time.sleep(1)
        link.Write((270, 0, *LASER_BLUE))
        time.sleep(1)

      new_flight = DifferentFlights(flight, last_flight)
      if new_flight:
        Log('Flight changed from %s to %s' % (
            messageboard.DisplayFlightNumber(last_flight),
            messageboard.DisplayFlightNumber(flight)
        ), ser=link)

        # Turn off laser so that line isn't traced while it moves to new position
        link.Write((*last_angles, *LASER_RGB_OFF))

      last_flight = flight




                            <----SKIPPED LINES---->





  # Read in the saved display mode, if it exists
  display_mode = messageboard.ReadFile(REMOTE_DISPLAY_MODE, log_exception=False)
  if not display_mode:
    display_mode = DISP_LAST_FLIGHT_NUMB_ORIG_DEST
  else:
    display_mode = int(display_mode)

  flight, json_desc_dict, configuration, additional_attr = InitialMessageValues(
      to_arduino_q)
  next_read = 0
  next_write = 0

  while not shutdown.value:
    if not to_arduino_q.empty():
      to_arduino_message = to_arduino_q.get(block=False)
      flight, json_desc_dict, configuration, additional_attr = to_arduino_message

      if 'test_remote' in configuration:
        messageboard.RemoveSetting(configuration, 'test_remote')


        def TestDisplayMode(m):
          SendRemoteMessage(
              flight, json_desc_dict, configuration, additional_attr,
              m, write_keys, write_format_tuple, link)
          time.sleep(1)

        TestDisplayMode(DISP_LAST_FLIGHT_NUMB_ORIG_DEST)
        TestDisplayMode(DISP_LAST_FLIGHT_AZIMUTH_ELEVATION)
        TestDisplayMode(DISP_FLIGHT_COUNT_LAST_SEEN)
        TestDisplayMode(DISP_RADIO_RANGE)

    if time.time() >= next_write:
      next_write = SendRemoteMessage(
          flight, json_desc_dict, configuration, additional_attr,
          display_mode, write_keys, write_format_tuple, link)

    if time.time() >= next_read:
      bytes_read = []
      values_t = link.Read(bytes_read=bytes_read)




                            <----SKIPPED LINES---->