From ef501ff4c3889109098ea6909147c3a171021eb2 Mon Sep 17 00:00:00 2001 From: aster94 Date: Wed, 27 Feb 2019 18:20:35 +0100 Subject: [PATCH] formattation and removed commented code --- Computer_Interface/Computer_Interface.pde | 17 +- Computer_Interface/DrawFunctions.pde | 12 +- Computer_Interface/MouseEvents.pde | 220 +++------------------- Microcontroller_Code/MEGA/MEGA.ino | 3 +- Microcontroller_Code/UNO/UNO.ino | 1 - 5 files changed, 39 insertions(+), 214 deletions(-) diff --git a/Computer_Interface/Computer_Interface.pde b/Computer_Interface/Computer_Interface.pde index 68484e9..a07d85f 100644 --- a/Computer_Interface/Computer_Interface.pde +++ b/Computer_Interface/Computer_Interface.pde @@ -155,9 +155,6 @@ class Box } } - - - //boolean box_left_drawn = false; Box box_pin_names = new Box(); // box for the pin names and number Box box_scroll_bar = new Box(); // a narrow box for the scroll bar @@ -182,8 +179,6 @@ class Button } } - - Button button_start = new Button(); Button button_time_draw = new Button(); Button button_time_format = new Button(); @@ -527,13 +522,13 @@ void draw() draw_boxes(); } - ScrollingBarPressed(); + ScrollingBarPressed(); } void getChannelCursorCurrentEvent(int index) { float compare1; - CurrentEventFloat = -(xShift - mouseX + xEdge ); + CurrentEventFloat = -(xShift - mouseX + xEdge); ChannelCursor1CurrentEvent0[1] = index; if (index != 16) { @@ -542,13 +537,13 @@ void getChannelCursorCurrentEvent(int index) index2 = s.charAt(0) - '1'; ChannelCursor1CurrentEvent0[0] = 0; // Keep records of the event we are in. //println (abs(xTime[46]+xShift)); - if (CurrentEventFloat < 0 || CurrentEventFloat > xTime[samples - 1] ) + if (CurrentEventFloat < 0 || CurrentEventFloat > xTime[samples - 1]) { if (CurrentEventFloat <= 0) { ChannelCursor1CurrentEvent0[0] = 0; } - if (CurrentEventFloat >= xTime[samples - 1] ) + if (CurrentEventFloat >= xTime[samples - 1]) { ChannelCursor1CurrentEvent0[0] = samples - 1; } @@ -557,7 +552,7 @@ void getChannelCursorCurrentEvent(int index) { for (int i = 1; i < samples - 1; i++) { - compare1 = ((xTime[i] ) + (xTime[i + 1] ) - (2 * CurrentEventFloat)); + compare1 = ((xTime[i]) + (xTime[i + 1]) - (2 * CurrentEventFloat)); if (compare1 < 0) { if (state[i][index1][index2]) @@ -653,7 +648,7 @@ void serialEvent(Serial board_port) } } -void scaletime() +void scaletime() { if (time_format == "ms") { diff --git a/Computer_Interface/DrawFunctions.pde b/Computer_Interface/DrawFunctions.pde index 41e56b1..f6e0dca 100644 --- a/Computer_Interface/DrawFunctions.pde +++ b/Computer_Interface/DrawFunctions.pde @@ -68,14 +68,14 @@ void draw_boxes() } y += 36; } - text(" ALL ", x, 610); - text("EVENTS", x, 625); + text(" ALL ", x, 610); + text("EVENTS", x, 625); } void drawCursorChannel(boolean CursorEnable) { if (CursorEnable) - { + { fill(50); stroke(75); if (ChannelCursor1CurrentEvent0[1] == 16) // This variable is used to define the channel on which we move or have marked, in this part we draw the rectangle that emphasizes a channel. @@ -149,8 +149,8 @@ void DrawChannelSignals() // finally we draw the lines line(xPos[n] + xShift, yPos, xTime[i] + xShift, yPos); // straight line line(xTime[i] + xShift, yPos, xTime[i] + xShift, yDiff); // vertical line - xPos[n] = xTime[i]; // save last position of the line for the pin - yPos = ySave; // load the initial value of the y + xPos[n] = xTime[i]; // save last position of the line for the pin + yPos = ySave; // load the initial value of the y } } yPos += 36; // go to the next pin @@ -191,7 +191,7 @@ void ScrollingBarPressed() } } -float[] spacing = {5, 8}; //used for the dashline function, pixels +float[] spacing = {5, 8}; //used for the dashline function, pixels float[] spacinggrid = {1, 50}; //used for the background reference lines void dashline(float x0, float y0, float x1, float y1, float[] spacing) { diff --git a/Computer_Interface/MouseEvents.pde b/Computer_Interface/MouseEvents.pde index dfb4838..855f1ff 100644 --- a/Computer_Interface/MouseEvents.pde +++ b/Computer_Interface/MouseEvents.pde @@ -12,25 +12,27 @@ boolean mouse_over_button(Button b) boolean mouse_over_channel(byte c) { - if (c<16){ - if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * c && mouseY < yEdge + 36 * c + 30 && PinAssignment[c] != 0) - { - return true; - } - else - { - return false; - } + if (c < 16) + { + if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * c && mouseY < yEdge + 36 * c + 30 && PinAssignment[c] != 0) + { + return true; + } + else + { + return false; + } } - else{ - if (mouseX > xEdge && mouseX < width && mouseY > yBottom - 36 && mouseY < yBottom) - { - return true; - } - else - { - return false; - } + else + { + if (mouseX > xEdge && mouseX < width && mouseY > yBottom - 36 && mouseY < yBottom) + { + return true; + } + else + { + return false; + } } } @@ -177,7 +179,7 @@ void keyPressed() // this function is called after a mouse button has been pressed and then released void mouseClicked() -{ +{ for (byte channel = 0; channel <= 16; channel++) { if (mouse_over_channel(channel)) @@ -190,105 +192,6 @@ void mouseClicked() } } - /* - if (mouseX > xEdge && mouseX < width && mouseY > yEdge && mouseY < yEdge + 30 && PinAssignment[0] != 0) - { - getChannelCursorCurrentEvent(0); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 && mouseY < yEdge + 36 + 30 && PinAssignment[1] != 0) - { - getChannelCursorCurrentEvent(1); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 2 && mouseY < yEdge + 36 * 2 + 30 && PinAssignment[2] != 0) - { - getChannelCursorCurrentEvent(2); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 3 && mouseY < yEdge + 36 * 3 + 30 && PinAssignment[3] != 0) - { - getChannelCursorCurrentEvent(3); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 4 && mouseY < yEdge + 36 * 4 + 30 && PinAssignment[4] != 0) - { - getChannelCursorCurrentEvent(4); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 5 && mouseY < yEdge + 36 * 5 + 30 && PinAssignment[5] != 0) - { - getChannelCursorCurrentEvent(5); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 6 && mouseY < yEdge + 36 * 6 + 30 && PinAssignment[6] != 0) - { - getChannelCursorCurrentEvent(6); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 7 && mouseY < yEdge + 36 * 7 + 30 && PinAssignment[7] != 0) - { - getChannelCursorCurrentEvent(7); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 8 && mouseY < yEdge + 36 * 8 + 30 && PinAssignment[8] != 0) - { - getChannelCursorCurrentEvent(8); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 9 && mouseY < yEdge + 36 * 9 + 30 && PinAssignment[9] != 0) - { - getChannelCursorCurrentEvent(9); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 10 && mouseY < yEdge + 36 * 10 + 30 && PinAssignment[10] != 0) - { - getChannelCursorCurrentEvent(10); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 11 && mouseY < yEdge + 36 * 11 + 30 && PinAssignment[11] != 0) - { - getChannelCursorCurrentEvent(11); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 12 && mouseY < yEdge + 36 * 12 + 30 && PinAssignment[12] != 0) - { - getChannelCursorCurrentEvent(12); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 13 && mouseY < yEdge + 36 * 13 + 30 && PinAssignment[13] != 0) - { - getChannelCursorCurrentEvent(13); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 14 && mouseY < yEdge + 36 * 14 + 30 && PinAssignment[14] != 0) - { - getChannelCursorCurrentEvent(14); - IsAnyChannelMarked = true; - movepos(); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 15 && mouseY < yEdge + 36 * 15 + 30 && PinAssignment[15] != 0) - { - getChannelCursorCurrentEvent(15); - IsAnyChannelMarked = true; - movepos(); - } - */ - if (mouse_over_button(button_time_draw)) { drawTimes = !drawTimes; @@ -375,8 +278,8 @@ void mouseClicked() } else { - IsAnyChannelMarked = false; - dataComplete = true; + IsAnyChannelMarked = false; + dataComplete = true; } } @@ -399,7 +302,7 @@ void mouseReleased() void mouseWheel(MouseEvent event) { // get the mouse movement and invert it - float wheel = map(event.getCount(), -1, 1, 1, -1); + float wheel = map(event.getCount(), -1, 1, 1, -1); // change the step of the mouse wheel depending on the reducer and time_format if (time_format == "ms") { @@ -468,85 +371,13 @@ void mouseMoved() if (mouse_over_channel(channel)) { cursor(HAND); - return; - // exit from the for loop + return; // exit from the for loop } else { cursor(ARROW); } } - - /* - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge && mouseY < yEdge + 30 && PinAssignment[0] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 && mouseY < yEdge + 36 + 30 && PinAssignment[1] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 2 && mouseY < yEdge + 36 * 2 + 30 && PinAssignment[2] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 3 && mouseY < yEdge + 36 * 3 + 30 && PinAssignment[3] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 4 && mouseY < yEdge + 36 * 4 + 30 && PinAssignment[4] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 5 && mouseY < yEdge + 36 * 5 + 30 && PinAssignment[5] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 6 && mouseY < yEdge + 36 * 6 + 30 && PinAssignment[6] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 7 && mouseY < yEdge + 36 * 7 + 30 && PinAssignment[7] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 8 && mouseY < yEdge + 36 * 8 + 30 && PinAssignment[8] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 9 && mouseY < yEdge + 36 * 9 + 30 && PinAssignment[9] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 10 && mouseY < yEdge + 36 * 10 + 30 && PinAssignment[10] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 11 && mouseY < yEdge + 36 * 11 + 30 && PinAssignment[11] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 12 && mouseY < yEdge + 36 * 12 + 30 && PinAssignment[12] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 13 && mouseY < yEdge + 36 * 13 + 30 && PinAssignment[13] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 14 && mouseY < yEdge + 36 * 14 + 30 && PinAssignment[14] != 0) - { - cursor(HAND); - } - else if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * 15 && mouseY < yEdge + 36 * 15 + 30 && PinAssignment[15] != 0) - { - cursor(HAND); - } - else - { - cursor(ARROW); - } - */ } // this function is called every time a mouse button is pressed @@ -555,7 +386,6 @@ void mousePressed() if (mouse_over_button(scroll_bar)) { isDraggable = true; - //scroll_bar_color = color(100, 200, 255); change color of the scroll bar } } diff --git a/Microcontroller_Code/MEGA/MEGA.ino b/Microcontroller_Code/MEGA/MEGA.ino index 75f415e..0efdbe9 100644 --- a/Microcontroller_Code/MEGA/MEGA.ino +++ b/Microcontroller_Code/MEGA/MEGA.ino @@ -1,5 +1,6 @@ /* - * Created: 11/12/2016 19.35.51 + * MEGA.ino + * * Author : sancho / Vincenzo */ diff --git a/Microcontroller_Code/UNO/UNO.ino b/Microcontroller_Code/UNO/UNO.ino index 72c6ab3..ba965bc 100644 --- a/Microcontroller_Code/UNO/UNO.ino +++ b/Microcontroller_Code/UNO/UNO.ino @@ -1,7 +1,6 @@ /* * UNO.ino * - * Created: 11/12/2016 19.35.51 * Author : Vincenzo * Led on A0 */