def main(): init_logging('power_controlled_lights.log') logging.info('Reading settings configuration file') cfg = ConfigParser() cfg.read('settings.cfg') device_cfg = ConfigParser() device_cfg.read('device_settings.cfg') logging.info('Initializing LED strip driver') color_strip = ColorStrip(device_cfg, LED_FREQ_HZ) signal.signal(signal.SIGTERM, lambda: color_strip.set_color(RgbColor(0, 0, 0))) logging.info('Creating ANT+ node') node = AntPlusNode(NETWORK_KEY) try: logging.info('Attaching ANT+ power meter') pwr_meter = node.attach_power_meter() logging.info('Initializing power light controller') plc = PowerLightController(node.stop, None, cfg, pwr_meter, color_strip) logging.info('Starting ANT+ node') node.start() except Exception as e: logging.error('Caught exception "%s"' % str(e)) raise finally: logging.info('Turning off LED strip') color_strip.set_color(RgbColor(0, 0, 0)) logging.info('Stopping ANT+ node') node.stop()
def main(): init_logging('hr_controlled_fan.log') logging.info('Reading settings configuration file') cfg = ConfigParser() cfg.read('settings.cfg') device_cfg = ConfigParser() device_cfg.read('device_settings.cfg') logging.info('Initializing fan driver') fan = FourSpeedRealayFan(device_cfg) logging.info('Creating ANT+ node') node = AntPlusNode(NETWORK_KEY) try: logging.info('Attaching ANT+ heart rate monitor') hrm = node.attach_hrm() logging.info('Initializing heart rate fan controller') hfc = HRFanController(node.stop, None, cfg, hrm, fan) logging.info('Starting ANT+ node') node.start() except Exception as e: logging.error('Caught exception "%s"' % str(e)) raise finally: logging.info('Turning off fan') fan.select_speed(0) logging.info('Stopping ANT+ node') node.stop()
def main(): node = AntPlusNode(NETWORK_KEY) try: cadence_sensor = node.attach_cadence_sensor() cadence_sensor.on_cadence_data = print_cadence node.start() finally: node.stop()
def main(): init_logging('control_fan_and_lights.log') logging.info('Reading settings configuration file') cfg = ConfigParser() cfg.read('settings.cfg') device_cfg = ConfigParser() device_cfg.read('device_settings.cfg') logging.info('Initializing fan driver') fan = FourSpeedRealayFan(device_cfg) logging.info('Initializing LED strip driver') color_strip = ColorStrip(device_cfg, LED_FREQ_HZ) signal.signal(signal.SIGTERM, lambda: color_strip.set_color(RgbColor(0, 0, 0))) logging.info('Creating ANT+ node') node = AntPlusNode(NETWORK_KEY) try: node_stopper = TwoClientNodeStopper(node) logging.info('Attaching ANT+ heart rate monitor') hrm = node.attach_hrm() logging.info('Initializing heart rate fan controller') hfc = HRFanController(node_stopper.stop_client1, node_stopper.cancel_stop_client1, cfg, hrm, fan) logging.info('Attaching ANT+ power meter') pwr_meter = node.attach_power_meter() meter_id = node.check_id_of_power_meter() logging.info('Initializing power light controller') plc = PowerLightController(node_stopper.stop_client2, node_stopper.cancel_stop_client2, cfg, pwr_meter, color_strip) logging.info('Starting ANT+ node') node.start() except Exception as e: logging.error('Caught exception "%s"' % str(e)) raise finally: logging.info('Turning off fan') fan.select_speed(0) logging.info('Turning off LED strip') color_strip.set_color(RgbColor(0, 0, 0)) logging.info('Stopping ANT+ node') node.stop()
def main(): node = AntPlusNode(NETWORK_KEY) try: power_meter = node.attach_power_meter() power_meter.on_power_data = print_power power_meter.on_cadence_data = print_cadence node.start() finally: node.stop()
def main(): node = AntPlusNode(NETWORK_KEY) try: # https://support.wahoofitness.com/hc/en-us/articles/115000738484-Tire-Size-Chart # 700x18c = 2.07 # 700x19c = 2.08 # 700x20c = 2.086 # 700x23c = 2.096 # 700x25c = 2.105 # 700x28c = 2.136 speed_sensor = node.attach_speed_sensor( wheel_circumference_meters=2.105) speed_sensor.on_speed_data = print_speed node.start() finally: node.stop()
def main(): parser = argparse.ArgumentParser( description= 'Monitor and print speed and cadence from ANT+ speed and cadence sensors' ) parser.add_argument( '-c', '--combined', action='store_true', default=False, help= 'Connect to separate speed and cadence sensors (some speed and cadence devices may work as individual speed and cadence senors)' ) args = parser.parse_args() node = AntPlusNode(NETWORK_KEY) try: # https://support.wahoofitness.com/hc/en-us/articles/115000738484-Tire-Size-Chart # 700x18c = 2.07 # 700x19c = 2.08 # 700x20c = 2.086 # 700x23c = 2.096 # 700x25c = 2.105 # 700x28c = 2.136 wheel_circumference_meters = 2.105 if args.combined: speed_and_cadence_sensor = node.attach_combined_speed_and_cadence_sensor( wheel_circumference_meters=wheel_circumference_meters) else: speed_and_cadence_sensor = node.attach_speed_and_cadence_sensor( wheel_circumference_meters=wheel_circumference_meters) speed_and_cadence_sensor.on_speed_data = print_speed speed_and_cadence_sensor.on_cadence_data = print_cadence node.start() finally: node.stop()