Næþ'n Lasseter / Mbed 2 deprecated DMX

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.c Source File

main.c

00001 #include "mbed.h"
00002 #include "DMXPacket.h"
00003 #include "iface.h"
00004 #include "TextLCD.h"
00005 
00006 DigitalOut dmx(p20);
00007 InterruptIn intr(p29);
00008 I2C io(p28, p27);
00009 
00010 TextLCD lcd(p16, p15, p13, p12, p11, p10); // rs, e, d4-d7
00011 
00012 int channelPointer = 0;
00013 char* channelData = (char*) calloc(CHANNELCOUNT, sizeof(char));
00014 int waddr = 0x40;
00015 int raddr = waddr+1;
00016 
00017 int main() {
00018     char byte[1];
00019     io.frequency(100000);
00020     byte[0]=0x0F;
00021     io.write(waddr, byte, 1);
00022     
00023     intr.fall(&keypress);
00024     
00025     init(&dmx);
00026     
00027     lcd.cls();
00028     lcd.printf("   Welcome to\n ** DMXDebug! **");
00029     wait(2);
00030     lcd.cls();
00031     
00032     //printf("\r\nWelcome to DMXDebug!\r\n");
00033     while (1) {
00034         //printf("\rChannel: %03d\t\tData: %03d", channelPointer, channelData[channelPointer]);
00035         lcd.locate(0, 0);
00036         lcd.printf("Channel : %03d\n   Data : %03d", channelPointer, channelData[channelPointer]);
00037         writePacket(&dmx, channelData, CHANNELCOUNT);
00038     }
00039 }