├── bulldog.core
├── build.gradle
├── .gitignore
├── src
│ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── bulldog
│ │ │ └── core
│ │ │ ├── Edge.java
│ │ │ ├── Polarity.java
│ │ │ ├── io
│ │ │ ├── uart
│ │ │ │ ├── UartSignalType.java
│ │ │ │ ├── UartRx.java
│ │ │ │ ├── UartTx.java
│ │ │ │ ├── UartPinFeature.java
│ │ │ │ ├── UartPort.java
│ │ │ │ └── AbstractUartPinFeature.java
│ │ │ ├── bus
│ │ │ │ ├── i2c
│ │ │ │ │ ├── I2cSignalType.java
│ │ │ │ │ ├── I2cScl.java
│ │ │ │ │ ├── I2cSda.java
│ │ │ │ │ ├── I2cPinFeature.java
│ │ │ │ │ ├── AbstractI2cPinFeature.java
│ │ │ │ │ ├── I2cBus.java
│ │ │ │ │ ├── I2cConnection.java
│ │ │ │ │ └── I2cDevice.java
│ │ │ │ ├── spi
│ │ │ │ │ ├── SpiSignalType.java
│ │ │ │ │ ├── SpiMode.java
│ │ │ │ │ ├── SpiMessage.java
│ │ │ │ │ ├── SpiDevice.java
│ │ │ │ │ └── SpiBus.java
│ │ │ │ └── Bus.java
│ │ │ ├── serial
│ │ │ │ ├── SerialDataListener.java
│ │ │ │ ├── SerialDataEventArgs.java
│ │ │ │ └── SerialPort.java
│ │ │ ├── PinIOOutputStream.java
│ │ │ ├── PinIOInputStream.java
│ │ │ └── IOPort.java
│ │ │ ├── Parity.java
│ │ │ ├── gpio
│ │ │ ├── event
│ │ │ │ ├── ValueChangedListener.java
│ │ │ │ ├── InterruptListener.java
│ │ │ │ ├── InterruptEventArgs.java
│ │ │ │ ├── FeatureActivationEventArgs.java
│ │ │ │ ├── FeatureActivationListener.java
│ │ │ │ └── ThresholdListener.java
│ │ │ ├── Pwm.java
│ │ │ ├── PinFeature.java
│ │ │ ├── base
│ │ │ │ ├── AbstractPinFeature.java
│ │ │ │ └── AbstractAnalogInput.java
│ │ │ └── PinBlockedException.java
│ │ │ ├── platform
│ │ │ ├── BoardFactory.java
│ │ │ ├── IncompatiblePlatformException.java
│ │ │ ├── PinProvider.java
│ │ │ ├── Platform.java
│ │ │ ├── Board.java
│ │ │ └── AbstractPinProvider.java
│ │ │ ├── util
│ │ │ ├── easing
│ │ │ │ ├── Easing.java
│ │ │ │ ├── LinearEasing.java
│ │ │ │ ├── EasingOptions.java
│ │ │ │ ├── QuintEasing.java
│ │ │ │ ├── SineEasing.java
│ │ │ │ ├── CircularEasing.java
│ │ │ │ ├── ExponentialEasing.java
│ │ │ │ └── BounceEasing.java
│ │ │ └── DaemonThreadFactory.java
│ │ │ └── Signal.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── core
│ │ ├── mocks
│ │ ├── MockedPinFeature3.java
│ │ ├── MockedPinFeature1.java
│ │ ├── MockedPinFeature2.java
│ │ ├── MockedBoard.java
│ │ ├── MockedDigitalOutput.java
│ │ ├── MockedPwm.java
│ │ ├── MockedAnalogInput.java
│ │ ├── MockedI2cBus.java
│ │ ├── MockedSerialPort.java
│ │ └── MockedDigitalInput.java
│ │ ├── gpio
│ │ ├── base
│ │ │ ├── TestAbstractDigitalOutput.java
│ │ │ └── TestAbstractDigitalInput.java
│ │ └── util
│ │ │ └── TestSoftPwm.java
│ │ └── testsuite
│ │ └── CompleteTestSuite.java
├── .checkstyle
├── .classpath
└── .project
├── bulldog.build
├── .gitignore
├── build.bat
├── buildAndTest.bat
├── cloc.bat
├── .classpath
├── settings.gradle
├── .project
├── src
│ └── main
│ │ └── resources
│ │ └── readme.txt
└── gradle.properties
├── bulldog.devices
├── .gitignore
├── build.gradle
├── src
│ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── bulldog
│ │ │ └── devices
│ │ │ ├── motor
│ │ │ ├── BipolarStepper.java
│ │ │ ├── AbstractStepper.java
│ │ │ └── UnipolarStepper.java
│ │ │ ├── lcd
│ │ │ ├── LcdFont.java
│ │ │ ├── HD44780Mode.java
│ │ │ ├── Lcd.java
│ │ │ └── LcdMode.java
│ │ │ ├── switches
│ │ │ ├── ButtonListener.java
│ │ │ └── RotaryEncoderListener.java
│ │ │ ├── actuators
│ │ │ ├── movement
│ │ │ │ ├── Move.java
│ │ │ │ ├── DirectMove.java
│ │ │ │ ├── Sweep.java
│ │ │ │ └── LinearMove.java
│ │ │ └── Actuator.java
│ │ │ ├── servo
│ │ │ ├── ServoListener.java
│ │ │ ├── TowerProMicroSG90.java
│ │ │ └── AdafruitServoDriver.java
│ │ │ ├── pwmdriver
│ │ │ ├── FrequencyLookupTable.java
│ │ │ └── PCA9685Pwm.java
│ │ │ └── portexpander
│ │ │ └── PCF8574DigitalOutput.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── devices
│ │ └── AppTest.java
├── .classpath
└── .project
├── bulldog.examples
├── .gitignore
├── build.gradle
├── .project
├── .classpath
└── src
│ ├── test
│ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── examples
│ │ └── AppTest.java
│ └── main
│ └── java
│ └── org
│ └── bulldog
│ └── examples
│ ├── LedExample.java
│ ├── I2cExample.java
│ ├── PinIOGroupExample.java
│ ├── ButtonExample.java
│ └── DigitalOutputExample.java
├── bulldog.linux.native
├── .gitignore
├── .classpath
├── src
│ └── main
│ │ └── c
│ │ ├── linux
│ │ ├── bulldog
│ │ │ ├── bulldog.h
│ │ │ ├── bulldog.c
│ │ │ ├── bulldogI2c.h
│ │ │ ├── bulldogSpi.h
│ │ │ ├── bulldogSerial.h
│ │ │ └── bulldogI2c.c
│ │ └── jni
│ │ │ ├── org_bulldog_linux_jni_NativeTools.h
│ │ │ └── org_bulldog_linux_jni_NativeSpi.h
│ │ └── beagleboneblack
│ │ ├── BBBIOlib
│ │ ├── BBBiolib_PWMSS.h
│ │ └── BBBiolib_ADCTSC.h
│ │ └── jni
│ │ ├── org_bulldog_beagleboneblack_jni_NativePwm.h
│ │ └── org_bulldog_beagleboneblack_jni_NativePwm.c
└── .project
├── bulldog.board.beagleboneblack
├── .gitignore
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ └── org.bulldog.core.platform.BoardFactory
│ │ └── java
│ │ │ └── org
│ │ │ └── bulldog
│ │ │ └── beagleboneblack
│ │ │ ├── BBBProperties.java
│ │ │ ├── io
│ │ │ ├── BBBSpiBus.java
│ │ │ ├── BBBI2cPinFeature.java
│ │ │ ├── BBBUartPinFeature.java
│ │ │ └── BBBI2cBus.java
│ │ │ ├── BeagleBoneBlackBoardFactory.java
│ │ │ ├── gpio
│ │ │ ├── BBBEmmc.java
│ │ │ ├── BBBHdmi.java
│ │ │ ├── BBBDigitalInput.java
│ │ │ ├── BBBDigitalOutput.java
│ │ │ └── BBBPwmManager.java
│ │ │ ├── BeagleBonePin.java
│ │ │ ├── jni
│ │ │ ├── NativePwm.java
│ │ │ └── NativeGpio.java
│ │ │ ├── sysfs
│ │ │ └── SysFsPwm.java
│ │ │ └── devicetree
│ │ │ ├── DeviceTreeCompiler.java
│ │ │ └── resources
│ │ │ └── pwm.dts.template
│ └── test
│ │ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── beagleboneblack
│ │ └── AppTest.java
├── .project
├── .classpath
└── build.gradle
├── bulldog.linux
├── build.gradle
├── src
│ └── main
│ │ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── linux
│ │ ├── io
│ │ ├── LinuxEpollListener.java
│ │ └── mmap
│ │ │ ├── ByteRegister.java
│ │ │ ├── LongRegister.java
│ │ │ ├── ShortRegister.java
│ │ │ ├── IntRegister.java
│ │ │ └── Register.java
│ │ ├── jni
│ │ ├── NativeI2c.java
│ │ ├── NativeTools.java
│ │ ├── NativeSpi.java
│ │ ├── NativePollResult.java
│ │ ├── NativeMmap.java
│ │ ├── NativeSerial.java
│ │ └── NativeEpoll.java
│ │ ├── sysinfo
│ │ └── CpuInfo.java
│ │ ├── util
│ │ ├── LinuxLibraryLoader.java
│ │ └── Commands.java
│ │ └── gpio
│ │ └── LinuxDigitalOutput.java
├── .classpath
└── .project
├── bulldog.board.cubieboard
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── services
│ │ │ └── org.bulldog.core.platform.BoardFactory
│ │ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── cubieboard
│ │ ├── CubieboardBoardFactory.java
│ │ ├── gpio
│ │ ├── CubieboardDigitalOutput.java
│ │ ├── CubieboardSysFsPin.java
│ │ └── CubieboardDigitalInput.java
│ │ ├── CubieboardPin.java
│ │ └── CubieboardNames.java
├── .project
├── build.gradle
└── .classpath
├── bulldog.board.raspberrypi
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── services
│ │ │ └── org.bulldog.core.platform.BoardFactory
│ │ └── java
│ │ └── org
│ │ └── bulldog
│ │ └── raspberrypi
│ │ ├── io
│ │ ├── RaspberryPiSpiBus.java
│ │ ├── RaspberryPiI2cPinFeature.java
│ │ └── RaspberryPiI2cBus.java
│ │ ├── RaspberryPiPin.java
│ │ ├── RaspberryPiBoardFactory.java
│ │ ├── gpio
│ │ ├── RaspiDigitalInput.java
│ │ ├── PwmFrequencyCalculator.java
│ │ └── RaspiDigitalOutput.java
│ │ └── RaspiNames.java
├── .project
├── build.gradle
└── .classpath
├── dist
└── Version-0.1.0
│ ├── bulldog.cubieboard
│ ├── libbulldog-linux.so
│ ├── bulldog.cubieboard.jar
│ └── bulldog.cubieboard-0.1.0.zip
│ ├── bulldog.raspberrypi
│ ├── libbulldog-linux.so
│ ├── bulldog.raspberrypi.jar
│ ├── bulldog.raspberrypi-0.1.0.zip
│ └── bulldog.raspberrypiWithSources-0.1.0.zip
│ ├── bulldog.beagleboneblack.hardfp
│ ├── libbulldog-linux.so
│ ├── bulldog.beagleboneblack.hardfp.jar
│ ├── bulldog.beagleboneblack.hardfp-0.1.0.zip
│ └── bulldog.beagleboneblack.hardfpWithSources-0.1.0.zip
│ ├── bulldog.beagleboneblack.softfp
│ ├── libbulldog-linux.so
│ ├── bulldog.beagleboneblack.softfp.jar
│ ├── bulldog.beagleboneblack.softfp-0.1.0.zip
│ └── bulldog.beagleboneblack.softfpWithSources-0.1.0.zip
│ └── javadoc
│ ├── org
│ └── bulldog
│ │ ├── devices
│ │ ├── led
│ │ │ └── package-frame.html
│ │ ├── dac
│ │ │ └── package-frame.html
│ │ ├── actuators
│ │ │ ├── package-frame.html
│ │ │ └── movement
│ │ │ │ └── package-frame.html
│ │ ├── sensors
│ │ │ └── package-frame.html
│ │ ├── motor
│ │ │ └── package-frame.html
│ │ ├── pwmdriver
│ │ │ └── package-frame.html
│ │ ├── portexpander
│ │ │ └── package-frame.html
│ │ ├── servo
│ │ │ └── package-frame.html
│ │ ├── switches
│ │ │ └── package-frame.html
│ │ └── lcd
│ │ │ └── package-frame.html
│ │ ├── linux
│ │ ├── sysinfo
│ │ │ └── package-frame.html
│ │ ├── sysfs
│ │ │ └── package-frame.html
│ │ ├── util
│ │ │ └── package-frame.html
│ │ ├── gpio
│ │ │ └── package-frame.html
│ │ ├── io
│ │ │ ├── mmap
│ │ │ │ └── package-frame.html
│ │ │ └── package-frame.html
│ │ └── jni
│ │ │ └── package-frame.html
│ │ ├── beagleboneblack
│ │ ├── devicetree
│ │ │ └── package-frame.html
│ │ ├── sysfs
│ │ │ └── package-frame.html
│ │ ├── jni
│ │ │ └── package-frame.html
│ │ ├── package-frame.html
│ │ ├── io
│ │ │ └── package-frame.html
│ │ └── gpio
│ │ │ └── package-frame.html
│ │ ├── core
│ │ ├── util
│ │ │ └── package-frame.html
│ │ ├── package-frame.html
│ │ ├── gpio
│ │ │ ├── util
│ │ │ │ └── package-frame.html
│ │ │ └── base
│ │ │ │ └── package-frame.html
│ │ └── io
│ │ │ ├── bus
│ │ │ ├── package-frame.html
│ │ │ └── spi
│ │ │ │ └── package-frame.html
│ │ │ ├── serial
│ │ │ └── package-frame.html
│ │ │ ├── package-frame.html
│ │ │ └── uart
│ │ │ └── package-frame.html
│ │ └── raspberrypi
│ │ ├── io
│ │ └── package-frame.html
│ │ ├── gpio
│ │ └── package-frame.html
│ │ └── package-frame.html
│ └── package-list
└── .gitignore
/bulldog.core/build.gradle:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/bulldog.core/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/bulldog.build/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/bulldog.devices/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/bulldog.examples/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/bulldog.linux.native/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/bulldog.linux/build.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | compile project(":bulldog.core")
3 | }
--------------------------------------------------------------------------------
/bulldog.build/build.bat:
--------------------------------------------------------------------------------
1 | gradle -x test --daemon clean build distribution archiveDistributions
--------------------------------------------------------------------------------
/bulldog.build/buildAndTest.bat:
--------------------------------------------------------------------------------
1 | gradle --daemon clean build distribution archiveDistributions
--------------------------------------------------------------------------------
/bulldog.build/cloc.bat:
--------------------------------------------------------------------------------
1 | %~dp0../bulldog.tools/tools/cloc-1.60.exe ../ --exclude-dir ../bulldog.tools
--------------------------------------------------------------------------------
/bulldog.devices/build.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | compile project(':bulldog.core')
3 | }
4 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/resources/META-INF/services/org.bulldog.core.platform.BoardFactory:
--------------------------------------------------------------------------------
1 | org.bulldog.cubieboard.CubieboardBoardFactory
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/resources/META-INF/services/org.bulldog.core.platform.BoardFactory:
--------------------------------------------------------------------------------
1 | org.bulldog.raspberrypi.RaspberryPiBoardFactory
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/Edge.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core;
2 |
3 | public enum Edge {
4 | Rising,
5 | Falling,
6 | Both
7 | }
8 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/Polarity.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core;
2 |
3 | public enum Polarity {
4 | Positive,
5 | Negative
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/resources/META-INF/services/org.bulldog.core.platform.BoardFactory:
--------------------------------------------------------------------------------
1 | org.bulldog.beagleboneblack.BeagleBoneBlackBoardFactory
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/motor/BipolarStepper.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.motor;
2 |
3 | public class BipolarStepper {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.cubieboard/libbulldog-linux.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.cubieboard/libbulldog-linux.so
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/uart/UartSignalType.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.uart;
2 |
3 | public enum UartSignalType {
4 | RX,
5 | TX
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/lcd/LcdFont.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.lcd;
2 |
3 | public enum LcdFont {
4 | Font_5x8,
5 | Font_8x10
6 | }
7 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.cubieboard/bulldog.cubieboard.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.cubieboard/bulldog.cubieboard.jar
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.raspberrypi/libbulldog-linux.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.raspberrypi/libbulldog-linux.so
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cSignalType.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 | public enum I2cSignalType {
4 | SDA,
5 | SCL
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/uart/UartRx.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.uart;
2 |
3 |
4 | public interface UartRx extends UartPinFeature {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/uart/UartTx.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.uart;
2 |
3 |
4 | public interface UartTx extends UartPinFeature {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/lcd/HD44780Mode.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.lcd;
2 |
3 | public enum HD44780Mode {
4 | FourBit,
5 | EightBit
6 | }
7 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.raspberrypi/bulldog.raspberrypi.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.raspberrypi/bulldog.raspberrypi.jar
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cScl.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 |
4 | public interface I2cScl extends I2cPinFeature {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cSda.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 |
4 | public interface I2cSda extends I2cPinFeature {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/Parity.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core;
2 |
3 | public enum Parity {
4 | None,
5 | Odd,
6 | Even,
7 | Mark,
8 | Space
9 | }
10 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.cubieboard/bulldog.cubieboard-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.cubieboard/bulldog.cubieboard-0.1.0.zip
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bulldog.tools/
2 | /.metadata/
3 | target/
4 | .settings/
5 | .gradle/
6 | Debug/
7 | Release/
8 | build/
9 | bin/
10 | bulldog.repository/
11 | dist/**/sources/**
12 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/libbulldog-linux.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/libbulldog-linux.so
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/libbulldog-linux.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/libbulldog-linux.so
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.raspberrypi/bulldog.raspberrypi-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.raspberrypi/bulldog.raspberrypi-0.1.0.zip
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/spi/SpiSignalType.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.spi;
2 |
3 | public enum SpiSignalType {
4 | MOSI,
5 | MISO,
6 | SCLK,
7 | SS
8 | }
9 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.raspberrypi/bulldog.raspberrypiWithSources-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.raspberrypi/bulldog.raspberrypiWithSources-0.1.0.zip
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/bulldog.beagleboneblack.hardfp.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/bulldog.beagleboneblack.hardfp.jar
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/bulldog.beagleboneblack.softfp.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/bulldog.beagleboneblack.softfp.jar
--------------------------------------------------------------------------------
/bulldog.build/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/event/ValueChangedListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.event;
2 |
3 | public interface ValueChangedListener {
4 |
5 | void valueChanged(T oldValue, T newValue);
6 | }
7 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/bulldog.beagleboneblack.hardfp-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/bulldog.beagleboneblack.hardfp-0.1.0.zip
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/bulldog.beagleboneblack.softfp-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/bulldog.beagleboneblack.softfp-0.1.0.zip
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/event/InterruptListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.event;
2 |
3 | public interface InterruptListener {
4 |
5 | void interruptRequest(InterruptEventArgs args);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/switches/ButtonListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.switches;
2 |
3 | public interface ButtonListener {
4 |
5 | void buttonPressed();
6 | void buttonReleased();
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/bulldog.linux.native/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/serial/SerialDataListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.serial;
2 |
3 | public interface SerialDataListener {
4 |
5 | void onSerialDataAvailable(SerialDataEventArgs args);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/platform/BoardFactory.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.platform;
2 |
3 |
4 | public interface BoardFactory {
5 |
6 | boolean isCompatibleWithPlatform();
7 | Board createBoard();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/bulldog.beagleboneblack.hardfpWithSources-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.hardfp/bulldog.beagleboneblack.hardfpWithSources-0.1.0.zip
--------------------------------------------------------------------------------
/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/bulldog.beagleboneblack.softfpWithSources-0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Datenheld/Bulldog/HEAD/dist/Version-0.1.0/bulldog.beagleboneblack.softfp/bulldog.beagleboneblack.softfpWithSources-0.1.0.zip
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 | import org.bulldog.core.gpio.PinFeature;
4 |
5 | public interface I2cPinFeature extends PinFeature {
6 |
7 | I2cBus getI2cBus();
8 | }
9 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/uart/UartPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.uart;
2 |
3 | import org.bulldog.core.gpio.PinFeature;
4 |
5 | public interface UartPinFeature extends PinFeature {
6 |
7 | public UartPort getPort();
8 | }
9 |
--------------------------------------------------------------------------------
/bulldog.build/settings.gradle:
--------------------------------------------------------------------------------
1 | includeFlat "bulldog.core",
2 | "bulldog.devices",
3 | "bulldog.examples",
4 | "bulldog.linux.native",
5 | "bulldog.linux",
6 | "bulldog.board.beagleboneblack",
7 | "bulldog.board.raspberrypi",
8 | "bulldog.board.cubieboard"
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/actuators/movement/Move.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.actuators.movement;
2 |
3 | import org.bulldog.devices.actuators.Actuator;
4 |
5 |
6 | public interface Move {
7 |
8 | void execute(Actuator actuator);
9 | }
10 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/Easing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public interface Easing {
4 |
5 | float easeIn(float t, float d);
6 | float easeOut(float t, float d);
7 | float easeInOut(float t, float d);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/bulldog.examples/build.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | compile project(":bulldog.core")
3 | compile project(":bulldog.devices")
4 | compile project(":bulldog.linux")
5 | compile project(":bulldog.board.beagleboneblack")
6 | compile project(":bulldog.board.raspberrypi")
7 | }
8 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/platform/IncompatiblePlatformException.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.platform;
2 |
3 | public class IncompatiblePlatformException extends RuntimeException {
4 |
5 | private static final long serialVersionUID = -7164560644328617567L;
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/bulldog/bulldog.h:
--------------------------------------------------------------------------------
1 | #ifndef BULLDOG_H
2 | #define BULLDOG_H
3 |
4 |
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 | extern void errorMessage(char* messageFormat, ...);
10 |
11 | #ifdef __cplusplus
12 | }
13 | #endif
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/io/LinuxEpollListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.io;
2 |
3 | import org.bulldog.linux.jni.NativePollResult;
4 |
5 | public interface LinuxEpollListener {
6 |
7 | void processEpollResults(NativePollResult[] results);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedPinFeature3.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 |
5 | public class MockedPinFeature3 extends MockedPinFeature2 {
6 |
7 | public MockedPinFeature3(Pin pin) {
8 | super(pin);
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/servo/ServoListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.servo;
2 |
3 | public interface ServoListener {
4 |
5 | void angleChanged(Servo servo, double oldAngle, double newAngle);
6 | void moveCompleted(Servo servo, double oldAngle, double newAngle);
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/bulldog/bulldog.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "bulldog.h"
4 |
5 | void errorMessage(char* messageFormat, ...) {
6 | va_list args;
7 | va_start(args, messageFormat);
8 | fprintf (stderr, messageFormat, args);
9 | va_end(args);
10 | }
11 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/uart/UartPort.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.uart;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.io.serial.SerialPort;
5 |
6 | public interface UartPort extends SerialPort {
7 |
8 | public Pin getRx();
9 | public Pin getTx();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/bulldog.core/.checkstyle:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bulldog.linux/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/Pwm.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio;
2 |
3 |
4 | public interface Pwm extends PinFeature {
5 |
6 | void enable();
7 | void disable();
8 | boolean isEnabled();
9 |
10 | void setDuty(double duty);
11 | double getDuty();
12 |
13 | void setFrequency(double frequency);
14 | double getFrequency();
15 | }
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/switches/RotaryEncoderListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.switches;
2 |
3 | import org.bulldog.core.gpio.event.ValueChangedListener;
4 |
5 |
6 | public interface RotaryEncoderListener extends ValueChangedListener {
7 |
8 | void turnedClockwise();
9 | void turnedCounterclockwise();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/BBBProperties.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack;
2 |
3 | public class BBBProperties {
4 | public static final String DOGTAG = "beagleboneblack.dogtag";
5 | public static final String HDMI_ENABLED = "beagleboneblack.hdmi.enabled";
6 | public static final String EMMC_ENABLED = "beagleboneblack.emmc.enabled";
7 | }
8 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/Bus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.core.io.IOPort;
6 |
7 | public interface Bus extends IOPort {
8 |
9 | public void selectSlave(int address) throws IOException;
10 | public boolean isSlaveSelected(int address);
11 | public BusConnection createConnection(int address);
12 | }
13 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/spi/SpiMode.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.spi;
2 |
3 | public enum SpiMode {
4 | Mode0(0),
5 | Mode1(1),
6 | Mode2(2),
7 | Mode3(3);
8 |
9 | private int modeValue;
10 |
11 | private SpiMode(int modeValue) {
12 | this.modeValue = modeValue;
13 | }
14 |
15 | public int getNumericValue() {
16 | return modeValue;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/platform/PinProvider.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.platform;
2 |
3 | import java.util.List;
4 |
5 | import org.bulldog.core.gpio.Pin;
6 |
7 | public interface PinProvider {
8 |
9 | List getPins();
10 | Pin getPinByAlias(String alias);
11 | Pin getPin(int address);
12 | Pin getPin(String name);
13 | Pin getPin(String port, int indexOnPort);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/io/BBBSpiBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.io;
2 |
3 | import org.bulldog.core.platform.Board;
4 | import org.bulldog.linux.io.LinuxSpiBus;
5 |
6 | public class BBBSpiBus extends LinuxSpiBus {
7 |
8 | public BBBSpiBus(String name, String deviceFilePath, Board board) {
9 | super(name, deviceFilePath, board);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/LinearEasing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public class LinearEasing implements Easing {
4 |
5 | public float easeIn(float t, float d) {
6 | return t/d;
7 | }
8 |
9 | public float easeOut(float t, float d) {
10 | return t/d;
11 | }
12 |
13 | public float easeInOut(float t, float d) {
14 | return t/d;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/PinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio;
2 |
3 |
4 |
5 | public interface PinFeature {
6 |
7 | String getName();
8 | Pin getPin();
9 |
10 | boolean isActivatedFeature();
11 | void activate();
12 |
13 | boolean isBlocking();
14 | void blockPin();
15 | void unblockPin();
16 |
17 | boolean isSetup();
18 |
19 | void setup();
20 | void teardown();
21 | }
22 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/io/RaspberryPiSpiBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi.io;
2 |
3 | import org.bulldog.core.platform.Board;
4 | import org.bulldog.linux.io.LinuxSpiBus;
5 |
6 | public class RaspberryPiSpiBus extends LinuxSpiBus {
7 |
8 | public RaspberryPiSpiBus(String name, String deviceFilePath, Board board) {
9 | super(name, deviceFilePath, board);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/event/InterruptEventArgs.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.event;
2 |
3 | import org.bulldog.core.Edge;
4 | import org.bulldog.core.gpio.Pin;
5 |
6 | public class InterruptEventArgs {
7 |
8 | private Edge edge;
9 |
10 | public InterruptEventArgs(Pin pin, Edge edge) {
11 | this.edge = edge;
12 | }
13 |
14 | public Edge getEdge() {
15 | return edge;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/pwmdriver/FrequencyLookupTable.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.pwmdriver;
2 |
3 | import java.util.HashMap;
4 |
5 | public class FrequencyLookupTable extends HashMap {
6 |
7 | /**
8 | *
9 | */
10 | private static final long serialVersionUID = 4953943440394262798L;
11 |
12 | public FrequencyLookupTable() {
13 | this.put(50.0, 134);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/event/FeatureActivationEventArgs.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.event;
2 |
3 | import org.bulldog.core.gpio.PinFeature;
4 |
5 | public class FeatureActivationEventArgs {
6 |
7 | private PinFeature feature;
8 |
9 | public FeatureActivationEventArgs(PinFeature feature) {
10 | this.feature = feature;
11 | }
12 |
13 | public PinFeature getPinFeature() {
14 | return this.feature;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/event/FeatureActivationListener.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.event;
2 |
3 | public interface FeatureActivationListener {
4 |
5 | void featureActivating(Object o, FeatureActivationEventArgs args);
6 | void featureActivated(Object o, FeatureActivationEventArgs args);
7 | void featureDeactivating(Object o, FeatureActivationEventArgs args);
8 | void featureDeactivated(Object o, FeatureActivationEventArgs args);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/DaemonThreadFactory.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util;
2 |
3 | import java.util.concurrent.Executors;
4 | import java.util.concurrent.ThreadFactory;
5 |
6 | public class DaemonThreadFactory implements ThreadFactory {
7 |
8 | @Override
9 | public Thread newThread(Runnable runnable) {
10 | Thread thread = Executors.defaultThreadFactory().newThread(runnable);
11 | thread.setDaemon(true);
12 | return thread;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.board.cubieboard
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.board.raspberrypi
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativeI2c.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 |
4 | public class NativeI2c {
5 |
6 | public static native byte i2cRead(int fileDescriptor);
7 | public static native int i2cWrite(int fileDescriptor, byte data);
8 | public static native int i2cSelectSlave(int busFileDescriptor, int slaveAddress);
9 | public static native int i2cOpen(String devicePath);
10 | public static native int i2cClose(int fileDescriptor);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/EasingOptions.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public enum EasingOptions {
4 | EaseIn,
5 | EaseOut,
6 | EaseInOut;
7 |
8 | public float calculate(Easing easing, float t, float d) {
9 | if(this == EasingOptions.EaseIn) {
10 | return easing.easeIn(t, d);
11 | } else if(this == EasingOptions.EaseOut) {
12 | return easing.easeOut(t, d);
13 | }
14 |
15 | return easing.easeInOut(t, d);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/java/org/bulldog/cubieboard/CubieboardBoardFactory.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.cubieboard;
2 |
3 | import org.bulldog.core.platform.Board;
4 | import org.bulldog.core.platform.BoardFactory;
5 |
6 |
7 | public class CubieboardBoardFactory implements BoardFactory {
8 |
9 | @Override
10 | public boolean isCompatibleWithPlatform() {
11 | return true;
12 | }
13 |
14 | @Override
15 | public Board createBoard() {
16 | return Cubieboard.getInstance();
17 | }
18 | }
--------------------------------------------------------------------------------
/bulldog.devices/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/bulldog/bulldogI2c.h:
--------------------------------------------------------------------------------
1 | #ifndef BULLDOG_I2C_H
2 | #define BULLDOG_I2C_H
3 |
4 |
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 | extern unsigned char i2cRead(int fileDescriptor);
10 | extern int i2cWrite(int fileDescriptor, unsigned char data);
11 | extern int i2cSelectSlave(int fd, int slaveAddress);
12 | extern int i2cOpen(char* busDevice);
13 | extern int i2cClose(int fileDescriptor);
14 |
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/QuintEasing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public class QuintEasing implements Easing {
4 |
5 | public float easeIn (float t, float d) {
6 | return (t/=d)*t*t*t*t;
7 | }
8 |
9 | public float easeOut (float t, float d) {
10 | return ((t=t/d-1)*t*t*t*t + 1);
11 | }
12 |
13 | public float easeInOut (float t, float d) {
14 | if ((t/=d/2) < 1) { return 0.5f*t*t*t*t*t; }
15 | return 0.5f*((t-=2)*t*t*t*t + 2);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/RaspberryPiPin.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 |
5 | public class RaspberryPiPin extends Pin {
6 |
7 | private int gpioAddress;
8 |
9 | public RaspberryPiPin(String name, int address, String port, int indexOnPort, int gpioNumber) {
10 | super(name, address, port, indexOnPort);
11 | this.gpioAddress = gpioNumber;
12 | }
13 |
14 | public int getGpioNumber() {
15 | return gpioAddress;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bulldog.core/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/build.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | distributions = [ new CubieboardDistribution() ]
3 | }
4 |
5 | class CubieboardDistribution {
6 | def distributionBaseName = 'bulldog.cubieboard'
7 | def distributionFiles = ['../bulldog.linux.native/build/binaries/bulldogSharedLibrary/cubieboard/libbulldog-linux.so']
8 | }
9 |
10 | dependencies {
11 | compile project(':bulldog.core')
12 | compile project(':bulldog.linux')
13 | runtime fileTree(dir: project(':bulldog.linux.native').buildDir, include: '**/*.so')
14 | }
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/build.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | distributions = [ new RaspberryPiDistribution() ]
3 | }
4 |
5 | class RaspberryPiDistribution {
6 | def distributionBaseName = 'bulldog.raspberrypi'
7 | def distributionFiles = ['../bulldog.linux.native/build/binaries/bulldogSharedLibrary/raspberrypi/libbulldog-linux.so']
8 | }
9 |
10 | dependencies {
11 | compile project(':bulldog.core')
12 | compile project(':bulldog.linux')
13 | runtime fileTree(dir: project(':bulldog.linux.native').buildDir, include: '**/*.so')
14 | }
--------------------------------------------------------------------------------
/bulldog.build/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.build
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.springsource.ide.eclipse.gradle.core.nature
16 | org.eclipse.jdt.core.javanature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/SineEasing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public class SineEasing implements Easing {
4 |
5 | public float easeIn(float t, float d) {
6 | return -1.0f * (float) Math.cos(t / d * (Math.PI / 2)) + 1.0f;
7 | }
8 |
9 | public float easeOut(float t, float d) {
10 | return (float) Math.sin(t / d * (Math.PI / 2));
11 | }
12 |
13 | public float easeInOut(float t, float d) {
14 | return -0.5f * ((float) Math.cos(Math.PI * t / d) - 1);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/bulldog.devices/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.devices
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.springsource.ide.eclipse.gradle.core.nature
16 | org.eclipse.jdt.core.javanature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/bulldog.examples/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.examples
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.springsource.ide.eclipse.gradle.core.nature
16 | org.eclipse.jdt.core.javanature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativeTools.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 | import java.io.FileDescriptor;
4 |
5 | public class NativeTools {
6 |
7 | public static final int OPEN_READ_ONLY = 0x00;
8 | public static final int OPEN_WRITE_ONLY = 0x01;
9 | public static final int OPEN_READ_WRITE = 0x02;
10 |
11 | public static native FileDescriptor getJavaDescriptor(int fileDescriptor);
12 | public static native int open(String filename, int flags);
13 | public static native int close(int fileDescriptor);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.board.beagleboneblack
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.springsource.ide.eclipse.gradle.core.nature
16 | org.eclipse.jdt.core.javanature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedPinFeature1.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPinFeature;
5 |
6 | public class MockedPinFeature1 extends AbstractPinFeature {
7 |
8 | public MockedPinFeature1(Pin pin) {
9 | super(pin);
10 |
11 | }
12 |
13 | @Override
14 | public String getName() {
15 | return "Mocked Feature";
16 | }
17 |
18 | @Override
19 | protected void setupImpl() {
20 | }
21 |
22 | @Override
23 | protected void teardownImpl() {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/lcd/Lcd.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.lcd;
2 |
3 | public interface Lcd {
4 |
5 | void setMode(LcdMode mode, LcdFont font);
6 | void write(String text);
7 | void writeAt(int row, int column, String text);
8 | void clear();
9 | void blinkCursor(boolean blink);
10 | void showCursor(boolean show);
11 | void home();
12 | void on();
13 | void off();
14 | void setCursorPosition(int line, int column);
15 | String readLine(int line);
16 | String read(int length);
17 | String read(int line, int column, int length);
18 | }
19 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedPinFeature2.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPinFeature;
5 |
6 | public class MockedPinFeature2 extends AbstractPinFeature {
7 |
8 | public MockedPinFeature2(Pin pin) {
9 | super(pin);
10 |
11 | }
12 |
13 | @Override
14 | public String getName() {
15 | return "Mocked Feature";
16 | }
17 |
18 | @Override
19 | protected void setupImpl() {
20 | }
21 |
22 | @Override
23 | protected void teardownImpl() {
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/spi/SpiMessage.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.spi;
2 |
3 | public class SpiMessage {
4 |
5 | private byte[] receivedBytes;
6 | private byte[] sentBytes;
7 |
8 | public byte[] getReceivedBytes() {
9 | return receivedBytes;
10 | }
11 |
12 | public void setReceivedBytes(byte[] receivedBytes) {
13 | this.receivedBytes = receivedBytes;
14 | }
15 |
16 | public byte[] getSentBytes() {
17 | return sentBytes;
18 | }
19 |
20 | public void setSentBytes(byte[] sentBytes) {
21 | this.sentBytes = sentBytes;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/actuators/Actuator.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.actuators;
2 |
3 | import org.bulldog.devices.actuators.movement.Move;
4 |
5 | public interface Actuator {
6 |
7 | public void moveTo(double position);
8 | public void setPosition(double position);
9 | public double getPosition();
10 |
11 | public void move(Move move);
12 | public void moveAsync(Move move);
13 | public void awaitMoveCompleted();
14 | public boolean isMoving();
15 |
16 | public int getMillisecondsPerUnit();
17 | public int getRefreshIntervalMilliseconds();
18 | }
19 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/RaspberryPiBoardFactory.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi;
2 |
3 | import org.bulldog.core.platform.Board;
4 | import org.bulldog.core.platform.BoardFactory;
5 | import org.bulldog.linux.util.LinuxLibraryLoader;
6 |
7 |
8 | public class RaspberryPiBoardFactory implements BoardFactory {
9 |
10 | @Override
11 | public boolean isCompatibleWithPlatform() {
12 | return true;
13 | }
14 |
15 | @Override
16 | public Board createBoard() {
17 | LinuxLibraryLoader.loadNativeLibrary();
18 | return new RaspberryPi();
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedBoard.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.platform.AbstractBoard;
5 |
6 | public class MockedBoard extends AbstractBoard {
7 |
8 | public MockedBoard() {
9 | for(int i = 0; i < 10; i++) {
10 | getPins().add(new Pin("P" + i, i, "A", i));
11 | getI2cBuses().add(new MockedI2cBus("I2C" + i));
12 | getSerialPorts().add(new MockedSerialPort("Serial" + i));
13 | }
14 | }
15 |
16 | @Override
17 | public String getName() {
18 | return "MockedBoard";
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedDigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.Signal;
4 | import org.bulldog.core.gpio.Pin;
5 | import org.bulldog.core.gpio.base.AbstractDigitalOutput;
6 |
7 | public class MockedDigitalOutput extends AbstractDigitalOutput {
8 |
9 | public MockedDigitalOutput(Pin pin) {
10 | super(pin);
11 | }
12 |
13 | @Override
14 | protected void setupImpl() {
15 | }
16 |
17 | @Override
18 | protected void teardownImpl() {
19 | }
20 |
21 | @Override
22 | protected void applySignalImpl(Signal signal) {
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/BeagleBoneBlackBoardFactory.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack;
2 |
3 | import org.bulldog.core.platform.Board;
4 | import org.bulldog.core.platform.BoardFactory;
5 | import org.bulldog.linux.util.LinuxLibraryLoader;
6 |
7 | public class BeagleBoneBlackBoardFactory implements BoardFactory {
8 |
9 | @Override
10 | public boolean isCompatibleWithPlatform() {
11 | return true;
12 | }
13 |
14 | @Override
15 | public Board createBoard() {
16 | LinuxLibraryLoader.loadNativeLibrary();
17 | return new BeagleBoneBlack();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/bulldog/bulldogSpi.h:
--------------------------------------------------------------------------------
1 | #ifndef BULLDOG_SPI_H
2 | #define BULLDOG_SPI_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | extern int spiOpen(char* busDevice, int mode, int speed, int bitsPerWord, int lsbFirst);
9 | extern int spiConfig(int fileDescriptor, int mode, int speed, int bitsPerWord, int lsbFirst);
10 | extern int spiTransfer(int fileDescriptor, unsigned int* txBuffer, unsigned int* rxBuffer, int transferLength, int delay, int speed, int bitsPerWord);
11 | extern int spiClose(int fileDescriptor);
12 |
13 | #ifdef __cplusplus
14 | }
15 | #endif
16 |
17 | #endif
18 |
19 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/platform/Platform.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.platform;
2 |
3 | import java.util.Iterator;
4 | import java.util.ServiceLoader;
5 |
6 | public class Platform {
7 |
8 | public static Board createBoard() throws IncompatiblePlatformException {
9 | Iterator iter = ServiceLoader.load(BoardFactory.class).iterator();
10 | while (iter.hasNext()) {
11 | BoardFactory detector = iter.next();
12 | if(detector.isCompatibleWithPlatform()) {
13 | return detector.createBoard();
14 | }
15 | }
16 |
17 | throw new IncompatiblePlatformException();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/servo/TowerProMicroSG90.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.servo;
2 |
3 | import org.bulldog.core.gpio.Pwm;
4 |
5 | public class TowerProMicroSG90 extends Servo {
6 |
7 | private static final double MIN_ANGLE_DEFAULT = 0.0225;
8 | private static final double MAX_ANGLE_DEFAULT = 0.1150;
9 | private static final double INITIAL_ANGLE_DEFAULT = 0.0;
10 | private static final int TIME_PER_DEGREE = (int)(0.1 / 60.0 * 1000);
11 |
12 | public TowerProMicroSG90(Pwm pwm) {
13 | super(pwm, INITIAL_ANGLE_DEFAULT, MIN_ANGLE_DEFAULT, MAX_ANGLE_DEFAULT, TIME_PER_DEGREE);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativeSpi.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 | import java.nio.ByteBuffer;
4 |
5 | public class NativeSpi {
6 |
7 | public static native int spiOpen(String filename, int mode, int speed, int bitsPerWord, boolean lsbFirst);
8 | public static native int spiConfig(int fileDescriptor, int mode, int speed, int bitsPerWord, boolean lsbFirst);
9 | public static native int spiClose(int fileDescriptor);
10 | public static native int spiTransfer(int fileDescriptor, ByteBuffer txBuffer, ByteBuffer rxBuffer, int transferLength, int delay, int speed, int bitsPerWord);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/serial/SerialDataEventArgs.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.serial;
2 |
3 | import org.bulldog.core.util.BulldogUtil;
4 |
5 | public class SerialDataEventArgs {
6 |
7 | private byte[] data;
8 | private SerialPort port;
9 |
10 | public SerialDataEventArgs(SerialPort port, byte[] data) {
11 | this.port = port;
12 | this.data = data;
13 | }
14 |
15 | public byte[] getData() {
16 | return data;
17 | }
18 |
19 | public SerialPort getPort() {
20 | return port;
21 | }
22 |
23 | public String getDataAsString() {
24 | return BulldogUtil.bytesToString(getData());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/gpio/RaspiDigitalInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi.gpio;
2 |
3 | import org.bulldog.core.Signal;
4 | import org.bulldog.core.gpio.Pin;
5 | import org.bulldog.linux.gpio.LinuxDigitalInput;
6 | import org.bulldog.linux.io.LinuxEpollListener;
7 |
8 | public class RaspiDigitalInput extends LinuxDigitalInput implements LinuxEpollListener {
9 |
10 | public RaspiDigitalInput(Pin pin) {
11 | super(pin);
12 | }
13 |
14 | public Signal read() {
15 | return getSysFsPin().getValue();
16 | }
17 |
18 | public void setup() {
19 | super.setup();
20 | }
21 |
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/CircularEasing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public class CircularEasing implements Easing {
4 |
5 | public float easeIn(float t, float d) {
6 | return -1.0f * ((float) Math.sqrt(1 - (t /= d) * t) - 1);
7 | }
8 |
9 | public float easeOut(float t, float d) {
10 | return (float) Math.sqrt(1 - (t = t / d - 1) * t);
11 | }
12 |
13 | public float easeInOut(float t, float d) {
14 | if ((t /= d / 2) < 1) {
15 | return -0.5f * ((float) Math.sqrt(1.0f - t * t) - 1);
16 | }
17 |
18 | return 0.5f * ((float) Math.sqrt(1 - (t -= 2) * t) + 1);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/java/org/bulldog/cubieboard/gpio/CubieboardDigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.cubieboard.gpio;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.cubieboard.CubieboardPin;
5 | import org.bulldog.linux.gpio.LinuxDigitalOutput;
6 | import org.bulldog.linux.sysfs.SysFsPin;
7 |
8 | public class CubieboardDigitalOutput extends LinuxDigitalOutput {
9 |
10 | public CubieboardDigitalOutput(Pin pin) {
11 | super(pin);
12 | }
13 |
14 | @Override
15 | protected SysFsPin createSysFsPin(Pin pin) {
16 | return new CubieboardSysFsPin(pin.getAddress(), ((CubieboardPin)pin).getFsName(), false);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/servo/AdafruitServoDriver.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.servo;
2 |
3 | import org.bulldog.core.io.bus.i2c.I2cBus;
4 | import org.bulldog.core.io.bus.i2c.I2cConnection;
5 | import org.bulldog.devices.pwmdriver.PCA9685;
6 |
7 | public class AdafruitServoDriver extends PCA9685 {
8 |
9 | private static final String NAME = "ADAFRUIT 16-CHANNEL 12-BIT PWM/SERVO DRIVER - I2C INTERFACE";
10 |
11 | public AdafruitServoDriver(I2cConnection connection) {
12 | super(connection);
13 | setName(NAME);
14 | }
15 |
16 | public AdafruitServoDriver(I2cBus bus, int address) {
17 | this(bus.createI2cConnection(address));
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/java/org/bulldog/cubieboard/CubieboardPin.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.cubieboard;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 |
5 | public class CubieboardPin extends Pin {
6 |
7 | private String fsName;
8 | private boolean interrupt;
9 |
10 | public CubieboardPin(String name, int address, String port, int indexOnPort, String fsName, boolean interrupt) {
11 | super(name, address, port, indexOnPort);
12 | this.fsName = fsName;
13 | this.interrupt = interrupt;
14 | }
15 |
16 | public String getFsName() {
17 | return fsName;
18 | }
19 |
20 | public boolean isInterrupt() {
21 | return interrupt;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/spi/SpiDevice.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.spi;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.core.io.bus.BusDevice;
6 |
7 | public class SpiDevice extends BusDevice {
8 |
9 | public SpiDevice(SpiConnection connection) {
10 | super(connection);
11 | }
12 |
13 | public SpiDevice(SpiBus bus, int address) {
14 | this(bus.createSpiConnection(address));
15 | }
16 |
17 | public SpiMessage transfer(byte[] bytes) throws IOException {
18 | return getBusConnection().transfer(bytes);
19 | }
20 |
21 | public SpiConnection getBusConnection() {
22 | return (SpiConnection)super.getBusConnection();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/AbstractI2cPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPinFeature;
5 |
6 | public abstract class AbstractI2cPinFeature extends AbstractPinFeature implements I2cSda, I2cScl {
7 |
8 | private static final String NAME = "I2C %s on Pin %s";
9 | private I2cSignalType signalType;
10 |
11 | public AbstractI2cPinFeature(Pin pin, I2cSignalType signalType) {
12 | super(pin);
13 | this.signalType = signalType;
14 | }
15 |
16 | @Override
17 | public String getName() {
18 | return String.format(NAME, signalType, getPin().getName());
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/serial/SerialPort.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.serial;
2 |
3 | import org.bulldog.core.Parity;
4 | import org.bulldog.core.io.IOPort;
5 |
6 | public interface SerialPort extends IOPort {
7 |
8 | int getBaudRate();
9 | void setBaudRate(int baudRate);
10 |
11 | Parity getParity();
12 | void setParity(Parity parity);
13 |
14 | int getDataBits();
15 | void setDataBits(int dataBits);
16 |
17 | int getStopBits();
18 | void setStopBits(int stopBits);
19 |
20 | void setBlocking(boolean blocking);
21 | boolean getBlocking();
22 |
23 | void addListener(SerialDataListener listener);
24 | void removeListener(SerialDataListener listener);
25 | }
26 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.core.gpio.Pin;
6 | import org.bulldog.core.io.bus.Bus;
7 |
8 | public interface I2cBus extends Bus {
9 |
10 | Pin getSDA();
11 | Pin getSCL();
12 | int getFrequency();
13 |
14 | void writeByteToRegister(int register, int b) throws IOException;
15 | void writeBytesToRegister(int register, byte[] bytes) throws IOException;
16 |
17 | byte readByteFromRegister(int register) throws IOException;
18 | int readBytesFromRegister(int register, byte[] buffer) throws IOException;
19 |
20 | I2cConnection createI2cConnection(int address);
21 | }
22 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/ExponentialEasing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public class ExponentialEasing implements Easing {
4 |
5 | public float easeIn(float t, float d) {
6 | return (t==0) ? 0.0f : (float)Math.pow(2, 10 * (t/d - 1));
7 | }
8 |
9 | public float easeOut(float t, float d) {
10 | return (t==d) ? 1.0f : (-(float)Math.pow(2, -10 * t/d) + 1);
11 | }
12 |
13 | public float easeInOut(float t, float d) {
14 | if (t==0) { return 0.0f; }
15 | if (t==d) { return 1.0f; }
16 | if ((t/=d/2) < 1) { return 0.5f * (float)Math.pow(2, 10 * (t - 1)); }
17 |
18 | return 0.5f * (-(float)Math.pow(2, -10 * (t-1)) + 2);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/actuators/movement/DirectMove.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.actuators.movement;
2 |
3 | import org.bulldog.core.util.BulldogUtil;
4 | import org.bulldog.devices.actuators.Actuator;
5 |
6 | public class DirectMove implements Move {
7 |
8 | private double toPosition = 0.0f;
9 |
10 | public DirectMove(double toPosition) {
11 | this.toPosition = toPosition;
12 | }
13 |
14 | @Override
15 | public void execute(Actuator actuator) {
16 | double startPosition = actuator.getPosition();
17 | actuator.setPosition(toPosition);
18 | int sleepyTime = (int)Math.abs(toPosition - startPosition) * actuator.getMillisecondsPerUnit();
19 | BulldogUtil.sleepMs(sleepyTime);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativePollResult.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 | import org.bulldog.core.util.BulldogUtil;
4 |
5 | public class NativePollResult {
6 |
7 | private int events;
8 | private int fd;
9 | private byte[] data;
10 |
11 | public NativePollResult(int fd, int events, byte[] data) {
12 | this.fd = fd;
13 | this.events = events;
14 | this.data = data;
15 | }
16 |
17 | public int getEvents() {
18 | return events;
19 | }
20 |
21 | public int getFileDescriptor() {
22 | return fd;
23 | }
24 |
25 | public byte[] getData() {
26 | return data;
27 | }
28 |
29 | public String getDataAsString() {
30 | return BulldogUtil.bytesToString(getData());
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/gpio/BBBEmmc.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.gpio;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPinFeature;
5 |
6 | public class BBBEmmc extends AbstractPinFeature {
7 |
8 | private static final String NAME_FORMAT = "EMMC on Pin %s - (you need to disable this feature at boot time)";
9 |
10 | public BBBEmmc(Pin pin) {
11 | super(pin);
12 | }
13 |
14 | @Override
15 | public String getName() {
16 | return String.format(NAME_FORMAT, getPin().getName());
17 | }
18 |
19 | @Override
20 | protected void setupImpl() {
21 | blockPin();
22 | }
23 |
24 | @Override
25 | protected void teardownImpl() {
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/gpio/BBBHdmi.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.gpio;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPinFeature;
5 |
6 | public class BBBHdmi extends AbstractPinFeature {
7 |
8 | private static final String NAME_FORMAT = "HDMI on Pin %s - (you need to disable this feature at boot time)";
9 |
10 | public BBBHdmi(Pin pin) {
11 | super(pin);
12 | }
13 |
14 | @Override
15 | public String getName() {
16 | return String.format(NAME_FORMAT, getPin().getName());
17 | }
18 |
19 | @Override
20 | protected void setupImpl() {
21 | blockPin();
22 | }
23 |
24 | @Override
25 | protected void teardownImpl() {
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/bulldog.core/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.core
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder
15 |
16 |
17 |
18 |
19 |
20 | org.springsource.ide.eclipse.gradle.core.nature
21 | org.eclipse.jdt.core.javanature
22 | edu.umd.cs.findbugs.plugin.eclipse.findbugsNature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/bulldog.linux/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.linux
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder
15 |
16 |
17 |
18 |
19 |
20 | org.springsource.ide.eclipse.gradle.core.nature
21 | org.eclipse.jdt.core.javanature
22 | edu.umd.cs.findbugs.plugin.eclipse.findbugsNature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/uart/AbstractUartPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.uart;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPinFeature;
5 |
6 | public abstract class AbstractUartPinFeature extends AbstractPinFeature implements UartRx, UartTx {
7 |
8 | private static final String NAME = "UART %s on Pin %s";
9 | private UartSignalType signalType;
10 |
11 | public AbstractUartPinFeature(Pin pin, UartSignalType signalType) {
12 | super(pin);
13 | this.signalType = signalType;
14 | }
15 |
16 | @Override
17 | public String getName() {
18 | return String.format(NAME, signalType, getPin().getName());
19 | }
20 |
21 | public UartSignalType getSignalType() {
22 | return signalType;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/beagleboneblack/BBBIOlib/BBBiolib_PWMSS.h:
--------------------------------------------------------------------------------
1 | #ifndef BBBIO_PWMSS_H
2 | #define BBBIO_PWMSS_H
3 | /* ---------------------------------------------------------------------------- */
4 | #define BBBIO_PWMSS_COUNT 3
5 | #define BBBIO_PWMSS0 0
6 | #define BBBIO_PWMSS1 1
7 | #define BBBIO_PWMSS2 2
8 |
9 | /* ---------------------------------------------------------------------------- */
10 | int BBBIO_PWMSS_Setting(unsigned int PWMID , float HZ ,float dutyA ,float dutyB);
11 | int BBBIO_PWM_Init();
12 | void BBBIO_PWM_Release();
13 | int BBBIO_PWMSS_Status(unsigned int PWMID);
14 | void BBBIO_ehrPWM_Enable(unsigned int PWMSS_ID);
15 | void BBBIO_ehrPWM_Disable(unsigned int PWMSS_ID);
16 | /* ---------------------------------------------------------------------------- */
17 | #endif
18 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/build.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | distributions = [ new SoftFpDistribution(), new HardFpDistribution() ]
3 | }
4 |
5 | class SoftFpDistribution {
6 | def distributionBaseName = 'bulldog.beagleboneblack.softfp'
7 | def distributionFiles = ['../bulldog.linux.native/build/binaries/bulldogSharedLibrary/beagleboneblackSoftFp/libbulldog-linux.so']
8 | }
9 |
10 | class HardFpDistribution {
11 | def distributionBaseName = 'bulldog.beagleboneblack.hardfp'
12 | def distributionFiles = ['../bulldog.linux.native/build/binaries/bulldogSharedLibrary/beagleboneblackHardFp/libbulldog-linux.so']
13 | }
14 |
15 | dependencies {
16 | compile project(':bulldog.core')
17 | compile project(':bulldog.linux')
18 | runtime fileTree(dir: project(':bulldog.linux.native').buildDir, include: '**/*.so')
19 | }
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/java/org/bulldog/cubieboard/gpio/CubieboardSysFsPin.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.cubieboard.gpio;
2 |
3 | import org.bulldog.linux.sysfs.SysFsPin;
4 |
5 | public class CubieboardSysFsPin extends SysFsPin {
6 | private static final String directory = "/sys/class/gpio";
7 |
8 | private String fsName;
9 | private boolean interrupt;
10 |
11 | public CubieboardSysFsPin(int pin, String fsName, boolean interrupt) {
12 | super(pin);
13 | this.fsName = fsName;
14 | this.interrupt = interrupt;
15 | }
16 |
17 | @Override
18 | public String getPinDirectory() {
19 | return directory + "/gpio" + fsName + "/";
20 | }
21 |
22 | @Override
23 | public void setEdge(String edge) {
24 | if (interrupt)
25 | super.setEdge(edge);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/bulldog.examples/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/io/RaspberryPiI2cPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi.io;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.io.bus.i2c.AbstractI2cPinFeature;
5 | import org.bulldog.core.io.bus.i2c.I2cBus;
6 | import org.bulldog.core.io.bus.i2c.I2cSignalType;
7 |
8 | public class RaspberryPiI2cPinFeature extends AbstractI2cPinFeature {
9 |
10 | public RaspberryPiI2cPinFeature(I2cBus bus, Pin pin, I2cSignalType signalType) {
11 | super(pin, signalType);
12 | }
13 |
14 |
15 | @Override
16 | public boolean isBlocking() {
17 | return false;
18 | }
19 |
20 | @Override
21 | protected void setupImpl() {
22 | }
23 |
24 | @Override
25 | protected void teardownImpl() {
26 | }
27 |
28 | @Override
29 | public I2cBus getI2cBus() {
30 | return null;
31 | }
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/PinIOOutputStream.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io;
2 |
3 | import java.io.IOException;
4 | import java.io.OutputStream;
5 |
6 | import org.bulldog.core.Signal;
7 | import org.bulldog.core.gpio.DigitalOutput;
8 | import org.bulldog.core.util.BitMagic;
9 |
10 | public class PinIOOutputStream extends OutputStream {
11 |
12 | private PinIOGroup group;
13 |
14 | public PinIOOutputStream(PinIOGroup group) {
15 | this.group = group;
16 | }
17 |
18 | @Override
19 | public void write(int b) throws IOException {
20 | group.startEnable();
21 |
22 | for(int i = 0; i < group.getDataPins().length; i++) {
23 | DigitalOutput out = group.getDataPins()[i];
24 | Signal signal = Signal.fromNumericValue(BitMagic.getBit(b, i));
25 | out.applySignal(signal);
26 | }
27 |
28 | group.endEnable();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/bulldog.devices/src/test/java/org/bulldog/devices/AppTest.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices;
2 |
3 | import junit.framework.Test;
4 | import junit.framework.TestCase;
5 | import junit.framework.TestSuite;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | extends TestCase
12 | {
13 | /**
14 | * Create the test case
15 | *
16 | * @param testName name of the test case
17 | */
18 | public AppTest( String testName )
19 | {
20 | super( testName );
21 | }
22 |
23 | /**
24 | * @return the suite of tests being tested
25 | */
26 | public static Test suite()
27 | {
28 | return new TestSuite( AppTest.class );
29 | }
30 |
31 | /**
32 | * Rigourous Test :-)
33 | */
34 | public void testApp()
35 | {
36 | assertTrue( true );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/bulldog.examples/src/test/java/org/bulldog/examples/AppTest.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.examples;
2 |
3 | import junit.framework.Test;
4 | import junit.framework.TestCase;
5 | import junit.framework.TestSuite;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | extends TestCase
12 | {
13 | /**
14 | * Create the test case
15 | *
16 | * @param testName name of the test case
17 | */
18 | public AppTest( String testName )
19 | {
20 | super( testName );
21 | }
22 |
23 | /**
24 | * @return the suite of tests being tested
25 | */
26 | public static Test suite()
27 | {
28 | return new TestSuite( AppTest.class );
29 | }
30 |
31 | /**
32 | * Rigourous Test :-)
33 | */
34 | public void testApp()
35 | {
36 | assertTrue( true );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/sysinfo/CpuInfo.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.sysinfo;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.bulldog.linux.util.Commands;
6 |
7 | public class CpuInfo {
8 |
9 | private static final String CPU_REVISION = "CPU revision";
10 |
11 | private static HashMap properties = new HashMap();
12 |
13 | static {
14 | String cpuInfo = Commands.cat("/proc/cpuinfo");
15 | String[] infos = cpuInfo.split("\n");
16 | for(String info : infos) {
17 | String[] tokens = info.split(":");
18 | if(tokens.length >= 2) {
19 | System.out.println(tokens[0].trim() + " : " + tokens[1].trim());
20 | properties.put(tokens[0].trim(), tokens[1].trim());
21 | }
22 | }
23 | }
24 |
25 | public static String getCPURevision() {
26 | return properties.get(CPU_REVISION);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/io/BBBI2cPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.io;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.io.bus.i2c.AbstractI2cPinFeature;
5 | import org.bulldog.core.io.bus.i2c.I2cBus;
6 | import org.bulldog.core.io.bus.i2c.I2cSignalType;
7 |
8 | public class BBBI2cPinFeature extends AbstractI2cPinFeature {
9 |
10 | public BBBI2cPinFeature(I2cBus bus, Pin pin, I2cSignalType signalType) {
11 | super(pin, signalType);
12 | // TODO Auto-generated constructor stub
13 | }
14 |
15 | @Override
16 | public boolean isBlocking() {
17 | return false;
18 | }
19 |
20 | @Override
21 | protected void setupImpl() {
22 | }
23 |
24 | @Override
25 | protected void teardownImpl() {
26 | }
27 |
28 | @Override
29 | public I2cBus getI2cBus() {
30 | return null;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/io/BBBUartPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.io;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.io.uart.AbstractUartPinFeature;
5 | import org.bulldog.core.io.uart.UartPort;
6 | import org.bulldog.core.io.uart.UartSignalType;
7 |
8 | public class BBBUartPinFeature extends AbstractUartPinFeature {
9 |
10 | private BBBUartPort port;
11 |
12 | public BBBUartPinFeature(BBBUartPort port, Pin pin, UartSignalType signalType) {
13 | super(pin, signalType);
14 | this.port = port;
15 | }
16 |
17 | @Override
18 | protected void setupImpl() {
19 | port.setup();
20 | blockPin();
21 | }
22 |
23 | @Override
24 | protected void teardownImpl() {
25 | port.teardown();
26 | }
27 |
28 | @Override
29 | public UartPort getPort() {
30 | return port;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/io/RaspberryPiI2cBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi.io;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.io.bus.i2c.I2cSignalType;
5 | import org.bulldog.linux.io.LinuxI2cBus;
6 |
7 | public class RaspberryPiI2cBus extends LinuxI2cBus {
8 |
9 | private Pin sdaPin;
10 | private Pin sclPin;
11 |
12 | public RaspberryPiI2cBus(String name, String deviceFilePath, Pin sdaPin, Pin sclPin) {
13 | super(name, deviceFilePath);
14 | this.sdaPin = sdaPin;
15 | this.sclPin = sclPin;
16 | sdaPin.addFeature(new RaspberryPiI2cPinFeature(this, sdaPin, I2cSignalType.SDA));
17 | sclPin.addFeature(new RaspberryPiI2cPinFeature(this, sclPin, I2cSignalType.SCL));
18 | }
19 |
20 | public Pin getSCL() {
21 | return sclPin;
22 | }
23 |
24 | public Pin getSDA() {
25 | return sdaPin;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/led/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.led
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/BeagleBonePin.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 |
5 | public class BeagleBonePin extends Pin {
6 |
7 | private int bank;
8 | private int pinIndex;
9 | private String am335xName;
10 |
11 | public BeagleBonePin(String name, String am335xName, int bank, int pinIndex, String port, int indexOnPort) {
12 | super(name, 32 * bank + pinIndex, port, indexOnPort);
13 | this.am335xName = am335xName;
14 | }
15 |
16 | public int getBank() {
17 | return bank;
18 | }
19 |
20 | public int getPinIndex() {
21 | return pinIndex;
22 | }
23 |
24 | public int getPortNumeric() {
25 | int portNumber = Integer.parseInt(getPort().substring(1));
26 | return portNumber;
27 | }
28 |
29 | public String getAm335xName() {
30 | return am335xName;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/dac/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.dac
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/test/java/org/bulldog/beagleboneblack/AppTest.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack;
2 |
3 | import junit.framework.Test;
4 | import junit.framework.TestCase;
5 | import junit.framework.TestSuite;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | extends TestCase
12 | {
13 | /**
14 | * Create the test case
15 | *
16 | * @param testName name of the test case
17 | */
18 | public AppTest( String testName )
19 | {
20 | super( testName );
21 | }
22 |
23 | /**
24 | * @return the suite of tests being tested
25 | */
26 | public static Test suite()
27 | {
28 | return new TestSuite( AppTest.class );
29 | }
30 |
31 | /**
32 | * Rigourous Test :-)
33 | */
34 | public void testApp()
35 | {
36 | assertTrue( true );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/sysinfo/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.sysinfo
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/util/easing/BounceEasing.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.util.easing;
2 |
3 | public class BounceEasing implements Easing {
4 |
5 | public float easeIn(float t, float d) {
6 | return 1.0f - easeOut(d - t, d);
7 | }
8 |
9 | public float easeOut(float t, float d) {
10 | if ((t /= d) < (1 / 2.75f)) {
11 | return 1.0f * (7.5625f * t * t);
12 | } else if (t < (2 / 2.75f)) {
13 | return 1.0f * (7.5625f * (t -= (1.5f / 2.75f)) * t + .75f);
14 | } else if (t < (2.5 / 2.75)) {
15 | return 1.0f * (7.5625f * (t -= (2.25f / 2.75f)) * t + .9375f);
16 | } else {
17 | return 1.0f * (7.5625f * (t -= (2.625f / 2.75f)) * t + .984375f);
18 | }
19 | }
20 |
21 | public float easeInOut(float t, float d) {
22 | if (t < d / 2) {
23 | return easeIn(t * 2, d) * 0.5f;
24 | } else {
25 | return easeOut(t * 2 - d, d) * .5f + 0.5f;
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/PinIOInputStream.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | import org.bulldog.core.Signal;
7 | import org.bulldog.core.gpio.DigitalInput;
8 | import org.bulldog.core.util.BitMagic;
9 |
10 | public class PinIOInputStream extends InputStream {
11 |
12 | private PinIOGroup group;
13 |
14 | public PinIOInputStream(PinIOGroup group) {
15 | this.group = group;
16 | }
17 |
18 | @Override
19 | public int read() throws IOException {
20 |
21 | group.startEnable();
22 |
23 | int value = 0;
24 | for(int i = 0; i < group.getDataPins().length; i++) {
25 | DigitalInput in = group.getDataPins()[i];
26 | Signal signal = in.read();
27 | value = BitMagic.setBit(value, i, signal.getNumericValue());
28 | }
29 |
30 | group.endEnable();
31 |
32 | return value;
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/util/LinuxLibraryLoader.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.util;
2 |
3 | import java.io.File;
4 | import java.security.CodeSource;
5 |
6 | public class LinuxLibraryLoader {
7 |
8 | public static void loadNativeLibrary() {
9 | String codeDirectory = getJarFileDirectory();
10 | File file = new File(codeDirectory + "/libbulldog-linux.so");
11 | if(file.exists()) {
12 | System.load(file.getAbsolutePath());
13 | } else {
14 | System.loadLibrary("bulldog-linux");
15 | }
16 | }
17 |
18 | private static String getJarFileDirectory() {
19 | try {
20 | CodeSource codeSource = LinuxLibraryLoader.class.getProtectionDomain().getCodeSource();
21 | File jarFile = new File(codeSource.getLocation().toURI().getPath());
22 | String jarDir = jarFile.getParentFile().getPath();
23 | return jarDir;
24 | } catch(Exception ex) {
25 | return null;
26 | }
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/io/mmap/ByteRegister.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.io.mmap;
2 |
3 | import org.bulldog.core.util.BitMagic;
4 |
5 | public class ByteRegister extends Register {
6 |
7 | public ByteRegister(MemoryMap map, long address) {
8 | super(map, address, Byte.class);
9 | }
10 |
11 | @Override
12 | public void setValue(Byte value) {
13 | getMemoryMap().setByteValue(getAddress(), value);
14 | }
15 |
16 | @Override
17 | public Byte getValue() {
18 | return getMemoryMap().getByteValueAt(getAddress());
19 | }
20 |
21 | @Override
22 | public void setBit(int index) {
23 | setValue(BitMagic.setBit(getValue(), index, 1));
24 | }
25 |
26 | @Override
27 | public void clearBit(int index) {
28 | setValue(BitMagic.setBit(getValue(), index, 0));
29 | }
30 |
31 | @Override
32 | public void toggleBit(int index) {
33 | setValue(BitMagic.toggleBit(getValue(), index));
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/io/mmap/LongRegister.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.io.mmap;
2 |
3 | import org.bulldog.core.util.BitMagic;
4 |
5 | public class LongRegister extends Register {
6 |
7 | public LongRegister(MemoryMap map, long address) {
8 | super(map, address, Long.class);
9 | }
10 |
11 | @Override
12 | public void setValue(Long value) {
13 | getMemoryMap().setLongValue(getAddress(), value);
14 | }
15 |
16 | @Override
17 | public Long getValue() {
18 | return getMemoryMap().getLongValueAt(getAddress());
19 | }
20 |
21 | @Override
22 | public void setBit(int index) {
23 | setValue(BitMagic.setBit(getValue(), index, 1));
24 | }
25 |
26 | @Override
27 | public void clearBit(int index) {
28 | setValue(BitMagic.setBit(getValue(), index, 0));
29 | }
30 |
31 | @Override
32 | public void toggleBit(int index) {
33 | setValue(BitMagic.toggleBit(getValue(), index));
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/io/mmap/ShortRegister.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.io.mmap;
2 |
3 | import org.bulldog.core.util.BitMagic;
4 |
5 | public class ShortRegister extends Register {
6 |
7 | public ShortRegister(MemoryMap map, long address) {
8 | super(map, address, Short.class);
9 | }
10 |
11 | @Override
12 | public void setValue(Short value) {
13 | getMemoryMap().setShortValue(getAddress(), value);
14 | }
15 |
16 | @Override
17 | public Short getValue() {
18 | return getMemoryMap().getShortValueAt(getAddress());
19 | }
20 |
21 | @Override
22 | public void setBit(int index) {
23 | setValue(BitMagic.setBit(getValue(), index, 1));
24 | }
25 |
26 | @Override
27 | public void clearBit(int index) {
28 | setValue(BitMagic.setBit(getValue(), index, 0));
29 | }
30 |
31 | @Override
32 | public void toggleBit(int index) {
33 | setValue(BitMagic.toggleBit(getValue(), index));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/actuators/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.actuators
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/gpio/BBBDigitalInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.gpio;
2 |
3 | import org.bulldog.beagleboneblack.BeagleBonePin;
4 | import org.bulldog.beagleboneblack.jni.NativeGpio;
5 | import org.bulldog.core.Signal;
6 | import org.bulldog.core.gpio.Pin;
7 | import org.bulldog.linux.gpio.LinuxDigitalInput;
8 |
9 | public class BBBDigitalInput extends LinuxDigitalInput {
10 |
11 | public BBBDigitalInput(Pin pin) {
12 | super(pin);
13 | }
14 |
15 | public Signal read() {
16 | BeagleBonePin bbbPin = (BeagleBonePin)getPin();
17 | return Signal.fromNumericValue(NativeGpio.digitalRead(bbbPin.getPortNumeric(), bbbPin.getIndexOnPort()));
18 | }
19 |
20 | public void setup() {
21 | super.setup();
22 | BeagleBonePin bbbPin = (BeagleBonePin)getPin();
23 | NativeGpio.pinMode(bbbPin.getPortNumeric(), bbbPin.getIndexOnPort(), NativeGpio.DIRECTION_IN);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/io/mmap/IntRegister.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.io.mmap;
2 |
3 | import org.bulldog.core.util.BitMagic;
4 |
5 | public class IntRegister extends Register {
6 |
7 | public IntRegister(MemoryMap map, long address) {
8 | super(map, address, Integer.class);
9 | }
10 |
11 | @Override
12 | public void setValue(Integer value) {
13 | getMemoryMap().setIntValue(getAddress(), value);
14 | }
15 |
16 | @Override
17 | public Integer getValue() {
18 | return getMemoryMap().getIntValueAt(getAddress());
19 | }
20 |
21 | @Override
22 | public void setBit(int index) {
23 | setValue(BitMagic.setBit(getValue(), index, 1));
24 | }
25 |
26 | @Override
27 | public void clearBit(int index) {
28 | setValue(BitMagic.setBit(getValue(), index, 0));
29 | }
30 |
31 | @Override
32 | public void toggleBit(int index) {
33 | setValue(BitMagic.toggleBit(getValue(), index));
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/sensors/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.sensors
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/IOPort.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.OutputStream;
6 |
7 | public interface IOPort {
8 |
9 | public String getName();
10 | public String getAlias();
11 | public void setAlias(String alias);
12 |
13 | public void open() throws IOException;
14 | public boolean isOpen();
15 | public void close() throws IOException;
16 |
17 | public void writeByte(int b) throws IOException;
18 | public void writeBytes(byte[] bytes) throws IOException;
19 | public void writeString(String string) throws IOException;
20 |
21 | public byte readByte() throws IOException;
22 | public int readBytes(byte[] buffer) throws IOException;
23 | public String readString() throws IOException;
24 |
25 | public OutputStream getOutputStream() throws IOException;
26 | public InputStream getInputStream() throws IOException;
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/pwmdriver/PCA9685Pwm.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.pwmdriver;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPwm;
5 |
6 | public class PCA9685Pwm extends AbstractPwm {
7 |
8 | private PCA9685 driver;
9 |
10 | public PCA9685Pwm(Pin pin, PCA9685 driver) {
11 | super(pin);
12 | this.driver = driver;
13 | }
14 |
15 | @Override
16 | protected void setupImpl() {
17 | }
18 |
19 | @Override
20 | protected void teardownImpl() {
21 | }
22 |
23 | @Override
24 | protected void setPwmImpl(double frequency, double duty) {
25 | driver.setFrequency(frequency);
26 | driver.setDuty(getPin().getAddress(), duty);
27 | }
28 |
29 | @Override
30 | protected void enableImpl() {
31 | driver.enableChannel(getPin().getAddress());
32 | }
33 |
34 | @Override
35 | protected void disableImpl() {
36 | driver.enableChannel(getPin().getAddress());
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/java/org/bulldog/cubieboard/CubieboardNames.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.cubieboard;
2 |
3 | public class CubieboardNames {
4 |
5 | // PB
6 | public static final String PB18 = "PB18";
7 |
8 | // PG
9 | public static final String PG0 = "PG0";
10 | public static final String PG1 = "PG1";
11 | public static final String PG2 = "PG2";
12 | // public static final String PG3 = "PG3";
13 | public static final String PG4 = "PG4";
14 | public static final String PG5 = "PG5";
15 | public static final String PG6 = "PG6";
16 | public static final String PG7 = "PG7";
17 | public static final String PG8 = "PG8";
18 | public static final String PG9 = "PG9";
19 | public static final String PG10 = "PG10";
20 | public static final String PG11 = "PG10";
21 |
22 | // PH
23 | public static final String PH14 = "PH14";
24 | public static final String PH15 = "PH15";
25 | public static final String PH20 = "PH20";
26 | }
27 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/actuators/movement/Sweep.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.actuators.movement;
2 |
3 | import org.bulldog.devices.actuators.Actuator;
4 |
5 |
6 | public class Sweep implements Move {
7 |
8 | private int durationMilliseconds;
9 |
10 | public Sweep(int durationMilliseconds) {
11 | this.durationMilliseconds = durationMilliseconds;
12 | }
13 |
14 | @Override
15 | public void execute(Actuator actuator) {
16 | double currentPosition = actuator.getPosition();
17 | double totalDistance = (180.0 - currentPosition) + 180.0;
18 |
19 | double timeFactorFirstMove = (180.0 - currentPosition) / totalDistance;
20 | double timeFactorSecondMove = 1.0 - timeFactorFirstMove;
21 |
22 | new LinearMove(180.0, (int)Math.round(durationMilliseconds * timeFactorFirstMove)).execute(actuator);
23 | new LinearMove(0.0, (int)Math.round(durationMilliseconds * timeFactorSecondMove)).execute(actuator);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/bulldog.build/src/main/resources/readme.txt:
--------------------------------------------------------------------------------
1 | ____ _
2 | | _ \ ___ __ _ __| |_ __ ___ ___
3 | | |_) / _ \/ _` |/ _` | '_ ` _ \ / _ \
4 | | _ < __/ (_| | (_| | | | | | | __/
5 | |_| \_\___|\__,_|\__,_|_| |_| |_|\___|
6 |
7 |
8 |
9 | Contents of this archive:
10 |
11 | * bulldog..jar
12 | the libbulldog jar for your board
13 |
14 | * libbulldog-linux.so
15 | the native binary for your linux distribution (libbulldog-linux.so)
16 |
17 | * license.txt
18 | licensing information for this software
19 |
20 | * readme.txt
21 | this file
22 |
23 |
24 | Installation:
25 |
26 | Just copy the native library and the jar to the place you want them to be.
27 | They must be in the same directory. Then, just use the jar in your project
28 | like you would use any other jar.
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/io/BBBI2cBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.io;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.io.bus.i2c.I2cSignalType;
5 | import org.bulldog.linux.io.LinuxI2cBus;
6 |
7 | public class BBBI2cBus extends LinuxI2cBus {
8 |
9 | private Pin sdaPin;
10 | private Pin sclPin;
11 | private int frequency;
12 |
13 | public BBBI2cBus(String name, String deviceFilePath, Pin sdaPin, Pin sclPin, int frequency) {
14 | super(name, deviceFilePath);
15 | this.sdaPin = sdaPin;
16 | this.sclPin = sclPin;
17 | sdaPin.addFeature(new BBBI2cPinFeature(this, sdaPin, I2cSignalType.SDA));
18 | sclPin.addFeature(new BBBI2cPinFeature(this, sclPin, I2cSignalType.SCL));
19 | }
20 |
21 | public Pin getSCL() {
22 | return sclPin;
23 | }
24 |
25 | public Pin getSDA() {
26 | return sdaPin;
27 | }
28 |
29 | @Override
30 | public int getFrequency() {
31 | return frequency;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/jni/NativePwm.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.jni;
2 |
3 | public class NativePwm {
4 |
5 | public static native int setup();
6 | public static native void teardown();
7 | public static native int setPwm(int pwmId, float frequency, float dutyA, float dutyB);
8 | public static native void enable(int pwmId);
9 | public static native void disable(int pwmId);
10 |
11 | private static boolean isInitialized = false;
12 |
13 | static {
14 | initialize();
15 | }
16 |
17 | public static void initialize() {
18 | if (isInitialized) {
19 | return;
20 | }
21 | setup();
22 | isInitialized = true;
23 | Runtime.getRuntime().addShutdownHook(new Thread() {
24 | @Override
25 | public void run() {
26 | deinitialize();
27 | }
28 | });
29 | }
30 |
31 | public static void deinitialize() {
32 | if (isInitialized) {
33 | teardown();
34 | isInitialized = false;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/beagleboneblack/devicetree/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.beagleboneblack.devicetree
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/bulldog.build/gradle.properties:
--------------------------------------------------------------------------------
1 | #org.gradle.java.home = C:/Program Files (x86)/Java/jdk1.7.0_40
2 | org.gradle.java.home = C:/Program Files/Java/jdk1.7.0_55
3 | org.gradle.jvmargs = -XX:MaxPermSize=128m
4 |
5 | systemProp.org.bulldog.gcc.arm.root = ../bulldog.tools/toolchains/linaro/bin
6 | systemProp.org.bulldog.gcc.arm.ccompiler = arm-linux-gnueabihf-gcc.exe
7 | systemProp.org.bulldog.gcc.arm.cppcompiler= arm-linux-gnueabihf-g++.exe
8 | systemProp.org.bulldog.gcc.arm.linker = arm-linux-gnueabihf-ld.exe
9 | systemProp.org.bulldog.gcc.arm.assembler = arm-linux-gnueabihf-as.exe
10 | systemProp.org.bulldog.gcc.arm.archiver = arm-linux-gnueabihf-ar.exe
11 | systemProp.org.bulldog.gcc.arm.includes = ../bulldog.tools/toolchains/linaro/arm-linux-gnueabihf/libc/usr/include
12 | systemProp.org.bulldog.jdk.arm.includes = ../bulldog.tools/jdk/jdk1.7.0_55_arm_softfp/include/
13 | systemProp.org.bulldog.jdk.arm.includes.linux = ../bulldog.tools/jdk/jdk1.7.0_55_arm_softfp/include/linux/
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/sysfs/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.sysfs
7 |
8 |
9 |
10 |
11 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/bulldog.examples/src/main/java/org/bulldog/examples/LedExample.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.examples;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.beagleboneblack.BBBNames;
6 | import org.bulldog.core.gpio.Pwm;
7 | import org.bulldog.core.platform.Board;
8 | import org.bulldog.core.platform.Platform;
9 | import org.bulldog.core.util.BulldogUtil;
10 | import org.bulldog.devices.led.Led;
11 |
12 | public class LedExample {
13 |
14 | public static void main(String... args) throws IOException {
15 |
16 | //Get your platform
17 | final Board board = Platform.createBoard();
18 |
19 | //Get a PWM
20 | Pwm pwm = board.getPin(BBBNames.PWM_P8_13).as(Pwm.class);
21 |
22 | //Construct the LED with it
23 | Led led = new Led(pwm);
24 |
25 | led.setBrightness(1.0);
26 | BulldogUtil.sleepMs(1000);
27 |
28 | led.setBrightness(0.5);
29 | BulldogUtil.sleepMs(1000);
30 |
31 | for(int i = 0; i < 5; i++) {
32 | led.fadeIn(1000);
33 | led.fadeOut(1000);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/util/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.util
7 |
8 |
9 |
10 |
11 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/platform/Board.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.platform;
2 |
3 | import java.util.List;
4 | import java.util.Properties;
5 |
6 | import org.bulldog.core.io.IOPort;
7 | import org.bulldog.core.io.bus.i2c.I2cBus;
8 | import org.bulldog.core.io.bus.spi.SpiBus;
9 | import org.bulldog.core.io.serial.SerialPort;
10 |
11 | public interface Board extends PinProvider {
12 |
13 | String getName();
14 |
15 | List getI2cBuses();
16 | I2cBus getI2cBus(String name);
17 |
18 | List getSpiBuses();
19 | SpiBus getSpiBus(String name);
20 |
21 | List getSerialPorts();
22 | SerialPort getSerialPort(String name);
23 |
24 | List getAllIOPorts();
25 | IOPort getIOPortByAlias(String alias);
26 | IOPort getIOPortByName(String name);
27 |
28 | Properties getProperties();
29 | void setProperty(String propertyName, String value);
30 | String getProperty(String propertyName);
31 | boolean hasProperty(String propertyName);
32 |
33 | void shutdown();
34 | }
35 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/gpio/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.gpio
7 |
8 |
9 |
10 |
11 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/util/Commands.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.util;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | public class Commands {
7 |
8 | public static String cat(String filename) {
9 | return shellExecute("cat", filename);
10 | }
11 |
12 | public static String shellExecute(String command, String... args) {
13 | ProcessBuilder cmd;
14 | String result = "";
15 |
16 | try {
17 | String[] processInfo = new String[args.length + 1];
18 | processInfo[0] = command;
19 | for(int i = 0; i < args.length; i++) {
20 | processInfo[i + 1] = args[i];
21 | }
22 | cmd = new ProcessBuilder(processInfo);
23 |
24 | Process process = cmd.start();
25 | InputStream in = process.getInputStream();
26 | byte[] re = new byte[1024];
27 | while (in.read(re) != -1) {
28 | result = result + new String(re);
29 | }
30 | in.close();
31 | } catch (IOException ex) {
32 | throw new RuntimeException(ex);
33 | }
34 |
35 | return result;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/beagleboneblack/sysfs/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.beagleboneblack.sysfs
7 |
8 |
9 |
10 |
11 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/gpio/BBBDigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.gpio;
2 |
3 | import org.bulldog.beagleboneblack.BeagleBonePin;
4 | import org.bulldog.beagleboneblack.jni.NativeGpio;
5 | import org.bulldog.core.Signal;
6 | import org.bulldog.core.gpio.Pin;
7 | import org.bulldog.core.gpio.base.AbstractDigitalOutput;
8 |
9 | public class BBBDigitalOutput extends AbstractDigitalOutput {
10 |
11 | public BBBDigitalOutput(Pin pin) {
12 | super(pin);
13 | }
14 |
15 | protected void setupImpl() {
16 | BeagleBonePin bbbPin = (BeagleBonePin)getPin();
17 | NativeGpio.pinMode(bbbPin.getPortNumeric(), bbbPin.getIndexOnPort(), NativeGpio.DIRECTION_OUT);
18 | applySignal(getAppliedSignal());
19 | }
20 |
21 | protected void teardownImpl() {
22 | }
23 |
24 | @Override
25 | protected void applySignalImpl(Signal signal) {
26 | BeagleBonePin bbbPin = (BeagleBonePin)getPin();
27 | NativeGpio.digitalWrite(bbbPin.getPortNumeric(), bbbPin.getIndexOnPort(), signal == Signal.High ? NativeGpio.HIGH : NativeGpio.LOW);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/portexpander/PCF8574DigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.portexpander;
2 |
3 | import org.bulldog.core.Signal;
4 | import org.bulldog.core.gpio.Pin;
5 | import org.bulldog.core.gpio.base.AbstractDigitalOutput;
6 | import org.bulldog.core.util.BitMagic;
7 |
8 | public class PCF8574DigitalOutput extends AbstractDigitalOutput {
9 |
10 | private PCF8574 expander;
11 |
12 | public PCF8574DigitalOutput(Pin pin, PCF8574 expander) {
13 | super(pin);
14 | this.expander = expander;
15 | }
16 |
17 | @Override
18 | protected void setupImpl() {
19 | }
20 |
21 | @Override
22 | protected void teardownImpl() {
23 | }
24 |
25 | @Override
26 | protected void applySignalImpl(Signal signal) {
27 | byte state = expander.getState();
28 | byte newState = BitMagic.setBit(state, getPin().getAddress(), signal.getNumericValue());
29 | expander.writeState(newState);
30 | }
31 |
32 | @Override
33 | public Signal getAppliedSignal() {
34 | return Signal.fromNumericValue(BitMagic.getBit(expander.getState(), getPin().getAddress()));
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/bulldog.examples/src/main/java/org/bulldog/examples/I2cExample.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.examples;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.beagleboneblack.BBBNames;
6 | import org.bulldog.core.io.bus.i2c.I2cBus;
7 | import org.bulldog.core.platform.Board;
8 | import org.bulldog.core.platform.Platform;
9 | import org.bulldog.core.util.BulldogUtil;
10 | import org.bulldog.devices.sensors.BH1750LightIntensitySensor;
11 |
12 | public class I2cExample {
13 |
14 | public static void main(String... args) throws IOException {
15 |
16 | //Get your platform
17 | final Board board = Platform.createBoard();
18 |
19 | I2cBus bus = board.getI2cBus(BBBNames.I2C_1);
20 |
21 | //Let's assume we have got a device on address xx
22 | BH1750LightIntensitySensor sensor = new BH1750LightIntensitySensor(bus, 0x23);
23 | sensor.initMode(BH1750LightIntensitySensor.MODE_HIGH_RES_05_LX_CONTINUOUS);
24 |
25 | while(true) {
26 | double luminosity = sensor.readLuminanceNormalized();
27 | System.out.println(luminosity + "[lx normalized]");
28 | BulldogUtil.sleepMs(100);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/util/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.util
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/gpio/PwmFrequencyCalculator.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi.gpio;
2 |
3 | public class PwmFrequencyCalculator {
4 |
5 | private static final double CLOCK_FREQUENCY = 19200000.0;
6 |
7 | public static int calculateDivisorRegister(double targetFrequency) {
8 |
9 | int minDivF = 1024;
10 | int currentDivreg = 0;
11 |
12 | for (int i = 1; i < 4096; i++) {
13 | boolean error = false;
14 | double frequency = targetFrequency * i;
15 |
16 | double divisor = CLOCK_FREQUENCY / frequency;
17 | int DIVI = (int) Math.floor(divisor);
18 | int DIVF = (int) Math.floor((divisor - DIVI) * 1024);
19 | int divreg = (0x5a << 24) | ((int) DIVI << 12) | (DIVF);
20 |
21 | if (Double.isNaN(DIVF) || Double.isInfinite(DIVI) || DIVI < 1 || DIVI > 4095) {
22 | error = true;
23 | }
24 |
25 | if(DIVF < minDivF && error == false) {
26 | currentDivreg = divreg;
27 | minDivF = DIVF;
28 | }
29 |
30 | if (DIVF == 0 && error == false) {
31 | return divreg;
32 | }
33 |
34 | }
35 |
36 | return currentDivreg;
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core
7 |
8 |
9 |
10 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/gpio/base/TestAbstractDigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.base;
2 |
3 | import junit.framework.TestCase;
4 |
5 | import org.bulldog.core.gpio.DigitalOutput;
6 | import org.bulldog.core.gpio.Pin;
7 | import org.bulldog.core.mocks.MockedDigitalOutput;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 |
11 | public class TestAbstractDigitalOutput {
12 |
13 | private Pin pin;
14 | private GpioTester gpioTester;
15 |
16 | @Before
17 | public void setup() {
18 | pin = new Pin("Testpin", 0, "A", 0);
19 | MockedDigitalOutput output = new MockedDigitalOutput(pin);
20 | pin.addFeature(output);
21 | gpioTester = new GpioTester();
22 | }
23 |
24 | @Test
25 | public void testOutput() {
26 | gpioTester.testOutput(pin.as(DigitalOutput.class));
27 | }
28 |
29 | @Test
30 | public void testName() {
31 | DigitalOutput output = pin.as(DigitalOutput.class);
32 | String name = output.getName();
33 | TestCase.assertNotNull(name);
34 | }
35 |
36 | @Test
37 | public void testBlinking() {
38 | gpioTester.testBlinking(pin.as(DigitalOutput.class));
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/gpio/util/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.gpio.util
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/gpio/LinuxDigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.gpio;
2 |
3 | import org.bulldog.core.Signal;
4 | import org.bulldog.core.gpio.Pin;
5 | import org.bulldog.core.gpio.base.AbstractDigitalOutput;
6 | import org.bulldog.linux.sysfs.SysFsPin;
7 |
8 | public class LinuxDigitalOutput extends AbstractDigitalOutput {
9 |
10 | private SysFsPin sysFsPin;
11 |
12 | public LinuxDigitalOutput(Pin pin) {
13 | super(pin);
14 | sysFsPin = createSysFsPin(pin);
15 | }
16 |
17 | protected SysFsPin createSysFsPin(Pin pin) {
18 | return new SysFsPin(pin.getAddress());
19 | }
20 |
21 | @Override
22 | protected void setupImpl() {
23 | exportPinIfNecessary();
24 | }
25 |
26 | @Override
27 | protected void teardownImpl() {
28 | unexportPin();
29 | }
30 |
31 | protected void exportPinIfNecessary() {
32 | sysFsPin.exportIfNecessary();
33 | sysFsPin.setDirection("out");
34 | }
35 |
36 | protected void unexportPin() {
37 | sysFsPin.unexport();
38 | }
39 |
40 | @Override
41 | protected void applySignalImpl(Signal signal) {
42 | sysFsPin.setValue(signal);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/bulldog.linux.native/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bulldog.linux.native
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
15 | clean,full,incremental,
16 |
17 |
18 |
19 |
20 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
21 | full,incremental,
22 |
23 |
24 |
25 |
26 |
27 | org.springsource.ide.eclipse.gradle.core.nature
28 | org.eclipse.jdt.core.javanature
29 | org.eclipse.cdt.core.cnature
30 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
31 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cConnection.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.core.io.bus.BusConnection;
6 |
7 | public class I2cConnection extends BusConnection {
8 |
9 | public I2cConnection(I2cBus bus, int address) {
10 | super(bus, address);
11 | }
12 |
13 | public byte readByteFromRegister(int register) throws IOException {
14 | writeByte((byte)register);
15 | return readByte();
16 | }
17 |
18 | public int readBytesFromRegister(int register, byte[] buffer) throws IOException {
19 | writeByte((byte)register);
20 | return readBytes(buffer);
21 | }
22 |
23 | public void writeByteToRegister(int register, int data) throws IOException {
24 | writeBytes(new byte[] { (byte)register, (byte)data });
25 | }
26 |
27 | public void writeBytesToRegister(int register, byte[] data) throws IOException {
28 | byte[] bytesToWrite = new byte[data.length + 1];
29 | bytesToWrite[0] = (byte)register;
30 | System.arraycopy(data, 0, bytesToWrite, 1, data.length);
31 | }
32 |
33 | public I2cBus getBus() {
34 | return (I2cBus)super.getBus();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativeMmap.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 | public class NativeMmap {
4 |
5 | public static final int NONE = 0x00;
6 | public static final int READ = 0x01;
7 | public static final int WRITE = 0x02;
8 | public static final int EXEC = 0x04;
9 |
10 | public static final int SHARED = 0x01;
11 | public static final int PRIVATE = 0x02;
12 |
13 | public static native long createMap(long address, long length, int protection, int flags, int fileDescriptor, long offset);
14 | public static native int deleteMap(long address, long length);
15 |
16 | public static native void setLongValueAt(long address, long value);
17 | public static native long getLongValueAt(long address);
18 |
19 | public static native void setIntValueAt(long address, int value);
20 | public static native int getIntValueAt(long address);
21 |
22 | public static native void setShortValueAt(long address, short value);
23 | public static native short getShortValueAt(long address);
24 |
25 | public static native void setByteValueAt(long address, byte value);
26 | public static native byte getByteValueAt(long address);
27 | }
28 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/motor/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.motor
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/sysfs/SysFsPwm.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.sysfs;
2 |
3 | import org.bulldog.core.Polarity;
4 |
5 |
6 | public class SysFsPwm {
7 |
8 | private BBBSysFs sysfsUtil = new BBBSysFs();
9 | private String directory = null;
10 | private int slot = -1;
11 |
12 | public SysFsPwm(String path, int slot) {
13 | this.directory = path;
14 | this.slot = slot;
15 | }
16 |
17 | public void setPeriod(long period) {
18 | sysfsUtil.echo(directory + "/period", String.valueOf(period));
19 | }
20 |
21 | public void setDuty(long duty) {
22 | sysfsUtil.echo(directory + "/duty", String.valueOf(duty));
23 | }
24 |
25 | public void setPolarity(Polarity polarity) {
26 | sysfsUtil.echo(directory + "/polarity", polarity == Polarity.Negative ? "0" : "1");
27 | }
28 |
29 | public void enable() {
30 | sysfsUtil.echo(directory + "/run", "1");
31 | }
32 |
33 | public void disable() {
34 | sysfsUtil.echo(directory + "/run", "0");
35 | }
36 |
37 | public int getSlot() {
38 | return slot;
39 | }
40 |
41 | public String getDirectory() {
42 | return directory;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativeSerial.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 | import java.nio.ByteBuffer;
4 |
5 | public class NativeSerial {
6 |
7 | public static final int SERIAL_BLOCK = 1;
8 | public static final int SERIAL_NO_BLOCK = 0;
9 | public static final int SERIAL_DEFAULT_TIMEOUT = 5;
10 | public static final int PARENB = 0000400;
11 | public static final int PARODD = 0001000;
12 | public static final int CMSPAR = 010000000000;
13 |
14 | public static native int serialOpen(String devicePath, int baud);
15 | public static native int serialOpen(String devicePath, int parity, int baud, boolean blocking, int readTimeout, int numDataBits, int numStopBits);
16 | public static native int serialClose(int fileDescriptor);
17 | public static native byte serialRead(int fileDescriptor);
18 | public static native int serialReadBuffer(int fileDescriptor, ByteBuffer buffer, int bufferSize);
19 | public static native int serialDataAvailable(int fileDescriptor);
20 | public static native int serialWrite(int fileDescriptor, byte data);
21 | public static native int serialWriteBuffer(int fileDescriptor, ByteBuffer buffer, int bufferSize);
22 | }
23 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/beagleboneblack/jni/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.beagleboneblack.jni
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/jni/org_bulldog_linux_jni_NativeTools.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class org_bulldog_linux_jni_NativeTools */
4 |
5 | #ifndef _Included_org_bulldog_linux_jni_NativeTools
6 | #define _Included_org_bulldog_linux_jni_NativeTools
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | /*
12 | * Class: org_bulldog_linux_jni_NativeTools
13 | * Method: getJavaDescriptor
14 | * Signature: (I)[Ljava/io/FileDescriptor
15 | */
16 | JNIEXPORT jobject JNICALL Java_org_bulldog_linux_jni_NativeTools_getJavaDescriptor
17 | (JNIEnv *, jclass, jint);
18 |
19 | /*
20 | * Class: org_bulldog_linux_jni_NativeTools
21 | * Method: open
22 | * Signature: (Ljava/lang/String;I)I
23 | */
24 | JNIEXPORT jint JNICALL Java_org_bulldog_linux_jni_NativeTools_open
25 | (JNIEnv *, jclass, jstring, jint);
26 |
27 | /*
28 | * Class: org_bulldog_linux_jni_NativeTools
29 | * Method: close
30 | * Signature: (I)I
31 | */
32 | JNIEXPORT jint JNICALL Java_org_bulldog_linux_jni_NativeTools_close
33 | (JNIEnv *, jclass, jint);
34 |
35 | #ifdef __cplusplus
36 | }
37 | #endif
38 | #endif
39 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/pwmdriver/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.pwmdriver
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/motor/AbstractStepper.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.motor;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 | import java.util.concurrent.Future;
6 |
7 | import org.bulldog.devices.actuators.movement.Move;
8 | import org.bulldog.devices.actuators.Actuator;
9 |
10 | public abstract class AbstractStepper implements Actuator {
11 |
12 | private ExecutorService executor = Executors.newSingleThreadExecutor();
13 | private Future> currentMove = null;
14 |
15 |
16 | public abstract void forward();
17 | public abstract void backward();
18 | public abstract void stop();
19 |
20 | public void move(Move move) {
21 | move.execute(this);
22 | }
23 |
24 | public void moveAsync(final Move move) {
25 | currentMove = executor.submit(new Runnable() {
26 |
27 | @Override
28 | public void run() {
29 | move(move);
30 | }
31 |
32 | });
33 | }
34 |
35 | public void awaitMoveCompleted() {
36 | if(currentMove != null) {
37 | try {
38 | currentMove.get();
39 | } catch (Exception e) {
40 | throw new RuntimeException(e);
41 | }
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/bulldog/bulldogSerial.h:
--------------------------------------------------------------------------------
1 | #ifndef BULLDOG_SERIAL_H
2 | #define BULLDOG_SERIAL_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | #define SERIAL_BLOCK 1
9 | #define SERIAL_NO_BLOCK 0
10 | #define SERIAL_DEFAULT_TIMEOUT 5
11 | #define SERIAL_DEFAULT_STOP_BITS 1
12 | #define SERIAL_DEFAULT_DATA_BITS 8
13 |
14 | extern int serialOpen(char* portname, int baud, int parity, int blocking, int readTimeout, int numDataBits, int numStopBits);
15 | extern int serialOpenSimple(char* portname, int baud);
16 | extern int serialClose(int fd);
17 |
18 | extern int serialWriteCharacter(int fileDescriptor, unsigned char data);
19 | extern int serialWriteBuffer(int fileDescriptor, char* data);
20 |
21 | extern int serialReadBuffer(int fileDescriptor, char* buffer, int bufferSize);
22 | extern unsigned char serialReadCharacter(int fileDescriptor);
23 | extern int serialDataAvailable(int fd);
24 |
25 | extern int serialSetAttributes(int fd, int speed, int parity, int readTimeout, int numDataBits, int numStopBits);
26 | extern void serialSetBlocking(int fd, int block, int readTimeout);
27 |
28 | #ifdef __cplusplus
29 | }
30 | #endif
31 |
32 | #endif
33 |
34 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/raspberrypi/io/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.raspberrypi.io
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/i2c/I2cDevice.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.i2c;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.core.io.bus.BusDevice;
6 |
7 | public class I2cDevice extends BusDevice {
8 |
9 | public I2cDevice(I2cConnection connection) {
10 | super(connection);
11 | }
12 |
13 | public I2cDevice(I2cBus bus, int address) {
14 | this(bus.createI2cConnection(address));
15 | }
16 |
17 | public byte readByteFromRegister(int register) throws IOException {
18 | return getBusConnection().readByteFromRegister(register);
19 | }
20 |
21 | public int readBytesFromRegister(int register, byte[] buffer) throws IOException {
22 | return getBusConnection().readBytesFromRegister(register, buffer);
23 | }
24 |
25 | public void writeByteToRegister(int register, int data) throws IOException {
26 | getBusConnection().writeByteToRegister(register, data);
27 | }
28 |
29 | public void writeBytesToRegister(int register, byte[] data) throws IOException {
30 | getBusConnection().writeBytesToRegister(register, data);
31 | }
32 |
33 | public I2cConnection getBusConnection() {
34 | return (I2cConnection)super.getBusConnection();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/io/bus/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.io.bus
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/portexpander/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.portexpander
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bulldog.examples/src/main/java/org/bulldog/examples/PinIOGroupExample.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.examples;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.beagleboneblack.BBBNames;
6 | import org.bulldog.core.gpio.DigitalIO;
7 | import org.bulldog.core.io.PinIOGroup;
8 | import org.bulldog.core.platform.Board;
9 | import org.bulldog.core.platform.Platform;
10 | import org.bulldog.core.util.BulldogUtil;
11 |
12 | public class PinIOGroupExample {
13 |
14 | public static void main(String[] args) throws IOException
15 | {
16 | //Grab the platform the application is running on
17 | Board board = Platform.createBoard();
18 |
19 | PinIOGroup ioGroup = new PinIOGroup(board.getPin(BBBNames.P8_15).as(DigitalIO.class),
20 | 100,
21 | board.getPin(BBBNames.P8_11).as(DigitalIO.class),
22 | board.getPin(BBBNames.P8_12).as(DigitalIO.class),
23 | board.getPin(BBBNames.P8_13).as(DigitalIO.class),
24 | board.getPin(BBBNames.P8_14).as(DigitalIO.class)
25 |
26 | );
27 |
28 | while(true) {
29 | for(int i = 0; i < 16; i++) {
30 | ioGroup.writeByte(i);
31 | }
32 | BulldogUtil.sleepMs(100);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/actuators/movement/LinearMove.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.actuators.movement;
2 |
3 | import org.bulldog.core.util.BulldogUtil;
4 | import org.bulldog.devices.actuators.Actuator;
5 |
6 | public class LinearMove implements Move {
7 |
8 | private double toPosition;
9 | private int milliseconds;
10 |
11 | public LinearMove(double toPosition, int milliseconds) {
12 | this.milliseconds = milliseconds;
13 | this.toPosition = toPosition;
14 | }
15 |
16 | @Override
17 | public void execute(Actuator actuator) {
18 | if(milliseconds <= 0) {
19 | new DirectMove(toPosition).execute(actuator);
20 | } else {
21 | double startPosition = actuator.getPosition();
22 | double delta = Math.abs(startPosition - toPosition);
23 | int amountSteps = (int)(milliseconds / actuator.getRefreshIntervalMilliseconds());
24 | double stepSize = delta / amountSteps;
25 | for(int i = 0; i < amountSteps; i++) {
26 | if(startPosition < toPosition) {
27 | actuator.setPosition(actuator.getPosition() + stepSize);
28 | } else {
29 | actuator.setPosition(actuator.getPosition()- stepSize);
30 | }
31 | BulldogUtil.sleepMs(actuator.getRefreshIntervalMilliseconds());
32 | }
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/gpio/RaspiDigitalOutput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi.gpio;
2 |
3 | import org.bulldog.core.Signal;
4 | import org.bulldog.core.gpio.Pin;
5 | import org.bulldog.core.gpio.base.AbstractDigitalOutput;
6 | import org.bulldog.raspberrypi.BCM2835;
7 | import org.bulldog.raspberrypi.RaspberryPiPin;
8 |
9 | public class RaspiDigitalOutput extends AbstractDigitalOutput {
10 |
11 | public RaspiDigitalOutput(Pin pin) {
12 | super(pin);
13 | }
14 |
15 | @Override
16 | protected void setupImpl() {
17 | RaspberryPiPin pin = (RaspberryPiPin)getPin();
18 | BCM2835.configureAsInput(pin.getGpioNumber());
19 | BCM2835.configureAsOutput(pin.getGpioNumber());
20 | }
21 |
22 |
23 | @Override
24 | protected void teardownImpl() {
25 |
26 | }
27 |
28 | @Override
29 | protected void applySignalImpl(Signal signal) {
30 | int value = 1 << getRaspberryPiPin().getGpioNumber();
31 | if(signal == Signal.High) {
32 | BCM2835.getGpioMemory().setIntValue(BCM2835.GPIO_SET, value);
33 | } else {
34 | BCM2835.getGpioMemory().setIntValue(BCM2835.GPIO_CLEAR, value);
35 | }
36 | }
37 |
38 | private RaspberryPiPin getRaspberryPiPin() {
39 | RaspberryPiPin pin = (RaspberryPiPin)getPin();
40 | return pin;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/io/serial/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.io.serial
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
18 |
Classes
19 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedPwm.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.base.AbstractPwm;
5 |
6 | public class MockedPwm extends AbstractPwm {
7 |
8 | private boolean enableImplCalled = false;
9 | private boolean disableImplCalled = false;
10 | private boolean pwmImplCalled = false;
11 |
12 | public MockedPwm(Pin pin) {
13 | super(pin);
14 | }
15 |
16 | @Override
17 | protected void setupImpl() {
18 | }
19 |
20 | @Override
21 | protected void teardownImpl() {
22 | }
23 |
24 | @Override
25 | protected void setPwmImpl(double frequency, double duty) {
26 | pwmImplCalled = true;
27 | }
28 |
29 | public boolean pwmImplCalled() {
30 | return pwmImplCalled;
31 | }
32 |
33 | @Override
34 | protected void enableImpl() {
35 | enableImplCalled = true;
36 | }
37 |
38 | public boolean enableImplCalled() {
39 | return enableImplCalled;
40 | }
41 |
42 | @Override
43 | protected void disableImpl() {
44 | disableImplCalled = true;
45 | }
46 |
47 | public boolean disableImplCalled() {
48 | return disableImplCalled;
49 | }
50 |
51 | public void reset() {
52 | disableImplCalled = false;
53 | enableImplCalled = false;
54 | pwmImplCalled = false;
55 | }
56 |
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/io/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.io
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/raspberrypi/gpio/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.raspberrypi.gpio
7 |
8 |
9 |
10 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/package-list:
--------------------------------------------------------------------------------
1 | org.bulldog.beagleboneblack
2 | org.bulldog.beagleboneblack.devicetree
3 | org.bulldog.beagleboneblack.gpio
4 | org.bulldog.beagleboneblack.io
5 | org.bulldog.beagleboneblack.jni
6 | org.bulldog.beagleboneblack.sysfs
7 | org.bulldog.core
8 | org.bulldog.core.gpio
9 | org.bulldog.core.gpio.base
10 | org.bulldog.core.gpio.event
11 | org.bulldog.core.gpio.util
12 | org.bulldog.core.io
13 | org.bulldog.core.io.bus
14 | org.bulldog.core.io.bus.i2c
15 | org.bulldog.core.io.bus.spi
16 | org.bulldog.core.io.serial
17 | org.bulldog.core.io.uart
18 | org.bulldog.core.platform
19 | org.bulldog.core.util
20 | org.bulldog.core.util.easing
21 | org.bulldog.devices.actuators
22 | org.bulldog.devices.actuators.movement
23 | org.bulldog.devices.dac
24 | org.bulldog.devices.lcd
25 | org.bulldog.devices.led
26 | org.bulldog.devices.motor
27 | org.bulldog.devices.portexpander
28 | org.bulldog.devices.pwmdriver
29 | org.bulldog.devices.sensors
30 | org.bulldog.devices.servo
31 | org.bulldog.devices.switches
32 | org.bulldog.examples
33 | org.bulldog.linux.gpio
34 | org.bulldog.linux.io
35 | org.bulldog.linux.io.mmap
36 | org.bulldog.linux.jni
37 | org.bulldog.linux.sysfs
38 | org.bulldog.linux.sysinfo
39 | org.bulldog.linux.util
40 | org.bulldog.raspberrypi
41 | org.bulldog.raspberrypi.gpio
42 | org.bulldog.raspberrypi.io
43 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/jni/NativeEpoll.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.jni;
2 |
3 | public class NativeEpoll {
4 |
5 | public static final int EPOLLIN = 0x001;
6 | public static final int EPOLLPRI = 0x002;
7 | public static final int EPOLLOUT = 0x004;
8 | public static final int EPOLLRDNORM = 0x040;
9 | public static final int EPOLLRDBAND = 0x080;
10 | public static final int EPOLLWRNORM = 0x100;
11 | public static final int EPOLLWRBAND = 0x200;
12 | public static final int EPOLLMSG = 0x400;
13 | public static final int EPOLLERR = 0x008;
14 | public static final int EPOLLHUP = 0x010;
15 | public static final int EPOLLRDHUP = 0x2000;
16 | public static final int EPOLLWAKEUP = 1 << 29;
17 | public static final int EPOLLONESHOT = 1 << 30;
18 | public static final int EPOLLET = 1 << 31;
19 | public static final int EPOLL_CTL_ADD = 1;
20 | public static final int EPOLL_CTL_DEL = 2;
21 | public static final int EPOLL_CTL_MOD = 3;
22 |
23 | public static native int epollCreate();
24 | public static native int addFile(int epfd, int opcode, String filename, int events);
25 | public static native int removeFile(int epfd, int fd);
26 | public static native NativePollResult[] waitForInterrupt(int epfd);
27 | public static native void stopWait(int epfd);
28 | public static native void shutdown(int epfd);
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/servo/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.servo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/raspberrypi/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.raspberrypi
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedAnalogInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import java.util.concurrent.Future;
4 |
5 | import org.bulldog.core.gpio.Pin;
6 | import org.bulldog.core.gpio.base.AbstractAnalogInput;
7 |
8 | public class MockedAnalogInput extends AbstractAnalogInput {
9 |
10 | private double value;
11 | private double[] samples;
12 |
13 | public MockedAnalogInput(Pin pin) {
14 | super(pin);
15 | }
16 |
17 | public void setValueToRead(double value) {
18 | this.value = value;
19 | }
20 |
21 | public void setSamples(double[] samples) {
22 | this.samples = samples;
23 | }
24 |
25 | @Override
26 | public double read() {
27 | return value;
28 | }
29 |
30 | @Override
31 | public double[] sample(int amountSamples) {
32 | return samples;
33 | }
34 |
35 | @Override
36 | public double[] sample(int amountSamples, float frequency) {
37 | return samples;
38 | }
39 |
40 | @Override
41 | public Future sampleAsync(int amountSamples) {
42 | // TODO Auto-generated method stub
43 | return null;
44 | }
45 |
46 | @Override
47 | public Future sampleAsync(int amountSamples, float frequency) {
48 | // TODO Auto-generated method stub
49 | return null;
50 | }
51 |
52 | @Override
53 | protected void setupImpl() {
54 | }
55 |
56 | @Override
57 | protected void teardownImpl() {
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/bulldog.board.raspberrypi/src/main/java/org/bulldog/raspberrypi/RaspiNames.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.raspberrypi;
2 |
3 | public class RaspiNames {
4 |
5 | public static final String P1_3 = "P1_3";
6 | public static final String P1_5 = "P1_5";
7 | public static final String P1_7 = "P1_7";
8 | public static final String P1_8 = "P1_8";
9 | public static final String P1_10 = "P1_10";
10 | public static final String P1_11 = "P1_11";
11 | public static final String P1_12 = "P1_12";
12 | public static final String P1_13 = "P1_13";
13 | public static final String P1_15 = "P1_15";
14 | public static final String P1_16 = "P1_16";
15 | public static final String P1_18 = "P1_18";
16 | public static final String P1_19 = "P1_19";
17 | public static final String P1_21 = "P1_21";
18 | public static final String P1_22 = "P1_22";
19 | public static final String P1_23 = "P1_23";
20 | public static final String P1_24 = "P1_24";
21 | public static final String P1_26 = "P1_26";
22 |
23 | public static final String P5_3 = "P5_3";
24 | public static final String P5_4 = "P5_4";
25 | public static final String P5_5 = "P5_5";
26 | public static final String P5_6 = "P5_6";
27 |
28 | public static final String PWM_PIN = P1_12;
29 |
30 | public static final String I2C_0 = "I2C_0";
31 | public static final String SPI_0_CS0 = "SPI_0_0";
32 | public static final String SPI_0_CS1 = "SPI_0_1";
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/gpio/base/TestAbstractDigitalInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.base;
2 |
3 | import junit.framework.TestCase;
4 |
5 | import org.bulldog.core.gpio.DigitalInput;
6 | import org.bulldog.core.gpio.Pin;
7 | import org.bulldog.core.mocks.MockedDigitalInput;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 |
11 | public class TestAbstractDigitalInput {
12 |
13 | private Pin pin;
14 | private MockedDigitalInput mock;
15 | private GpioTester gpioTester;
16 |
17 | @Before
18 | public void setup() {
19 | pin = new Pin("Testpin", 0, "A", 0);
20 | mock = new MockedDigitalInput(pin);
21 | pin.addFeature(mock);
22 | gpioTester = new GpioTester();
23 | }
24 |
25 | @Test
26 | public void testRead() {
27 | gpioTester.testRead(pin.as(DigitalInput.class), mock);
28 | }
29 |
30 | @Test
31 | public void testReadDebounced() {
32 | gpioTester.testReadDebounced(pin.as(DigitalInput.class), mock);
33 | }
34 |
35 | @Test
36 | public void testInterruptTrigger() {
37 | gpioTester.testInterruptTrigger(pin.as(DigitalInput.class));
38 | }
39 |
40 | @Test
41 | public void testInterrupts() {
42 | gpioTester.testInterrupts(pin.as(DigitalInput.class));
43 | }
44 |
45 | @Test
46 | public void testName() {
47 | DigitalInput input = pin.as(DigitalInput.class);
48 | TestCase.assertNotNull(input.getName());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/bulldog.examples/src/main/java/org/bulldog/examples/ButtonExample.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.examples;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.beagleboneblack.BBBNames;
6 | import org.bulldog.core.Signal;
7 | import org.bulldog.core.gpio.DigitalInput;
8 | import org.bulldog.core.platform.Board;
9 | import org.bulldog.core.platform.Platform;
10 | import org.bulldog.core.util.BulldogUtil;
11 | import org.bulldog.devices.switches.Button;
12 | import org.bulldog.devices.switches.ButtonListener;
13 |
14 | public class ButtonExample {
15 |
16 | public static void main(String[] args) throws IOException
17 | {
18 | //Grab the platform the application is running on
19 | Board board = Platform.createBoard();
20 |
21 | //Set up a digital input
22 | DigitalInput buttonSignal = board.getPin(BBBNames.P8_12).as(DigitalInput.class);
23 |
24 | //Create the button with this DigitalInput
25 | Button button = new Button(buttonSignal, Signal.Low);
26 |
27 | //Add a button listener
28 | button.addListener(new ButtonListener() {
29 |
30 | public void buttonPressed() {
31 | System.out.println("PRESSED");
32 | }
33 |
34 | public void buttonReleased() {
35 | System.out.println("RELEASED");
36 | }
37 |
38 | });
39 |
40 | while(true) {
41 | BulldogUtil.sleepMs(50);
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/bulldog.board.cubieboard/src/main/java/org/bulldog/cubieboard/gpio/CubieboardDigitalInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.cubieboard.gpio;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.event.InterruptListener;
5 | import org.bulldog.cubieboard.CubieboardPin;
6 | import org.bulldog.linux.gpio.LinuxDigitalInput;
7 | import org.bulldog.linux.io.LinuxEpollListener;
8 | import org.bulldog.linux.sysfs.SysFsPin;
9 |
10 | public class CubieboardDigitalInput extends LinuxDigitalInput implements LinuxEpollListener {
11 |
12 | public CubieboardDigitalInput(Pin pin) {
13 | super(pin);
14 | }
15 |
16 | @Override
17 | protected SysFsPin createSysFsPin(Pin pin) {
18 | return new CubieboardSysFsPin(pin.getAddress(), ((CubieboardPin)pin).getFsName(), ((CubieboardPin)pin).isInterrupt());
19 | }
20 |
21 | @Override
22 | public void addInterruptListener(InterruptListener listener) {
23 | checkInterruptsAllowed();
24 | super.addInterruptListener(listener);
25 | }
26 |
27 | @Override
28 | public void enableInterrupts() {
29 | checkInterruptsAllowed();
30 | super.enableInterrupts();
31 | }
32 |
33 | private void checkInterruptsAllowed() {
34 | if (!((CubieboardPin)getPin()).isInterrupt())
35 | throw new RuntimeException("Pin " + getName() + " is not connected to interrupt controller");
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/jni/NativeGpio.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.jni;
2 |
3 | public class NativeGpio {
4 |
5 | public static final int DIRECTION_OUT = 1;
6 | public static final int DIRECTION_IN = 0;
7 |
8 | public static final int HIGH = 1;
9 | public static final int LOW = 0;
10 |
11 | public static native boolean setup();
12 | public static native boolean teardown();
13 | public static native void pinMode(int port, int pin, int direction);
14 | public static native int digitalRead(int port, int pin);
15 | public static native void digitalWrite(int port, int pin, int state);
16 | public static native void enableGpio();
17 | //public static native int debouncePin(int port, int pin, int ms);
18 |
19 | private static boolean isInitialized = false;
20 |
21 | static {
22 | initialize();
23 | }
24 |
25 | public static int getBank(int pin) {
26 | return (int) (pin / 32);
27 | }
28 |
29 | public static void initialize() {
30 | if (isInitialized) {
31 | return;
32 | }
33 | setup();
34 | enableGpio();
35 | isInitialized = true;
36 | Runtime.getRuntime().addShutdownHook(new Thread() {
37 | @Override
38 | public void run() {
39 | deinitialize();
40 | }
41 | });
42 |
43 | }
44 |
45 | public static void deinitialize() {
46 | if (isInitialized) {
47 | teardown();
48 | isInitialized = false;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/beagleboneblack/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.beagleboneblack
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/switches/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.switches
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
18 |
Classes
19 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/beagleboneblack/io/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.beagleboneblack.io
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/devicetree/DeviceTreeCompiler.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.devicetree;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.PrintWriter;
7 |
8 | public class DeviceTreeCompiler {
9 |
10 | private static final String FIRMWARE_PATH = "/lib/firmware/";
11 | private static final String OBJECT_FILE_PATTERN = "%s%s.dtbo";
12 | private static final String DEFINITION_FILE_PATTERN = "%s%s.dts";
13 | private static final String COMPILER_CALL = "dtc -O dtb -o %s -b 0 -@ %s";
14 |
15 | public static void compileOverlay(String overlay, String deviceName) throws IOException, InterruptedException {
16 | String objectFile = String.format(OBJECT_FILE_PATTERN, FIRMWARE_PATH, deviceName);
17 | String overlayFile = String.format(DEFINITION_FILE_PATTERN, FIRMWARE_PATH, deviceName);
18 |
19 | File file = new File(overlayFile);
20 | FileOutputStream outputStream = new FileOutputStream(file);
21 | PrintWriter writer = new PrintWriter(outputStream);
22 | writer.write(overlay);
23 | writer.close();
24 |
25 | Process compile = Runtime.getRuntime().exec(String.format(COMPILER_CALL, objectFile, overlayFile));
26 | int code = compile.waitFor();
27 | if(code > 0) {
28 | throw new RuntimeException("Device Tree Overlay compilation failed: " + overlayFile + " could not be compiled");
29 | }
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/devicetree/resources/pwm.dts.template:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 CircuitCo
3 | * Copyright (C) 2013 Texas Instruments
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License version 2 as
7 | * published by the Free Software Foundation.
8 | */
9 | /dts-v1/;
10 | /plugin/;
11 |
12 | / {
13 | compatible = "ti,beaglebone", "ti,beaglebone-black";
14 |
15 | /* identification */
16 | part-number = "bd_pwm_${pin_name}";
17 | version = "${version}";
18 |
19 | /* state the resources this cape uses */
20 | exclusive-use =
21 | /* the pin header uses */
22 | "${pin_name_dotted}",
23 | /* the hardware IP uses */
24 | "${pwm_name}${qualifier}";
25 |
26 | fragment@0 {
27 | target = <&am33xx_pinmux>;
28 | __overlay__ {
29 | pwm_${pin_name}: pinmux_pwm_${pin_name}_pins {
30 | pinctrl-single,pins = <${pin_address} ${mux_mode}>;
31 | };
32 | };
33 | };
34 |
35 | fragment@1 {
36 | target = <&ocp>;
37 | __overlay__ {
38 | pwm_test_${pin_name} {
39 | compatible = "pwm_test";
40 | pwms = <&${pwm_name} ${channel} ${period} ${polarity}>;
41 | pwm-names = "PWM_${pin_name}";
42 | pinctrl-names = "default";
43 | pinctrl-0 = <&pwm_${pin_name}>;
44 | enabled = <0>;
45 | duty = <0>;
46 | status = "okay";
47 | };
48 | };
49 | };
50 | };
51 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/base/AbstractPinFeature.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.base;
2 |
3 | import org.bulldog.core.gpio.Pin;
4 | import org.bulldog.core.gpio.PinFeature;
5 |
6 | public abstract class AbstractPinFeature implements PinFeature {
7 |
8 | private Pin pin;
9 | private boolean isSetup = false;
10 |
11 | public AbstractPinFeature(Pin pin) {
12 | this.pin = pin;
13 | }
14 |
15 | public Pin getPin() {
16 | return pin;
17 | }
18 |
19 | public boolean isActivatedFeature() {
20 | return this.getPin().getActiveFeature() == this;
21 | }
22 |
23 | public void activate() {
24 | getPin().activateFeature(getClass());
25 | }
26 |
27 | public void blockPin() {
28 | pin.block(this);
29 | }
30 |
31 | public boolean isBlocking() {
32 | return pin.getBlocker() == this;
33 | }
34 |
35 | public void unblockPin() {
36 | getPin().unblock(this);
37 | }
38 |
39 | protected abstract void setupImpl();
40 | protected abstract void teardownImpl();
41 |
42 | public void setup() {
43 | setupImpl();
44 | isSetup = true;
45 | }
46 |
47 | public void teardown() {
48 | teardownImpl();
49 | isSetup = false;
50 | }
51 |
52 | public boolean isSetup() {
53 | return isSetup;
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | String string = this.getName();
59 | if(string == null) {
60 | string = super.toString();
61 | }
62 |
63 | return string;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedI2cBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.core.gpio.Pin;
6 | import org.bulldog.core.io.bus.i2c.I2cBus;
7 | import org.bulldog.core.io.bus.i2c.I2cConnection;
8 |
9 | public class MockedI2cBus extends MockedBus implements I2cBus {
10 |
11 | public MockedI2cBus(String name) {
12 | super(name);
13 | }
14 |
15 | public Pin getSDA() {
16 | return null;
17 | }
18 |
19 | public Pin getSCL() {
20 | return null;
21 | }
22 |
23 | @Override
24 | public int getFrequency() {
25 | return 0;
26 | }
27 |
28 | @Override
29 | public void writeByteToRegister(int register, int b) throws IOException {
30 | // TODO Auto-generated method stub
31 |
32 | }
33 |
34 | @Override
35 | public void writeBytesToRegister(int register, byte[] bytes)
36 | throws IOException {
37 | // TODO Auto-generated method stub
38 |
39 | }
40 |
41 | @Override
42 | public byte readByteFromRegister(int register) throws IOException {
43 | // TODO Auto-generated method stub
44 | return 0;
45 | }
46 |
47 | @Override
48 | public int readBytesFromRegister(int register, byte[] buffer)
49 | throws IOException {
50 | // TODO Auto-generated method stub
51 | return 0;
52 | }
53 |
54 | @Override
55 | public I2cConnection createI2cConnection(int address) {
56 | // TODO Auto-generated method stub
57 | return null;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedSerialPort.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.Parity;
4 | import org.bulldog.core.io.serial.SerialDataListener;
5 | import org.bulldog.core.io.serial.SerialPort;
6 |
7 | public class MockedSerialPort extends MockedIOPort implements SerialPort {
8 |
9 | public MockedSerialPort(String name) {
10 | super(name);
11 | }
12 |
13 | @Override
14 | public int getBaudRate() {
15 | return 0;
16 | }
17 |
18 | @Override
19 | public void setBaudRate(int baudRate) {
20 | }
21 |
22 | @Override
23 | public Parity getParity() {
24 | return null;
25 | }
26 |
27 | @Override
28 | public void setParity(Parity parity) {
29 | }
30 |
31 | @Override
32 | public void setBlocking(boolean blocking) {
33 | }
34 |
35 | @Override
36 | public boolean getBlocking() {
37 | return false;
38 | }
39 |
40 | @Override
41 | public void addListener(SerialDataListener listener) {
42 | }
43 |
44 | @Override
45 | public void removeListener(SerialDataListener listener) {
46 | }
47 |
48 | @Override
49 | public int getDataBits() {
50 | return 0;
51 | }
52 |
53 | @Override
54 | public void setDataBits(int dataBits) {
55 | }
56 |
57 | @Override
58 | public int getStopBits() {
59 | // TODO Auto-generated method stub
60 | return 0;
61 | }
62 |
63 | @Override
64 | public void setStopBits(int stopBits) {
65 | // TODO Auto-generated method stub
66 |
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/lcd/LcdMode.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.lcd;
2 |
3 | public enum LcdMode {
4 |
5 | Display1x8 (1, 8, 0x00, 0x07),
6 | Display1x16(1, 16, 0x00, 0x0F),
7 | Display1x20(1, 20, 0x00, 0x13),
8 | Display1x40(1, 40, 0x00, 0x27),
9 | Display2x8 (2, 8, 0x00, 0x07, 0x40, 0x47),
10 | Display2x12(2, 12, 0x00, 0x0b, 0x40, 0x4b),
11 | Display2x16(2, 16, 0x00, 0x0f, 0x40, 0x4f),
12 | Display2x20(2, 20, 0x00, 0x13, 0x40, 0x53),
13 | Display2x24(2, 24, 0x00, 0x17, 0x40, 0x57),
14 | Display2x40(2, 40, 0x00, 0x27, 0x40, 0x67),
15 | Display4x16(4, 16, 0x00, 0x0F, 0x40, 0x4f, 0x10, 0x1f, 0x50, 0x5f),
16 | Display4x20(4, 20, 0x00, 0x13, 0x40, 0x53, 0x14, 0x27, 0x54, 0x67);
17 |
18 |
19 | private int[] memoryOffsets;
20 | private int rows;
21 | private int columns;
22 |
23 | private LcdMode(int rows, int cols, int... memoryOffsets) {
24 | this.memoryOffsets = memoryOffsets;
25 | this.rows = rows;
26 | this.columns = cols;
27 | }
28 |
29 | public int getRows() {
30 | return rows;
31 | }
32 |
33 | public int getColumns() {
34 | return columns;
35 | }
36 |
37 | public int getMemoryOffset(int row, int column) {
38 | if(column >= getColumns()) {
39 | throw new RuntimeException("Illegal column value specified");
40 | }
41 |
42 | if(row >= getRows()) {
43 | throw new RuntimeException("Illegal row value specified");
44 | }
45 |
46 | return memoryOffsets[row*2] + column;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/jni/org_bulldog_linux_jni_NativeSpi.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class org_bulldog_linux_jni_NativeSpi */
4 |
5 | #ifndef _Included_org_bulldog_linux_jni_NativeSpi
6 | #define _Included_org_bulldog_linux_jni_NativeSpi
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: org_bulldog_linux_jni_NativeSpi
12 | * Method: spiOpen
13 | * Signature: (Ljava/lang/String;III)I
14 | */
15 | JNIEXPORT jint JNICALL Java_org_bulldog_linux_jni_NativeSpi_spiOpen
16 | (JNIEnv *, jclass, jstring, jint, jint, jint, jboolean);
17 |
18 |
19 | /*
20 | * Class: org_bulldog_linux_jni_NativeSpi
21 | * Method: spiOpen
22 | * Signature: (Ljava/lang/String;III)I
23 | */
24 | JNIEXPORT jint JNICALL Java_org_bulldog_linux_jni_NativeSpi_spiConfig
25 | (JNIEnv *, jclass, jint, jint, jint, jint, jboolean);
26 |
27 | /*
28 | * Class: org_bulldog_linux_jni_NativeSpi
29 | * Method: spiClose
30 | * Signature: (I)I
31 | */
32 | JNIEXPORT jint JNICALL Java_org_bulldog_linux_jni_NativeSpi_spiClose
33 | (JNIEnv *, jclass, jint);
34 |
35 | /*
36 | * Class: org_bulldog_linux_jni_NativeSpi
37 | * Method: spiTransfer
38 | * Signature: (IJJIIII)I
39 | */
40 | JNIEXPORT jint JNICALL Java_org_bulldog_linux_jni_NativeSpi_spiTransfer
41 | (JNIEnv *, jclass, jint, jobject, jobject, jint, jint, jint, jint);
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif
47 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/io/bus/spi/SpiBus.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.io.bus.spi;
2 |
3 | import java.io.IOException;
4 | import java.util.List;
5 |
6 | import org.bulldog.core.gpio.DigitalOutput;
7 | import org.bulldog.core.gpio.Pin;
8 | import org.bulldog.core.io.bus.Bus;
9 |
10 |
11 | public interface SpiBus extends Bus {
12 |
13 | Pin getMISO();
14 | Pin getMOSI();
15 | Pin getSCLK();
16 | List getSlaveSelectPins();
17 |
18 | int getSpeedInHz();
19 | void setSpeedInHz(int hz);
20 |
21 | void setBitsPerWord(int bpw);
22 | int getBitsPerWord();
23 |
24 | void setDelayMicroseconds(int delay);
25 | int getDelayMicroseconds();
26 |
27 | void setMode(SpiMode mode);
28 | SpiMode getMode();
29 |
30 | void useLeastSignificantBitFirst();
31 | void useMostSignificantBitFirst();
32 | boolean isLSBUsed();
33 | boolean isMSBUsed();
34 |
35 | void selectSlave(DigitalOutput chipSelect);
36 | void selectSlaves(DigitalOutput... chipSelects);
37 | void selectSlaves(Integer... chipSelectAddresses);
38 |
39 | SpiConnection createSpiConnection();
40 | SpiConnection createSpiConnection(int chipSelectAddress);
41 | SpiConnection createSpiConnection(DigitalOutput chipSelect);
42 | SpiConnection createSpiConnection(DigitalOutput... chipSelects);
43 | SpiConnection createSpiConnection(int...chipSelectAddress);
44 |
45 | void broadcast(byte[] bytes, DigitalOutput... chipSelects) throws IOException;
46 | SpiMessage transfer(byte[] buffer);
47 | }
48 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/io/mmap/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.io.mmap
7 |
8 |
9 |
10 |
11 |
12 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/linux/bulldog/bulldogI2c.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "bulldogI2c.h"
10 | #include "bulldog.h"
11 |
12 | unsigned char i2cRead(int fileDescriptor) {
13 | char buffer;
14 | if(read(fileDescriptor, &buffer, 1) < 0) {
15 | errorMessage("read failed: %s", strerror(errno));
16 | }
17 | return buffer;
18 | }
19 |
20 | int i2cWrite(int fileDescriptor, unsigned char data) {
21 | int bytesWritten = write(fileDescriptor, &data, 1);
22 | if(bytesWritten < 0) {
23 | errorMessage("error %d writing byte via i2c: %s", errno, strerror(errno));
24 | }
25 | return bytesWritten;
26 | }
27 |
28 | int i2cWriteBuffer(int fileDescriptor, char* data) {
29 | int bytesWritten = write(fileDescriptor, data, strlen(data));
30 | if(bytesWritten < 0) {
31 | errorMessage("error %d writing byte via i2c: %s", errno, strerror(errno));
32 | }
33 | return bytesWritten;
34 | }
35 |
36 | int i2cSelectSlave(int fd, int slaveAddress) {
37 | if (ioctl (fd, I2C_SLAVE, slaveAddress) < 0) {
38 | return -1 ;
39 | }
40 |
41 | return fd;
42 | }
43 |
44 | int i2cOpen(char* busDevice) {
45 | int fd;
46 | if ((fd = open (busDevice, O_RDWR)) < 0) {
47 | errorMessage("open failed: %s", strerror(errno));
48 | return -1 ;
49 | }
50 |
51 | return fd;
52 | }
53 |
54 | int i2cClose(int fileDescriptor) {
55 | return close(fileDescriptor);
56 | }
57 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/actuators/movement/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.actuators.movement
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/bulldog.linux/src/main/java/org/bulldog/linux/io/mmap/Register.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.linux.io.mmap;
2 |
3 | public abstract class Register {
4 |
5 | private MemoryMap map;
6 | private long address;
7 | private Class clazz;
8 |
9 | public Register(MemoryMap map, long address, Class clazz) {
10 | this.map = map;
11 | this.address = address;
12 | this.clazz = clazz;
13 | }
14 |
15 | public abstract void setValue(T value);
16 | public abstract T getValue();
17 | public abstract void setBit(int index);
18 | public abstract void clearBit(int index);
19 | public abstract void toggleBit(int index);
20 |
21 | public Class getContentClass() {
22 | return clazz;
23 | }
24 |
25 | public MemoryMap getMemoryMap() {
26 | return map;
27 | }
28 |
29 | public long getAddress() {
30 | return address;
31 | }
32 |
33 | @SuppressWarnings("unchecked")
34 | public void xor(T val) {
35 | long currentValue = getValue().longValue();
36 | currentValue ^= val.longValue();
37 | this.setValue((T) val.getClass().cast(currentValue));
38 | }
39 |
40 | @SuppressWarnings("unchecked")
41 | public void or(T val) {
42 | long currentValue = getValue().longValue();
43 | currentValue |= val.longValue();
44 | this.setValue((T) val.getClass().cast(currentValue));
45 | }
46 |
47 | @SuppressWarnings("unchecked")
48 | public void and(T val) {
49 | long currentValue = getValue().longValue();
50 | currentValue &= val.longValue();
51 | this.setValue((T) val.getClass().cast(currentValue));
52 | }
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/jni/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.jni
7 |
8 |
9 |
10 |
11 |
12 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/testsuite/CompleteTestSuite.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.testsuite;
2 |
3 | import org.bulldog.core.TestSignal;
4 | import org.bulldog.core.bus.TestBusConnection;
5 | import org.bulldog.core.gpio.base.TestAbstractAnalogInput;
6 | import org.bulldog.core.gpio.base.TestAbstractDigitalInput;
7 | import org.bulldog.core.gpio.base.TestAbstractDigitalOutput;
8 | import org.bulldog.core.gpio.base.TestAbstractPinFeature;
9 | import org.bulldog.core.gpio.base.TestAbstractPwm;
10 | import org.bulldog.core.gpio.base.TestDigitalIOFeature;
11 | import org.bulldog.core.gpio.base.TestPin;
12 | import org.bulldog.core.gpio.util.TestSoftPwm;
13 | import org.bulldog.core.platform.TestAbstractBoard;
14 | import org.bulldog.core.platform.TestAbstractPinProvider;
15 | import org.bulldog.core.util.TestBitMagic;
16 | import org.bulldog.core.util.TestBulldogUtil;
17 | import org.junit.runner.RunWith;
18 | import org.junit.runners.Suite;
19 | import org.junit.runners.Suite.SuiteClasses;
20 |
21 | @RunWith(Suite.class)
22 | @SuiteClasses({
23 | TestAbstractPinProvider.class,
24 | TestAbstractBoard.class,
25 | TestPin.class,
26 | TestAbstractPinFeature.class,
27 | TestAbstractDigitalOutput.class,
28 | TestAbstractDigitalInput.class,
29 | TestDigitalIOFeature.class,
30 | TestAbstractAnalogInput.class,
31 | TestAbstractPwm.class,
32 | TestSignal.class,
33 | TestSoftPwm.class,
34 | TestBusConnection.class,
35 | TestBulldogUtil.class,
36 | TestBitMagic.class
37 | })
38 | public class CompleteTestSuite {
39 |
40 | }
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/linux/io/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.linux.io
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/gpio/base/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.gpio.base
7 |
8 |
9 |
10 |
11 |
12 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/mocks/MockedDigitalInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.mocks;
2 |
3 | import org.bulldog.core.Signal;
4 | import org.bulldog.core.gpio.Pin;
5 | import org.bulldog.core.gpio.base.AbstractDigitalInput;
6 |
7 | public class MockedDigitalInput extends AbstractDigitalInput {
8 |
9 | private volatile Signal appliedSignal;
10 |
11 | public MockedDigitalInput(Pin pin) {
12 | super(pin);
13 | appliedSignal = Signal.Low;
14 | }
15 |
16 | public void setSignalToRead(Signal signal) {
17 | this.appliedSignal = signal;
18 | }
19 |
20 | public void bounceSignal(final Signal signal, final long bounceTimeMs) {
21 | Thread thread = new Thread(new Runnable() {
22 |
23 | @Override
24 | public void run() {
25 | long delta = 0;
26 | long start = System.currentTimeMillis();
27 | Signal nextSignal = signal;
28 | while(delta < bounceTimeMs) {
29 | setSignalToRead( nextSignal == Signal.High ? Signal.Low : Signal.High);
30 | delta = System.currentTimeMillis() - start;
31 | }
32 |
33 | setSignalToRead(signal);
34 | }
35 |
36 | });
37 |
38 | thread.setPriority(Thread.MAX_PRIORITY);
39 | thread.start();
40 | }
41 |
42 | @Override
43 | public Signal read() {
44 | return appliedSignal;
45 | }
46 |
47 | @Override
48 | protected void setupImpl() {
49 | }
50 |
51 | @Override
52 | protected void teardownImpl() {
53 | }
54 |
55 |
56 | @Override
57 | protected void enableInterruptsImpl() {
58 | }
59 |
60 | @Override
61 | protected void disableInterruptsImpl() {
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/devices/lcd/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.devices.lcd
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
22 |
Enums
23 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/Signal.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core;
2 |
3 | import org.bulldog.core.util.BulldogUtil;
4 |
5 | public enum Signal {
6 | High(1, true),
7 | Low(0, false);
8 |
9 | private int numericValue;
10 | private boolean booleanValue;
11 |
12 | Signal(int numericValue, boolean booleanValue) {
13 | this.numericValue = numericValue;
14 | this.booleanValue = booleanValue;
15 | }
16 |
17 | public int getNumericValue() {
18 | return numericValue;
19 | }
20 |
21 | public boolean getBooleanValue() {
22 | return booleanValue;
23 | }
24 |
25 | public static Signal fromNumericValue(int value) {
26 | if(value == 0) { return Signal.Low; }
27 | return Signal.High;
28 | }
29 |
30 | public static Signal fromBooleanValue(boolean value) {
31 | if(value) { return Signal.High; }
32 | return Signal.Low;
33 | }
34 |
35 | public static Signal fromString(String value) {
36 | if(value == null) { throw new IllegalArgumentException("value cannot be null!"); };
37 |
38 | String interpretedValue = value.trim().toLowerCase();
39 |
40 | if(BulldogUtil.isStringNumeric(interpretedValue)) {
41 | if(Double.parseDouble(interpretedValue) == 0) { return Signal.Low; }
42 | return Signal.High;
43 | } else {
44 | if(interpretedValue.equals("low")) { return Signal.Low; }
45 | else if(interpretedValue.equals("high")) { return Signal.High; };
46 |
47 | throw new IllegalArgumentException(interpretedValue + " is not a valid value for a signal");
48 | }
49 | }
50 |
51 | public Signal inverse() {
52 | return this == Signal.High ? Signal.Low : Signal.High;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/PinBlockedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * (C) Copyright 2014 libbulldog (http://libbulldog.org/) and others.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.bulldog.core.gpio;
18 |
19 | // TODO: Auto-generated Javadoc
20 | /**
21 | * The Class PinBlockedException.
22 | */
23 | public class PinBlockedException extends RuntimeException {
24 |
25 | /** The Constant serialVersionUID. */
26 | private static final long serialVersionUID = 6737984685844582750L;
27 |
28 | /** The blocker. */
29 | private PinFeature blocker;
30 |
31 | /**
32 | * Instantiates a new pin blocked exception.
33 | *
34 | * @param blocker the blocker
35 | */
36 | public PinBlockedException(PinFeature blocker) {
37 | super(String.format("Pin %s is currently blocked by %s", blocker.getPin().getName(), blocker.getName()));
38 | this.blocker = blocker;
39 | }
40 |
41 | /**
42 | * Gets the blocker.
43 | *
44 | * @return the blocker
45 | */
46 | public PinFeature getBlocker() {
47 | return blocker;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/event/ThresholdListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * (C) Copyright 2014 libbulldog (http://libbulldog.org/) and others.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.bulldog.core.gpio.event;
18 |
19 | /**
20 | * The listener interface for receiving threshold events.
21 | * The class that is interested in processing a threshold
22 | * event implements this interface, and the object created
23 | * with that class is registered with a component using the
24 | * component's {@code addThresholdListener} method. When
25 | * the threshold event occurs, that object's appropriate
26 | * method is invoked.
27 | *
28 | */
29 | public interface ThresholdListener {
30 |
31 | /**
32 | * Callback method that is triggered when the threshold is reached.
33 | */
34 | void thresholdReached();
35 |
36 | /**
37 | * Checks if the threshold is reached.
38 | *
39 | * @param thresholdValue the threshold value
40 | * @return true, if is threshold reached - false otherwise
41 | */
42 | boolean isThresholdReached(double thresholdValue);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/io/bus/spi/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.io.bus.spi
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
17 |
Classes
18 |
23 |
Enums
24 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/beagleboneblack/gpio/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.beagleboneblack.gpio
7 |
8 |
9 |
10 |
11 |
12 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/dist/Version-0.1.0/javadoc/org/bulldog/core/io/uart/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | org.bulldog.core.io.uart
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Interfaces
14 |
20 |
Classes
21 |
24 |
Enums
25 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/platform/AbstractPinProvider.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.platform;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.bulldog.core.gpio.Pin;
7 |
8 | public class AbstractPinProvider implements PinProvider {
9 |
10 | private List pins = new ArrayList();
11 |
12 | public List getPins() {
13 | return pins;
14 | }
15 |
16 | public Pin getPin(int address) {
17 | for(Pin pin : getPins()) {
18 | if(pin.getAddress() == address) {
19 | return pin;
20 | }
21 | }
22 |
23 | return null;
24 | }
25 |
26 | public Pin getPin(String port, int index) {
27 | if(port == null) { throw new IllegalArgumentException("Null may not be passed as a name for a port."); }
28 | if(index < 0) { throw new IllegalArgumentException("Index cannot be smaller than 0"); }
29 |
30 | for(Pin pin : getPins()) {
31 | if(port.equals(pin.getPort()) && index == pin.getIndexOnPort()) {
32 | return pin;
33 | }
34 | }
35 |
36 | return null;
37 | }
38 |
39 | public Pin getPin(String name) {
40 | if(name == null) { throw new IllegalArgumentException("Null may not be passed as a name for a pin."); }
41 |
42 | for(Pin pin : getPins()) {
43 | if(name.equals(pin.getName())) {
44 | return pin;
45 | }
46 | }
47 |
48 | return null;
49 | }
50 |
51 | public Pin getPinByAlias(String alias) {
52 | if(alias == null) { throw new IllegalArgumentException("Null may not be passed as an alias name for a pin."); }
53 |
54 | for(Pin pin : getPins()) {
55 | if(alias.equals(pin.getAlias())) {
56 | return pin;
57 | }
58 | }
59 |
60 | return null;
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/beagleboneblack/jni/org_bulldog_beagleboneblack_jni_NativePwm.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class org_bulldog_beagleboneblack_jni_NativePwm */
4 |
5 | #ifndef _Included_org_bulldog_beagleboneblack_jni_NativePwm
6 | #define _Included_org_bulldog_beagleboneblack_jni_NativePwm
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
12 | * Method: setup
13 | * Signature: ()I
14 | */
15 | JNIEXPORT jint JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_setup
16 | (JNIEnv *, jclass);
17 |
18 | /*
19 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
20 | * Method: teardown
21 | * Signature: ()I
22 | */
23 | JNIEXPORT void JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_teardown
24 | (JNIEnv *, jclass);
25 |
26 | /*
27 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
28 | * Method: setPwm
29 | * Signature: (IFFF)I
30 | */
31 | JNIEXPORT jint JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_setPwm
32 | (JNIEnv *, jclass, jint, jfloat, jfloat, jfloat);
33 |
34 | /*
35 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
36 | * Method: enable
37 | * Signature: (I)V
38 | */
39 | JNIEXPORT void JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_enable
40 | (JNIEnv *, jclass, jint);
41 |
42 | /*
43 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
44 | * Method: disable
45 | * Signature: (I)V
46 | */
47 | JNIEXPORT void JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_disable
48 | (JNIEnv *, jclass, jint);
49 |
50 | #ifdef __cplusplus
51 | }
52 | #endif
53 | #endif
54 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/beagleboneblack/BBBIOlib/BBBiolib_ADCTSC.h:
--------------------------------------------------------------------------------
1 | #ifndef BBBIO_ADCTSC_H
2 | #define BBBIO_ADCTSC_H
3 | /*-------------------------------------------------------------------------- */
4 | #define BBBIO_ADC_AIN0 0
5 | #define BBBIO_ADC_AIN1 1
6 | #define BBBIO_ADC_AIN2 2
7 | #define BBBIO_ADC_AIN3 3
8 | #define BBBIO_ADC_AIN4 4
9 | #define BBBIO_ADC_AIN5 5
10 | #define BBBIO_ADC_AIN6 6
11 |
12 |
13 | /* step config control operator*/
14 | #define BBBIO_ADC_STEP_MODE_SW_ONE_SHOOT 0x0
15 | #define BBBIO_ADC_STEP_MODE_SW_CONTINUOUS 0x1
16 | #define BBBIO_ADC_STEP_MODE_HW_ONE_SHOOT 0x2
17 | #define BBBIO_ADC_STEP_MODE_HW_CONTINUOUS 0x3
18 |
19 | #define BBBIO_ADC_STEP_AVG_1 0x0
20 | #define BBBIO_ADC_STEP_AVG_2 0x1
21 | #define BBBIO_ADC_STEP_AVG_4 0x2
22 | #define BBBIO_ADC_STEP_AVG_8 0x3
23 | #define BBBIO_ADC_STEP_AVG_16 0x4
24 |
25 | #define BBBIO_ADC_WORK_MODE_BUSY_POLLING 0x1
26 | #define BBBIO_ADC_WORK_MODE_TIMER_INT 0x2
27 |
28 | /* ------------------------------------------------------------------------- */
29 | int BBBIO_ADCTSC_Init();
30 | void BBBIO_ADCTSC_step_work();
31 |
32 | unsigned int BBBIO_ADCTSC_work(unsigned int fetch_size);
33 | int BBBIO_ADCTSC_channel_ctrl(unsigned int chn_ID, int mode, int open_dly, int sample_dly, int sample_avg, unsigned int *buf, unsigned int buf_size);
34 | void BBBIO_ADCTSC_module_ctrl(unsigned int work_type, unsigned int clkdiv);
35 | #define BBBIO_ADCTSC_channel_enable(A) BBBIO_ADCTSC_channel_status(A,1)
36 | #define BBBIO_ADCTSC_channel_disable(A) BBBIO_ADCTSC_channel_status(A,0)
37 |
38 | void BBBIO_ADCTSC_channel_status(int chn_ID ,int enable);
39 | /* ------------------------------------------------------------------------- */
40 | #endif
41 |
--------------------------------------------------------------------------------
/bulldog.devices/src/main/java/org/bulldog/devices/motor/UnipolarStepper.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.devices.motor;
2 |
3 | import org.bulldog.core.gpio.DigitalOutput;
4 |
5 | import org.bulldog.core.io.PinIOGroup;
6 |
7 | public class UnipolarStepper extends AbstractStepper {
8 |
9 | private byte[] steps = new byte[] { 0b0101, 0b0110, 0b1010, 0b1001 };
10 | private double position;
11 |
12 | public UnipolarStepper(DigitalOutput out1, DigitalOutput out2, DigitalOutput out3, DigitalOutput out4) {
13 |
14 | }
15 |
16 | public UnipolarStepper(PinIOGroup group) {
17 |
18 | }
19 |
20 | @Override
21 | public void moveTo(double position) {
22 | // TODO Auto-generated method stub
23 |
24 | }
25 |
26 | @Override
27 | public void setPosition(double position) {
28 | // TODO Auto-generated method stub
29 |
30 | }
31 |
32 | public void step() {
33 | }
34 |
35 | @Override
36 | public double getPosition() {
37 | // TODO Auto-generated method stub
38 | return 0;
39 | }
40 |
41 | @Override
42 | public int getMillisecondsPerUnit() {
43 | // TODO Auto-generated method stub
44 | return 0;
45 | }
46 |
47 | @Override
48 | public int getRefreshIntervalMilliseconds() {
49 | // TODO Auto-generated method stub
50 | return 0;
51 | }
52 |
53 | @Override
54 | public void forward() {
55 | // TODO Auto-generated method stub
56 |
57 | }
58 |
59 | @Override
60 | public void backward() {
61 | // TODO Auto-generated method stub
62 |
63 | }
64 |
65 | @Override
66 | public void stop() {
67 | // TODO Auto-generated method stub
68 |
69 | }
70 |
71 | @Override
72 | public boolean isMoving() {
73 | // TODO Auto-generated method stub
74 | return false;
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/bulldog.board.beagleboneblack/src/main/java/org/bulldog/beagleboneblack/gpio/BBBPwmManager.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.beagleboneblack.gpio;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashSet;
5 | import java.util.List;
6 | import java.util.Set;
7 |
8 | public class BBBPwmManager {
9 |
10 | private Set activePwms = new HashSet();
11 |
12 | public boolean canActivatePwmOnPin(BBBPwm pwm) {
13 | if(pwm == null) {
14 | throw new IllegalArgumentException("pwm must not be null!");
15 | }
16 | BBBPwm activePwm = getActivePin(pwm);
17 | return activePwm == null && !(pwm == activePwm);
18 | }
19 |
20 | public BBBPwm getActivePin(BBBPwm pwm) {
21 | List activeSiblings = findPwmByGroup(pwm.getPwmGroup());
22 | for(BBBPwm siblingPwm : activeSiblings) {
23 | if(siblingPwm.getQualifier().equals(pwm.getQualifier())) {
24 | return siblingPwm;
25 | }
26 | }
27 |
28 | return null;
29 | }
30 |
31 | public BBBPwm getActiveSibling(BBBPwm pwm) {
32 | List activeSiblings = findPwmByGroup(pwm.getPwmGroup());
33 | for(BBBPwm siblingPwm : activeSiblings) {
34 | if(!siblingPwm.getQualifier().equals(pwm.getQualifier())) {
35 | return siblingPwm;
36 | }
37 | }
38 |
39 | return null;
40 | }
41 |
42 | public void addActivePwm(BBBPwm pwm) {
43 | activePwms.add(pwm);
44 | }
45 |
46 | public void removeActivePwm(BBBPwm pwm) {
47 | activePwms.remove(pwm);
48 | }
49 |
50 | private List findPwmByGroup(String group) {
51 | List pwms = new ArrayList();
52 | for(BBBPwm pwm : activePwms) {
53 | if(pwm.getPwmGroup().equals(group)) {
54 | pwms.add(pwm);
55 | }
56 | }
57 |
58 | return pwms;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/bulldog.core/src/main/java/org/bulldog/core/gpio/base/AbstractAnalogInput.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.base;
2 |
3 | import java.util.concurrent.Executors;
4 | import java.util.concurrent.ScheduledExecutorService;
5 | import java.util.concurrent.ScheduledFuture;
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import org.bulldog.core.gpio.AnalogInput;
9 | import org.bulldog.core.gpio.Pin;
10 | import org.bulldog.core.gpio.event.ThresholdListener;
11 |
12 |
13 | public abstract class AbstractAnalogInput extends AbstractPinFeature implements AnalogInput {
14 |
15 | private static final String NAME_FORMAT = "Analog Input on Pin %s";
16 |
17 | private ScheduledFuture> future;
18 | private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
19 |
20 | public AbstractAnalogInput(Pin pin) {
21 | super(pin);
22 | }
23 |
24 | public String getName() {
25 | return String.format(NAME_FORMAT, getPin().getName());
26 | }
27 |
28 | public void startMonitor(int periodMicroSeconds, final ThresholdListener listener) {
29 | if(listener == null) {
30 | throw new IllegalArgumentException("listener cannot be null");
31 | }
32 |
33 | blockPin();
34 | future = scheduler.scheduleAtFixedRate(new Runnable() {
35 | public void run() {
36 | double[] samples = sample(10);
37 | for(int i = 0; i < samples.length; i++) {
38 | if(listener.isThresholdReached(samples[i])) {
39 | listener.thresholdReached();
40 | }
41 | }
42 | }
43 | },
44 | 0,
45 | periodMicroSeconds,
46 | TimeUnit.MICROSECONDS);
47 | }
48 |
49 | public void stopMonitor() {
50 | if(future == null) { return; }
51 | future.cancel(true);
52 | unblockPin();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/bulldog.core/src/test/java/org/bulldog/core/gpio/util/TestSoftPwm.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.core.gpio.util;
2 |
3 | import junit.framework.TestCase;
4 |
5 | import org.bulldog.core.Signal;
6 | import org.bulldog.core.gpio.DigitalOutput;
7 | import org.bulldog.core.gpio.Pin;
8 | import org.bulldog.core.mocks.MockedDigitalOutput;
9 | import org.bulldog.core.util.BulldogUtil;
10 | import org.junit.Before;
11 | import org.junit.Test;
12 |
13 | public class TestSoftPwm {
14 |
15 | private Pin pin;
16 |
17 | @Before
18 | public void setup() {
19 | pin = new Pin("Testpin", 0, "A", 0);
20 | MockedDigitalOutput output = new MockedDigitalOutput(pin);
21 | pin.addFeature(output);
22 | }
23 |
24 | @Test
25 | public void testSoftPwm() {
26 | DigitalOutput output = pin.as(DigitalOutput.class);
27 | SoftPwm pwm = new SoftPwm(output);
28 | pwm.setDuty(0.2);
29 | pwm.setFrequency(10.0);
30 | pwm.enable();
31 |
32 | BulldogUtil.sleepMs(100);
33 | //Measure 100 times for one second.
34 | //20 readings should be high;
35 | int highCount = 0;
36 | int lowCount = 0;
37 | for(int i = 0; i < 100; i++) {
38 | Signal signal = output.getAppliedSignal();
39 | if(signal == Signal.High) {
40 | highCount++;
41 | } else {
42 | lowCount++;
43 | }
44 | BulldogUtil.sleepMs(1);
45 | }
46 |
47 | TestCase.assertEquals(80, lowCount);
48 | TestCase.assertEquals(20, highCount);
49 |
50 | pwm.disable();
51 | pwm.disable(); //should have no effect
52 | BulldogUtil.sleepMs(50);
53 |
54 | Signal signal = output.getAppliedSignal();
55 | for(int i = 0; i < 100; i++) {
56 | TestCase.assertEquals(signal, output.getAppliedSignal());
57 | BulldogUtil.sleepMs(1);
58 | }
59 |
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/bulldog.examples/src/main/java/org/bulldog/examples/DigitalOutputExample.java:
--------------------------------------------------------------------------------
1 | package org.bulldog.examples;
2 |
3 | import java.io.IOException;
4 |
5 | import org.bulldog.beagleboneblack.BBBNames;
6 | import org.bulldog.core.Signal;
7 | import org.bulldog.core.gpio.DigitalOutput;
8 | import org.bulldog.core.platform.Board;
9 | import org.bulldog.core.platform.Platform;
10 | import org.bulldog.core.util.BulldogUtil;
11 |
12 | public class DigitalOutputExample {
13 |
14 | public static void main(String[] args) throws IOException
15 | {
16 | //Detect the board we are running on
17 | Board board = Platform.createBoard();
18 |
19 | //Set up a digital output
20 | DigitalOutput output = board.getPin(BBBNames.P8_12).as(DigitalOutput.class);
21 |
22 | //Set a high signal on the output
23 | output.write(Signal.High);
24 |
25 | //Toggle it
26 | output.toggle();
27 | BulldogUtil.sleepMs(500);
28 |
29 | //Set it high
30 | output.high();
31 | BulldogUtil.sleepMs(500);
32 |
33 | //Set it low
34 | output.low();
35 | BulldogUtil.sleepMs(500);
36 |
37 | //Yet another way of applying a signal
38 | output.applySignal(Signal.High);
39 | BulldogUtil.sleepMs(500);
40 |
41 | //Let it blink 3 times
42 | output.blinkTimes(500, 3);
43 | output.awaitBlinkingStopped();
44 |
45 | //Let it blink 5 seconds, 10 times a second
46 | output.startBlinking(100, 5000);
47 | output.awaitBlinkingStopped();
48 |
49 | //Let it blink 5 times a second indefinitely
50 | output.startBlinking(200);
51 |
52 | while(true) {
53 | BulldogUtil.sleepMs(50);
54 | }
55 |
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/bulldog.linux.native/src/main/c/beagleboneblack/jni/org_bulldog_beagleboneblack_jni_NativePwm.c:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | #include "../BBBIOlib/BBBiolib_PWMSS.h"
4 |
5 | /*
6 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
7 | * Method: setup
8 | * Signature: ()I
9 | */
10 | JNIEXPORT jint JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_setup
11 | (JNIEnv * env, jclass clazz) {
12 | return BBBIO_PWM_Init();
13 | }
14 |
15 | /*
16 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
17 | * Method: teardown
18 | * Signature: ()I
19 | */
20 | JNIEXPORT void JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_teardown
21 | (JNIEnv * env, jclass clazz) {
22 | BBBIO_PWM_Release();
23 | }
24 |
25 | /*
26 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
27 | * Method: setPwm
28 | * Signature: (IFFF)I
29 | */
30 | JNIEXPORT jint JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_setPwm
31 | (JNIEnv * env, jclass clazz, jint pwmId, jfloat frequency, jfloat dutyA, jfloat dutyB) {
32 | return BBBIO_PWMSS_Setting(pwmId , frequency , dutyA ,dutyB);
33 | }
34 |
35 | /*
36 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
37 | * Method: enable
38 | * Signature: (I)V
39 | */
40 | JNIEXPORT void JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_enable
41 | (JNIEnv * env, jclass clazz, jint pwmId) {
42 | BBBIO_ehrPWM_Enable(pwmId);
43 | }
44 |
45 | /*
46 | * Class: org_bulldog_beagleboneblack_jni_NativePwm
47 | * Method: disable
48 | * Signature: (I)V
49 | */
50 | JNIEXPORT void JNICALL Java_org_bulldog_beagleboneblack_jni_NativePwm_disable
51 | (JNIEnv * env, jclass clazz, jint pwmId) {
52 | BBBIO_ehrPWM_Disable(pwmId);
53 | }
54 |
--------------------------------------------------------------------------------