/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / UTIL_GetTemp() question

Username:     
Password:     
             

Forum

# 1   2008-08-05 20:23:19 UTIL_GetTemp() question

oDCo
New member
Registered: 2008-07-22
Posts: 4

UTIL_GetTemp() question

Hello,

I'm new to programming in C and would like a quick bit of help if possible.

Using the 'Hello, World!' example in the Primer manual as a basis I thought I'd display the temperature instead of the string. However, I just can't figure out how to get the data from UTIL_GetTemp().

Please can someone clarify if UTIL_GetTemp() can be used and if so how?

As a side note, I found this post (http://www.stm32circle.com/forum/viewtopic.php?id=173) while searching the forum which mentions that DRAW_DisplayTemp() has not been included in 1.7.

Thanks in advance.

Last edited by oDCo (2008-08-05 20:24:17)

Offline

 

# 2   2008-08-07 09:59:58 UTIL_GetTemp() question

matloub
Member
Registered: 2008-02-21
Posts: 98

Re: UTIL_GetTemp() question

Hi

It might be intersting to know what you mean by you can not get data from this function.
What have you been trying?  You can post your code lines for instance.

Have you looked at:
http://www.stm32circle.com/circleos_doc/_util_8c.html

Best regards,
Matloub

Offline

 

# 3   2008-08-08 22:03:14 UTIL_GetTemp() question

oDCo
New member
Registered: 2008-07-22
Posts: 4

Re: UTIL_GetTemp() question

Hello, thank you for your response smile

Basically, I want to display the temperature on screen by using UTIL_GetTemp().

I know I shouldn't be using UTIL_int2str() as I'm guessing UTIL_GetTemp() will provide a floating number as opposed to an interger but I can't find a way of displaying a floating number on screen.

Code:

/************************* (C) COPYRIGHT 2007 RAISONANCE **********************
* File Name          :  Application.c
* Author             :
* Date First Issued  :
* Description        :  Circle_App CircleOS application template.
* Revision           :
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "circle_api.h"

/* Private defines -----------------------------------------------------------*/

#define NEEDEDVERSION "V 1.5" // Put here the minimal CircleOS version needed by your application

/* Private variables ---------------------------------------------------------*/

/* Private functions ---------------------------------------------------------*/
enum MENU_code MsgVersion(void);

/* Public variables ----------------------------------------------------------*/

const char Application_Name[8+1] = {"TempDisp"};  // max 8 characters for application name


/*******************************************************************************
* Function Name  : Application_Ini
* Description    : Initialization function of Circle_App. This function will
*                  be called only once by CircleOS.
* Input          : None
* Return         : MENU_CONTINUE_COMMAND
*******************************************************************************/
enum MENU_code Application_Ini ( void )
   {
   if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0)
      {
      return MsgVersion();
      }
      
      
      
      
      // TODO: Write your application initialization function here.

      
      
   return MENU_CONTINUE_COMMAND;
   }

/*******************************************************************************
* Function Name  : Application_Handler
* Description    : Management of the Circle_App.
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code Application_Handler ( void )
   {

   // TODO: Write your application handling here.
   //       This routine will get called repeatedly by CircleOS, until we
   //       return MENU_LEAVE

   int temp;
   char temptext[] ="";
   temp = UTIL_GetTemp();
   UTIL_int2str(temptext,temp,10,1);
   
   DRAW_DisplayString( 5, 20, temptext, sizeof(temptext)); // X, Y, string, length
   return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
   }

/*******************************************************************************
* Function Name  : MsgVersion
* Description    : Display the current CircleOS version and the version needed
*                  exit to main menu after 4 secondes
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code MsgVersion(void)
   {
   int hh,mm,ss,ss2;
   
   DRAW_DisplayString(5,60,"CircleOS",17);
   DRAW_DisplayString(80,60,UTIL_GetVersion(),3);
   DRAW_DisplayString(5,34,NEEDEDVERSION,3);
   DRAW_DisplayString(40,34," required",12);
   
   RTC_GetTime(&hh,&mm,&ss);
   ss = ss + 4;                  // 4 secondes 
   ss = ss%60;
   
   do
      {
      RTC_GetTime(&hh,&mm,&ss2);
      }while (ss2 != ss);           // do while < 4 secondes
   
   return MENU_REFRESH;
   }

When I compile the code I get this message:

Code:

  
----------------Make Started: 'Moving Text' in configuration 'Circle_Debug'-------------------------- 
  
Building C:\Program Files\Raisonance\Ride\examples\MoveText01.c 
 Running : GCC 
 \"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -MD -D_STM32F103RBT6_ -D_STM3x_ -D_STM32x_ -mthumb   -mcpu=cortex-m3 "C:\Program Files\Raisonance\Ride\examples\MoveText01.c" -o "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o" -I "." -I "C:\Program Files\Raisonance\Ride\Lib\ARM\include" -c     -fsigned-char  -g          -ffunction-sections        -mlittle-endian 
 \"C:\Program Files\Raisonance\Ride\Bin\rexrdr.exe" "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.lst" 0 "C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o" 
 \"C:\Program Files\Raisonance\Ride\Bin\rexrdr.exe" "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o.sizetmp" 0 "C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-size.exe" "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o" 
  
Building C:\Program Files\Raisonance\Ride\examples\Moving Text.rapp 
 Running : LD 
 \"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb  -Wl,-T -Xlinker "C:\Program Files\Raisonance\Ride\examples\objdebug\Moving Text.elf.ld" -u _start  -nostartfiles -Wl,-Map -Xlinker "C:\Program Files\Raisonance\Ride\examples\objdebug\Moving Text.map"   
 C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o: In function `Application_Handler':  
 C:\Program Files\Raisonance\Ride\examples/MoveText01.c:66: undefined reference to `UTIL_GetTemp'  
 collect2: ld returned 1 exit status  
  
Build failed

Any help would be greatly appreciated.

David

Last edited by oDCo (2008-08-10 12:22:40)

Offline

 

# 4   2008-08-11 17:28:58 UTIL_GetTemp() question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: UTIL_GetTemp() question

There is a function named "DRAW_DisplayTemp" in circleOS (see draw.c).
You can see how it works...

Offline

 

# 5   2008-08-11 19:07:19 UTIL_GetTemp() question

oDCo
New member
Registered: 2008-07-22
Posts: 4

Re: UTIL_GetTemp() question

But DRAW_DisplayTemp() doesn't appear to work either.

If I change my Application handler to this:

Code:

/*******************************************************************************
* Function Name  : Application_Handler
* Description    : Management of the Circle_App.
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code Application_Handler ( void )
   {

   // TODO: Write your application handling here.
   //       This routine will get called repeatedly by CircleOS, until we
   //       return MENU_LEAVE

//   int temp = 1.9;
//   char temptext[] ="";
//   temp = UTIL_GetTemp();
//   UTIL_uint2str(temptext,temp,10,1);
   
//   DRAW_DisplayString( 5, 20, temptext, sizeof(temptext)); // X, Y, string, length
   DRAW_DisplayTemp(60,0);

   return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
   }

I can this message:

Code:

  
----------------Make Started: 'Moving Text' in configuration 'Circle_Debug'-------------------------- 
  
Building C:\Program Files\Raisonance\Ride\examples\MoveText01.c 
 Running : GCC 
 \"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -MD -D_STM32F103RBT6_ -D_STM3x_ -D_STM32x_ -mthumb   -mcpu=cortex-m3 "C:\Program Files\Raisonance\Ride\examples\MoveText01.c" -o "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o" -I "." -I "C:\Program Files\Raisonance\Ride\Lib\ARM\include" -c     -fsigned-char  -g          -ffunction-sections        -mlittle-endian 
 \"C:\Program Files\Raisonance\Ride\Bin\rexrdr.exe" "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.lst" 0 "C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o" 
 \"C:\Program Files\Raisonance\Ride\Bin\rexrdr.exe" "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o.sizetmp" 0 "C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-size.exe" "C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o" 
  
Building C:\Program Files\Raisonance\Ride\examples\Moving Text.rapp 
 Running : LD 
 \"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb  -Wl,-T -Xlinker "C:\Program Files\Raisonance\Ride\examples\objdebug\Moving Text.elf.ld" -u _start  -nostartfiles -Wl,-Map -Xlinker "C:\Program Files\Raisonance\Ride\examples\objdebug\Moving Text.map"   
 C:\Program Files\Raisonance\Ride\examples\objdebug\MoveText01.o: In function `Application_Handler':  
 C:\Program Files\Raisonance\Ride\examples/MoveText01.c:71: undefined reference to `DRAW_DisplayTemp'  
 collect2: ld returned 1 exit status  
  
Build failed

You said in this post (http://www.stm32circle.com/forum/viewtopic.php?id=173) that DRAW_DisplayTemp() is not included in CircleOS 1.7 . . .  I've just tried running CircleOS 2.0 but that didn't work either.

Am I missing something?  I'm sorry if I'm being stupid but I can't figure this out.

Offline

 

# 6   2008-08-12 09:31:27 UTIL_GetTemp() question

matloub
Member
Registered: 2008-02-21
Posts: 98

Re: UTIL_GetTemp() question

Hi

I think the problem is that UTIL_GetTemp() has been added to Circle_api.h but only to the one in CircleOS !
To resolve this you can download CircleOS version 2 from "Resources"
Then copy the file Circle_api.h from CircleOS\source\OS\  to your:
C:\Program Files\Raisonance\Ride\Examples\ARM\Primer\STM32\toggle_with_CircleOS\src

Or you can can work directly from the projects in circleOS.

Best regards,
Matloub

Offline

 

# 7   2008-08-12 19:36:43 UTIL_GetTemp() question

oDCo
New member
Registered: 2008-07-22
Posts: 4

Re: UTIL_GetTemp() question

Hello Matloub, thank you for your assistance.

The above solution has now got my first code working.  Two more questions now, sorry . . .

1) The numbers which are being displayed range from 450 to 470, I assume this is actually 45.0°C to 47.0°C as if I include UTIL_SetTempMode(1) the range changes to 1160 to 1200?

If the above is correct, I can use a floating number and divide the output by 10

Code:

float temp;
temp = UTIL_GetTemp()/10;

to correct the figure but I now can't find a way of converting a float to a char.

How can I convert a float to a char?  The stuff I've found online hasn't helped/worked.

2) As previously mentioned, copying the CircleOS 2.0 circle_api.h file into C:\Program Files\Raisonance\Ride\Examples\ARM\Primer\STM32\toggle_with_CircleOS\src has worked, whoever this didn't work when I previously installed 2.0 as per these instructions: http://www.stm32circle.com/projects/project.php?id=49.

Any ideas why it didn't work first time?

Thanks for all your help, I really appreciate it.

David

Offline

 

Board footer