0

Adafruit Data type help
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit Data type help

by anini119 on Mon Apr 22, 2019 9:29 pm

Code: Select all | TOGGLE FULL SIZE
/*********************************************************************
  Adapted from Bluefruit LE Connect Plotter
  for Feather Bluefruit -> Bluefruit LE Connect app
  (MIT License)
*********************************************************************/
#include <Arduino.h>
#include <SPI.h>
#if not defined (_VARIANT_ARDUINO_DUE_X_) && not defined (_VARIANT_ARDUINO_ZERO_)
#include <SoftwareSerial.h>
#endif

#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"
#include "BluefruitConfig.h"

#define FACTORYRESET_ENABLE         1
#define MINIMUM_FIRMWARE_VERSION    "0.6.6"
#define MODE_LED_BEHAVIOUR          "MODE"
/*=========================================================================*/

// Data to plot
#define NUMBER 143
int data[NUMBER] = {-1.00627745,-1.00064115,-0.9947667,-0.98881285,-0.982859,-0.9767464,-0.9707132,-0.96491815,-0.95920245,-0.9534868,-0.9479299,-0.9422936,-0.9365779,-0.931021,-0.9253847,-0.91966905,-0.9139534,-0.9083171,-0.9026014,-0.8969651,-0.8912494,-0.8855337,-0.879818,-0.8741817,-0.86846605,-0.86298855,-0.85743165,-0.85179535,-0.84607965,-0.84036395,-0.83464825,-0.82885315,-0.8231375,-0.81734245,-0.8116268,-0.80606985,-0.80035415,-0.79463845,-0.78892275,-0.7831277,-0.77741205,-0.77177575,-0.76613945,-0.7604238,-0.7547875,-0.7491512,-0.7434355,-0.7377198,-0.7320835,-0.7264472,-0.7208109,-0.7151746,-0.7095383,-0.703902,-0.6982657,-0.6926294,-0.6869931,-0.6813568,-0.67572055,-0.6701636,-0.6645273,-0.658891,-0.65317535,-0.64745965,-0.64182335,-0.63610765,-0.63047135,-0.62475565,-0.61911935,-0.61348305,-0.60784675,-0.60221045,-0.59649475,-0.59077905,-0.58514275,-0.5794271,-0.57363205,-0.56799575,-0.56228005,-0.5565644,-0.5509281,-0.54513305,-0.53949675,-0.53393985,-0.52830355,-0.52266725,-0.51711035,-0.51155345,-0.50591715,-0.50028085,-0.4945652,-0.48892895,-0.48337205,-0.47781515,-0.47209945,-0.46646315,-0.4609062,-0.4552699,-0.449713,-0.4441561,-0.4385992,-0.4330423,-0.427406,-0.4216903,-0.4158952,-0.4101795,-0.40438445,-0.3986688,-0.39295315,-0.3872375,-0.3815218,-0.3757267,-0.370011,-0.3642953,-0.358659,-0.3529433,-0.34730705,-0.3415914,-0.3358757,-0.33016,-0.3244443,-0.318808,-0.3131717,-0.3075354,-0.304752789,-0.301925611,-0.299139353,-0.2963025,-0.2935108,-0.2906605,-0.287860231,-0.2851225,-0.28232,-0.2795921,-0.276787222,-0.2738765,-0.271041286,-0.2683195,-0.2657792,-0.2631595,-0.260381,-0.2572055,-0.25403};
int counter = 0;

// Create the Bluefruit Object
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);


// A small helper
void error(const __FlashStringHelper*err) {
  Serial.println(err);
  while (1);
}

/*=========================================================================
 * Setup
 */
void setup(void)
{
  // Set up Serial output
  Serial.begin(115200);
  Serial.println(F("Adafruit Bluefruit Data Plotting"));
  Serial.println(F("------------------------------------------------"));

  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(VERBOSE_MODE) )
  {
    error(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
  }
  Serial.println( F("OK!") );

  if ( FACTORYRESET_ENABLE )
  {
    /* Perform a factory reset to make sure everything is in a known state */
    Serial.println(F("Performing a factory reset: "));
    if ( ! ble.factoryReset() ) {
      error(F("Couldn't factory reset"));
    }
  }

  /* Disable command echo from Bluefruit */
  ble.echo(false);

  Serial.println("Requesting Bluefruit info:");
  /* Print Bluefruit information */
  ble.info();

  Serial.println(F("Please use Adafruit Bluefruit LE app to connect in UART mode"));
  Serial.println(F("Then Enter characters to send to Bluefruit"));
  Serial.println();

  ble.verbose(false);  // debug info is a little annoying after this point!

  /* Wait for connection */
  while (! ble.isConnected()) {
    delay(500);
  }

  Serial.println(F("******************************"));

  // LED Activity command is only supported from 0.6.6
  if ( ble.isVersionAtLeast(MINIMUM_FIRMWARE_VERSION) )
  {
    // Change Mode LED Activity
    Serial.println(F("Change LED activity to " MODE_LED_BEHAVIOUR));
    ble.sendCommandCheckOK("AT+HWModeLED=" MODE_LED_BEHAVIOUR);
  }

  // Set module to DATA mode
  Serial.println( F("Switching to DATA mode!") );
  ble.setMode(BLUEFRUIT_MODE_DATA);
 
 delay(5000);                  //wait 1 second

  // Plot values in data array
  for (int i=0; i<NUMBER; i++) {
    ble.print(String( data[ i ] ).c_str());
    if (i < NUMBER-1) {
      ble.println();
         } 
  }
  // plot the values

  Serial.println(F("******************************"));
}

void loop () {
   
}


I have to plot the given range of data having negative and Positive Values.
What is the command such that the adafruit feather prints this data?

Thanks in Advance.

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Please be positive and constructive with your questions and comments.