Permalink
Browse files

Whitespace cleanup in L3G.cpp/h

  • Loading branch information...
1 parent 594eeba commit 93a40c5706caa539d547d33f8904d7fe03b6acfe Jon Schlueter committed Nov 13, 2012
Showing with 19 additions and 19 deletions.
  1. +12 −12 L3G/L3G.cpp
  2. +7 −7 L3G/L3G.h
View
@@ -4,7 +4,7 @@
// Defines ////////////////////////////////////////////////////////////////
-// The Arduino two-wire interface uses a 7-bit number for the address,
+// The Arduino two-wire interface uses a 7-bit number for the address,
// and sets the last bit correctly based on reads and writes
#define L3G4200D_ADDRESS_SA0_LOW (0xD0 >> 1)
#define L3G4200D_ADDRESS_SA0_HIGH (0xD2 >> 1)
@@ -14,7 +14,7 @@
// Public Methods //////////////////////////////////////////////////////////////
bool L3G::init(byte device, byte sa0)
-{
+{
_device = device;
switch (_device)
{
@@ -31,8 +31,8 @@ bool L3G::init(byte device, byte sa0)
}
else
return autoDetectAddress();
- break;
-
+ break;
+
case L3GD20_DEVICE:
if (sa0 == L3G_SA0_LOW)
{
@@ -46,8 +46,8 @@ bool L3G::init(byte device, byte sa0)
}
else
return autoDetectAddress();
- break;
-
+ break;
+
default:
return autoDetectAddress();
}
@@ -74,29 +74,29 @@ void L3G::writeReg(byte reg, byte value)
byte L3G::readReg(byte reg)
{
byte value;
-
+
Wire.beginTransmission(address);
Wire.write(reg);
Wire.endTransmission();
Wire.requestFrom(address, (byte)1);
value = Wire.read();
Wire.endTransmission();
-
+
return value;
}
// Reads the 3 gyro channels and stores them in vector g
void L3G::read()
{
Wire.beginTransmission(address);
- // assert the MSB of the address to get the gyro
+ // assert the MSB of the address to get the gyro
// to do slave-transmit subaddress updating.
- Wire.write(L3G_OUT_X_L | (1 << 7));
+ Wire.write(L3G_OUT_X_L | (1 << 7));
Wire.endTransmission();
Wire.requestFrom(address, (byte)6);
while (Wire.available() < 6);
-
+
uint8_t xlg = Wire.read();
uint8_t xhg = Wire.read();
uint8_t ylg = Wire.read();
@@ -143,6 +143,6 @@ bool L3G::autoDetectAddress(void)
if (readReg(L3G_WHO_AM_I) == 0xD4) return true;
address = L3GD20_ADDRESS_SA0_HIGH;
if (readReg(L3G_WHO_AM_I) == 0xD4) return true;
-
+
return false;
}
View
@@ -56,27 +56,27 @@ class L3G
{
float x, y, z;
} vector;
-
+
vector g; // gyro angular velocity readings
bool init(byte device = L3G_DEVICE_AUTO, byte sa0 = L3G_SA0_AUTO);
-
+
void enableDefault(void);
-
+
void writeReg(byte reg, byte value);
byte readReg(byte reg);
-
+
void read(void);
-
+
// vector functions
static void vector_cross(const vector *a, const vector *b, vector *out);
static float vector_dot(const vector *a,const vector *b);
static void vector_normalize(vector *a);
-
+
private:
byte _device; // chip type (4200D or D20)
byte address;
-
+
bool autoDetectAddress(void);
};

0 comments on commit 93a40c5

Please sign in to comment.