Beispiel #1
0
static void RemoteTask (void *pvParameters) {
  (void)pvParameters;
#if PL_CONFIG_HAS_JOYSTICK
  (void)APP_GetXY(&midPointX, &midPointY, NULL, NULL);
#endif
  FRTOS1_vTaskDelay(1000/portTICK_PERIOD_MS);
  for(;;) {
    if (REMOTE_isOn) {
#if PL_CONFIG_HAS_JOYSTICK
      if (REMOTE_useJoystick) {
        uint8_t buf[2];
        int16_t x, y;
        int8_t x8, y8;

        /* send periodically messages */
        APP_GetXY(&x, &y, &x8, &y8);
        buf[0] = x8;
        buf[1] = y8;
        if (REMOTE_isVerbose) {
          uint8_t txtBuf[48];

          UTIL1_strcpy(txtBuf, sizeof(txtBuf), (unsigned char*)"TX: x: ");
          UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), x8);
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" y: ");
          UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), y8);
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" to addr 0x");
    #if RNWK_SHORT_ADDR_SIZE==1
          UTIL1_strcatNum8Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
    #else
          UTIL1_strcatNum16Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
    #endif
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)"\r\n");
          SHELL_SendString(txtBuf);
        }
        (void)RAPP_SendPayloadDataBlock(buf, sizeof(buf), RAPP_MSG_TYPE_JOYSTICK_XY, RNETA_GetDestAddr(), RPHY_PACKET_FLAGS_REQ_ACK);
        LED1_Neg();
      }
#endif
      FRTOS1_vTaskDelay(200/portTICK_PERIOD_MS);
    } else {
      FRTOS1_vTaskDelay(1000/portTICK_PERIOD_MS);
    }
  } /* for */
}
Beispiel #2
0
static void StatusPrintXY(CLS1_ConstStdIOType *io) {
  uint16_t x, y;
  int8_t x8, y8;
  uint8_t buf[64];

  if (APP_GetXY(&x, &y, &x8, &y8)==ERR_OK) {
    UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"X: 0x");
    UTIL1_strcatNum16Hex(buf, sizeof(buf), x);
    UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"(");
    UTIL1_strcatNum8s(buf, sizeof(buf), x8);
    UTIL1_strcat(buf, sizeof(buf), (unsigned char*)") Y: 0x");
    UTIL1_strcatNum16Hex(buf, sizeof(buf), y);
    UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"(");
    UTIL1_strcatNum8s(buf, sizeof(buf), y8);
    UTIL1_strcat(buf, sizeof(buf), (unsigned char*)")\r\n");
  } else {
    UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"GetXY() failed!\r\n");
  }
  CLS1_SendStatusStr((unsigned char*)"  analog", buf, io->stdOut);
}
Beispiel #3
0
static portTASK_FUNCTION(RemoteTask, pvParameters) {
#if PL_HAS_WATCHDOG
    int i;
#endif

    (void)pvParameters;
#if PL_HAS_JOYSTICK
    (void)APP_GetXY(&midPointX, &midPointY, NULL, NULL);
#endif
    for(;;) {
        if (REMOTE_isOn) {
#if PL_HAS_ACCEL
            if (REMOTE_useAccelerometer) {
#if PL_HAS_KEYS
                uint8_t buf[7];
                uint8_t keys;
#else /* PL_HAS_KEYS */
                uint8_t buf[6];
#endif /* PL_HAS_KEYS */
                int16_t x, y, z;

                /* send periodically accelerometer messages */
#if PL_HAS_KEYS
                APP_GetKeys(&keys);
#endif /* PL_HAS_KEYS */
                ACCEL_GetValues(&x, &y, &z);
                buf[0] = (uint8_t)(x&0xFF);
                buf[1] = (uint8_t)(x>>8);
                buf[2] = (uint8_t)(y&0xFF);
                buf[3] = (uint8_t)(y>>8);
                buf[4] = (uint8_t)(z&0xFF);
                buf[5] = (uint8_t)(z>>8);
#if PL_HAS_KEYS
                buf[6] = keys;
#endif /* PL_HAS_KEYS */
                if (REMOTE_isVerbose) {
                    uint8_t txtBuf[48];

                    UTIL1_strcpy(txtBuf, sizeof(txtBuf), (unsigned char*)"TX: x: ");
                    UTIL1_strcatNum16s(txtBuf, sizeof(txtBuf), x);
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" y: ");
                    UTIL1_strcatNum16s(txtBuf, sizeof(txtBuf), y);
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" z: ");
                    UTIL1_strcatNum16s(txtBuf, sizeof(txtBuf), z);
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" to addr 0x");
#if RNWK_SHORT_ADDR_SIZE==1
                    UTIL1_strcatNum8Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
#else
                    UTIL1_strcatNum16Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
#endif
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)"\r\n");
                    SHELL_SendString(txtBuf);
                }
                (void)RAPP_SendPayloadDataBlock(buf, sizeof(buf), RAPP_MSG_TYPE_ACCEL, RNETA_GetDestAddr(), RPHY_PACKET_FLAGS_REQ_ACK);
                LED1_Neg();
            }
#endif
#if PL_HAS_JOYSTICK
            if (REMOTE_useJoystick) {
#if PL_HAS_KEYS
                uint8_t buf[3];
                uint8_t keys;
#else /* PL_HAS_KEYS */
                uint8_t buf[2];
#endif /* PL_HAS_KEYS */
                int16_t x, y;
                int8_t x8, y8;

                /* send periodically accelerometer messages */
#if PL_HAS_KEYS
                APP_GetKeys(&keys);
#endif /* PL_HAS_KEYS */
                APP_GetXY(&x, &y, &x8, &y8);
                buf[0] = x8;
                buf[1] = y8;
#if PL_HAS_KEYS
                buf[2] = keys;
#endif /* PL_HAS_KEYS */
                if (REMOTE_isVerbose) {
                    uint8_t txtBuf[48];

                    UTIL1_strcpy(txtBuf, sizeof(txtBuf), (unsigned char*)"TX: x: ");
                    UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), x8);
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" y: ");
                    UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), y8);
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" to addr 0x");
#if RNWK_SHORT_ADDR_SIZE==1
                    UTIL1_strcatNum8Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
#else
                    UTIL1_strcatNum16Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
#endif
                    UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)"\r\n");
                    SHELL_SendString(txtBuf);
                }
                (void)RAPP_SendPayloadDataBlock(buf, sizeof(buf), RAPP_MSG_TYPE_JOYSTICK_XY, RNETA_GetDestAddr(), RPHY_PACKET_FLAGS_REQ_ACK);
                LED1_Neg();
            }
#endif
#if PL_HAS_WATCHDOG
            for(i=0; i<2; i++) { /* do it in smaller steps */
                WDT_IncTaskCntr(WDT_TASK_ID_REMOTE, 100);
                FRTOS1_vTaskDelay(100/portTICK_RATE_MS);
            }
#else
            FRTOS1_vTaskDelay(200/portTICK_RATE_MS);
#endif
        } else {
#if PL_HAS_WATCHDOG
            for(i=0; i<10; i++) { /* do it in smaller steps */
                WDT_IncTaskCntr(WDT_TASK_ID_REMOTE, 100);
                FRTOS1_vTaskDelay(100/portTICK_RATE_MS);
            }
#else
            FRTOS1_vTaskDelay(1000/portTICK_RATE_MS);
#endif
        }
    } /* for */
Beispiel #4
0
static void RemoteTask (void *pvParameters) {
  (void)pvParameters;
#if PL_CONFIG_HAS_JOYSTICK
  (void)APP_GetXY(&midPointX, &midPointY, NULL, NULL);
#endif
  FRTOS1_vTaskDelay(1000/portTICK_PERIOD_MS);
  for(;;) {
    if (REMOTE_isOn) {
#if PL_CONFIG_HAS_JOYSTICK
      if (REMOTE_useJoystick) {
        uint8_t buf[2];
        int16_t x, y;
        int8_t x8, y8;

        /* send periodically messages */
        APP_GetXY(&x, &y, &x8, &y8);
        if(x8 > 100)
        	buf[0] = 1;
        else if(x8 < -100)
        	buf[0] = 2;
        else
        	buf[0] = 0;
        //buf[0] = x8;
        if(normalSpeedPressed) {
        	if(fastSpeedPressed) {
        		buf[1] = 2;					// fast speed
        	} else {
        		buf[1] = 1;					// normal speed
        	}
        } else if (retourSpeedPressed) {
        	buf[1] = 3;						// retour
        } else {
        	buf[1] = 0;						// stand
        }
        if(startLineFollow == 1) {
        	buf[1] = 4; // left handed
        	startLineFollow = 0;
        }
        if(startLineFollow == 2) {
        	buf[1] = 5; // right handed
        	startLineFollow = 0;
        }
        //buf[1] = y8;
        if (REMOTE_isVerbose) {
          uint8_t txtBuf[48];

          UTIL1_strcpy(txtBuf, sizeof(txtBuf), (unsigned char*)"TX: x: ");
          UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), x8);
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" y: ");
          UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), y8);
          //UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" to addr 0x");
    #if RNWK_SHORT_ADDR_SIZE==1
          //UTIL1_strcatNum8Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
    #else
          //UTIL1_strcatNum16Hex(txtBuf, sizeof(txtBuf), RNETA_GetDestAddr());
    #endif
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" 0/R/L: ");
          UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), buf[0]);
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)" 0/N/F/R: ");
          UTIL1_strcatNum8s(txtBuf, sizeof(txtBuf), buf[1]);
          UTIL1_strcat(txtBuf, sizeof(txtBuf), (unsigned char*)"\r\n");
          SHELL_SendString(txtBuf);
        }
        (void)RAPP_SendPayloadDataBlock(buf, sizeof(buf), RAPP_MSG_TYPE_JOYSTICK_XY, RNETA_GetDestAddr(), RPHY_PACKET_FLAGS_REQ_ACK);
        LED1_Neg();
      }
#endif
      FRTOS1_vTaskDelay(20/portTICK_PERIOD_MS);
    } else {
      FRTOS1_vTaskDelay(1000/portTICK_PERIOD_MS);
    }
  } /* for */
}