Air Quality 2 click compiling problems

General discussion on mikroC PRO for FT90x.
Post Reply
Author
Message
Mysse
Posts: 2
Joined: 06 Jan 2018 09:45

Air Quality 2 click compiling problems

#1 Post by Mysse » 07 Jan 2018 14:54

Hello,

I'm trying to get example of Air Quality 2 click to get compiled, but i receive errors. Example is taken from https://libstock.mikroe.com/projects/do ... ft90x.mpkg help file example air_quality_2_FT90x.c

I have mikroC PRO 2.2.1+visual TFT as software and HMI 5" FT900 Rev 1, hmi-bb and mikroprog for FT90X as hardware.

Compile errors:

Code: Select all

0 122 Compilation Started stdint.h
61 324 Undeclared identifier 'co2_array' in expression AirQuality2_TEST.c
61 324 Undeclared identifier 'co2_array_ind' in expression AirQuality2_TEST.c
61 322 Pointer required AirQuality2_TEST.c
62 324 Undeclared identifier 'co2_array_ind' in expression AirQuality2_TEST.c
62 324 Undeclared identifier 'co2_array_ind' in expression AirQuality2_TEST.c
66 324 Undeclared identifier 'co2_array' in expression AirQuality2_TEST.c
66 322 Pointer required AirQuality2_TEST.c
66 317 Operator '' is not applicable to these operands '' AirQuality2_TEST.c
0 102 Finished (with errors): 07 tammi 2018, 14:59:02 AirQuality2_TEST.mcpf9
My code:

Code: Select all

/***************************************************************************/
#include "air_quality_2_click.h"

/***************************************************************************/
#define POLLING_PERIOD 5000

#define SAMPLES 12
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
static iaq_info_t info;
static char str_buffer[16];

static iaq_status_t iaq_status;


/***************************************************************************/
static void system_init( void );

/***************************************************************************/
static void system_init( void )
{
    UART1_Init( 57600 );

    I2CM1_Init( _I2CM_SPEED_MODE_STANDARD, _I2CM_SWAP_DISABLE );
    air_quality_2_click_init();

    UART1_Write_Text("\x0C");   // Write new page.
    UART1_Write_Text("---------------------------------------------------\r\n");
    UART1_Write_Text("-|               System initialized.             |-\r\n");
    UART1_Write_Text("---------------------------------------------------\r\n");
}

static void status_to_str(iaq_status_t status, char* str)
{
    switch (status)
    {
    case IAQ_OK:
        strcpy(str, "OK");
        break;
    case IAQ_BUSY:
        strcpy(str, "BUSY");
        break;
    case IAQ_ERROR:
        strcpy(str, "ERROR");
        break;
    case IAQ_RUNIN:
        strcpy(str, "RUNIN");
        break;
    default:
        strcpy(str, "UNKNOWN");
        break;
    }
}

static float get_average(uint16_t sample)
{
    uint8_t i;
    float sum = 0;

    co2_array[co2_array_ind++] = sample;
    if(co2_array_ind == SAMPLES) co2_array_ind = 0;

    for(i = 0; i < SAMPLES; i++ )
    {
        sum += co2_array[i];
    }

    return sum / SAMPLES;
}

/***************************************************************************/
void main()
{
    system_init();

    while (1)
    {
        // Read measurements.
        iaq_status = air_quality_2_click_info(&info);

        // Write results to UART.
        UART1_Write_Text("Status:\x09\x09");
        status_to_str(iaq_status, str_buffer);
        UART1_Write_Text(str_buffer);
        UART1_Write_Text("\r\n");

        UART1_Write_Text("CO2:\x09\x09");
        LongToStr(info.co2_eq, str_buffer);
        UART1_Write_Text(Ltrim(str_buffer));
        UART1_Write_Text("\x09ppm\r\n");

        UART1_Write_Text("TVOC:\x09\x09");
        LongToStr(info.tvoc_eq, str_buffer);
        UART1_Write_Text(Ltrim(str_buffer));
        UART1_Write_Text("\x09ppb\r\n");

        UART1_Write_Text("Resistance:\x09");
        LongToStr(info.resistance, str_buffer);
        UART1_Write_Text(Ltrim(str_buffer));
        UART1_Write_Text("\x09ohm\r\n");

        UART1_Write_Text("---------------------------------------------------");
        UART1_Write_Text("\r\n");

        Delay_ms(POLLING_PERIOD);
    }
}

/*************** END OF FUNCTIONS *********************************************/
I tried this as workaround for errors:

Code: Select all

float co2_array[12] = { 0 };
    int co2_array_ind = 0;

    //co2_array[*co2_array_ind++] = sample;
    //if(co2_array_ind == SAMPLES) co2_array_ind = 0;

    for(i = 0; i < SAMPLES; i++ )
    {
        co2_array[i] = sample;
    }
But then i get this:

Code: Select all

0 122 Compilation Started stdint.h
116 123 Compiled Successfully AirQuality2_TEST.c
62 1164 Variable 'co2_array_ind' has been eliminated by optimizer AirQuality2_TEST.c
0 127 All files Compiled in 78 ms  
0 360 Unresolved extern 'TFT_16bit_RS' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_DataPort_Lo' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_WR' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_RS' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_DataPort_Lo' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_WR' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_CS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RD' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_CS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RD' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 102 Finished (with errors): 07 tammi 2018, 15:02:00 AirQuality2_TEST.mcpf9
After commenting this line and doing my workaround:

Code: Select all

// iaq_status = air_quality_2_click_info(&info);
i get prog compiled but its not getting any readings

Terminal:

Code: Select all

Status:		OK

CO2:		0	ppm

TVOC:		0	ppb

Resistance:	0	ohm

---------------------------------------------------
Any help is appreciated.

User avatar
marko.stankovic
mikroElektronika team
Posts: 108
Joined: 18 Dec 2017 15:44

Re: Air Quality 2 click compiling problems

#2 Post by marko.stankovic » 09 Jan 2018 10:13

Hi,

When you open example go to Project -> Edit Search Paths, then in section Header files and Source files
click on Add header path and Add search path icon and then in both cases choose Uses in Click_Air_quality_2, and at the end click on Apply.
I think this should solve the problem.

Best Regards,
Marko Stankovic.

Mysse
Posts: 2
Joined: 06 Jan 2018 09:45

Re: Air Quality 2 click compiling problems

#3 Post by Mysse » 16 Jan 2018 18:27

I have added search paths for it before trying those desperate measures :D

But i have purchased clicker 2 PIC32MX to make sensor readings to HMI via serial, since PIC32 seems to have better support on click boards at libstock. Hope it all will sort out better and easier with PIC32.

Post Reply

Return to “mikroC PRO for FT90x General”