Degree Computation
Dependencies: aconno_SEGGER_RTT LSM9DS1 Si7006A20 adc52832_common aconnoMPL115A1 aconno_bsp
source/main.cpp
- Committer:
- jurica238814
- Date:
- 2018-12-12
- Revision:
- 0:442d98af8cc7
- Child:
- 3:b62a73dc76b7
File content as of revision 0:442d98af8cc7:
/* * aconno.de * Made by Jurica Resetar * Edited by Karlo Milicevic * Edited by Dominik Bartolovic * All right reserved * */ #include "mbed.h" #include "ble/BLE.h" #include "acd52832_bsp.h" #include "GapAdvertisingData.h" #include "aconnoConfig.h" #include "Si7006A20.h" #include "LSM9DS1.h" #include "adc52832_common/utilities.h" #include "acd_nrf52_saadc.h" #include "tasks.h" #include <events/mbed_events.h> #include "aconnoHelpers.h" GapAdvertisingData adv_data = GapAdvertisingData(); advertising_packet advertisementPacket; LSM9DS1 *mems; DigitalOut lightPower(p28); DigitalOut temperaturePower(p31); DigitalOut shdn(p6); DigitalOut power(p2); Thread updateDataThread; Thread sendDataThread; EventQueue eventQueue; /** * Callback triggered when the ble initialization process has finished */ void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) { BLE &ble = BLE::Instance(); advertisementPacket.header = APPLICATION_ID; /* setup advertising */ ble.gap().accumulateAdvertisingPayload( GapAdvertisingData::BREDR_NOT_SUPPORTED); ble.gap().accumulateAdvertisingPayload( GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)&advertisementPacket, sizeof(advertisementPacket)); ble.gap().setAdvertisingType( GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(ADV_INTERVAL_MS); ble.gap().setTxPower(TX_POWER_DB); // Set TX power to TX_POWER } void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { BLE &ble = BLE::Instance(); eventQueue.call(Callback<void()>(&ble, &BLE::processEvents)); } int main() { //printf("Main started.\r\n"); BLE &ble = BLE::Instance(); ble.init(bleInitComplete); ble.onEventsToProcess(scheduleBleEventsProcessing); while (ble.hasInitialized() == false) { /* spin loop */ } updateDataThread.start(updateDataTask); sendDataThread.start(sendDataTask); /* //DigitalOut bar(I2C_DATA); //DigitalOut foo(I2C_CLK); I2C *i2c; float result; while(true) { power = 1; ThisThread::sleep_for(500); i2c = new I2C(I2C_DATA, I2C_CLK); //I2C i2c(I2C_DATA, I2C_CLK); Si7006 si(i2c); si.getHumidity(&result); printf("Humidity is: %f\r\n", result); power = 0; //wait_ms(1000); //foo = 1; //bar = 1; //I2C fooI2C(I2C_DATA, I2C_CLK); ThisThread::sleep_for(1000); } */ while(true) { Thread::wait(0xFFFFFFFF); } }