/* Licensed under the MIT License. */

#include <stdlib.h>
#include <stdio.h>

#include "esp32_azureiotkit_sensors.h"
#include "esp_err.h"
#include "nvs_flash.h"

// Macro to help obtain the length of a string define discounting the byte used for null-terminator (\0).
#define lengthof(x)                      (sizeof(x) - 1)

#define OLED_SPLASH_MESSAGE              "Hello World!"

int last_sensor_read_time =              0;
const int sensor_read_frequency_millis = 5000;
bool led1_on = false;
bool led2_on = true;

void setup() {
    esp32_azureiotkit_initialize_sensors();
}

void loop() {
  if ((millis() - last_sensor_read_time) >= sensor_read_frequency_millis)
  {
      int pitch, roll, accelX, accelY, accelZ;
      esp32_azureiotkit_get_pitch_roll_accel(&pitch, &roll, &accelX, &accelY, &accelZ);
      printf("pitch=%d\r\n", pitch);
      printf("roll=%d\r\n", roll);
      printf("acceleration X=%d\r\n", accelX);
      printf("acceleration Y=%d\r\n", accelY);
      printf("acceleration Z=%d\r\n", accelZ);

      last_sensor_read_time = millis();
  }
}
D0D1D2D3D4D5D6D7GNDLOGIC