本文整理汇总了Java中com.pi4j.wiringpi.Gpio.delayMicroseconds方法的典型用法代码示例。如果您正苦于以下问题:Java Gpio.delayMicroseconds方法的具体用法?Java Gpio.delayMicroseconds怎么用?Java Gpio.delayMicroseconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.pi4j.wiringpi.Gpio
的用法示例。
在下文中一共展示了Gpio.delayMicroseconds方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public void send(int[] pulses,int size) {
if (log.isLoggable(Level.FINEST)) {
StringBuilder pulse_as_text = new StringBuilder();
for (int i=0;i<size;i++) {
if (i>0)
pulse_as_text.append(",");
if ((i%2)==1) {
pulse_as_text.append("(l:"+pulses[i]+")");
}
else {
pulse_as_text.append("(h:"+pulses[i]+")");
}
}
log.log(Level.FINEST,"Pulse: "+pulse_as_text.toString());
}
for(int i = 0; i < size; i++) {
if ((i%2)==1) {
Gpio.delayMicroseconds(pulses[i]); // off
}
else {
pulse(pulses[i]); // on
}
}
}
示例2: read
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public boolean[] read() {
final boolean[] data = new boolean[8];
Gpio.digitalWrite(CLK_INH, Gpio.HIGH);
Gpio.digitalWrite(SH_LD, Gpio.LOW);
Gpio.delayMicroseconds(1);
Gpio.digitalWrite(SH_LD, Gpio.HIGH);
Gpio.digitalWrite(CLK_INH, Gpio.LOW);
for (int i = 7; i >= 0; i--) {
Gpio.digitalWrite(CLK, Gpio.HIGH);
Gpio.digitalWrite(CLK, Gpio.LOW);
data[i] = Gpio.digitalRead(QH) == Gpio.HIGH ? true : false;
}
return data;
}
示例3: sendBeam
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
@Override
public void sendBeam(byte[] message) throws Exception {
if (encoder==null)
throw new Exception("Could not send beam. Did not setup encoder yet!");
int signal[] = encoder.getEncodedSignal(message);
send(signal);
for (int i=0;i<numRepeats;i++) {
Gpio.delayMicroseconds(delayBetweenRepeats); // off
send(signal);
}
}
示例4: transmitSignal
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
/**
* Sends an IRSignal through the IRTransmitter connected to the setted PWM pin.
* @param signal the IRSignal sent through the PWM pin.
* @see IRSignal
*/
public void transmitSignal(IRSignal signal) {
int[] pulses = signal.getPulses();
for(int i = 0; i < signal.getNbPulses(); i++) {
Gpio.delayMicroseconds(pulses[i * 2]); // off
pulse(pulses[i * 2 + 1]); // on
}
}
示例5: penUp
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public synchronized void penUp(){
if (properties.getPenUpPosition()!=lastPosition){
try{
int penUpValue=(int) ((SERVO_MAX_VALUE-SERVO_MIN_VALUE)/100.0*properties.getPenUpPosition()+SERVO_MIN_VALUE);
String servoPenUpCommand = buildServoCommand(properties.getPenPinNumber(), penUpValue);
FileUtils.writeStringToFile(servoPipeFile, servoPenUpCommand);
} catch (Exception e){
throw new RuntimeException(e.getMessage());
}
Gpio.delayMicroseconds(properties.getPenUpPeriodInMilliseconds()*1000);
lastPosition=properties.getPenUpPosition();
}
}
示例6: penDown
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public synchronized void penDown(){
if (properties.getPenDownPosition()!=lastPosition){
try{
int penDownValue=(int) ((SERVO_MAX_VALUE-SERVO_MIN_VALUE)/100.0*properties.getPenDownPosition()+SERVO_MIN_VALUE);
String servoPenDownCommand = buildServoCommand(properties.getPenPinNumber(), penDownValue);
FileUtils.writeStringToFile(servoPipeFile, servoPenDownCommand);
} catch (Exception e){
throw new RuntimeException(e.getMessage());
}
Gpio.delayMicroseconds(properties.getPenDownPeriodInMilliseconds()*1000);
lastPosition=properties.getPenDownPosition();
}
}
示例7: penUp
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public synchronized void penUp(){
if (isPenDown){
SoftPwm.softPwmWrite(properties.getPenPinNumber(), properties.getPenUpPowerLevel());
Gpio.delayMicroseconds(properties.getPenUpPeriodInMilliseconds()*1000);
SoftPwm.softPwmWrite(properties.getPenPinNumber(), properties.getPenUpHoldPowerLevel());
isPenDown=false;
}
}
示例8: penDown
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public synchronized void penDown(){
if (!isPenDown){
SoftPwm.softPwmWrite(properties.getPenPinNumber(), 0); // off
Gpio.delayMicroseconds(properties.getPenDownPeriodInMilliseconds()*1000);
isPenDown=true;
}
}
示例9: transmit
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
private void transmit(int nHighPulses, int nLowPulses) {
if (this.transmitterPin != null) {
this.transmitterPin.high();
Gpio.delayMicroseconds(this.pulseLength * nHighPulses);
this.transmitterPin.low();
Gpio.delayMicroseconds(this.pulseLength * nLowPulses);
}
}
示例10: pulse
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
private void pulse(long micros) {
pwm.setPwm(50); // 50%
Gpio.delayMicroseconds(micros);
pwm.setPwm(0);
}
示例11: detectSignal
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
/**
* Polls until an infrared signal is detected and then return this signal.
* <p><b>! Attention !</b> Polling means ~100% of CPU for 1 core.</p>
* @return the IRSignal corresponding to the newly detected infrared signal.
*/
public IRSignal detectSignal() {
// We will store up to 100 pulse pairs (this is -a lot-).
// Pair is high and low pulse (2 int per pulse).
int[] signal = new int[200];
// temporary storage timing
int highPulse, lowPulse;
boolean completeSignalDetected = false;
int currentPulse = 0;
// setted to true as soon as a new signal start to be detected
boolean newSignalDetected = false;
while(!completeSignalDetected) {
highPulse = 0;
lowPulse = 0;
// HIGH / OFF
while(Gpio.digitalRead(pinNumber) == 1 && !completeSignalDetected) {
// pin is still HIGH
// count off another few microseconds
highPulse++;
Gpio.delayMicroseconds(RESOLUTION);
// If the pulse is too long, we timed out:
// either nothing was received or the code is finished,
if((highPulse * RESOLUTION >= MAX_PULSE) && newSignalDetected) {
completeSignalDetected = true;
}
}
if(!completeSignalDetected) {
// we didn't time out so lets stash the reading
signal[currentPulse * 2] = highPulse * RESOLUTION;
}
// LOW / ON
// same as above for low pulse
while(Gpio.digitalRead(pinNumber) == 0 && !completeSignalDetected) {
// pin is still LOW
if(!newSignalDetected)
newSignalDetected = true;
// count off another few microseconds
lowPulse++;
Gpio.delayMicroseconds(RESOLUTION);
// If the pulse is too long, we timed out:
// either nothing was received or the code is finished,
// so print what we've grabbed so far and then reset
if(lowPulse * RESOLUTION >= MAX_PULSE) {
completeSignalDetected = true;
}
}
if(!completeSignalDetected) {
signal[currentPulse * 2 + 1] = lowPulse * RESOLUTION;
}
// we read one high-low pulse successfully, continue !
currentPulse++;
}
return new IRSignal(signal);
}
示例12: stepMotors
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public synchronized void stepMotors(Direction leftMotorDirection, Direction rightMotorDirection, long delayInMicroSeconds){
// take the Max of any of the delays: Minimum Left, Minimum Right, or delayInMicroSeconds
if ((leftMotorDirection==Direction.NONE) && (rightMotorDirection==Direction.NONE)) return;
long minDelayInMicroseconds = 0;
if (leftMotorDirection!=Direction.NONE){ // only need to get minimum if moving
minDelayInMicroseconds = properties.getLeftMotorMinStepPeriodInMicroseconds();
}
if (rightMotorDirection!=Direction.NONE){ // only need to get minimum if moving
minDelayInMicroseconds = Math.max(minDelayInMicroseconds, properties.getRightMotorMinStepPeriodInMicroseconds());
}
delayInMicroSeconds = Math.max(delayInMicroSeconds,minDelayInMicroseconds);
long delay = delayInMicroSeconds-((System.nanoTime()-lastMotorTimeNanos)/1000);
if (delay>0){
Gpio.delayMicroseconds(delay);
}
if (leftMotorDirection!=Direction.NONE){
if (properties.isLeftMotorInvertDirection() == (leftMotorDirection==Direction.FORWARD)){
Gpio.digitalWrite(properties.getLeftMotorDirectionPinNumber(), true);
} else {
Gpio.digitalWrite(properties.getLeftMotorDirectionPinNumber(), false);
}
Gpio.delayMicroseconds(2);
Gpio.digitalWrite(properties.getLeftMotorStepPinNumber(), true);
Gpio.delayMicroseconds(2);
Gpio.digitalWrite(properties.getLeftMotorStepPinNumber(), false);
}
if (rightMotorDirection!=Direction.NONE){
if (properties.isRightMotorInvertDirection() == (rightMotorDirection==Direction.FORWARD)){
Gpio.digitalWrite(properties.getRightMotorDirectionPinNumber(), true);
} else {
Gpio.digitalWrite(properties.getRightMotorDirectionPinNumber(), false);
}
Gpio.delayMicroseconds(2);
Gpio.digitalWrite(properties.getRightMotorStepPinNumber(), true);
Gpio.delayMicroseconds(2);
Gpio.digitalWrite(properties.getRightMotorStepPinNumber(), false);
}
lastMotorTimeNanos=System.nanoTime();
}
示例13: pulse
import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
/**
* Sends an IR pulse for a duration of micros microseconds.
* <p>Note: this method isn't placed in the parent PWMComponent, because it's deprecated to use a Gpio.delayMicroseconds.
* Indeed, since the system is not in realtime executions, we can't get any guarantee regarding the microseconds delays.</p>
* @param micros
*/
private void pulse(long micros) {
Gpio.pwmWrite(pinNumber, 50); // 50%
Gpio.delayMicroseconds(micros);
Gpio.pwmWrite(pinNumber, 0);
}