Show Posts
Pages: [1]
1  Topics / Product Design / An interface made with arduino on: September 30, 2012, 01:41:36 pm
Hi!

I would like to show in this forum an interface that I made some time ago.

http://velegno.net/interface-i/

It is basically a grid of lasers controlled by an arduino.

I hope you enjoy it!
2  Topics / Interactive Art / "Laser interface" made with arduino on: September 30, 2012, 01:38:20 pm
Hi!

I would like to show in this forum an interface that I made some time ago.

http://velegno.net/interface-i/

It is basically a grid of lasers controlled by an arduino.

I hope you enjoy it!


3  Using Arduino / Programming Questions / Re: polymorphism on: February 25, 2011, 12:54:53 pm
thanks, I added the following code and now it started to work.

I will have a number of routines which share some data but have different "execute" functions (in the future)  smiley-wink

Code:
void gr_routine::execute(    ) {
   
  return;
 
}
4  Using Arduino / Programming Questions / polymorphism on: February 25, 2011, 10:41:52 am
hi, i'm experimenting with polymorphism in arduino, but I'm getting the following error message:

bi_grafic.cpp.o: In function `gr_routine':
C:\Users\JUANCA~1\AppData\Local\Temp\build4041774866979188726.tmp/bi_grafic.cpp:116: undefined reference to `vtable for gr_routine'
C:\Users\JUANCA~1\AppData\Local\Temp\build4041774866979188726.tmp/bi_grafic.cpp:116: undefined reference to `vtable for gr_routine'

does anybody know why  smiley-fat

thanks in advance

bi_grafic.h
Code:
class gr_routine {

  public:
  
  gr_routine();
  gr_routine(  uint8_t* driver_in  );
    
  virtual void execute();
    
protected:

  uint8_t* gr_driver;
  

};





class routine_a : public gr_routine {

public:

  routine_a(  uint8_t* driver_in  ) ;
  
  virtual void execute();

private:

  int  a_counter1;
  int  a_counter2;
  int  a_counter3;
  
  uint8_t* gr_driver;
  
};




bi_grafic.cpp
Code:
gr_routine::gr_routine(  uint8_t* driver_in  )  {
  
  gr_driver = driver_in;

}


gr_routine::gr_routine(    ) {
    
  Serial.println("gr_routine_called");
  
}



routine_a::routine_a(  uint8_t* driver_in  ) :  gr_routine()  {
  
  a_counter1 = 1;
  a_counter2 = 2;
  a_counter3 = 3;
  
  gr_driver = driver_in;
  
}


void routine_a::execute(){

  if (a_counter1 > 7) {     a_counter1 = 0;   }
  if (a_counter2 > 7) {     a_counter2 = 0;   }
  if (a_counter3 > 7) {     a_counter3 = 0;   }

/* here comes some more code */

    a_counter1++;
    a_counter2++;
    a_counter3++;

}
5  Using Arduino / Programming Questions / Re: assign memory dinamically on: February 08, 2011, 05:45:54 pm
its trying to allocate 4+5+1+2 = 12 uint8_t.

I declare two objects of this class in my program. The first one is a "global variable" and the second one is declared during runtime. Until now I've haven't any troubles with the global one. The program stops only when the second object is declared in runtime. (until now)

How can I know where is malloc trying to allocate the object and if that space is free?

I'm a little bit confused. any help is really welcome.

thx
6  Using Arduino / Programming Questions / assign memory dinamically on: February 08, 2011, 03:19:11 pm
hi,

I'm trying to create a class where I need to assign memory dinamically. However the program stops suddenly when it reaches malloc.

I'm almost sure that malloc is corrupting random data. Can somebody tell me how to do it correctly?

Code:

class bi_packet{
 
  public:
 
  bi_packet(int nod_id_len_in, int crrcmd_len_in, int counter_len_in, int num_routines_in);
  ~bi_packet();

  int nod_id_len;
  int crrcmd_len;
  int counter_len;
  int packet_len;
 
  int num_routines;
 
  uint8_t* packet;
 
  uint8_t* nod_id;
  uint8_t* crrcmd;
  uint8_t* crrcmd_id;
  uint8_t* cmd_id;
  uint8_t* counter;
 
   
};



---

Code:

bi_packet::bi_packet(int nod_id_len_in, int crrcmd_len_in, int counter_len_in, int num_routines_in){

  nod_id_len   =  nod_id_len_in;
  crrcmd_len   =  crrcmd_len_in;
  counter_len  =  counter_len_in;
  packet_len   =  nod_id_len + crrcmd_len + 1 + counter_len;
 
  num_routines =  num_routines_in;

  packet  = (uint8_t *) malloc (  (packet_len) *  sizeof(uint8_t));  // *** HERE STOPS RUNNING  ***

  nod_id    =  packet;
  crrcmd    =  packet + nod_id_len;
  crrcmd_id =  packet + nod_id_len;
  cmd_id    =  packet + nod_id_len + crrcmd_len;
  counter   =  packet + nod_id_len + crrcmd_len + 1;

}

bi_packet::~bi_packet(){
 
  free(packet);

}

Pages: [1]