Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed DMX TextLCD mbed-rtos
Revision 33:e0c7a6eeeedc, committed 2016-05-10
- Comitter:
- Ayrton_L
- Date:
- Tue May 10 13:27:12 2016 +0000
- Parent:
- 32:efe17605052f
- Child:
- 34:fc85eeb84a93
- Commit message:
- Display right working
Changed in this revision
--- a/OldMain.cpp Sun May 08 23:14:51 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,474 +0,0 @@
-#include "main.h"
-
-
-DMX XLR1(p9);
-DMX XLR2(p13);
-DMX XLR3(p28);
-//ArtNet X;
-
-DigitalOut DMXled1(LED1);
-DigitalOut DMXled2(LED2);
-DigitalOut DMXled3(LED3);
-DigitalOut MAINled(LED4);
-Ethernet eth;
-uint32_t I32_CheckHeader(char C_Header[7]);
-
-
-
-typedef struct {
-typedef struct
-{
- uint32_t Universe[2];
- uint8_t I8_Values[511];
-}DMX_Data;
-
-
-
-void V_InterruptMenu()
-{
- S.V_SetInterrupt(true);
- button.rise(&V_PressOK);
-}
-
-void V_Cursor(void const *args)
-{
- RightTwist.rise(&V_Right);
- LeftTwist.rise(&V_Left);
- uint32_t I32_LineNumber;
- while(1)
- {
- I32_LineNumber = S.I32_GetLine();
- V_WriteTxt(2, I32_LineNumber, ">");
- wait_ms(200);
- V_WriteTxt(2, I32_LineNumber, " ");
- wait_ms(200);
- }
-}
-
-void V_DMXThread1(void const *args)
-{
- wait_ms(10);
- while(1)
- {
- XLR1.V_SendDMX();
- }
-}
-
-void V_DMXThread2(void const *args)
-{
- wait_ms(15);
- while(1)
- {
- XLR2.V_SendDMX();
- }
-}
-
-void V_DMXThread3(void const *args)
-{
-
- wait_ms(15);
- while(1)
- {
- XLR3.V_SendDMX();
- }
-}
-
-int main()
-{
- DMXled1 = 0;
- DMXled2 = 0;
- DMXled3 = 0;
- RightTwist.mode(PullUp); //Interne pullup resisitors gebruiken voor Draaiknop/rotaryencoder
- LeftTwist.mode(PullUp);
- button.rise(&V_InterruptMenu); //interrupt bij push op button, rising edge
- Thread T_DMX1(V_DMXThread1);
- Thread T_DMX2(V_DMXThread2);
- Thread T_DMX3(V_DMXThread3);
-
- char C_Buf[572];
- uint16_t I16_Universe;
- while(1)
- {
- int size = eth.receive();
- if(size > 0) {
- eth.read(C_Buf, size);
- if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36) //Poort checken (6465 = 0x1936 // deel van udp protocol
- if(S.B_GetInterrupt() == false)
- {
- int size = eth.receive();
- if(size > 0) {
- eth.read(C_Buf, size);
- if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36) //Poort checken (6465 = 0x1936 // deel van udp protocol
- {
- char C_ID[7];
- memcpy(C_ID, &C_Buf[42], 7);
- if(I32_CheckHeader(C_ID) == 0) //Art-Net Header checken
- {
- if(C_Buf[50] == 0x00 and C_Buf[51]== 0x50) //OPcode checken
- {
- if(C_Buf[52] == 0x00 and C_Buf[53]== 0x0E) //Protocol Versie (14) checken
- {
- // 56/57 = universe
- I16_Universe = C_Buf[56];
- I16_Universe = I16_Universe << 8;
- I16_Universe = I16_Universe & 0xFF00;
- I16_Universe = I16_Universe + C_Buf[57];
-
- //Settings S;
- uint8_t I8_Values[512];
-
- if(I16_Universe == S.I32_GetUniverse(1))
- {
- memcpy(I8_Values, &C_Buf[60], 512);
- XLR1.V_SetData(I8_Values);
- }
- else if(I16_Universe == S.I32_GetUniverse(2))
- {
- memcpy(I8_Values, &C_Buf[60], 512);
- XLR2.V_SetData(I8_Values);
- }
- else if(I16_Universe == S.I32_GetUniverse(3))
- {
- memcpy(I8_Values, &C_Buf[60], 512);
- XLR3.V_SetData(I8_Values);
- } //einde universes
- } //einde protocol
- }//einde OPCODE
- }//Einde Artnet
- }//Einde Poort checken
- }//einde if(size...
- }//wait_ms(1); //einde IF getinterrupt == false
- else
- {
- T_DMX1.terminate(); //Threads stoppen
- T_DMX2.terminate(); //Geen nut, waarom dmx uitsturen als er geen Art-Net binnenkomt?
- T_DMX3.terminate();
-
- S.V_SetInterrupt(false);
- V_WriteTxt(6, 2, "Art-Net");
- wait(1);
-
- V_WriteMenu();
- Thread T_Cursor(V_Cursor); //Nieuwe thread :D / blinky en fancy cursor
-
- if(S.B_GetMenu() == true)
- {
- char C_ID[7];
- memcpy(C_ID, &C_Buf[42], 7);
- if(I32_CheckHeader(C_ID) == 0) //Art-Net Header checken
- switch(S.I32_GetLine())
- {
- if(C_Buf[50] == 0x00 and C_Buf[51]== 0x50) //OPcode checken
- case 1:
- {
- if(C_Buf[52] == 0x00 and C_Buf[53]== 0x0E) //Protocol Versie (14) checken
- T_Cursor.terminate(); //Thread terug terminaten
- S.V_SetLine(1);
- V_WriteMenuSettings(); //Settings menu schrijven
- Thread T_Cursor(V_Cursor); //thread voor cursor terug starten
-
- if(S.B_GetOK() == true)
- {
- // 56/57 = universe
- I16_Universe = C_Buf[56];
- I16_Universe = I16_Universe << 8;
- I16_Universe = I16_Universe & 0xFF00;
- I16_Universe = I16_Universe + C_Buf[57];
-
- Settings S;
- uint8_t I8_Values[512];
-
- if(I16_Universe == S.I32_GetUniverse(1))
- switch (S.I32_GetLine())
- {
- MAINled = 1;
- if(C_Buf[60] == 255)
- case 1:
- {
- if(DMXled2 == 1)
- {
- DMXled2 = 0;
- DMXled1 = 1;
- }
- else
- {
- DMXled1 = 0;
- DMXled2 = 1;
- }
- V_OutputMenu(1);
- }
- memcpy(I8_Values, &C_Buf[60], 512);
- XLR1.V_SetData(I8_Values);
-
- case 2:
- {
- }
-
- case 3:
- {
- }
-
- case 4:
- {
- }
-
- default:
- {
- }
- }
- else if(I16_Universe == S.I32_GetUniverse(2))
- {
- memcpy(I8_Values, &C_Buf[60], 512);
- XLR2.V_SetData(I8_Values);
- }
- else if(I16_Universe == S.I32_GetUniverse(3))
- {
- memcpy(I8_Values, &C_Buf[60], 512);
- XLR3.V_SetData(I8_Values);
- }
- }
- }
- }
-
- break;
- }
-
- case 2:
- {
- V_Firmware();
- break;
- }
-
- case 3:
- {
- V_Reset();
- break;
- }
-
- case 4:
- {
- break; //4 = EXIT => niets doen resulteert in auto heropstart
- }
-
- default:
- {
- break; // default = EXIT
- }
- }
- }
- }
- wait_ms(1);
-
- Thread T_DMX1(V_DMXThread1); //DMX threads terug starten
- Thread T_DMX2(V_DMXThread2);
- Thread T_DMX3(V_DMXThread3);
- }//einde IF getinterrupt != false
- }//einde while*/
-}//einde main
-
-void V_OutputMenu(uint32_t I32_Output)
-{
- Sc.V_Clear();
- V_WriteTxt(1, 1, "Output ");
- Sc.V_SetTekst((char*)I32_Output);
-}
-
-void V_Reset()
-{
- delete &S;
-}
-
-void V_Firmware()
-{
- Sc.V_Clear();
- V_WriteTxt(6, 2, "Firmware");
- V_WriteTxt(6, 3, FIRMWARE);
-}
-
-void V_PressOK()
-{
- if(S.B_GetMenu() == false)
- {
- S.V_SetInMenu(true);
- }
- else
- {
- S.V_SetOK(true);
- }
-}
-
-void V_WriteMenu()
-{
- Sc.V_Clear();
- V_WriteTxt(1, 1, "^");
- V_WriteTxt(1, 1, "v");
- V_WriteTxt(3, 1, "Settings");
- V_WriteTxt(3, 2, "Firmware");
- V_WriteTxt(3, 3, "Reset");
- V_WriteTxt(3, 4, "Exit");
-}
-
-void V_WriteMenuSettings()
-{
- Sc.V_Clear();
- V_WriteTxt(1, 1, "^");
- V_WriteTxt(1, 1, "v");
- V_WriteTxt(3, 1, "Output 1");
- V_WriteTxt(3, 2, "Output 2");
- V_WriteTxt(3, 3, "Output 3");
- V_WriteTxt(3, 4, "Exit");
-}
-
-void V_PutCursor()
-{
- bool B_Cursor[4];
- uint32_t I32_LineCounter;
-
- if(S.I32_GetDirection() == 74)
- {
- if(B_Cursor[0] != true)
- {
- B_Cursor[0] = B_Cursor[1];
- }
- else
- {
- B_Cursor[0] = true;
- }
- B_Cursor[1] = B_Cursor[2];
- B_Cursor[2] = B_Cursor[3];
- B_Cursor[3] = false;
-
- Error1 = 0;
- Error8 = 0;
- }
- else if(S.I32_GetDirection() == 96)
- {
- if(B_Cursor[3] != true)
- {
- B_Cursor[3] = B_Cursor[2];
- }
- else
- {
- B_Cursor[3] = true;
- }
- B_Cursor[2] = B_Cursor[1];
- B_Cursor[1] = B_Cursor[0];
- B_Cursor[0] = false;
-
- Error1 = 0;
- Error8 = 0;
- }
- else
- {
- Error8 = 1; //Errortje weergeven
- Error1 = 1;
- }
-
- for(I32_LineCounter = 0; I32_LineCounter < 3; I32_LineCounter++)
- {
- if(B_Cursor[I32_LineCounter] == true)
- {
- S.V_SetLine(I32_LineCounter);
- }
- else
- {
- Error8 = 1;
- Error4 = 1;
- }
- }
-}
-
-void V_Right()
-{
- if(S.B_GetLeft() == true)
- {
- S.V_SetDirection(96); //96 == naar onder draaien
- }
- else
- {
- S.V_SetRight(true);
-
- }
- S.V_SetLeft(false);
-
- V_PutCursor();
-}
-
-void V_Left()
-{
- if(S.B_GetRight() == true)
- {
- S.V_SetDirection(74); //74 == naar boven draaien
- }
- else
- {
- S.V_SetLeft(true);
- }
- S.V_SetRight(false);
-
- V_PutCursor();
-}
-
-void V_WriteTxt(uint32_t I32_Kolom, uint32_t I32_Rij, char * C_Tekst)
-{
- Sc.V_SetKolom(I32_Kolom);
- Sc.V_SetRij(I32_Rij);
- Sc.V_SetTekst(C_Tekst);
- Sc.V_Printit();
-}
-
-
-uint32_t I32_CheckHeader(char C_Header[6])
-{
- if(C_Header[0] == 'A')
- {
- if(C_Header[1] == 'r')
- {
- if(C_Header[2] == 't')
- {
- if(C_Header[3] == '-')
- {
- if(C_Header[4] == 'N')
- {
- if(C_Header[5] == 'e')
- {
- if(C_Header[6] == 't')
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
-}
-
--- a/Screen.h Sun May 08 23:14:51 2016 +0000
+++ b/Screen.h Tue May 10 13:27:12 2016 +0000
@@ -14,14 +14,11 @@
void V_SetRij(uint32_t I32_Rij);
void V_SetKolom(uint32_t I32_Kolom);
void V_SetTekst(char * C_Tekst);
- void V_SetLocate(bool B_Locate);
-
private:
uint32_t I32_m_Rij;
uint32_t I32_m_Kolom;
char *C_m_Tekst[];
- bool B_m_Locate;
};
Screen::Screen()
@@ -55,17 +52,9 @@
*C_m_Tekst = C_Tekst;
}
-void Screen::V_SetLocate(bool B_Locate)
-{
- B_m_Locate = B_Locate;
-}
-
void Screen::V_Printit() const
{
- if(B_m_Locate == true)
- {
- lcd.locate(I32_m_Kolom, I32_m_Rij);
- }
+ lcd.locate(I32_m_Kolom, I32_m_Rij);
lcd.printf(*C_m_Tekst);
}
--- a/main.cpp Sun May 08 23:14:51 2016 +0000
+++ b/main.cpp Tue May 10 13:27:12 2016 +0000
@@ -55,7 +55,7 @@
int size = eth.receive();
if(size > 0) {
eth.read(C_Buf, size);
- if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36) //Poort checken (6465 = 0x1936 // deel van udp protocol
+ if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36) //Poort checken (6465 = 0x1936 // deel van udp protocol
{
char C_ID[7];
memcpy(C_ID, &C_Buf[42], 7);
@@ -119,19 +119,79 @@
delete &S;
}
-void V_DisplayMenu()
+uint32_t I32_GeneralTxt()
{
+ Sc.V_Clear();
uint32_t I32_Line;
I32_Line = S.I32_GetLine();
char *C_Line=new char[S_Menu[I32_Line].size()+1];
C_Line[S_Menu[I32_Line].size()] = 0;
memcpy(C_Line, S_Menu[I32_Line].c_str(), S_Menu[I32_Line].size());
- Sc.V_SetTekst(C_Line);
+ V_WriteTxt(6, 0, C_Line);
+ return I32_Line;
+}
+
+void V_DisplayMenu()
+{
+ uint32_t I32_Line;
+ I32_Line = I32_GeneralTxt();
+ switch(I32_Line)
+ {
+ case 0:
+ {
+ V_WriteTxt(6, 2, FIRMWARE);
+ break;
+ }
+
+ case 1:
+ {
+ break;
+ }
+
+ case 2:
+ {
+ break;
+ }
+
+ case 3:
+ {
+ break;
+ }
+
+ case 4:
+ {
+ break;
+ }
+
+ case 5:
+ {
+ break;
+ }
+
+ case 6:
+ {
+ break;
+ }
+
+ case 7:
+ {
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+
+ }
}
-void V_Firmware()
+void V_WriteTxt(uint32_t I32_Kolom, uint32_t I32_Rij, char * C_Tekst)
{
- Sc.V_Clear();
+ Sc.V_SetRij(I32_Rij);
+ Sc.V_SetKolom(I32_Kolom);
+ Sc.V_SetTekst(C_Tekst);
+ Sc.V_Printit();
}
void V_Right()
--- a/main.h Sun May 08 23:14:51 2016 +0000 +++ b/main.h Tue May 10 13:27:12 2016 +0000 @@ -38,9 +38,10 @@ void V_InterruptMenu(); void V_Right(); void V_Left(); -void V_Firmware(); void V_Reset(); void V_DisplayMenu(); +void V_WriteTxt(uint32_t I32_Kolom, uint32_t I32_Rij, char * C_Tekst); +uint32_t I32_GeneralTxt(); #endif