001package com.pi4j.io.gpio.tasks.impl; 002 003/* 004 * #%L 005 * ********************************************************************** 006 * ORGANIZATION : Pi4J 007 * PROJECT : Pi4J :: Java Library (Core) 008 * FILENAME : GpioBlinkStopTaskImpl.java 009 * 010 * This file is part of the Pi4J project. More information about 011 * this project can be found here: http://www.pi4j.com/ 012 * ********************************************************************** 013 * %% 014 * Copyright (C) 2012 - 2013 Pi4J 015 * %% 016 * Licensed under the Apache License, Version 2.0 (the "License"); 017 * you may not use this file except in compliance with the License. 018 * You may obtain a copy of the License at 019 * 020 * http://www.apache.org/licenses/LICENSE-2.0 021 * 022 * Unless required by applicable law or agreed to in writing, software 023 * distributed under the License is distributed on an "AS IS" BASIS, 024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 025 * See the License for the specific language governing permissions and 026 * limitations under the License. 027 * #L% 028 */ 029 030 031import java.util.concurrent.ScheduledFuture; 032 033import com.pi4j.io.gpio.GpioPinDigitalOutput; 034import com.pi4j.io.gpio.PinState; 035 036public class GpioBlinkStopTaskImpl implements Runnable { 037 038 private final GpioPinDigitalOutput pin; 039 private final PinState stopState; 040 private final ScheduledFuture<?> blinkTask; 041 042 public GpioBlinkStopTaskImpl(GpioPinDigitalOutput pin, PinState stopState, ScheduledFuture<?> blinkTask) { 043 this.pin = pin; 044 this.stopState = stopState; 045 this.blinkTask = blinkTask; 046 } 047 048 public void run() { 049 // cancel the blinking task 050 blinkTask.cancel(true); 051 052 // set the pin to the stop blinking state 053 pin.setState(stopState); 054 } 055}