Pages: [1]   Go Down
Author Topic: Problema con funzione ltoa  (Read 214 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Salve come da titolo ho un piccolo problema, mi spiego meglio quando vado a compilare mi da questo errore :
xxxxxxx.ino: In function 'void readConfig()':
xxxxxxx:xx: error: 'ltoa' was not declared in this scope
 

Code:
#include <EEPROM.h>
#include "EEPROMAnything.h"

char ArmCode[];
char disarmCode[];
char adminCode[] ;

struct config_t
{
    long arm;
    long disarm;
    long admin;
    int c_hour;
    int c_minute;
    int c_second;
} configuration;

void saveConfig() {
  configuration.arm = atol(ArmCode);
  configuration.disarm = atol(disarmCode);
  configuration.admin = atol(adminCode);
  configuration.c_hour = hour;
  configuration.c_minute = minute;
  configuration.c_second = second;
  EEPROM_writeAnything(0, configuration);
}
void readConfig() {
  EEPROM_readAnything(0, configuration);
  ltoa(configuration.arm, ArmCode, 10);
  ltoa(configuration.disarm,disarmCode,10);
  ltoa(configuration.admin,adminCode,10);
  hour = configuration.c_hour;
  minute = configuration.c_minute;
  second = configuration.c_second;
}

come posso risolverlo?
grazie in anticipo
Logged

Cagliari, Italy
Offline Offline
Tesla Member
***
Karma: 104
Posts: 6616
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Devi includere il file dove dichiari la funzione LTOA.
Mi pare non esista nella libreria standard di Arduino.
Logged

Code fast. Code easy. Codebender --> http://codebender.cc/?referrer=PaoloP

Selvazzano Dentro - Padova
Offline Offline
God Member
*****
Karma: 28
Posts: 933
"Chi sa fa, chi non sa insegna"
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sì che esiste e fa parte della stdlib: long to array (ltoa)

Forse va dichiarata la libreria con un #include <stdlib.h>

Quote
char * ltoa (long int __val, char * __s, int __radix)      

Convert a long integer to a string.

The function ltoa() converts the long integer value from val into an ASCII representation that will be stored under s. The caller is responsible for providing sufficient storage in s.

Note:
The minimal size of the buffer s depends on the choice of radix. For example, if the radix is 2 (binary), you need to supply a buffer with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one character for each bit plus one for the string terminator. Using a larger radix will require a smaller minimal buffer size.
Warning:
If the buffer is too small, you risk a buffer overflow.
Conversion is done using the radix as base, which may be a number between 2 (binary conversion) and up to 36. If radix is greater than 10, the next digit after '9' will be the letter 'a'.

If radix is 10 and val is negative, a minus sign will be prepended.
« Last Edit: August 05, 2013, 11:30:09 am by cyberhs » Logged

Pages: [1]   Go Up
Jump to: