Rank: Advanced Member
Groups: BetaUser, Registered Joined: 12/28/2015(UTC) Posts: 31
Was thanked: 18 time(s) in 18 post(s)
|
Dear Admin, I'm trying to compile a custom node with a program of mine little complicated, with cycle, custom function all inside in one custom agent....may i do that?? if not i'm dead.... The compiler give me many errors that i don't understand, because i can't find where is the line of the error....if you can for a future release, it would be nice that the line of errors will indicated by the compiler in red... In fact when the compiler say to me: "Line 35:expected "}" at the end of input....but i don't know where is the line 35 in my code... again: "Line 130:a function-definition is not allowed here before "{" token....what does it mean???? Please I need an help, because i need a solution for my code for a project of mine... Here below i show you my code.... but there's a manner to code an agent and share the variables globally??? I thank you a lot in advance.....Lestroso Quote: <EmbrioCopy> <Version>1.3.2.0</Version> <Nodes> <Node> <UniqueID>b212a32e-9f5a-4123-8ced-140a989d5747</UniqueID> <AssemblyType>Embrio.NodeEngine.AgentController.Nodes.AgentControllerCustomArduinoNode</AssemblyType> <NodeType>Custom Arduino Node</NodeType> <UserDefinedName>BRAIN CODE</UserDefinedName> <Description>A node that lets you write any Arduino code to interact with the Arduino hardware. Can be both an input and output.</Description> <NodeColor>144,183,227,255</NodeColor> <X>0</X> <Y>0</Y> <Width>1028</Width> <IncludeCode>#include "Allcolors.h" #include "Wire.h" #include "ColorSwitch.h" #include "Inputtasto.h" #include "Wtv020sd16p.h" #include "LiquidCrystal_I2C.h" </IncludeCode> <DeclerationCode>LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); #define TRUE 1 #define FALSE 0 #define OK 1 #define NOK 0 #define PAD1 12 #define PAD2 11 #define PAD3 10 #define PAD4 9 #define buz 6 #define TUTTOROSSO 36 #define TUTTOVERDE 18 #define TUTTOBLU 9 #define TUTTOACQUA 27 #define TUTTOGIALLO 54 #define TUTTOVIOLA 45 #define TUTTOBIANCO -1 //////// //dichiarazioni sd player int resetPin = 2; // The pin number of the reset pin. int clockPin = 3; // The pin number of the clock pin. int dataPin = 4; // The pin number of the data pin. int busyPin = 5; // The pin number of the busy pin. Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin); /////////////////////////////////////////////////////////// int buttonState1 = 0; int buttonState2 = 0; int buttonState3 = 0; int buttonState4 = 0; ///////////////////////////////////// int endGame(); void refreshKeys(); void resetKeyColors(int color); void resetKeys(); void initRandom(); int checkKeys(int _pressedKey, int _nextpressedKey);
/////////////////////////////////// int sec = 120; </DeclerationCode> <SetupCode> typedef struct tasto { int colore; int suono; int valore; int pushed; int checked; } t_tasto; int pressedKey = 0; int npressedKey = 0; int primo_tasto = NOK; int secondo_tasto = NOK; t_tasto Key[17]; pinMode(PAD1, INPUT); pinMode(PAD2, INPUT); pinMode(PAD3, INPUT); pinMode(PAD4, INPUT); pinMode(buz, OUTPUT); for (int i = 1; i <= 16; i++) { Key[i].colore = ROSSO; Key[i].suono = 0;// Key[i].valore = 0; Key[i].pushed = FALSE; Key[i].checked = FALSE; } Key[0].checked = FALSE;</SetupCode> <ImageName>arduino.png</ImageName> <InfoURL></InfoURL> <IsOpen>True</IsOpen> <EditWidth>360</EditWidth> <CodeDefinitions> <CodeDefinition> <TriggerInputID>5d267506-8101-44fb-b547-9689ffe393d4</TriggerInputID> <UpdateCondition>Trigger</UpdateCondition> <Code> int pressedkey; pressedKey = Inputtasto(); // 1° tasto if (pressedKey != 0 &amp;&amp; Key[pressedKey].checked == FALSE) { Key[pressedKey].colore =NERO; ColorSwitch(pressedKey,ROSSO); delay (50); ColorSwitch(pressedKey,NERO); delay (50); ColorSwitch(pressedKey,ROSSO); delay (50); ColorSwitch(pressedKey,NERO); delay (50); ColorSwitch(pressedKey,ROSSO); delay (50); Key[pressedKey].pushed = TRUE; ColorSwitch(pressedKey,NERO); wtv020sd16p.asyncPlayVoice(Key[pressedKey].valore); delay (1000); wtv020sd16p.asyncPlayVoice(501); } if (Key[pressedKey].checked == TRUE) // Controlla che il tasto non sia gia&apos; stato riconosciuto;Qui CERA WHILE!!!! { pressedKey = Inputtasto(); if (pressedKey != 0 &amp;&amp; Key[pressedKey].checked == FALSE) { Key[pressedKey].colore = NERO; Key[pressedKey].pushed = TRUE; } } if (pressedKey != 0) { primo_tasto = OK; if (primo_tasto)//cera while!!!! { npressedKey = Inputtasto(); if (npressedKey != 0 &amp;&amp; Key[npressedKey].checked == FALSE) ////mod qui { ColorSwitch(npressedKey,ROSSO); delay (50); ColorSwitch(npressedKey,NERO); delay (50); ColorSwitch(npressedKey,ROSSO); delay (50); ColorSwitch(npressedKey,NERO); delay (50); ColorSwitch(npressedKey,ROSSO); delay (50); ColorSwitch(npressedKey,NERO); Key[npressedKey].colore = NERO; Key[npressedKey].pushed = TRUE; Key[npressedKey].valore; wtv020sd16p.asyncPlayVoice(Key[npressedKey].valore); delay (1000); wtv020sd16p.asyncPlayVoice(501); } if((Key[npressedKey].checked == TRUE) || (npressedKey == pressedKey))// qui cera while!!!! { npressedKey = Inputtasto(); if (npressedKey != 0 &amp;&amp; Key[npressedKey].checked == FALSE) { Key[npressedKey].colore = NERO;//tolto rosso Key[npressedKey].pushed = TRUE; } } if (npressedKey != 0) { primo_tasto = NOK; secondo_tasto = OK; } } } if (secondo_tasto == OK) { secondo_tasto = NOK; if (checkKeys(pressedKey, npressedKey) == TRUE) { if (endGame() == TRUE) { Allcolors(0); delay(1000); for (int i = 1; i &lt;= 16; i++) { ColorSwitch(i,BLU); delay(150); ColorSwitch(i,NERO); } for (int i = 1; i &lt;= 16; i++) { ColorSwitch(i,BLU); delay(100); ColorSwitch(i,NERO); } for (int i = 1; i &lt;= 16; i++) { ColorSwitch(i,BLU); delay(50); ColorSwitch(i,NERO); } ////Effetto luce//// for(int i = 0; i&lt; 6; i++) { Allcolors(TUTTOROSSO); delay(100); Allcolors(TUTTOVERDE); delay(100); Allcolors(TUTTOBLU); delay(100); Allcolors(TUTTOGIALLO); delay(100); Allcolors(TUTTOACQUA); delay(100); Allcolors(TUTTOVIOLA); delay(100); Allcolors(TUTTOBIANCO); delay(100); Allcolors(0); } //////////////////////////////// resetKeys(); initRandom(); ///scrivi che hai vinto } } else { Key[pressedKey].pushed = FALSE; Key[npressedKey].pushed = FALSE; } } } int checkKeys(int _pressedKey, int _nextpressedKey) { if (Key[_pressedKey].valore == Key[_nextpressedKey].valore) { Key[_pressedKey].pushed = TRUE; Key[_pressedKey].colore = VERDE; Key[_pressedKey].checked = TRUE; Key[_nextpressedKey].pushed = TRUE; Key[_nextpressedKey].colore = VERDE; Key[_nextpressedKey].checked = TRUE; return 1; } else { Key[_pressedKey].pushed = TRUE; Key[_pressedKey].colore = NERO; Key[_pressedKey].checked = FALSE; Key[_nextpressedKey].pushed = TRUE; Key[_nextpressedKey].colore = NERO; Key[_nextpressedKey].checked = FALSE; return 0; } } int endGame() { for (int i = 1; i &lt;= 16; i++) { if (Key[i].checked == 0) return 0; } return 1; } void resetKeys() { for (int i = 1; i &lt;= 16; i++) { Key[i].colore = NERO; Key[i].suono = 0; Key[i].pushed = FALSE; Key[i].checked = FALSE; } } void initRandom() { int start[17] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 }; randomSeed(analogRead(0)); //equivalente a srand(time(NULL)); for (int x = 0; x &lt; 20; x++) { for (int x = 1; x &lt;= 16; x++) { int i = random(1, 16); int temp = start[x]; start[x] = start[i]; start[i] = temp; } } for (int i = 1; i &lt;= 16; i++) { Key[i].valore = start[i]; }
} }</Code> <UniqueID>b658c417-6d5f-4c08-ad15-f33dc28b1170</UniqueID> </CodeDefinition> <CodeDefinition> <TriggerInputID>5d267506-8101-44fb-b547-9689ffe393d4</TriggerInputID> <UpdateCondition>Trigger</UpdateCondition> <Code> if (Key[1].pushed == TRUE) ColorSwitch(1, Key[1].colore); if (Key[2].pushed == TRUE) ColorSwitch(2, Key[2].colore); if (Key[3].pushed == TRUE) ColorSwitch(3, Key[3].colore); if (Key[4].pushed == TRUE) ColorSwitch(4, Key[4].colore); if (Key[5].pushed == TRUE) ColorSwitch(5, Key[5].colore); if (Key[6].pushed == TRUE) ColorSwitch(6, Key[6].colore); if (Key[7].pushed == TRUE) ColorSwitch(7, Key[7].colore); if (Key[8].pushed == TRUE) ColorSwitch(8, Key[8].colore); if (Key[9].pushed == TRUE) ColorSwitch(9, Key[9].colore); if (Key[10].pushed == TRUE) ColorSwitch(10, Key[10].colore); if (Key[11].pushed == TRUE) ColorSwitch(11, Key[11].colore); if (Key[12].pushed == TRUE) ColorSwitch(12, Key[12].colore); if (Key[13].pushed == TRUE) ColorSwitch(13, Key[13].colore); if (Key[14].pushed == TRUE) ColorSwitch(14, Key[14].colore); if (Key[15].pushed == TRUE) ColorSwitch(15, Key[15].colore); if (Key[16].pushed == TRUE) ColorSwitch(16, Key[16].colore);
</Code> <UniqueID>f7e192a7-0128-497c-8c8e-7f1b6759040d</UniqueID> </CodeDefinition> </CodeDefinitions> <Inputs> <Input> <UniqueID>5d267506-8101-44fb-b547-9689ffe393d4</UniqueID> <DefinitionID>00000000-0000-0000-0000-000000000000</DefinitionID> <DefaultName>Trigger 1</DefaultName> <CustomName>Program Brain</CustomName> <IsDisplayed>True</IsDisplayed> <IsNative>False</IsNative> <TypeName>Trigger</TypeName> <IsOutsideConnection>True</IsOutsideConnection> <IOType>Embrio.NodeEngine.NodeIO.TriggerNodeInput</IOType> <ShowGraph>False</ShowGraph> <LinkedIOID>00000000-0000-0000-0000-000000000000</LinkedIOID> <IsUserAdded>True</IsUserAdded> <ConnectedOutputs></ConnectedOutputs> </Input> </Inputs> <Outputs></Outputs> </Node> </Nodes> </EmbrioCopy>
Edited by user Saturday, January 02, 2016 9:04:41 AM(UTC)
| Reason: Not specified
|
1 user thanked fasasoftware@gmail.com for this useful post.
|
|