This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::start() { | |
// Initialise the Gyro - assumes configuration is done | |
// Control Register 4 - enable gyro axis output bits (5, 4 & 3) | |
// The other bits default to 0. CTRL_REG4 = 0b00111000 = 0x38 | |
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG4, 0x38); | |
// Initialise the Accelerometer | |
// Control Register 5 XL - enable accel axis output bits (5, 4 & 3) | |
// The other bits default to 0. CTRL_REG5_XL = 0b00111000 = 0x38 | |
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG5_XL, 0x38); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::setAccelBandwidth(AccelBW bandwidth) { | |
if (!_config.accel.autoBandwidthEnable) { | |
uint8_t CTRL_REG6_XL = readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG6_XL); | |
// Clear the BW_XL bits (1 & 0), maintain the rest | |
// 0xFC = 0b11111100, BW_XL = 00, bandwidth = 408 Hz (default) | |
CTRL_REG6_XL &= 0xFC; | |
switch(bandwidth) { | |
case AccelBW::BW_50Hz: // BW_XL = 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::setGyroBandwidth(GyroBW bandwidth) { | |
uint8_t CTRL_REG1_G = readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG1_G); | |
// Clear the BW_G bits (0 & 1), maintain the rest | |
// 0xFC = 0b11111100, BW_G = 00, bandwidth = LOW (default) | |
CTRL_REG1_G &= 0xFC; | |
switch(bandwidth) { | |
case GyroBW::MIDDLE: // BW_G = 01 | |
CTRL_REG1_G |= 0x01; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::setMagODR(MagODR rate) { | |
if (rate > ODR_80Hz) { | |
enableFastODR(true); | |
switch(rate) { | |
case MagODR::ODR_155Hz: // OM = 11, mode = ULTRA | |
setMagOperatingMode(ULTRA); | |
break; | |
case MagODR::ODR_300Hz: // OM = 10, mode = HIGH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::setGyroODR(GyroODR rate) { | |
uint8_t CTRL_REG1_G = readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG1_G); | |
// Clear the ODR_G bits (7, 6 & 5), maintain the rest | |
// 0x1F = 0b00011111, ODR_G = 000, mode = power-down | |
CTRL_REG1_G &= 0x1F; | |
_config.gyro.powerDown = false; | |
_config.gyroAccelOpMode = NORMAL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::setGyroScale(GyroScale scale) { | |
uint8_t CTRL_REG1_G = readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG1_G); | |
// Clear the FS bits (3 & 4), maintain the rest | |
// 0xE7 = 0b11100111, FS = 00, scale = 245 DPS | |
CTRL_REG1_G &= 0xE7; | |
switch(scale) { | |
case GyroScale::FS_500DPS: | |
CTRL_REG1_G |= (0x01 << 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReefwingLSM9DS1::reset() { | |
writeByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_CTRL_REG8, 0x05); | |
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_CTRL_REG2_M, 0x0c); | |
delay(20); | |
// Check that chip boot up is complete - bit 3 is BOOT_STATUS | |
// Mask the STATUS_REG with 0b00001000 = 0x08 | |
while ((readByte(LSM9DS1AG_ADDRESS, LSM9DS1AG_STATUS_REG) & 0x08) != 0) { | |
yield(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_LSM9DS1.h> | |
Adafruit_LSM9DS1 lsm; | |
void setup() { | |
Serial.begin(9600); | |
if (!lsm.begin()) { | |
Serial.println("Failed to initialize LSM9DS1!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import random | |
# Send GET request to Quotes to Scrape website | |
base_url = 'http://quotes.toscrape.com/page/{}/' | |
page_number = 1 | |
quotes = [] | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import random | |
# Send GET request to Quotes to Scrape website | |
url = 'http://quotes.toscrape.com/' | |
response = requests.get(url) | |
# Use BeautifulSoup to parse the HTML content of the response | |
soup = BeautifulSoup(response.content, 'html.parser') |