Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Pointer, generic class, functions… so much complex for me on: October 04, 2012, 03:57:16 am
Well… ok…
I don't know C++ enough.

There is no constructor and "t_Data" is never set.
Do you omit an implicit code?
Perhaps I have other classes with the same issue.

"{ 'a', 'b', 'c', '\0' }" stay in the main file?
2  Using Arduino / Programming Questions / Pointer, generic class, functions… so much complex for me on: October 04, 2012, 02:17:27 am
Hi,

I'm "objectizing" my code. First, I create a generic Array class. Then I refactor my code unsuccessfully, I re-refactor my code unsuccessfully, I re-re-refactor my code… I'm lost.

My error is:
Quote
Core2.cpp:33: error: no matching function for call to 'Schedule::Schedule(int, const prog_char [17], int, int, Array<unsigned char>*&)'
Schedule.h:40: note: candidates are: Schedule::Schedule(byte, const prog_char*, boolean, unsigned int, Array<const unsigned char>)
Schedule.h:37: note:                 Schedule::Schedule(const Schedule&)

An my related files:
Code:
#ifndef ARRAY_H_
#define ARRAY_H_
#include <Arduino.h>

template<class T>
class Array {
  public:
  Array(const T* elements);
  __attribute__((always_inline)) inline const T* getElments() { return this->_elements; };
  __attribute__((always_inline)) inline const uint8_t size()  { return this->_size; };
 
  protected:
  const T* _elements;
  uint8_t _size;
};

template <class T>
Array<T>::Array(const T* elements)
{
  this->_size = ARRAYLEN(elements);
  this->_elements = elements;
}
#endif ARRAY_H_


Code:
#ifndef SCHEDULE_H_
#define SCHEDULE_H_
#include <Arduino.h>
#include <avr/pgmspace.h>
#include "macros.h"
#include "Array.h"
#include "Connector.h"

class Schedule : public ConnectorDigital {
  public:
  Schedule(byte id, const prog_char* label, const boolean isNC, unsigned int data, Array<const uint8_t>* digitals) {
    this->_pin      = (id << 2) | isNC;
    this->_label    = label;
    this->_schedule = data;
    this->_digitals = digitals;
  };
 
  protected:
  unsigned int _schedule;
  Array<const uint8_t>* _digitals;
};
#endif SCHEDULE_H_

and Core2.cpp:
Code:
static const uint8_t schedulePins_13_values[] = { 1, 2, 3, 4 };
Array<uint8_t>* schedulePins_13 = new Array<uint8_t>(schedulePins_13_values);
static Schedule schedule_13 = Schedule(13, Dictionary::test, false, 1324, schedulePins_13 );

I'm confused :/
3  Using Arduino / Storage / Re: Using SD card only for the initial configuration: how eject it? on: September 25, 2012, 08:21:25 am
Don't panic, all is right smiley-wink

Just that I'm rewriting my configuration in a text file instead as #define in an header file. And my code about the SD is only in my setup.

Thanks!
4  Using Arduino / Storage / Using SD card only for the initial configuration: how eject it? on: September 25, 2012, 08:10:54 am
Hi,

I have the Arduino Ethernet Shield with an SD card reader.
I would like read the SD card only while the setup() process. As soon as the program runs the main loop I wish remove my SD card (for using it with another Arduino project or with my camera). Well, after reading my configuration my SD card is useless.
Which code I have to write for a clean eject? Just closing my ini file, some pins to power off?

During the setup my 13-led is HIGH. So while this led switch off, I know I can remove the card… if it is the right way.
5  Using Arduino / Programming Questions / Re: using PROG_MEM in static struct… howto? on: September 17, 2012, 08:14:19 am
Yes, it should work smiley-wink
But I would like writing inline configuration.


Certainly, I will predefine a dictionary… if there is no inline possibility.
6  Using Arduino / Programming Questions / Re: Assigning a value in a struct, then can't read it in other namespace... perhaps on: September 17, 2012, 07:07:53 am
Sorry, I have lot of files and functions.
I copy/paste only functions which are called. Yes, my code is an aggregation of the 2 quotes here  smiley-red
7  Using Arduino / Programming Questions / Re: using PROG_MEM in static struct… howto? on: September 17, 2012, 07:02:33 am
I shall store in flash memory the string which names the relative pin.
And my pointer can stay in the RAM.

I watch some code with lines as:
Code:
static const prog_char *label PROGMEM = "my string";

I would initialize my structure writing something like:
Code:
  static intfPulse pulses[] = {
    { 13, 0, "LED" }
  }

Do you see what I mean?
8  Using Arduino / Programming Questions / Re: Assigning a value in a struct, then can't read it in other namespace... perhaps on: September 17, 2012, 05:00:05 am
Yeah, I think I will remove the namespaces from my project…

But, as I include some extern libraries I would like protecting my variable names.
Moreover, I don't use Class while it is possible. I have nothing to instantiate.
9  Using Arduino / Programming Questions / using PROG_MEM in static struct… howto? on: September 17, 2012, 04:33:34 am
Hi,

I would write a structure to manipulate my connections:
Code:
struct intfPulse
{
  const byte pin;
  uint8_t value;
  const prog_char *label PROGMEM;
};

namespace Core {
  static intfPulse pulses[] = {
    { 13, 0, "LED" }
  }
}

But, I just have to write:
Code:
prog_char *test = Core::pulses[0].label;

test[0] == 'L';
// OK

pgm_read_byte_near(&test50]) == 'L';
// NOK

So I guess my string is not in flash memory…

If I add "static" before "const prog_char *label PROGMEM;", I fail:
Quote
error: too many initializers for 'intfPulse'

If I write "{ 13, 0, PSTR("LED") }", I fail:
Quote
error: statement-expressions are not allowed outside functions nor in template-argument lists

And I can combine both, and obtain a double failure…


How can I store only one element of my structure in the flash memory?
10  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet library set HIGH to PIN #10 on: September 17, 2012, 12:37:59 am
Thanks!

Well, I do it as soon as I receive my Arduino kit… with wires :p
11  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet library set HIGH to PIN #10 on: September 16, 2012, 06:14:19 am
Interesting. Yes, this shield is designed to be on the top.

Do you have a link to a documention about "pin blinding"?
I cut the pin #10 of the LCD shied then I join the whole #10 with another pin?
Or an assembly can prevent cutting the pin #10?
12  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet library set HIGH to PIN #10 on: September 16, 2012, 02:33:31 am
Thanks a lot!

Damned, if I plug the LCD 1602 shield on, I can't set the backlight  smiley-cry
13  Using Arduino / Installation & Troubleshooting / Re: trouble uploading on ubuntu 12.04 on: September 16, 2012, 02:28:44 am
On ubuntu 12.04, I have no problem for uploading to Arduino Mega (1280) through the IDE 1.0.1
The official package is still IDE 1.0… and so I can't ran it. I uninstalled this version smiley-wink
14  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet library set HIGH to PIN #10 on: September 15, 2012, 10:24:40 am
Well, I list all functions which modify the pin #10:

Anywhere:
W5100.readSnSR(_sock);

In the "socket" constructor:
W5100.writeSnMR(s, protocol | flag);
W5100.writeSnPORT(s, port);
W5100.execCmdSn(s, Sock_OPEN);

As I'm beginning to learn C language, these functions are mysterious for me  smiley-sad-blue
15  Using Arduino / Networking, Protocols, and Devices / Ethernet library set HIGH to PIN #10 on: September 15, 2012, 09:39:17 am
Hi,

I'm writing a program which for LCD shield & W5100 Shield.
For testing my software modules I plugged only the W5100 shield. OK
Now I plug only the LCD module which uses the pin #10 to power the backlight.

But when I call W5100.readSnSR(i) the pin #10 is setting HIGH.

Each time I watch "W5100.readSnSR(_sock)", I replaced it by:
Code:
        delay(2000);
        digitalWrite(10, LOW);
        Serial.print(_sock);
        Serial.print("(");
        delay(2000);
  out = W5100.readSnSR(_sock);
        delay(2000);
        digitalWrite(10, LOW);
        Serial.print(")");
        delay(2000);

The parameter is 0.

And, there is another thing which power up the pin #10 but I don't locate yet it.
Pages: [1] 2