2017-11-01 29 views
0

私のコードには複数のエラーがあり、数時間のデバッグ後にはコンパイルできません。このコードは、異なる色のカテゴリを読み込んで明確にするループで実行する必要があります。また、コードをアクティブにするために近接センサーを使用しました。Mbedコードの問題

コードは7つのループで実行されます。私がpと定義した各ループでは、関数rgb_processから明確な値をblock [p]というスタックに入れます。以下のようにエラーがあります:

Warning: Parameter "rgb_c" was set but never used in "main.cpp", Line: 22, Col: 49 
Warning: Parameter "rgb_r" was set but never used in "main.cpp", Line: 22, Col: 59 
Warning: Parameter "rgb_g" was set but never used in "main.cpp", Line: 22, Col: 69 
Warning: Parameter "rgb_b" was set but never used in "main.cpp", Line: 22, Col: 79 
Error: Identifier "rgb_readings" is undefined in "main.cpp", Line: 40, Col: 20 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 45, Col: 30 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 45, Col: 46 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 45, Col: 62 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 45, Col: 78 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 50, Col: 34 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 50, Col: 50 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 50, Col: 66 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 50, Col: 82 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 55, Col: 38 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 55, Col: 54 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 55, Col: 70 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 55, Col: 86 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 60, Col: 42 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 60, Col: 58 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 60, Col: 74 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 60, Col: 90 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 65, Col: 46 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 65, Col: 62 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 65, Col: 78 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 65, Col: 94 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 70, Col: 49 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 70, Col: 65 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 70, Col: 81 
Error: Expression must have pointer-to-object type in "main.cpp", Line: 70, Col: 97 
Error: Type name is not allowed in "main.cpp", Line: 101, Col: 28 
Error: Expected a ")" in "main.cpp", Line: 101, Col: 32 
Error: Too few arguments in function call in "main.cpp", Line: 101, Col: 32 
Error: Expected a ";" in "main.cpp", Line: 102, Col: 10 
Error: Type name is not allowed in "main.cpp", Line: 131, Col: 27 
#include "mbed.h" 
#include "stdint.h" 
#include "MCP23017.h" 
#include "C12832.h" 
#include "TCS3472_I2C.h" 
#include "VL6180.h" 
#include <string> 
#include <iostream> 
using namespace std; 

DigitalOut RED_CHIP(p21); 
DigitalOut BLUE_CHIP(p22); 
DigitalOut GREEN_CHIP(p23); 
DigitalOut Red(p23); 
DigitalOut Green(p24); 
DigitalOut Blue(p25); 
TCS3472_I2C rgb_sensor(p9,p10); 
C12832 lcd(p5,p7,p6,p8,p11); 
Serial pc(USBTX,USBRX); 
VL6180 TOF_sensor(p28,p27); 

void coloursensorread (int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b) //colour sensor read 
{ 
    wait(3); 

    rgb_sensor.enablePowerAndRGBC(); 
    rgb_sensor.setIntegrationTime(100); 
    rgb_sensor.getAllColors(rgb_readings); 
    rgb_c= rgb_readings[0]; 
    rgb_r= rgb_readings[1]; 
    rgb_g= rgb_readings[2]; 
    rgb_b= rgb_readings[3]; 

     //pc.printf("C:%d, R:%d, G:%d, B:%d\n",rgb_readings[0],rgb_readings[1],rgb_readings[2],rgb_readings[3]); 
     wait(2); 
} 

void rgb_process(int p,int rgb_c,int rgb_r,int rgb_g,int rgb_b,int block [5]) 
{ 
     if ((4000<rgb_readings[0]<2300)&(2450<rgb_readings[1]<1750)&(850<rgb_readings[2]<400)&(800<rgb_readings[3]<400)) //red 
     { 
      block [p] = 0; 
      //r = r+1; 
     } 
      else if ((rgb_c[0]>1000)&(rgb_r[1]<1000)&(rgb_g[2]>2000)&(rgb_b[3]<1000)) //green 
      { 
       block [p] = 1; 
       //r = r+1; 
      } 
       else if ((rgb_c[0]>1000)&(rgb_r[1]<1000)&(rgb_g[2]<1000)&(rgb_b[3]>2000)) //blue 
       { 
        block [p] =2; 
        //r = r+1; 
       } 
        else if ((rgb_c[0]>1000)&(rgb_r[1]<1000)&(rgb_g[2]>2000)&(rgb_b[3]<1000)) //yellow (edit values) 
        { 
         block [p] = 3; 
         // r = r+1; 
        } 
         else if ((rgb_c[0]>1000)&(rgb_r[1]<1000)&(rgb_g[2]>2000)&(rgb_b[3]<1000)) //orange (edit Values) 
         { 
          block [p]=4; 
          // r = r+1; 
         } 
          else if ((rgb_c[0]>1000)&(rgb_r[1]<1000)&(rgb_g[2]>2000)&(rgb_b[3]<1000)) //white (edit values) 
          { 
           block [p] =5; 
           //r = r+1; 
          } 
           else if((rgb_c[0]>1000)&(rgb_r[1]<1000)&(rgb_g[2]>2000)&(rgb_b[3]<1000)) //black (edit values) 
           { 
            block [p]=6; 
            //r = r+1; 
           } 

}       

void prox_sensor() 
{ 
    uint8_t dist; 

    TOF_sensor.VL6180_Init(); 
    pc.printf("TOF Sensor"); 
    wait(2); 
    //lcd.cls(); lcd.locate(0,0); 

     //lcd.cls(); 
     dist = TOF_sensor.getDistance(); 
     pc.printf("D=%d",dist); 
     wait(1); 
     //lcd.locate(0,0); 
} 




    void colourresult(int p, int block[5],int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b,int b0,int b1,int b2,int b3,int b4,int b5) 
{ 
    for (p = 0;p<6;p++) 
    { 
     coloursensorread (int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b) 
     rgb_process(int p,int rgb_c,int rgb_r,int rgb_g,int rgb_b,int block [5]) 
     wait(1); 
    } 
    b0 = block [0]; 
    b1 = block [1]; 
    b2 = block [2]; 
    b3 = block [3]; 
    b4 = block [4]; 
    b5 = block [5]; 
    pc.printf("%d,%d,%d,%d,%d,%d\n",b0,b1,b2,b3,b4,b5); 
} 



void ReadData(int p, int block[5],int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b,int b0,int b1,int b2,int b3,int b4,int b5) 
{ 
    uint8_t dist; 
    TOF_sensor.VL6180_Init(); 

    for (;;) 
    { 
     //lcd.cls(); 
     dist = TOF_sensor.getDistance(); 
     //lcd.locate(0,0); 
     pc.printf("Distance=%d", dist); 
     wait(1); 

     if (dist>99) 
     { 
      colourresult(int p, int block[5],int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b,int b0,int b1,int b2,int b3,int b4,int b5); 
      return ReadData(int p, int block[5],int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b,int b0,int b1,int b2,int b3,int b4,int b5); 
      } 
      else { 
       wait(3); 
       return ReadData(int p, int block[5],int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b,int b0,int b1,int b2,int b3,int b4,int b5); 
       } 
      } 
    } 

int main() 
{ 
    int rgb_readings[3]; 
    int block [5]; 
    int b0; 
    int b1; 
    int b2; 
    int b3; 
    int b4; 
    int b5; 
    int rgb_c; 
    int rgb_r; 
    int rgb_g; 
    int rgb_b; 

    int p; 
    ReadData(int p, int block[5],int rgb_readings[3],int rgb_c,int rgb_r,int rgb_g,int rgb_b,int b0,int b1,int b2,int b3,int b4,int b5); 
+0

アームMBEDは...あなた – ivoruJavaBoy

+0

@ivoruJavaBoyすでに編集されたエラーを助けるために容易になります。 –

答えて

0

、あなたのコードのデバッグを支援したい場合は、私がオンラインコンパイラにインポートすることができるリンクを共有示唆しています。それ以外の場合は、別のバージョンのライブラリや他のものを使用してしまうかもしれません。

私たちが助けてくれるように、コードへのリンクを共有してください。

-Austin あなたがエラーマーヴィンのログを含める必要があります