<commit_before>/**
 * @file
 * @brief nxt entry point
 */
#include "servo_config.h"


/**
 * @brief main task
 */
task main()
{
    ubyte nRcvBuffer[kMaxSizeOfMessage];
    bNxtLCDStatusDisplay = true;
    wait1Msec(2000); // Give time to start the program at the far end as well

    //
    // Send and receive 1M messages
    //
    for (long nSendTotal = 0; nSendTotal < 1000000; ++nSendTotal)
    {
        if (false == checkBTLinkConnected())
            ErrorFatal("Connect");
        int success = readMessage(nRcvBuffer, kMaxSizeOfMessage);
        if (success == 0)
        {
            string str;
            StringFromChars(str, (char*)nRcvBuffer);
            LogMsg(str);
        }
        wait1Msec(1);
    }

    return;
}

// if (message == 'f'){
//   motor[motorD] = 50;
//   motor[motorE] = 50;
// }
// else if (message == 'b'){
//   motor[motorD] = -50;
//   motor[motorE] = -50;
// }
// else if (message == 'l'){
//   motor[motorD] = 0;
//   motor[motorE] = 50;
// }
// else if (message == 'r'){
//   motor[motorD] = 50;
//   motor[motorE] = 0;

<commit_msg>Added some basic motor processing<commit_after>/**
 * @file
 * @brief nxt entry point
 */
#include "servo_config.h"


/**
 * @brief main task
 */
task main()
{
    ubyte nRcvBuffer[kMaxSizeOfMessage];
    bNxtLCDStatusDisplay = true;
    wait1Msec(2000); // Give time to start the program at the far end as well

    //
    // Send and receive 1M messages
    //
    for (long nSendTotal = 0; nSendTotal < 1000000; ++nSendTotal)
    {
        if (false == checkBTLinkConnected())
            ErrorFatal("Connect");
        int success = readMessage(nRcvBuffer, kMaxSizeOfMessage);
        if (success == 0)
        {
            string str;
            StringFromChars(str, (char*)nRcvBuffer);
            //LogMsg(str);
            processAction(str);
        }
        wait1Msec(1);
    }

    return;
}

/**
 * @brief process an action contained in str and run action
 * @returns
 * On success, returns 0. On error, returns -1.
 */
int processAction(const string& str)
{
    UBYTE message = str[0];
    
    if (message == 'f')
    {
      motor[motorD] = 50;
      motor[motorE] = 50;
    }
    else if (message == 'b')
    {
      motor[motorD] = -50;
      motor[motorE] = -50;
    }
    else if (message == 'l')
    {
      motor[motorD] = 0;
      motor[motorE] = 50;
    }
    else if (message == 'r')
    {
      motor[motorD] = 50;
      motor[motorE] = 0;
    }
    else
    {
        return -1;
    }
    return 0;
}



{'fraction_non_alphanumeric': 0.14928343949044587, 'fraction_numerical': 0.026671974522292995, 'mean_word_length': 1.9669421487603307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '77294', 'n_tokens_mistral': 943, 'n_tokens_neox': 864, 'n_words': 218}