Skip to content

Commit

Permalink
Update README.md, dependencies and organize project
Browse files Browse the repository at this point in the history
Bumped version to 1.1
  • Loading branch information
twyatt committed Jan 25, 2017
1 parent 7e541fd commit 37d2b98
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 88 deletions.
36 changes: 1 addition & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
## Java
*.class
*.war
*.ear
hs_err_pid*

## Eclipse
.classpath
.project
.metadata
**/bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.externalToolBuilders/
*.launch

## NetBeans
**/nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

## Gradle
.gradle
build/

## OS Specific
.DS_Store
/bin
.idea/
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
![Breakout Board](breakout.jpg)
![Breakout Board](artwork/breakout.jpg)

# Screenshot
![Screenshot](screenshot.png)
![Screenshot](artwork/screenshot.png)

# Instructions
## Schematic
![Pi Schematic](schematic-pi.jpg)
![ADXL345 Schematic](schematic-adxl345.jpg)

## Wiring
![Wiring](wiring.jpg)
![ADXL345 Schematic](artwork/schematic.jpg)

## Computer
* Compile project
Expand All @@ -24,3 +20,27 @@ $ unzip pi-adxl345.zip
$ cd pi-adxl345
$ sudo bin/pi-adxl345
```

# Troubleshooting
You can install i2c-tools by running:
```bash
$ sudo apt-get install i2c-tools
```

Then, confirm that your ADXL345 is recognized by running:
```bash
$ sudo i2cdetect -y 1
```

You should get an output similar to:
```
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
```
File renamed without changes
File renamed without changes
File renamed without changes
41 changes: 6 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,62 +1,33 @@
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'application'

// In this section you declare where to find the dependencies of your project
repositories {
// Use 'maven central' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
jcenter()
}

sourceSets {
main {
java {
srcDirs = ["src"]
}
}
}

// In this section you declare the dependencies for your production and test code
dependencies {
compile('com.pi4j:pi4j-core:0.0.5') {
compile('com.pi4j:pi4j-core:1.1') {
exclude module: 'pi4j-native'
}
compile('com.pi4j:pi4j-device:0.0.5') {
compile('com.pi4j:pi4j-device:1.1') {
exclude module: 'pi4j-native'
}
compile('com.pi4j:pi4j-gpio-extension:0.0.5') {
compile('com.pi4j:pi4j-gpio-extension:1.1') {
exclude module: 'pi4j-native'
}

//compile fileTree(dir: 'libs', include: '*.jar')

// The production code uses the SLF4J logging API at compile time
//compile 'org.slf4j:slf4j-api:1.7.5'

// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
//testCompile "junit:junit:4.11"
}

sourceCompatibility = 1.7
targetCompatibility = 1.7

// http://www.gradle.org/docs/current/userguide/application_plugin.html
mainClassName = "com.traviswyatt.pi.adxl345.Main"

jar {
baseName = 'adxl345'
version = '1.0'
version = '1.1'

manifest {
attributes 'Main-Class': mainClassName
}
}

tasks.eclipse.doLast {
delete ".project"
}
Binary file removed schematic-pi.jpg
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.i2cdevlib;

import java.io.IOException;

import com.pi4j.io.i2c.I2CDevice;

import java.io.IOException;

/**
* Partial adaptation from:
* https://github.com/jrowberg/i2cdevlib/blob/master/MSP430/I2Cdev/I2Cdev.cpp
*/
public class I2Cdev {

/** Read a single bit from an 8-bit device register.
* @param devAddr I2C slave device address
* @param regAddr Register regAddr to read from
* @param bitNum Bit position to read (0-7)
* @return Single bit value
Expand Down Expand Up @@ -39,7 +38,6 @@ public static void writeBit(I2CDevice i2c, int regAddr, int bitNum, boolean valu
}

/** Read multiple bits from an 8-bit device register.
* @param devAddr I2C slave device address
* @param regAddr Register regAddr to read from
* @param bitStart First bit position to read (0-7)
* @param length Number of bits to read (not more than 8)
Expand All @@ -60,7 +58,6 @@ public static int readBits(I2CDevice i2c, int regAddr, int bitStart, int length)
}

/** Write multiple bits in an 8-bit device register.
* @param devAddr I2C slave device address
* @param regAddr Register regAddr to write to
* @param bitStart First bit position to write (0-7)
* @param length Number of bits to write (not more than 8)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.traviswyatt.pi.adxl345;

import java.io.IOException;

import com.i2cdevlib.I2Cdev;
import com.pi4j.io.i2c.I2CDevice;
import com.pi4j.io.i2c.I2CFactory;

import java.io.IOException;

public class ADXL345 {

/**
Expand Down Expand Up @@ -204,7 +204,7 @@ public ADXL345(int bus, int address) {
*
* @throws IOException
*/
public void setup() throws IOException {
public void setup() throws IOException, I2CFactory.UnsupportedBusNumberException {
// http://pi4j.com/example/control.html
i2c = I2CFactory.getInstance(i2cBus).getDevice(devAddr);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.traviswyatt.pi.adxl345;

import java.io.IOException;

import com.pi4j.io.i2c.I2CBus;
import com.pi4j.io.i2c.I2CFactory;

import java.io.IOException;

public class Main {

public static void main(String[] args) throws IOException {
public static void main(String[] args) throws IOException, I2CFactory.UnsupportedBusNumberException {
// http://developer-blog.net/wp-content/uploads/2013/09/raspberry-pi-rev2-gpio-pinout.jpg
// http://pi4j.com/example/control.html
ADXL345 adxl345 = new ADXL345(I2CBus.BUS_1);
Expand Down
Binary file removed wiring.jpg
Binary file not shown.

0 comments on commit 37d2b98

Please sign in to comment.