Show Posts
Pages: 1 ... 50 51 [52] 53 54 ... 152
766  Using Arduino / Programming Questions / Re: How to undo a flipped state? on: January 19, 2014, 01:18:09 am
Do you intend:

Code:
digitalRead( BTN_01 == LOW )

or

Code:
digitalRead( BTN_01 ) == LOW

They are very different.
767  Using Arduino / Programming Questions / Re: how to use ''for'' on: January 18, 2014, 10:37:53 pm
What is your event, an interrupt?
And are you just trying to control the loop() function rather than a loop construct like for or while?
768  Development / Other Software Development / Re: Reference Array - add a sub topic for handling arrays on: January 18, 2014, 04:25:19 am
There are more tricks to be played in C++ as operators may be defined for the struct/class. With a template class you can also handle different array sizes and avoid using the heap (malloc/free, new/delete).
Cheers!

GCC also supports compound literals. Not something which is standard.

Assign new array to old array using kowalski's struct & compund literal:
Code:
//Initialisation, this is standard use.
array_t matrix = {{ 'a','b','c','d','e','f','g','\0' }};

//Assignment using compound literal
matrix = ( array_t  ){{ 'h','i','j','k','l','m','n','\0' }};

Using a template version of memcpy ( passing size in like standard memcpy, 3 params ):
Code:
template< typename T >
  T *arrcpy( T *dest, const T *source, int size ){
    while( --size >= 0x00 ){ dest[ size ] = source[ size ]; }
    return dest;
  }

Using a template version of memcpy specifically for arrays ( no third parameter to pass size ):
Code:
template< typename T, size_t N >
  T *arrcpy( T (&dest)[N], const T (&source)[N] ){
    int size = N;
    while( --size >= 0 ){ dest[ size ] = source[ size ]; }
    return dest;
  }
769  Using Arduino / Networking, Protocols, and Devices / Re: What is the "latest.txt" file? on: January 18, 2014, 12:13:07 am
Latest stable version I guess.

Remember the pre 1.0 versions were 4 digits ( 0022 ).
The IDE peeps might have once wanted to put in an "check for updates" feature.
Seems like it was updated around the time of the 105 release.

Quote
Last-Modified: Wed, 02 Oct 2013 13:46:55 GMT
770  Using Arduino / Networking, Protocols, and Devices / Re: DhcpAddressPrinter error on: January 16, 2014, 09:41:19 am
I don't use the ICS features for this, well not directly anyway.

In windows 7 go to your 'network sharing center'
On the left click 'Change adapter settings'

There you will see an icon for your wifi and an icon for your LAN.
Right click the LAN and select bridge connections.
Select both icons and right click -> 'bridge connections'

Once done, your Arduino can use DHCP from the router your laptop connects to.
771  Using Arduino / Networking, Protocols, and Devices / Re: How to get remote IP without modding the core. on: January 16, 2014, 07:43:26 am
If it were added to the Client class, it would have to be a virtual function. This would break all existing classes that derive from Client.
772  Using Arduino / Programming Questions / Re: Bitshifting Isn't Working right. on: January 16, 2014, 02:12:05 am
Where is the rest of your code, I can only guess that testData is even an integer type.

Your output does not look like it came from that code.

Code:
for(int i=0; i<8; i++){
   Serial.print(testData)
   testData = testData >> i;
   delay(2000);
}

You print the initial value and shift 0 bits in the first iteration. Your output should contain the starting value twice when the second iteration prints the data.
773  Using Arduino / Programming Questions / Re: "precompiled headers" problem - how to force recompilation? on: January 16, 2014, 01:16:11 am
There is no need for run time control over a compile time constant. Using templates you can achieve what you want. Depending on how the library is structured, it may be very simple.

What is the library you are using. Searching finds pinChangeInt.h not pinChange.h. I'll give an example if I can find it.

As it stands, the libraries are compiled first which is why only the header can see the change you made to the define ( your sketch is not used to compile cpp library files ). Using templates makes the library dependent on your code.
774  Using Arduino / Networking, Protocols, and Devices / Re: How to get remote IP without modding the core. on: January 15, 2014, 07:37:37 am
I agree its a feature that should be built in.

The point of providing it as a sit on top feature is for portability/compatibility reasons. Possibly even the same reason you had for this post: http://forum.arduino.cc/index.php?topic=197103.msg1458910#msg1458910

When its added into the core then great, no need for a fix, however there is also now no need for delving into the Ethernet library until that time arrives.

I also pointed out it was for the Ethernet shield. After your experience ( and liudr ) with the Wifi shield, I don't think I'll have one for a while to even test.
775  Using Arduino / Networking, Protocols, and Devices / Re: How to get remote IP without modding the core. on: January 15, 2014, 07:20:49 am
I understand this, however my version does not require modification to the core, or its libraries, whereas the method yourself and I linked both require the core to be changed in some way.
776  Using Arduino / Networking, Protocols, and Devices / How to get remote IP without modding the core. on: January 15, 2014, 07:01:05 am
People should never write open source libraries with private data members in classes, as you may know, this prevents you from deriving the class and adding your own extensions to it. This is what has happened to the Ethernet library, you cannot access private members needed to retrieve the remote IP.

You can mod the core yourself ( and every time you update the IDE ) using the intructions here: http://forum.arduino.cc/index.php?topic=82416.msg619420#msg619420

However I have a tiny library for use with your Arduino Ethernet shield projects that allows you to get this information without modifying the core libraries.

There is one function RemoteIP, it takes a reference to an EthernetClient object and returns an IPAddress object.
The IPAddress structure is part of the core and is printable.

Code:

EthernetClient client = server.available();

//...
Serial.print( "Remote IP: );
Serial.println( RemoteIP( client ) );

The library, create a new library folder called EthernetFix and a .h file with the same name. Then copy the code below into it.
You can just copy it into the sketch, however a library is more convenient for multiple projects.
Code: (EthernetFix.h)
//Requires your sketch to include Ethernet.h
#include <Arduino.h>
#include <utility/w5100.h>

template<typename Tag, typename Tag::type M>
  struct AccessMember{
    friend typename Tag::type get( Tag ){ return M; }
};

struct EthernetClient_Socket{
  typedef uint8_t EthernetClient::*type;
  friend type get( EthernetClient_Socket );
};

template struct AccessMember< EthernetClient_Socket, &EthernetClient::_sock >;

IPAddress RemoteIP( EthernetClient &c ){
  byte remoteIP[ 4 ];
  W5100.readSnDIPR( c.*get( EthernetClient_Socket() ), remoteIP );
  return ( remoteIP );
}


Using the output from surfer tims web server I got this result:
Quote
Client request #1: GET / HTTP/1.1
file = /
file type =
method = GET
params =
protocol = HTTP/1.1
Remote IP: 192.168.1.100
Home page SD file
filename format ok
File not found
disconnected
SRAM = 6483
SRAM = 6483

Happy programming!

NOTE: To use the library in multiple C++ files you may need to move the RemoteIP function to a cpp file with only the prototype in the header. Ask if you need help with this.
777  Products / Arduino Yún / Re: Uploading sketch via Ethernet on: January 13, 2014, 12:22:34 am
If you use a dish, you do not need to connect the yun to it, simply sit it in the middle. This will reflect some energy that would normally head in the opposite direction to your router.

The Ethernet over power line and POE seem like good alternatives.
778  Products / Arduino Yún / Re: Uploading sketch via Ethernet on: January 11, 2014, 09:09:42 pm
Add a directional antenna to your router and yun.

I Cut a lid for a 100 spool of CD's in half and lined it with foil, works quite well with my router. Not sure about the yun, maybe put the whole device in the middle of dish.
779  Community / Bar Sport / Re: Million-and-one noob q:s about Programmers, Programs, Programming and Pragmatism on: January 11, 2014, 08:36:44 pm
As for loop and setup, there is no need to re-write main.h/.cpp if you use the IDE or .cpp files in another compiler. C++ supports function overloading so you can simply provide your own int main() in your local files.

I have started an article on using int main() in relation to the IDE: http://arduino.genx.biz/FAQ/content/2/2/en/can-i-use-int-main-with-arduino.html
780  Development / Other Software Development / Re: Sublime Text and Stino: Best IDE you can have. on: January 11, 2014, 07:34:40 pm
SPI_CONTINUE and SPI_LAST do not appear to be in the Arduino package ( 1.0.5 ). You might have left out/improperly included a library and/or sublime might not define something that is used to conditionally include the SPI_x symbols.
Pages: 1 ... 50 51 [52] 53 54 ... 152