Show Posts
Pages: 1 ... 23 24 [25] 26 27 ... 150
361  Using Arduino / Programming Questions / Re: Array of functions? on: May 11, 2014, 10:30:15 pm
So are you saying I should change:

Code:
typedef void (* GPSdata)();
GPSdata displayInfo[3] = {&TinyGPSTime::value, &TinyGPSLocation::lat, &TinyGPSLocation::lng};

to

Code:
typedef void (* GPSdata)();
GPSdata displayInfo[3] = {uint32_t(&TinyGPSTime::value), uint32_t(&TinyGPSLocation::lat), uint32_t(&TinyGPSLocation::lng)};

Because, that doesn't work either (same error). =/

What? No... that is not what I said at all???

The three functions:
  • TinyGPSTime::value
  • TinyGPSLocation::lat
  • TinyGPSLocation::lng

Do they all have the same prototype? As in all take the same parameters ( or none ) and return the same type ( or none ).
Don't just reply yes or no, give details please ( what is/are the prototype(s) ).

If they are the same, you can change your typedef to that prototype.
362  Using Arduino / Programming Questions / Re: Array of functions? on: May 11, 2014, 10:00:08 pm
Here is a hint:
 
Quote
uint32_t (TinyGPSTime:smiley-kiss)()' to 'void (*) (int)

void (*) (int) is a pointer to a function that does not return a value, and takes a single 'int' parameter.

uint32_t (TinyGPSTime::*)() is a pointer to a member function which takes no parameters but returns a uint32_t.

They are completely different function prototypes.

Wrap code that does not format properly in [code][/code] tags. Otherwise :* looks like smiley-kiss ( or nobbc tags )
363  Using Arduino / Project Guidance / Re: Saving Data to Falsh on: May 11, 2014, 05:28:42 am
If you want to delete the data and replace it with something else, you need to look at the EEPROM, PROGMEM is for read only use.
364  Using Arduino / Programming Questions / Re: Pass classes by reference on: May 10, 2014, 10:41:06 pm
No worries, I guess you have used another programming language. Its common for VB users to do this ( I did, and VB6 was my first ).
365  Using Arduino / Programming Questions / Re: Pass classes by reference on: May 10, 2014, 09:56:59 pm
Use the following then report back:
Code:
Time Tiempo;

Code:
Time Tiempo();
This is a function that returns a type 'Time' and has no parameters
366  Development / Other Software Development / Re: Game SDK direct to pins on Arduino on: May 10, 2014, 07:33:44 pm
I guess you have no idea what you are doing???

XPlane does not run on Arduino, it will communicate with devices using some protocol like RS232 over serial, maybe ethernet too.

You will have to write an interpreter to parse the commands coming in and then you will have to decide what to do with the command.
367  Development / Suggestions for the Arduino Project / Re: GCC Versions across platforms on: May 10, 2014, 11:18:54 am
They are already working on it.

http://forum.arduino.cc/index.php?topic=176498.msg1585982#msg1585982

That link is also part of a thread for an IDE that does support 4.8.1
368  Development / Other Software Development / Re: Game SDK direct to pins on Arduino on: May 10, 2014, 02:25:30 am
What SDK?
And by SDK do you mean software development kit?

No bootloader is needed to access the pins directly, quite an unrelated tool, it simply writes a sketch to flash at boot time if one is waiting to be uploaded.
369  Using Arduino / Programming Questions / Re: Stuck in for loops! on: May 09, 2014, 02:05:42 am
Don't even need an array. This would be even simpler if the last element was evenly spaced liked the rest.

Code:
switch( pattern ){
  case 10: pattern = 11;
  default: ahue = bhue = chue  = ( pattern - 1 ) * 16;
}
370  Using Arduino / Programming Questions / Re: How to make a "global" array that's accessible in classes? on: May 08, 2014, 09:51:17 pm
Can I take a stab and guess that you are declaring the array in your sketch and trying to access it directly by name in your library?

Its not going to work this way as the library is compiled before your sketch is seen! You need to do as people have mentioned and pass into the class a pointer or reference to the array. Or have a global pointer that you can set in your library .h.

371  Using Arduino / Installation & Troubleshooting / Re: uninstall firmware from arduino on: May 06, 2014, 04:41:45 pm
The .pde is the sketch, rename it to .ino for the new IDE. There may be other files with the sketch too ( .h, .cpp, .c )

Also use the search feature to check that the old include "WProgram.h" is changed to the newer "Arduino.h"

If you have troubles, post the firmware package and me or someone else can compile it for you.
Once compiled the IDE can be used to upload. Or that xloader app I linked will upload the .hex made by the IDE
372  Using Arduino / Programming Questions / Re: Combining data types to send over CAN in one object on: May 06, 2014, 09:24:54 am
My BitBool library is good for this: http://forum.arduino.cc/index.php?topic=128407.0

I used 32 bits to make things easier.
Sets the first 13 bits ( 0 - 12 ) to 1
Then sets the two booleans.
I offset the unsigned int ( 8bit ) by 1 bit so I can write the value in directly.
There is still the last 8 bits free and bit 15, so your unsigned int can be 16 bits if needed.

Code:
#include <BitBool.h>

union MSG{
  BitBool< 32 > bits;
  uint32_t blob;
} msg = { B11111111, B00011111 };


void setup() {
  
  msg.bits[ 13 ] = true;
  msg.bits[ 14 ] = false;
  msg.bits.Data[ 2 ] = '!';
  
  Serial.begin( 9600 );
  Serial.println( msg.blob, HEX );

}

void loop() {}

EDIT: fixed up the description
373  Using Arduino / Programming Questions / Re: Setting void pointer to null. on: May 06, 2014, 09:04:35 am
Quote
however it is incomplete and only void pointers can be subject things like comparisons.
Say what? Is there a non- missing from that statement somewhere?

Nope, a void pointer can be compared as it is a simple pointer and pointers are always the same size. You cannot dereference a void pointer and compare the result with another dereferenced pointer type. There is no layout information for the compiler to generate any comparison.

374  Using Arduino / Programming Questions / Re: Global Variables and reading from the serial, memory management on: May 06, 2014, 04:04:20 am
It will cause dynamic allocations, weather or not that's an issue to you is a  different question.

F() uses PSTR, so you can do this instead:
Code:
//Inside a function
char *test = PSTR( "TEST" );
char *test2 = PSTR( "TEST2" );

//Or globally
char test[] PROGMEM = "TEST";
char test2[] PROGMEM = "TEST2";

stuff_progmem( char *str ){
 //Access str using pgm_read_byte funtions.
}

EDIT: modified the code to show both local and global declarations.
375  Using Arduino / Programming Questions / Re: Global Variables and reading from the serial, memory management on: May 06, 2014, 03:25:59 am
If the code is usable in multiple locations or is cluttering up another function then for sure use a separate function.
Pages: 1 ... 23 24 [25] 26 27 ... 150