Forum suggestion

You know what would be excellent? A code box for forum posts. You know what I mean? Keep that posted code contained in a box to preserve the aesthetics of the post itself. Yeah.

Two cents :ching:

Nice

You mean like in many forums where code is inside a box so it looks better?

Good idea!

You mean something like

You mean something like this:

void setup()
{ pinMode(8, OUTPUT);
}
etc
etc
etc
etc
etc

Sorry, I just don’t think that’s possible.

rotflm.gif

Hmm - maybe it isn't after all. It has a scroll bar when editing.

Let me try something different (holy smokes - this is even worse):

/*
* Set up the accelerometer and gyroscope in the IMU.
 * Read data from them and spit it out on the serial port.
 *
 * JRW 12/11/10
 */

#include <Wire.h> /

#include “i2c.h”
#include “adxl345.h”
#include “itg3200.h”
#include “IMUfilter.h”

#define GYRO 0x68
#define ACCEL 0x53
#define FILTER_RATE 0.01

ADXL adxl(ACCEL);
ITG itg(GYRO);
IMUfilter imuFilter(FILTER_RATE, 0.6);
int count=0;
long lastmillis=0;

float ax=0,ay=0,az=0,gx=0,gy=0,gz=0;
float loops=0;
float sumx,sumy,sumz=0;

void setup() {
i2c.begin();
Serial.begin(57600);
Serial.println(“I2C initialised.”);
adxl.init();
itg.init();
itg.wake();

while (!itg.dataReady()) {
}

unsigned char whoami=i2c.readRegister(ACCEL,ADXL_WHO_AM_I);
Serial.print("Accel: ");
Serial.println(whoami,HEX);

whoami=i2c.readRegister(GYRO,ITG_WHO_AM_I);
Serial.print("Gyro: ");
Serial.println(whoami,HEX);
Serial.print("Temp: ");
Serial.println(itg.getTemp());

/Serial.println(i2c::readRegister(ACCEL, ADXL_TIME_INACT),DEC);
Serial.println(i2c::readRegister(ACCEL, ADXL_THRESH_INACT),DEC);
Serial.println(i2c::readRegister(ACCEL, ADXL_ACT_INACT_CTL),BIN);
Serial.println(i2c::readRegister(ACCEL, ADXL_POWER_CTL),BIN);
delay(5000);
/
//Serial.println(i2c::readRegister(GYRO, ITG_PWR_MGM),BIN);
//delay(2000);
}

void loop() {

while (!adxl.dataReady()) {
}
if (adxl.sleeping()) {
  Serial.println("Sleeping");
}
else
{
  ax+=adxl.getX();
  ay+=adxl.getY();
  az+=adxl.getZ();
  /*Serial.print(ax);
   Serial.print('\t');
   Serial.print(ay);
   Serial.print('\t');
   Serial.println(az);*/
}
while (!itg.dataReady()) {
}
gx+=(float)itg.getX();
gy+=(float)itg.getY()*PI/180.0;
gz+=(float)itg.getZ()*PI/180.0;
loops++;
//}

long current=millis();
if (current-lastmillis>FILTER_RATE1000) {
lastmillis=current;
imuFilter.updateFilter(gx/loops
PI/180.0, gy/loopsPI/180.0, gz/loopsPI/180.0, ax, ay, az);
imuFilter.computeEuler();
sumx+=gx/loopsFILTER_RATE;
sumy+=gy/loops
FILTER_RATE;
sumz+=gz/loops*FILTER_RATE;
/Serial.print(ax);
Serial.print(’\t’);
Serial.print(ay);
Serial.print(’\t’);
Serial.println(az);
/

if (count++&gt;10) {
  Serial.print(imuFilter.getPitch()/PI*180.0);
  Serial.print('\t');
  Serial.print(imuFilter.getRoll()/PI*180.0);
  Serial.print('\t');
  Serial.print(imuFilter.getYaw()/PI*180.0);
  Serial.print('\t');
  Serial.print(sumx);
  Serial.print('\t');
  Serial.print(sumy);
  Serial.print('\t');
  Serial.println(sumz);
  count=0;
  /*Serial.print(itg.getX());
   Serial.print('\t');
   Serial.print(itg.getY());
   Serial.print('\t');
   Serial.print(itg.getZ());
   Serial.print('\t');
   Serial.print(adxl.getX());
   Serial.print('\t');
   Serial.print(adxl.getY());
   Serial.print('\t');
   Serial.println(adxl.getZ());*/
  /*Serial.print(imuFilter.q0);
   Serial.print('\t');
   Serial.print(imuFilter.q1);
   Serial.print('\t');
   Serial.print(imuFilter.q2);
   Serial.print('\t');
   Serial.println(imuFilter.q3);*/
}

ax=0,ay=0,az=0,gx=0,gy=0,gz=0;
loops=0;
}
else {
//Serial.println(“Waiting”);
}
}

I think it’s a must have.

I think it’s a must have.

Clean up in Forum

Hrm, looks like someone’s Arduino threw up in here…

Word!

It would really help clean up pages where people are posting large code snippets back and forth.  I see the hand broom icon in the comment window will clean up messy code, not the same thing.