/****************************************************************************************
 * Notice:  When compiling, be sure to use the flags -lX11, -lpthread and of course,    *
 *          be sure the DLP-2232PB-G is plugged into a USB port. I use:                 *
 *                                                                                      *
 *          cc -Wall -lX11 -lpthread -o scope scope.c                                   *
 *                                                                                      *
 *          Pin 5 (AN1) of the DLP-2232PB-G is being used for the input.  Remember, its *
 *          input impedance is quite low and a preamp may be necessary.                 *
 *                                                                                      *
 *          Edit main() to try the various capabilities.                                *
 *          The thermometer routines need a pull-up resistor.  See ds18s20 spec sheet.  *
 *                                                                                      *
 *          Study the 16F877A port specs carefully.  Different pins/ports have varied   *
 *          capabilities - Schmidtt trigger, open-collector, TTL                        *
 *                                                                                      *
 *          Written by Craig Van Degrift <craig@yosemitefoothills.com>                  *
 *                     http://yosemitefoothills.com                                     *
 *                                                                                      *
 *          This demo code is only a best effort.  Use at your own risk.                *
 *          Uncomment the function calls in main() to try the different capabilities.   *
 *                                                                                      *
 *          Consider this code a framework which will need considerable modification    *
 *          to meet the needs of a particular measurement task.                         *
 *                                                                                      *
 ****************************************************************************************/

#include "core.h"
const char* device="/dev/ttyUSB3";
const char* dlpId="DLP-M0";
#include "dlp2232pbg.h"
#include "scope.h"
//#include "thermometers.h"
//#include "mavica.h"


int main(int argc, char** argv) {
  verbose = true;
  struct scope_arg scope_settings1;
  struct scope_arg scope_settings2;

  scope_settings1.digital_port = PortC;
  if (scope_settings1.digital_port == PortA)
    setup_a_to_d(Vdd_Vss, 0, 32);
//  scope_settings1.digital_pin = Pin3;
  scope_settings1.digital_pin = All;
  scope_settings1.block_count = 150;
  scope_settings1.block_size = 0;
  scope_settings1.delay = 0;
  scope_settings1.t_scale_expansion = 1;
  scope_settings1.type = Digital;
  scope_settings1.display_width = 1280;
  pthread_create(&scope_thread1, NULL, scope, (void*)&scope_settings1);

  scope_settings2.analog_input = AN0;
  setup_a_to_d(Vdd_Vss, 5, 32);
  scope_settings2.block_count = 5;
  scope_settings2.block_size = 0;
  scope_settings2.delay = 0;
  scope_settings2.t_scale_expansion = 1;
  scope_settings2.type = Analog;
  scope_settings2.display_width = 1200;
  pthread_create(&scope_thread2, NULL, scope, (void*)&scope_settings2);

  scope_deinit();   // deinit() needs to be done at end except when scope() is run
  return 0;
}
