Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional param for I2C address in constructor #19

Merged
merged 2 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ssd1306/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ allprojects {
apply from: 'build.gradle'
apply plugin: 'maven-publish'

def packageVersion = '0.1'
def packageVersion = '0.2'

task sourceJar(type: Jar) {
classifier = 'sources'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class Ssd1306 implements Closeable {
* I2C address for this peripheral
*/
public static final int I2C_ADDRESS = 0x3C;
public static final int I2C_ADDRESS_ALT = 0x3D;

// Protocol constants
private static final int COMMAND_ACTIVATE_SCROLL = 0x2F;
Expand Down Expand Up @@ -103,7 +104,17 @@ public enum ScrollMode {
* @throws IOException
*/
public Ssd1306(String i2cName) throws IOException {
I2cDevice device = new PeripheralManagerService().openI2cDevice(i2cName, I2C_ADDRESS);
this(i2cName, I2C_ADDRESS);
}

/**
* Create a new Ssd1306 driver connected to the named I2C bus and address
* @param i2cName I2C bus name the display is connected to
* @param i2cAddress I2C address of the display
* @throws IOException
*/
public Ssd1306(String i2cName, int i2cAddress) throws IOException {
I2cDevice device = new PeripheralManagerService().openI2cDevice(i2cName, i2cAddress);
try {
init(device);
} catch (IOException | RuntimeException e) {
Expand Down