void value not ignored as it ought to be

Help...
Today I use the new version of Arduino 1.0. :astonished:
I found two big surprise for me.

the first: setTimeout is changed, not work like in version 022 =(

the second: what is this error? "void value not ignored as it ought to be"

my simple code:

String getName[1]="VR";
String getValue[1]="FF";
boolean Verbose;

void loop(){
for (int i=1;i<=10;i++){
if (getName_.toUpperCase()=="VR" && getValue*.toUpperCase()=="FF"){_
_
Verbose=true;_
_ getValue="00";
break;
}
}
}*_

toUpperCase is declared like this:

	void toUpperCase(void);

Thus it doesn't return a value, thus doing this is wrong:

getName [i].toUpperCase()=="VR"

You want something like this:

getName [i].toUpperCase();  // convert to upper case
if (getName [i] == "VR")
  // do something

But why are you doing this?

String getName[1]="VR";
String getValue[1]="FF";

That's declaring an array of one item. How useful is that?

And since arrays start at 0, then this is wrong anyway:

for (int i=1;i<=10;i++){
if (getName [i].toUpperCase()

Since there is only one item (at position 0) you certainly can't work your way from items 1 to 10.

Next time please use "code" tags so your code isn't put into italics when it hits things like "i" in brackets.

sorry for my imperfect previous request.
The code that place is just an example to generate the error.
I simplify it more ...
I do not want change the contents of aa, I use toUpperCase () on the fly just to the if statement. This works well with Arduino 022, what has changed in Arduino 1.0?

String aa="vr";

void loop(){
            if (aa.toUpperCase()=="VR"){
                .....
            }
}

what has changed in Arduino 1.0?

You've already been told. The toUpperCase() function no longer returns a copy of the String converted to upper case. It now converts the String object it is called for to upper case.

If you want to work on a copy of the String, YOU must copy it.

ok, I understand, thank you.

for the first point instead? any advice?
Is there any other way to get setTimeout functionality as it was before (simpleTimer.h) ?

Thank you for any adivice

Ste

Is there any other way to get setTimeout functionality as it was before (simpleTimer.h) ?

All we have is your comment that "it doesn't work the same as before".

What did it do in 0022? What is it doing now? What code are you using?

stemaste:
Is there any other way to get setTimeout functionality as it was before (simpleTimer.h) ?

Don't upgrade? I haven't. Everything still works.

stemaste:
I do not want change the contents of aa, I use toUpperCase () on the fly just to the if statement. This works well with Arduino 022, what has changed in Arduino 1.0?

Judging by the old code, it used to make a temporary copy:

String String::toUpperCase() const
{
  String temp = _buffer;

  for ( unsigned int i = 0; i < _length; i++ )
    temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
  return temp;
}

That's really two copies - one in the function and another returned as the result. The authors must have decided that the extra memory wasted by those copies was something you should do explicitly.

Now it just changes the original:

void String::toUpperCase(void)
{
	if (!buffer) return;
	for (char *p = buffer; *p; p++) {
		*p = toupper(*p);
	}
}

That uses less memory. And if you want to use it you have to make your own copy - just the one, not two.

Did you read this? It explains the difference:

stemaste:
the first: setTimeout is changed, not work like in version 022 =(

Sketch:

#include <SoftwareSerial.h>

SoftwareSerial foo (2, 3);

void setup ()
{
  foo.setTimeout (10);
}
void loop () {}

Version 0022:

sketch_dec21a.cpp: In function 'void setup()':
sketch_dec21a:6: error: 'class SoftwareSerial' has no member named 'setTimeout'

Version 1.0:

Binary sketch size: 2558 bytes (of a 32256 byte maximum)

So you are right, they are different. It compiles under version 1.0. And your complaint is? ...

And your complaint is? ...

Well, OP did say:

Is there any other way to get setTimeout functionality as it was before (simpleTimer.h) ?

thank you for any help,
I think that will solve the problem of "toUpperCase" with this simple function:

void loop(){
            if (ofToUpperCase(aa) =="VR"){
              .....
            }
}

String ofToUpperCase(String js){
  js.toUpperCase();
  return (js); 
}

for the setTimeout I have not understood yet.
I use in various parts of my procedure the function setTimeout (milliseconds, functionx) using the fact that the process continues without waiting for the result of functionx.
In this way I generated n procedures that work in parallel and each are different things but with a contemporary result.
for example:

#include <SimpleTimer.h>

SimpleTimer timer;

void setup(){
    for (int pin=3;pin<=9;pin++)
      analogWrite(pin,0);
    for (int pin=11;pin<=13;pin++)
      analogWrite(pin,0);
}

void loop(){
  timer.run();
  timer.setTimeout(1,goLed1);
  timer.setTimeout(1,goLed2);
}

void goLed1(){
 int j;
 for(j=0;j<=255;j++){
   analogWrite(6,j);
   delay(5);
 }
 delay(200);  
  for(j=255;j>=0;j--){
    analogWrite(6,j);
    delay(5);
  }
}
void goLed2(){
 int j;
 for(j=0;j<=255;j++){
   analogWrite(7,j);
   delay(5);
 }
 delay(200);  
  for(j=255;j>=0;j--){
    analogWrite(7,j);
    delay(5);
  }
}

rather than complaining, I am frustrated by having to change a working project only because the developers decided to ignore the past. A function can not 'change in an upgrade, I do another one if it is needed, I think.

Are evident, however, the limits of my knowledge, so take what I say with a grain of salt.

A small note: "And your complaint is?" I do not speak English, I can not tell the difference between irony and sarcasm in your words;-)

thanks again for any help

  timer.setTimeout(1,goLed1);
  timer.setTimeout(1,goLed2);

Once per millisecond, you want to call goLed1 and goLed2.

void goLed1(){
 int j;
 for(j=0;j<=255;j++){
   analogWrite(6,j);
   delay(5);
 }
 delay(200);  
  for(j=255;j>=0;j--){
    analogWrite(6,j);
    delay(5);
  }
}

This code will take more than 3000 milliseconds to execute. How can you expect to call it once per millisecond?

PaulS:

And your complaint is? ...

Well, OP did say:

Is there any other way to get setTimeout functionality as it was before (simpleTimer.h) ?

The original post said:

stemaste:
I found two big surprise for me.

the first: setTimeout is changed, not work like in version 022 =(

Then the poster said:

for the first point instead? any advice?

I went back to the first post, for the "first point". I had to hunt around to for any examples of setTimeout, in the absence of example code.

A small note: "And your complaint is?" I do not speak English, I can not tell the difference between irony and sarcasm in your words;-)

I'm sorry, I was simply asking what the reported problem is. You did not post any example code. How many times do we try to answer posts where a "problem" is reported but without any examples of such a problem?

I guessed what the problem might be, and could only find that what did not compiled under version 0022, now compiles under version 1.0.

It would help in future if you post the code that reproduces the problem, and specify if any additional, non-standard, libraries are used in your code, so that we might install and try them.

Forget the loop, this code is in the midst of a client event, is executed only once.
I launch the two functions in rapid succession with setTimeout.
Result that the two Fuzions are running at the some time.
I do not care how long they work, my procedure is free to accept new connections immediately without waiting for the end of the work of the two functions.

Only one function can execute at a time - either one of the functions called by the Timer class or loop(). Despite what you seem to think you can do, the Arduino does not have a multi-task operating system. It does one thing at a time.

stemaste:
thank you for any help,
I think that will solve the problem of "toUpperCase" with this simple function:

...

String ofToUpperCase(String js){
  js.toUpperCase();
  return (js);
}

You haven't solved your problem of possibly memory fragmentation but we'll let that pass. Why do you suppose the developers changed the behaviour of the toUpperCase library? Because it caused problems, I am guessing.


stemaste:
for the setTimeout I have not understood yet.
I use in various parts of my procedure the function setTimeout (milliseconds, functionx) using the fact that the process continues without waiting for the result of functionx.

Well, reading up on simpleTimer, it uses polling. So your design criteria will not be met.

void loop(){

timer.run();
  timer.setTimeout(1,goLed1);
  timer.setTimeout(1,goLed2);
}

Shouldn't you set the timeout first? Anyway, simpleTimer only checks the timer when you call timer.run (). Thus it waits for the functions goLed1 and/or goLed2 to finish. So you most certainly won't get 1 mS timeouts.

you're right, I review the basics of my plan.
Arduino is not multitasking, it is true, I thought it might work with isolated processes simulating multitasking.
but do not see how.
My project is simple in words, I have to wait for commands from the network http or udp and run the play of light that lasts for 5/10 seconds.

I would like to launch the game and go to take care of the network.
I'll have to handle the interrupt at this point ...or turning the soup of functions into a single loop, yuck

stemaste:
My project is simple in words, I have to wait for commands from the network http or udp and run the play of light that lasts for 5/10 seconds.
...
I'll have to handle the interrupt at this point ...or turning the soup of functions into a single loop, yuck

Basically, get rid of the delay() function. I discuss various approaches here:

You don't need a single function. All you need to do is check various things in your main loop, eg.

  • Has more data arrived?
  • Is it time to change the light display to the next one in sequence?

stemaste:
I thought it might work with isolated processes simulating multitasking.

That's what loop() and terse coding is for. You have to roll your own tasking.