Skip to main content
added 667 characters in body
Source Link
Spiked3
  • 2k
  • 12
  • 14

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc

If i was to look at your code, and accept its functionality as literal then the following would work;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          light_green,   tmotorNXT, PIDControl, encoder)

void testThing (tMotor&  motor_name)
{
    tmotor_name = light_green;
}

task main()
{
    tmotor motor_to_use = light_blue;
    testThing(motor_to_use);
    motor[motor_to_use] = 20; // will actually move light_green since testThing function changed its value
}

It's hard to guess what it is you are trying to actually do

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc

If i was to look at your code, and accept its functionality as literal then the following would work;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          light_green,   tmotorNXT, PIDControl, encoder)

void testThing (tMotor&  motor_name)
{
    tmotor_name = light_green;
}

task main()
{
    tmotor motor_to_use = light_blue;
    testThing(motor_to_use);
    motor[motor_to_use] = 20; // will actually move light_green since testThing function changed its value
}

It's hard to guess what it is you are trying to actually do

added 959 characters in body
Source Link
Spiked3
  • 2k
  • 12
  • 14

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}

The actual type of a tmotor is an enum (and used like an int) and the definition can be found in RobotCintrinsics.c included with the product.

for exmaple;

#if (1)

  // the actual 'enum' values for 'tMotor' are automatically defined by the ROBOTC compiler. Each platform
  // and circuit board type has its own set of "enum names" and it was becoming too hard to manage them in
  // this file. So they are automatically configured by the compiler which has better utilities for managing
  // differences between platform types.

  typedef enum tMotor;

#else

    // The old definitions are temporarily maintained here as well until the new implementation is confirmed
  // to be working well!

  #if defined(NXT) || defined(TETRIX)

        typedef enum
        {
          motorA = 0,
          motorB = 1,
          motorC = 2,
          mtr_S1_C1_1 =  3,

    ... etc
Source Link
Spiked3
  • 2k
  • 12
  • 14

The #pragma is more like a #define in terms of names, as opposed to a variable declaration.

Your code is very close; something like this would work fine;

#pragma config(Motor,  motorA,          light_blue,    tmotorNXT, PIDControl, encoder)

void testThing (tMotor  motor_name)
{
    motor[motor_name] = 20;   // set power to 20
}

task main()
{
    testThing(light_blue);
}