Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hello,
I want create a class for Generate a DMX signal. So i have write that :
#include "mbed.h" #include "DMX.h" DMX :: DMX(PinName Tx) : _Tx(Tx){} void DMX :: Init(){ _Tx= 0; wait_us(1000); } int * DMX :: intToBin(int nb){ int x=0, tab[8]; for(x = 0 ; nb > 0; x++){ tab[x] = nb % 2; nb /=2; } int * binaire = new int[8]; for(int i = 0; i<8; i++) binaire[i] = 0; for(int i = 0 ; i <= x ; i++) binaire[i] = tab[x-i]; return binaire ; } void DMX :: raz(){ int * infos = new int[512]; for(int i = 0; i< 512; i++) infos[i] = 0; setInfos(infos); } void DMX :: setInfos( int * infos){ Init(); _Tx=1; // MAB wait_us(8); for(int j = 0; j < 255 ; j++){ _Tx=0; // Start bit wait_us(4); //int * tmp = intToBin(infos[j]); for(int i = 0 ; i < 8 ; i++){ // DATA _Tx= tmp[i]; wait_us(4); } _Tx = 1; // Stop Bit wait_us(8); } _Tx = 1; // Repos }I have a DMX recepteur with LED RGB but there no detect my signal. My main is that :
#include "mbed.h" #include "DMX.h" DMX dmx(p9); int main(){ int * tab = new int[512]; for(int i = 0; i < 512; i++) tab[i] = 0; for(int i = 2; i < 512; i=i+6) tab[i] = 255; wait(1); dmx.raz(); while(1) { dmx.setInfos(tab); } }Can you help me please ?