01234567890123456789012345678901234567890123456789012345678901234567890123456789
736737738739740741742743744745746747748749750751752753754755 756757758759760761762763764765766767768769770771772773774775 883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923 | <----SKIPPED LINES----> for intensity in range(0, 255, 50): SendLEDTestMessage(*comms_args, intensity, 0, 0) for intensity in range(0, 255, 50): SendLEDTestMessage(*comms_args, 0, intensity, 0) for intensity in range(0, 255, 50): SendLEDTestMessage(*comms_args, 0, 0, intensity) SendLEDTestMessage(*comms_args, 0, 0, 0) def ServoTestDim(link, write_keys, write_format_tuple, rgb, gamma): """Dim LEDs at selected color from 100% to 0% with gamma correction.""" comms_args = link, write_keys, write_format_tuple for intensity in range(0, 101, 5): b = intensity / 100 SendLEDTestMessage(*comms_args, *GammaRGB(rgb, gamma, brightness=b)) def ServoTestSweep(link, write_keys, write_format_tuple, altitude=45): """Sweep red laser around 360 degrees.""" for azimuth in range(0, 360, 10): message_dict = GenerateServoMessage( laser=LASER_RED, angles=(azimuth, altitude)) link.Write(DictToValueTuple(message_dict, write_keys, write_format_tuple)) time.sleep(WRITE_DELAY_TIME) last_angles = (0, 0) last_laser = LASER_OFF last_led = LED_OFF def GenerateServoMessage( angles=None, laser=None, led=None, <----SKIPPED LINES----> last_flight = {} flight, json_desc_dict, configuration, additional_attr = InitialMessageValues( to_arduino_q) next_read = 0 next_write = 0 now = GetNow(json_desc_dict, additional_attr) gamma = GetGamma(configuration) while not shutdown.value: SetLoggingGlobals(configuration) if not to_arduino_q.empty(): flight, json_desc_dict, configuration, additional_attr = to_arduino_q.get( block=False) if 'test_servos_ordinal' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_ordinal') ServoTestOrdinal(link, write_keys, write_format_tuple) elif 'test_servos_sweep' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_sweep') ServoTestSweep(link, write_keys, write_format_tuple) elif 'test_servos_led' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_rgb') ServoTestRgb(link, write_keys, write_format_tuple) elif 'test_servos_dim' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_dim') ServoTestDim( link, write_keys, write_format_tuple, HexColorToRGBTuple(configuration['led_color']), gamma) gamma = GetGamma(configuration) 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 line isn't traced while it moves to new position message_dict = GenerateServoMessage(laser=LASER_OFF) message_tuple = DictToValueTuple( message_dict, write_keys, write_format_tuple) <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778 886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926 | <----SKIPPED LINES----> for intensity in range(0, 255, 50): SendLEDTestMessage(*comms_args, intensity, 0, 0) for intensity in range(0, 255, 50): SendLEDTestMessage(*comms_args, 0, intensity, 0) for intensity in range(0, 255, 50): SendLEDTestMessage(*comms_args, 0, 0, intensity) SendLEDTestMessage(*comms_args, 0, 0, 0) def ServoTestDim(link, write_keys, write_format_tuple, rgb, gamma): """Dim LEDs at selected color from 100% to 0% with gamma correction.""" comms_args = link, write_keys, write_format_tuple for intensity in range(0, 101, 5): b = intensity / 100 SendLEDTestMessage(*comms_args, *GammaRGB(rgb, gamma, brightness=b)) for intensity in range(100, -1, 5): b = intensity / 100 SendLEDTestMessage(*comms_args, *GammaRGB(rgb, gamma, brightness=b)) def ServoTestSweep(link, write_keys, write_format_tuple, altitude=45): """Sweep red laser around 360 degrees.""" for azimuth in range(0, 360, 10): message_dict = GenerateServoMessage( laser=LASER_RED, angles=(azimuth, altitude)) link.Write(DictToValueTuple(message_dict, write_keys, write_format_tuple)) time.sleep(WRITE_DELAY_TIME) last_angles = (0, 0) last_laser = LASER_OFF last_led = LED_OFF def GenerateServoMessage( angles=None, laser=None, led=None, <----SKIPPED LINES----> last_flight = {} flight, json_desc_dict, configuration, additional_attr = InitialMessageValues( to_arduino_q) next_read = 0 next_write = 0 now = GetNow(json_desc_dict, additional_attr) gamma = GetGamma(configuration) while not shutdown.value: SetLoggingGlobals(configuration) if not to_arduino_q.empty(): flight, json_desc_dict, configuration, additional_attr = to_arduino_q.get( block=False) if 'test_servos_ordinal' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_ordinal') ServoTestOrdinal(link, write_keys, write_format_tuple) elif 'test_servos_sweep' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_sweep') ServoTestSweep(link, write_keys, write_format_tuple) elif 'test_servos_rgb' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_rgb') ServoTestRgb(link, write_keys, write_format_tuple) elif 'test_servos_dim' in configuration: messageboard.RemoveSetting(configuration, 'test_servos_dim') ServoTestDim( link, write_keys, write_format_tuple, HexColorToRGBTuple(configuration['led_color']), gamma) gamma = GetGamma(configuration) 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 line isn't traced while it moves to new position message_dict = GenerateServoMessage(laser=LASER_OFF) message_tuple = DictToValueTuple( message_dict, write_keys, write_format_tuple) <----SKIPPED LINES----> |