<commit_before>#include "ultrasonic_sensors_controller.h"
#include "potentiometers_controller.h"
#include "motors_control.h"
#include "button_controller.h"

byte potentiometers_pins[4] = {0, 1, 2, 3};
byte ultrasonic_trig_pins[2] = {48, 50};
byte ultrasonic_echo_pins[2] = {49, 51};

ultrasonic ultrasonic(53,52);
t_motors_control motors_control(4);
t_potentiometers_controller potentiometers_control (4, potentiometers_pins);
t_ultrasonic_sensors_controller ultrasonic_sensors_controller (2, ultrasonic_trig_pins, ultrasonic_echo_pins);

char is_command_running;

char firmware_version[] = "2015.11.20.2";// year.month.day.version

char current_buffer[65];

#define DEBUG

//--------------------------------------------------------------------------------------------
void setup() 
{
  motors_control.reset_pins();

  Serial.begin(9600); //Open Serial connection
  
  Serial.print("Jenny 5 firmware version: ");
  Serial.print(firmware_version);
  Serial.println();
  //Print function list for user selection5
  Serial.println("Commands are:");
  Serial.println("Mx y# // Moves motor x with y steps. If y is negative the motor runs in the opposite direction. The motor remains locked at the end of the movement.");
  Serial.println("Dx#  // Disables motor x.");
  Serial.println("Lx#  // Lock motor x.");
  Serial.println("Sx y# // Sets speed of motor x to y.");
  Serial.println("Ax y# // Sets acceleration of motor x to y.");
  Serial.println("Ux# // Gets the distance as measured by ultrasonic sensor x.");
  Serial.println("Motor index is between 0 and num_motors - 1");
  
  Serial.println();

  current_buffer[0] = 0;
  is_command_running = 0;
}

//--------------------------------------------------------------------------------------------
void parse_and_execute_commands(char* tmp_str, byte str_length)
{
  byte i = 0;
  while (i < str_length){
    if (current_buffer[i] >= 'A' && current_buffer[i] <= 'Z' || current_buffer[i] >= 'a' && current_buffer[i] <= 'z'){
      if (tmp_str[i] == 'M' || tmp_str[i] == 'm'){// moves motor
        int motor_index, num_steps;
        sscanf(tmp_str + i + 1, "%d%d", &motor_index, &num_steps);
        motors_control.move_motor(motor_index, num_steps);
        is_command_running = 1;
        i += 3;
      }
      else
        if (tmp_str[i] == 'D' || tmp_str[i] == 'd'){// disables motor
          int motor_index;
          sscanf(tmp_str + i + 1, "%d", &motor_index);
          motors_control.disable_motor(motor_index);
          i++;
        }<commit_msg>added comments of new commands<commit_after>#include "ultrasonic_sensors_controller.h"
#include "potentiometers_controller.h"
#include "motors_control.h"
#include "button_controller.h"

byte potentiometers_pins[4] = {0, 1, 2, 3};
byte ultrasonic_trig_pins[2] = {48, 50};
byte ultrasonic_echo_pins[2] = {49, 51};

ultrasonic ultrasonic(53,52);
t_motors_control motors_control(4);
t_potentiometers_controller potentiometers_control (4, potentiometers_pins);
t_ultrasonic_sensors_controller ultrasonic_sensors_controller (2, ultrasonic_trig_pins, ultrasonic_echo_pins);

char is_command_running;

char firmware_version[] = "2015.11.22.0";// year.month.day.version

char current_buffer[65];

#define DEBUG

//--------------------------------------------------------------------------------------------
void setup() 
{
  motors_control.reset_pins();

  Serial.begin(9600); //Open Serial connection
  
  Serial.print("Jenny 5 firmware version: ");
  Serial.print(firmware_version);
  Serial.println();
  //Print function list for user selection5
  Serial.println("Commands are:");
  Serial.println("Mx y# // Moves motor x with y steps. If y is negative the motor runs in the opposite direction. The motor remains locked at the end of the movement.");
  Serial.println("Dx#  // Disables motor x.");
  Serial.println("Lx#  // Lock motor x.");
  Serial.println("Sx y# // Sets speed of motor x to y.");
  Serial.println("Ax y# // Sets acceleration of motor x to y.");
  Serial.println("Ux# // Gets the distance as measured by the ultrasonic sensor x.");
  Serial.println("Bx# // Gets the status of the button x.");
  Serial.println("Px# // Gets the position of the potentiometer x.");
  Serial.println("Motor index is between 0 and num_motors - 1");
  
  Serial.println();

  current_buffer[0] = 0;
  is_command_running = 0;
}

//--------------------------------------------------------------------------------------------
void parse_and_execute_commands(char* tmp_str, byte str_length)
{
  byte i = 0;
  while (i < str_length){
    if (current_buffer[i] >= 'A' && current_buffer[i] <= 'Z' || current_buffer[i] >= 'a' && current_buffer[i] <= 'z'){
      if (tmp_str[i] == 'M' || tmp_str[i] == 'm'){// moves motor
        int motor_index, num_steps;
        sscanf(tmp_str + i + 1, "%d%d", &motor_index, &num_steps);
        motors_control.move_motor(motor_index, num_steps);
        is_command_running = 1;
        i += 3;
      }
      else
        if (tmp_str[i] == 'D' || tmp_str[i] == 'd'){// disables motor
          int motor_index;
          sscanf(tmp_str + i + 1, "%d", &motor_index);
          motors_control.disable_motor(motor_index);
          i++;
        }
{'fraction_non_alphanumeric': 0.20154738878143133, 'fraction_numerical': 0.018955512572533847, 'mean_word_length': 2.7910557184750733, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5545698', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1614, 'n_words': 427}