<commit_before>/*
 * Pano Controller Firmware
 *
 * Copyright (C)2015-2017 <NAME>
 *
 * This file may be redistributed under the terms of the MIT license.
 * A copy of this license has been included with this distribution in the file LICENSE.
 */
#include <Arduino.h>
#include <SPI.h>
#include <DRV8834.h>
#include <MultiDriver.h>
#include "config.h"
#include "camera.h"
#include "display.h"
#include "mpu.h"
#include "battery.h"
#include "bluetooth.h"
#include "gcode.h"

static Display display(OLED_RESET);

static Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
static Bluetooth bluetooth(ble);

static Battery battery(BATTERY, BATT_R1, BATT_R2, VCC);
static Camera camera(CAMERA_FOCUS, CAMERA_SHUTTER);
static MPU mpu(MPU_I2C_ADDRESS, MPU_INT);
static DRV8834 horiz_motor(MOTOR_STEPS, DIR, HORIZ_STEP, nENABLE);
static DRV8834 vert_motor(MOTOR_STEPS, DIR, VERT_STEP);
static MultiDriver motors(horiz_motor, vert_motor);
static GCode gcode(Serial, motors, camera, mpu, battery);

void setup() {
    Serial.begin(115200);
    delay(2000); // wait for serial
    Serial.println("PanoController built " __DATE__ " " __TIME__);
    Serial.println("setup()");

    display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDRESS, false);
    display.setRotation(0);
    display.clearDisplay();
    display.setTextCursor(0,0);
    display.setTextColor(WHITE);
    display.setTextSize(TEXT_SIZE);

    Serial.println("Checking Camera Shutter Connection");
    pinMode(CAMERA_FOCUS, INPUT_PULLDOWN);
    pinMode(CAMERA_SHUTTER, INPUT_PULLDOWN);
    Serial.print("  Focus: ");
    Serial.println((digitalRead(CAMERA_FOCUS) ? "OK" : "N/C"));
    Serial.print("  Shutter: ");
    Serial.println((digitalRead(CAMERA_SHUTTER) ? "OK" : "N/C"));

    Serial.println("Configuring MPU");
    mpu.begin();

    Serial.println("Configuring stepper drivers");
    horiz_motor.begin(MOTOR_RPM, MICROSTEPS);
    vert_motor.begin(MOTOR_RPM, MICROSTEPS);
    motors.disable(); // turn off motors at startup
    horiz_motor.setSpeedProfile(DRV8834::LINEAR_SPEED, MOTOR_ACCEL, MOTOR_DECEL);
    vert_motor.setSpeedProfile(DRV8834::LINEAR_SPEED, MOTOR_ACCEL, MOTOR_DECEL);

/*
    Serial.println("Configuring Bluefruit LE");
    ble.begin(true);
    ble.echo(false);     // disable command echo
    ble.factoryReset();
    ble.info();
    ble.verbose(false);  // turn off debug info

    Serial.println("Initializing BLE App Communication");
    bluetooth.begin();

    ble.sendCommandCheckOK("AT+BLEBATTEN=1"); // enable battery service
    // ble.sendCommandCheckOK("AT+BLEPOWERLEVEL=0"); // can be used to change transmit power
*/
    Serial.print("Checking battery voltage... ");
    battery.begin();
    Serial.print(battery.voltage()); Serial.println("mV");

    gcode.begin();
    gcode.setGearRatio(HORIZ_GEAR_RATIO, VERT_GEAR_RATIO);

    Serial.println("System ready.");
}

#define BUF_SIZE 32
void loop() {
    static char buffer[BUF_SIZE];
    static char *eob = buffer + BUF_SIZE;
    static int len;

    if (Serial.available()){
        len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
        *(buffer+len) = '\0';
        Serial.print("Received: ");
        Serial.println(buffer);
        gcode.execute(buffer, buffer+len);
        
    }
    
    /*
     * Yield to other processes (ESP8266 and others)
     */
    yield();
}<commit_msg>Comment out  OLED display<commit_after>/*
 * Pano Controller Firmware
 *
 * Copyright (C)2015-2017 <NAME>
 *
 * This file may be redistributed under the terms of the MIT license.
 * A copy of this license has been included with this distribution in the file LICENSE.
 */
#include <Arduino.h>
#include <SPI.h>
#include <DRV8834.h>
#include <MultiDriver.h>
#include "config.h"
#include "camera.h"
#include "display.h"
#include "mpu.h"
#include "battery.h"
#include "bluetooth.h"
#include "gcode.h"

// static Display display(OLED_RESET);

static Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
static Bluetooth bluetooth(ble);

static Battery battery(BATTERY, BATT_R1, BATT_R2, VCC);
static Camera camera(CAMERA_FOCUS, CAMERA_SHUTTER);
static MPU mpu(MPU_I2C_ADDRESS, MPU_INT);
static DRV8834 horiz_motor(MOTOR_STEPS, DIR, HORIZ_STEP, nENABLE);
static DRV8834 vert_motor(MOTOR_STEPS, DIR, VERT_STEP);
static MultiDriver motors(horiz_motor, vert_motor);
static GCode gcode(Serial, motors, camera, mpu, battery);

void setup() {
    Serial.begin(115200);
    delay(2000); // wait for serial
    Serial.println("PanoController built " __DATE__ " " __TIME__);
    Serial.println("setup()");

/*
    display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDRESS, false);
    display.setRotation(0);
    display.clearDisplay();
    display.setTextCursor(0,0);
    display.setTextColor(WHITE);
    display.setTextSize(TEXT_SIZE);
*/
    Serial.println("Checking Camera Shutter Connection");
    pinMode(CAMERA_FOCUS, INPUT_PULLDOWN);
    pinMode(CAMERA_SHUTTER, INPUT_PULLDOWN);
    Serial.print("  Focus: ");
    Serial.println((digitalRead(CAMERA_FOCUS) ? "OK" : "N/C"));
    Serial.print("  Shutter: ");
    Serial.println((digitalRead(CAMERA_SHUTTER) ? "OK" : "N/C"));

    Serial.println("Configuring MPU");
    mpu.begin();

    Serial.println("Configuring stepper drivers");
    horiz_motor.begin(MOTOR_RPM, MICROSTEPS);
    vert_motor.begin(MOTOR_RPM, MICROSTEPS);
    motors.disable(); // turn off motors at startup
    horiz_motor.setSpeedProfile(DRV8834::LINEAR_SPEED, MOTOR_ACCEL, MOTOR_DECEL);
    vert_motor.setSpeedProfile(DRV8834::LINEAR_SPEED, MOTOR_ACCEL, MOTOR_DECEL);

/*
    Serial.println("Configuring Bluefruit LE");
    ble.begin(true);
    ble.echo(false);     // disable command echo
    ble.factoryReset();
    ble.info();
    ble.verbose(false);  // turn off debug info

    Serial.println("Initializing BLE App Communication");
    bluetooth.begin();

    ble.sendCommandCheckOK("AT+BLEBATTEN=1"); // enable battery service
    // ble.sendCommandCheckOK("AT+BLEPOWERLEVEL=0"); // can be used to change transmit power
*/
    Serial.print("Checking battery voltage... ");
    battery.begin();
    Serial.print(battery.voltage()); Serial.println("mV");

    gcode.begin();
    gcode.setGearRatio(HORIZ_GEAR_RATIO, VERT_GEAR_RATIO);

    Serial.println("System ready.");
}

#define BUF_SIZE 32
void loop() {
    static char buffer[BUF_SIZE];
    static char *eob = buffer + BUF_SIZE;
    static int len;

    if (Serial.available()){
        len = Serial.readBytesUntil('\n', buffer, BUF_SIZE);
        *(buffer+len) = '\0';
        Serial.print("Received: ");
        Serial.println(buffer);
        gcode.execute(buffer, buffer+len);
        
    }

    /*
     * Yield to other processes (ESP8266 and others)
     */
    yield();
}
{'fraction_non_alphanumeric': 0.13337285121517486, 'fraction_numerical': 0.017190278601066984, 'mean_word_length': 4.147978642257819, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927715', 'n_tokens_mistral': 2481, 'n_tokens_neox': 2324, 'n_words': 487}