I/O: Add @webref annotation

This commit is contained in:
gohai
2015-10-15 13:07:59 +02:00
parent cd03e69f1a
commit 575edf00d1
6 changed files with 58 additions and 0 deletions

View File

@@ -31,6 +31,9 @@ import java.util.HashMap;
import java.util.Map;
/**
* @webref
*/
public class GPIO {
// those constants are generally the same as in Arduino.h
@@ -99,6 +102,7 @@ public class GPIO {
* @see noInterrupts
* @see interrupts
* @see releaseInterrupt
* @webref
*/
public static void attachInterrupt(int pin, PApplet parent, String method, int mode) {
if (irqThreads.containsKey(pin)) {
@@ -159,6 +163,7 @@ public class GPIO {
* Board-specific classes, such as RPI, assign -1 to pins that carry power,
* ground and the like.
* @param pin GPIO pin
* @webref
*/
protected static void checkValidPin(int pin) {
if (pin < 0) {
@@ -176,6 +181,7 @@ public class GPIO {
* @return GPIO.HIGH (1) or GPIO.LOW (0)
* @see pinMode
* @see digitalWrite
* @webref
*/
public static int digitalRead(int pin) {
checkValidPin(pin);
@@ -211,6 +217,7 @@ public class GPIO {
* @param value GPIO.HIGH or GPIO.LOW
* @see pinMode
* @see digitalRead
* @webref
*/
public static void digitalWrite(int pin, int value) {
checkValidPin(pin);
@@ -250,6 +257,7 @@ public class GPIO {
* @param value true or false
* @see pinMode
* @see digitalRead
* @webref
*/
public static void digitalWrite(int pin, boolean value) {
if (value) {
@@ -269,6 +277,7 @@ public class GPIO {
* @param pin GPIO pin
* @see enableInterrupt
* @see waitForInterrupt
* @webref
*/
public static void disableInterrupt(int pin) {
enableInterrupt(pin, NONE);
@@ -284,6 +293,7 @@ public class GPIO {
* @param mode what to wait for: GPIO.CHANGE, GPIO.FALLING or GPIO.RISING
* @see waitForInterrupt
* @see disableInterrupt
* @webref
*/
public static void enableInterrupt(int pin, int mode) {
checkValidPin(pin);
@@ -322,6 +332,7 @@ public class GPIO {
* @see attachInterrupt
* @see noInterrupts
* @see releaseInterrupt
* @webref
*/
public static void interrupts() {
serveInterrupts = true;
@@ -338,6 +349,7 @@ public class GPIO {
* @see attachInterrupt
* @see interrupts
* @see releaseInterrupt
* @webref
*/
public static void noInterrupts() {
serveInterrupts = false;
@@ -355,6 +367,7 @@ public class GPIO {
* @see digitalRead
* @see digitalWrite
* @see releasePin
* @webref
*/
public static void pinMode(int pin, int mode) {
checkValidPin(pin);
@@ -416,6 +429,7 @@ public class GPIO {
* @see attachInterrupt
* @see noInterrupts
* @see interrupts
* @webref
*/
public static void releaseInterrupt(int pin) {
Thread t = irqThreads.get(pin);
@@ -443,6 +457,7 @@ public class GPIO {
* state even after the sketch has been closed.
* @param pin GPIO pin
* @see pinMode
* @webref
*/
public static void releasePin(int pin) {
checkValidPin(pin);
@@ -471,6 +486,7 @@ public class GPIO {
* @return true if the interrupt occured, false if the timeout occured
* @see enableInterrupt
* @see disableInterrupt
* @webref
*/
public static boolean waitForInterrupt(int pin, int timeout) {
checkValidPin(pin);
@@ -501,6 +517,7 @@ public class GPIO {
* @parm pin GPIO pin
* @see enableInterrupt
* @see disableInterrupt
* @webref
*/
public static void waitForInterrupt(int pin) {
waitForInterrupt(pin, -1);

View File

@@ -29,6 +29,9 @@ import java.util.ArrayList;
import java.util.Arrays;
/**
* @webref
*/
public class I2C {
protected String dev;
@@ -43,6 +46,7 @@ public class I2C {
*
* @param dev device name
* @see list
* @webref
*/
public I2C(String dev) {
NativeInterface.loadLibrary();
@@ -72,6 +76,7 @@ public class I2C {
* @see write
* @see read
* @see endTransmission
* @webref
*/
public void beginTransmission(int slave) {
// addresses 120 (0x78) to 127 are additionally reserved
@@ -87,6 +92,7 @@ public class I2C {
/**
* Closes the I2C device
* @webref
*/
public void close() {
NativeInterface.closeDevice(handle);
@@ -109,6 +115,7 @@ public class I2C {
* This executes any queued writes.
* @see beginTransmission
* @see write
* @webref
*/
public void endTransmission() {
if (!transmitting) {
@@ -132,6 +139,7 @@ public class I2C {
/**
* Lists all available I2C devices
* @return String array
* @webref
*/
public static String[] list() {
ArrayList<String> devs = new ArrayList<String>();
@@ -162,6 +170,7 @@ public class I2C {
* @see beginTransmission
* @see write
* @see endTransmission
* @webref
*/
public byte[] read(int len) {
if (!transmitting) {
@@ -194,6 +203,7 @@ public class I2C {
* @see beginTransmission
* @see read
* @see endTransmission
* @webref
*/
public void write(byte[] out) {
if (!transmitting) {
@@ -221,6 +231,7 @@ public class I2C {
* @see beginTransmission
* @see read
* @see endTransmission
* @webref
*/
public void write(String out) {
write(out.getBytes());
@@ -237,6 +248,7 @@ public class I2C {
* @see beginTransmission
* @see read
* @see endTransmission
* @webref
*/
public void write(int out) {
if (out < 0 || 255 < out) {

View File

@@ -32,6 +32,9 @@ import java.util.ArrayList;
import java.util.Arrays;
/**
* @webref
*/
public class LED {
protected String dev;
@@ -44,6 +47,7 @@ public class LED {
* Opens a LED device
* @param dev device name
* @see list
* @webref
*/
public LED(String dev) {
NativeInterface.loadLibrary();
@@ -98,6 +102,7 @@ public class LED {
/**
* Sets the brightness
* @param bright 0.0 (off) to 1.0 (maximum)
* @webref
*/
public void brightness(float bright) {
String fn = "/sys/class/leds/" + dev + "/brightness";
@@ -117,6 +122,7 @@ public class LED {
*
* Without calling this function the LED will remain in the current
* state even after the sketch has been closed.
* @webref
*/
public void close() {
// restore previous settings
@@ -137,6 +143,7 @@ public class LED {
/**
* Lists all available LED devices
* @return String array
* @webref
*/
public static String[] list() {
ArrayList<String> devs = new ArrayList<String>();

View File

@@ -32,6 +32,9 @@ import java.util.ArrayList;
import java.util.Arrays;
/**
* @webref
*/
public class PWM {
int channel;
@@ -42,6 +45,7 @@ public class PWM {
* Opens a PWM channel
* @param channel PWM channel
* @see list
* @webref
*/
public PWM(String channel) {
NativeInterface.loadLibrary();
@@ -82,6 +86,7 @@ public class PWM {
/**
* Disables the PWM output
* @webref
*/
public void clear() {
String fn = String.format("/sys/class/pwm/%s/gpio%d/enable", chip, channel);
@@ -97,6 +102,7 @@ public class PWM {
*
* Without calling this function the channel will remain in the current
* state even after the sketch has been closed.
* @webref
*/
public void close() {
// XXX: implicit clear()?
@@ -118,6 +124,7 @@ public class PWM {
/**
* Lists all available PWM channels
* @return String array
* @webref
*/
public static String[] list() {
ArrayList<String> devs = new ArrayList<String>();
@@ -148,6 +155,7 @@ public class PWM {
* Enables the PWM output
* @param period cycle period in Hz
* @param duty duty cycle, 0.0 (always off) to 1.0 (always on)
* @webref
*/
public void set(int period, float duty) {
// set period
@@ -184,6 +192,7 @@ public class PWM {
* the Arduino Uno, which have a frequency of 980 Hz.
* It is recommended to use set(period, duty) instead.
* @param duty duty cycle, 0.0 (always off) to 1.0 (always on)
* @webref
*/
public void set(float duty) {
set(1000, duty);

View File

@@ -23,6 +23,9 @@
package processing.io;
/**
* @webref
*/
public class RPI {
/*

View File

@@ -31,6 +31,9 @@ import java.util.HashMap;
import java.util.Map;
/**
* @webref
*/
public class SPI {
/**
@@ -70,6 +73,7 @@ public class SPI {
* Opens an SPI interface
* @param dev device name
* @see list
* @webref
*/
public SPI(String dev) {
NativeInterface.loadLibrary();
@@ -83,6 +87,7 @@ public class SPI {
/**
* Closes the SPI interface
* @webref
*/
public void close() {
NativeInterface.closeDevice(handle);
@@ -102,6 +107,7 @@ public class SPI {
/**
* Lists all available SPI interfaces
* @return String array
* @webref
*/
public static String[] list() {
ArrayList<String> devs = new ArrayList<String>();
@@ -126,6 +132,7 @@ public class SPI {
* @param maxSpeed maximum transmission rate in Hz, 500000 (500 kHz) is a resonable default
* @param dataOrder whether data is send with the first- or least significant bit first (SPI.MSBFIRST or SPI.LSBFIRST, the former is more common)
* @param mode SPI.MODE0 to SPI.MODE3 (see https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase)
* @webref
*/
public void settings(int maxSpeed, int dataOrder, int mode) {
this.maxSpeed = maxSpeed;
@@ -142,6 +149,7 @@ public class SPI {
* one byte being read in.
* @param out bytes to send
* @return bytes read in (array is the same length as out)
* @webref
*/
public byte[] transfer(byte[] out) {
// track the current setting per device across multiple instances
@@ -174,6 +182,7 @@ public class SPI {
* one byte being read in.
* @param out string to send
* @return bytes read in (array is the same length as out)
* @webref
*/
public byte[] transfer(String out) {
return transfer(out.getBytes());
@@ -188,6 +197,7 @@ public class SPI {
* one byte being read in.
* @param out single byte to send
* @return bytes read in (array is the same length as out)
* @webref
*/
public byte[] transfer(int out) {
if (out < 0 || 255 < out) {