mirror of
https://github.com/processing/processing4.git
synced 2026-01-27 10:21:26 +01:00
I/O: Remove casts to byte from example sketches
This commit is contained in:
@@ -20,18 +20,18 @@ void draw() {
|
||||
void setHeadingMode() {
|
||||
i2c.beginTransmission(0x21);
|
||||
// command byte for writing to EEPROM
|
||||
i2c.write((byte) 0x77);
|
||||
i2c.write(0x77);
|
||||
// address of the output data control byte
|
||||
i2c.write((byte) 0x4e);
|
||||
i2c.write(0x4e);
|
||||
// give us the plain heading
|
||||
i2c.write((byte) 0x00);
|
||||
i2c.write(0x00);
|
||||
i2c.endTransmission();
|
||||
}
|
||||
|
||||
float getHeading() {
|
||||
i2c.beginTransmission(0x21);
|
||||
// command byte for reading the data
|
||||
i2c.write((byte) 0x41);
|
||||
i2c.write(0x41);
|
||||
byte[] in = i2c.read(2);
|
||||
i2c.endTransmission();
|
||||
// put bytes together to tenth of degrees
|
||||
|
||||
@@ -21,7 +21,7 @@ void setAnalog(float fac) {
|
||||
// convert to 12 bit value
|
||||
int val = int(4095 * fac);
|
||||
i2c.beginTransmission(0x60);
|
||||
i2c.write((byte) (val >> 8));
|
||||
i2c.write((byte) (val & 255));
|
||||
i2c.write(val >> 8);
|
||||
i2c.write(val & 255);
|
||||
i2c.endTransmission();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ class MCP4725 extends I2C {
|
||||
// convert to 12 bit value
|
||||
int val = int(4095 * fac);
|
||||
beginTransmission(address);
|
||||
write((byte) (val >> 8));
|
||||
write((byte) (val & 255));
|
||||
write(val >> 8);
|
||||
write(val & 255);
|
||||
endTransmission();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user