Commit cc0d9a74 authored by Alex Wang Fu's avatar Alex Wang Fu
Browse files

update

parent 50aa1288
......@@ -269,6 +269,7 @@ void i2c_init(busio_i2c_obj_t* i2c)
common_hal_busio_i2c_construct(i2c, scl_pin, sda_pin, I2CBAUD, I2CTIMEOUT);
}
//! TODO: why do we need these delays, and are they an issue?
i2c_accel_sensor_t i2c_accel_create(busio_i2c_obj_t* i2c, uint8_t addr) {
i2c_accel_sensor_t i2c_accel_sensor;
i2c_accel_sensor.i2c_sensor.i2c = i2c;
......@@ -359,6 +360,9 @@ i2c_accel_sensor_t i2c_accel_create(busio_i2c_obj_t* i2c, uint8_t addr) {
}
void i2c_read_accel(i2c_accel_sensor_t sensor) {
/*
* Logic for this comes from `def acceleration(self):` in `adafruit_lis3dh.py`
*/
uint8_t buf[6];
i2c_read_register(sensor.i2c_sensor, _REG_OUT_X_L | 0x80, buf, 6);
......@@ -368,10 +372,9 @@ void i2c_read_accel(i2c_accel_sensor_t sensor) {
double divider = (double) sensor.divider;
printf("x: %f y: %f z: %f divider: %f\n", ((double)x / divider) * STANDARD_GRAVITY , ((double)y / divider) * STANDARD_GRAVITY, ((double)z / divider) * STANDARD_GRAVITY, divider);
printf("x: %f y: %f z: %f\n", ((double)x / divider) * STANDARD_GRAVITY , ((double)y / divider) * STANDARD_GRAVITY, ((double)z / divider) * STANDARD_GRAVITY);
}
void shared_module_ee285_test(void)
{
printf("Doing i2c test\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment