Show Posts
Pages: 1 ... 62 63 [64] 65 66 ... 120
946  Using Arduino / Programming Questions / Re: How do I create tags? on: January 11, 2013, 10:42:19 pm
Will this suffice the flow chart?

Code:
loop(){

  //return on LOW, loop will automatically restart.
  if( Variable != HIGH ) return;

  while( Variable == HIGH  ){
   //Do stuff while true.
  }
}
947  Using Arduino / Programming Questions / Re: Software Reset with WiFi Shield on: January 11, 2013, 06:57:39 am
Also, don't destroy your eeprom cos your wifi disconnected.

Code:
for (int i = 0; i < 1024; i++){
  if( EEPROM.read(i) != 0 ){
    EEPROM.write(i, 0);
  }
}

I'm not sure if EEPROM.write does this automatically, but it would be worth checking.
948  Using Arduino / Programming Questions / Re: help writing library on: January 10, 2013, 06:13:38 pm
post what you are getting, if you make buffer large enough you can manipulate extra text in there.
949  Using Arduino / Programming Questions / Re: pYro's puzzle #1: Increment this. on: January 10, 2013, 02:25:11 am
Yup, you got it, nice answer too.

C or C++ hasn't even come into play when this occurs, this happens even before macros are expanded.
The tokenizer creates the largest possible token from the source input, so the token '++' is considered before '+'.
950  Using Arduino / Displays / Re: need fast lcd on: January 10, 2013, 01:59:56 am
I'm using an SSD1289 here: http://arduino.cc/forum/index.php/topic,140111.0.html

Using a parallel connection on a mega I can clear the screen over 51 times a second. I'm in the middle of finishing up a beta release of a library for it, which I will release very soon.

But regardless of my library, the screen is cheap, it has a touch sensing screen, and works very well with an Arduino Mega ( don't bother with the UNO setup if you want speed ).
951  Using Arduino / Programming Questions / Re: pYro's puzzle #1: Increment this. on: January 10, 2013, 01:46:09 am
Anyone had a go yet?

I'll bump it back up for others to see anyway. This may be difficult, but I thought it was a good one for a first, the next one I have planned should be a little easier.
952  Using Arduino / Programming Questions / pYro's puzzle #1: Increment this. on: January 09, 2013, 08:40:04 am
Hi all,

Over the years I've encountered some great topics regarding C++ that I found interesting enough to archive in my 'box o stuff'.
As I have nothing better to do on a Wednesday night, I'll convey this information via interpretive dance in puzzle form for anybody else looking for a time passer.If you know the answer hold off a little ( or for a few posts between Q & A ) for people to have a crack. If people like these sorts of things, I'll post more.

And before anyone asks, I'm not trying to get someone to do my homework.

#1 Increment This


For the first entry, here is my own extension to a common puzzle. This requires a short preface.

Take the code below, what is printed to the serial monitor? ( not the question )

Code:
int i = 0;
int j = 1;

Serial.println( i+++j, DEC );

For those of you who haven't seen this, it is a classic example of 'order of evaluation', without looking at associativity, operator precedence defines how this is evaluated.

http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence
Precedence  Operator
1  ++ ( Suffix increment )
2  ++ ( Prefix increment )
2  + ( Unary plus )

So...
The suffix operator has precedence, and the code is:
Code:
i++ + j; //( i Suffix increment ) + j

rather than:

Code:
i + ++j; //i + ( j prefix increment )

As you can see operator precedence explains why this works... Or does it.

Why does the code below fail to compile while the two equivalent versions beneath it compile fine?
Code:
i+++++j;
Code:
i++ + ++j;
i+++ ++j;

Hint #1: the answer is not related to the spaces in the code, if you believe this is the answer, explain why the spaces didn't cause error with the version: 'i+++j'

Hint #2
Code:
i++++j;


Cheers.
953  Using Arduino / Programming Questions / Re: Text Array on: January 09, 2013, 02:58:43 am
If we're going to throw things out there that don't directly answer the question then I'll post this one -

Code:
uint32_t sNames[] = {
      '\0nuS'   // 0
    , '\0noM'   // 1
    , '\0euT'   // 2
    , '\0neW'   // 3
    , '\0uhT'   // 4
    , '\0irF'   // 5
    , '\0taS'   // 6
};

Serial.print((char*)&sNames[1]);


Oh, now I just feel silly ...


EDIT:  Then again this is more memory efficient than my original post!

This is wrong anyway,
multi-char character constants are bound to the size of an integer, therefore you can only use uint16_t on Arduino with 2 chars without truncation.
954  Using Arduino / Programming Questions / Re: enumeration declaration on: January 07, 2013, 02:51:40 pm
Enums are for ranges, what you have is a discrete set of values.
You are better off having a collection of strings in progmem that you can compare against, your key or index ( what would be the enum value ) is simply the index of the corresponding progmem string.

The error you had here:
Code:
fruits=setfood;

is because 'setfood' is a pointer, a 16-bit value that has nothing to do with the data it points to. The other problem here is on initialisation the enum can happily be set to values outside the range you specified. This is because the valid enum range is more than what is specified in the brackets.
955  Development / Other Software Development / Re: Help w/ Mouse.click(); when using absolute mode on: January 06, 2013, 07:04:33 pm
Post your code or something that shows what you have attempted. Try using the click and also the press and release options. These options do the same thing, so you could be sending the wrong mouse button ID.

The modifications would only affect what Arduino files are included ( WProgram.h changed to Arduino.h ), not the actual operation of the class.

This will though:

Code:
void Mouse_::click(uint8_t b)
{
_buttons = b;
// move(0,0,0);
_buttons = 0;
// move(0,0,0);
}

The move sends the x,y, and current button, so that function effectively does nothing but set _buttons to '0'
Try replacing the x,y params of move to the last known position ( or where you want the click ).
956  Using Arduino / Programming Questions / Re: Independent functions without using RTOS on: January 04, 2013, 07:29:43 am
I use an interrupt to do so multitasking in my current design. If you have a task that needs to run in a certain interval, you can utilize a timer.
As long as your timer task is shorter than the timer timeout; or alternatively you you break the task up into short parts that run over multiple iterations.

The benefit of this design is you aren't wasting processing time checking if the task actually needs to run, however it is harder to manage and you need to beware of the consequences of using shared memory.
957  Using Arduino / Programming Questions / Re: Clean way to turn interrupts on and off? on: January 04, 2013, 06:35:36 am
The sleep mode for ADC is non-default. I'm currently using the 8-bit mode at a 32x prescaler and it works well.
958  Products / Arduino Due / Re: Arduino 1.5.1 - Final? on: January 04, 2013, 12:35:58 am
I'd imagine this will be quite some time, if not 1.6b ( or whatever revision ) probably will come out very soon after anyway. The Due is still very new, there are people in the same boat as me and are still yet to try the Due. I'd imagine soon when the world is flooded with Due's there will be a surge of input here on how to improve the Arduino core for the ARM ( there are already a number of people investigating certain things ) and all these things may promote numerous revisions.

959  Using Arduino / Programming Questions / Re: Clean way to turn interrupts on and off? on: January 03, 2013, 06:21:06 pm
Check out the link in my signature, I have a class that works on global interrupts for atomic blocking. The 'Atomic_Force' mode emits only 2 instructions for interrupts off/on, you'd be up for a challenge writing code faster than it.

It has a 'Protect' function so you can make variable reads/writes, and function calls all protected from interrupts.
960  Community / Exhibition / Gallery / Re: IV-18 clock on: January 03, 2013, 06:31:45 am
Nice, those displays look nice with the internals visible. Good job.
Pages: 1 ... 62 63 [64] 65 66 ... 120