Merge pull request #9 from sancho11/pr

PR errors were fixed!
This commit is contained in:
aster94
2019-02-09 20:03:25 +01:00
committed by GitHub
3 changed files with 63 additions and 43 deletions

View File

@@ -4,10 +4,10 @@
//uncomment the line where your board is connected //uncomment the line where your board is connected
//String LA_port = "/dev/ttyACM0"; //linux DFU //String LA_port = "/dev/ttyACM0"; //linux DFU
//String LA_port = "/dev/ttyUSB0"; //linux Serial //String LA_port = "/dev/ttyUSB0"; //linux Serial
//String LA_port = "COM11"; //windows String LA_port = "COM5"; //windows
//Uncomment the board that you are using //Uncomment the board that you are using
//String board = "MEGA"; String board = "MEGA";
//String board = "UNO"; //String board = "UNO";
//String board = "STM32F1"; //String board = "STM32F1";
//String board = "ESP8266"; //String board = "ESP8266";
@@ -74,7 +74,7 @@ String image_format = ".jpg"; // supported jpt, tif
35 -------> OFF -------> DigitalPIN 32 -------> OFF -------> OFF 35 -------> OFF -------> DigitalPIN 32 -------> OFF -------> OFF
36 -------> OFF -------> DigitalPIN 31 -------> OFF -------> OFF 36 -------> OFF -------> DigitalPIN 31 -------> OFF -------> OFF
37 -------> OFF -------> DigitalPIN 30 -------> OFF -------> OFF 37 -------> OFF -------> DigitalPIN 30 -------> OFF -------> OFF
Any other -----> OFF -------> OFF -------> OFF -------> OFF Any other -------> OFF -------> OFF -------> OFF -------> OFF
*/ */
// import needed modules // import needed modules
@@ -155,6 +155,9 @@ class Box
} }
} }
//boolean box_left_drawn = false; //boolean box_left_drawn = false;
Box box_pin_names = new Box(); // box for the pin names and number 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 Box box_scroll_bar = new Box(); // a narrow box for the scroll bar
@@ -163,9 +166,9 @@ Box box_graph = new Box(); // box for the core of this program
class Button class Button
{ {
int from_left; float from_left;
int from_top; int from_top;
int width; float width;
int height; int height;
int corners = 5; int corners = 5;
String text; String text;
@@ -179,6 +182,8 @@ class Button
} }
} }
Button button_start = new Button(); Button button_start = new Button();
Button button_time_draw = new Button(); Button button_time_draw = new Button();
Button button_time_format = new Button(); Button button_time_format = new Button();
@@ -285,7 +290,7 @@ void setup()
scroll_bar.width = 20; scroll_bar.width = 20;
scroll_bar.height = 15; scroll_bar.height = 15;
scroll_bar.from_left = int(xEdge); scroll_bar.from_left = xEdge;
scroll_bar.from_top = box_bottom.from_top - scroll_bar.height; scroll_bar.from_top = box_bottom.from_top - scroll_bar.height;
//Here you chose the pins that yuo want to show in the Logic Analizer. Put 0 to OFF the channel. //Here you chose the pins that yuo want to show in the Logic Analizer. Put 0 to OFF the channel.
@@ -514,7 +519,7 @@ void draw()
pushMatrix(); // move the coordinate reference pushMatrix(); // move the coordinate reference
translate(xEdge, 0); translate(xEdge, 0);
drawCursorChannel(IsAnyChannelMarked); drawCursorChannel(IsAnyChannelMarked);
updatepos(); // Se encarga de decir que segmento de tiempos se va a escribir updatepos(); // Update the positions that will be draw
DrawChannelSignals(); DrawChannelSignals();
popMatrix(); popMatrix();
@@ -528,7 +533,7 @@ void draw()
void getChannelCursorCurrentEvent(int index) void getChannelCursorCurrentEvent(int index)
{ {
float compare1; float compare1;
CurrentEventFloat = -(xShift * 100000 - mouseX * 100000 + xEdge * 100000); CurrentEventFloat = -(xShift - mouseX + xEdge );
ChannelCursor1CurrentEvent0[1] = index; ChannelCursor1CurrentEvent0[1] = index;
if (index != 16) if (index != 16)
{ {
@@ -537,13 +542,13 @@ void getChannelCursorCurrentEvent(int index)
index2 = s.charAt(0) - '1'; index2 = s.charAt(0) - '1';
ChannelCursor1CurrentEvent0[0] = 0; // Keep records of the event we are in. ChannelCursor1CurrentEvent0[0] = 0; // Keep records of the event we are in.
//println (abs(xTime[46]+xShift)); //println (abs(xTime[46]+xShift));
if (CurrentEventFloat < 0 || CurrentEventFloat > xTime[samples - 1] * 100000) if (CurrentEventFloat < 0 || CurrentEventFloat > xTime[samples - 1] )
{ {
if (CurrentEventFloat <= 0) if (CurrentEventFloat <= 0)
{ {
ChannelCursor1CurrentEvent0[0] = 0; ChannelCursor1CurrentEvent0[0] = 0;
} }
if (CurrentEventFloat >= xTime[samples - 1] * 100000) if (CurrentEventFloat >= xTime[samples - 1] )
{ {
ChannelCursor1CurrentEvent0[0] = samples - 1; ChannelCursor1CurrentEvent0[0] = samples - 1;
} }
@@ -552,7 +557,7 @@ void getChannelCursorCurrentEvent(int index)
{ {
for (int i = 1; i < samples - 1; i++) for (int i = 1; i < samples - 1; i++)
{ {
compare1 = ((xTime[i] * 100000) + (xTime[i + 1] * 100000) - (2 * CurrentEventFloat)); compare1 = ((xTime[i] ) + (xTime[i + 1] ) - (2 * CurrentEventFloat));
if (compare1 < 0) if (compare1 < 0)
{ {
if (state[i][index1][index2]) if (state[i][index1][index2])
@@ -591,7 +596,7 @@ void updatepos()
void movepos() void movepos()
{ {
xShift = xTime[ChannelCursor1CurrentEvent0[0]]; xShift = xTime[ChannelCursor1CurrentEvent0[0]];
scroll_bar.from_left = int(map(xShift, 0, xEnd, xEdge, width - scroll_bar.width)); scroll_bar.from_left = map(xShift, 0, xEnd, xEdge, width - scroll_bar.width);
xShift = -xShift - (width - scroll_bar.width) / 2; xShift = -xShift - (width - scroll_bar.width) / 2;
dataComplete = true; dataComplete = true;
} }
@@ -648,7 +653,7 @@ void serialEvent(Serial board_port)
} }
} }
void scaletime() // Poner una r indicara que la funcion solo va a rehacer los tiempos. void scaletime()
{ {
if (time_format == "ms") if (time_format == "ms")
{ {

View File

@@ -41,8 +41,8 @@ void draw_boxes()
line(x, y - 20, xEdge, y - 20); line(x, y - 20, xEdge, y - 20);
line(x, y + 10, xEdge, y + 10); line(x, y + 10, xEdge, y + 10);
stroke(#EF7F1A); stroke(#EF7F1A);
dashline(xEdge, y - 23, width, y - 23, spacing); dashline(xEdge, y - 23, width, y - 23, spacinggrid);
dashline(xEdge, y + 13, width, y + 13, spacing); dashline(xEdge, y + 13, width, y + 13, spacinggrid);
stroke(white); stroke(white);
if (board == "STM32F1") if (board == "STM32F1")
{ {
@@ -68,6 +68,8 @@ void draw_boxes()
} }
y += 36; y += 36;
} }
text(" ALL ", x, 610);
text("EVENTS", x, 625);
} }
void drawCursorChannel(boolean CursorEnable) void drawCursorChannel(boolean CursorEnable)
@@ -78,7 +80,7 @@ void drawCursorChannel(boolean CursorEnable)
stroke(75); 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. 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.
{ {
rect(0, yBottom - 12, width - xEdge, 34); rect(0, yBottom - 36, width - xEdge, 34);
} }
else else
{ {
@@ -145,10 +147,8 @@ void DrawChannelSignals()
} }
// finally we draw the lines // finally we draw the lines
stroke(green);
line(xPos[n] + xShift, yPos, xTime[i] + xShift, yPos); // straight line line(xPos[n] + xShift, yPos, xTime[i] + xShift, yPos); // straight line
line(xTime[i] + xShift, yPos, xTime[i] + xShift, yDiff); // vertical 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 xPos[n] = xTime[i]; // save last position of the line for the pin
yPos = ySave; // load the initial value of the y yPos = ySave; // load the initial value of the y
} }
@@ -172,6 +172,7 @@ void DrawChannelSignals()
textCovered = !textCovered; textCovered = !textCovered;
dashline(xTime[i] + xShift, firstchange, xTime[i] + xShift, yBottom, spacing); dashline(xTime[i] + xShift, firstchange, xTime[i] + xShift, yBottom, spacing);
text(round(usTime[i]), xTime[i] + xShift + 2, (textCovered == true) ? yBottom : yBottom - 10); //write on different height text(round(usTime[i]), xTime[i] + xShift + 2, (textCovered == true) ? yBottom : yBottom - 10); //write on different height
stroke(green);
} }
} }
} }
@@ -182,7 +183,7 @@ void ScrollingBarPressed()
{ {
scroll_bar.from_left = mouseX - scroll_bar.width / 2; scroll_bar.from_left = mouseX - scroll_bar.width / 2;
if (scroll_bar.from_left < xEdge) if (scroll_bar.from_left < xEdge)
scroll_bar.from_left = int(xEdge); scroll_bar.from_left = xEdge;
if (scroll_bar.from_left > width - scroll_bar.width) if (scroll_bar.from_left > width - scroll_bar.width)
scroll_bar.from_left = width - scroll_bar.width; scroll_bar.from_left = width - scroll_bar.width;
updatepos(); updatepos();
@@ -190,7 +191,8 @@ void ScrollingBarPressed()
} }
} }
float[] spacing = {1, 50}; //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) void dashline(float x0, float y0, float x1, float y1, float[] spacing)
{ {
float distance = dist(x0, y0, x1, y1); float distance = dist(x0, y0, x1, y1);

View File

@@ -12,6 +12,7 @@ boolean mouse_over_button(Button b)
boolean mouse_over_channel(byte c) 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) if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * c && mouseY < yEdge + 36 * c + 30 && PinAssignment[c] != 0)
{ {
return true; return true;
@@ -21,6 +22,17 @@ boolean mouse_over_channel(byte c)
return false; return false;
} }
} }
else{
if (mouseX > xEdge && mouseX < width && mouseY > yBottom - 36 && mouseY < yBottom)
{
return true;
}
else
{
return false;
}
}
}
// this function is called every time a key is pressed // this function is called every time a key is pressed
void keyPressed() void keyPressed()
@@ -139,7 +151,7 @@ void keyPressed()
scroll_bar.from_left -= 1; scroll_bar.from_left -= 1;
if (scroll_bar.from_left < xEdge) if (scroll_bar.from_left < xEdge)
{ {
scroll_bar.from_left = int(xEdge); scroll_bar.from_left = xEdge;
} }
if (scroll_bar.from_left > width - scroll_bar.width) if (scroll_bar.from_left > width - scroll_bar.width)
{ {
@@ -152,7 +164,7 @@ void keyPressed()
scroll_bar.from_left += 1; scroll_bar.from_left += 1;
if (scroll_bar.from_left < xEdge) if (scroll_bar.from_left < xEdge)
{ {
scroll_bar.from_left = int(xEdge); scroll_bar.from_left = xEdge;
} }
if (scroll_bar.from_left > width - scroll_bar.width) if (scroll_bar.from_left > width - scroll_bar.width)
{ {
@@ -166,17 +178,18 @@ void keyPressed()
// this function is called after a mouse button has been pressed and then released // this function is called after a mouse button has been pressed and then released
void mouseClicked() void mouseClicked()
{ {
for (byte channel = 0; channel < 16; channel++) for (byte channel = 0; channel <= 16; channel++)
{ {
if (mouse_over_channel(channel)) if (mouse_over_channel(channel))
{ {
getChannelCursorCurrentEvent(channel); getChannelCursorCurrentEvent(channel);
IsAnyChannelMarked = true; IsAnyChannelMarked = true;
movepos(); movepos();
// exit from the for loop dataComplete = true;
break; return;
} }
} }
/* /*
if (mouseX > xEdge && mouseX < width && mouseY > yEdge && mouseY < yEdge + 30 && PinAssignment[0] != 0) if (mouseX > xEdge && mouseX < width && mouseY > yEdge && mouseY < yEdge + 30 && PinAssignment[0] != 0)
{ {
@@ -288,7 +301,7 @@ void mouseClicked()
println("new data coming"); println("new data coming");
board_port.clear(); board_port.clear();
xShift = (width - scroll_bar.width) / 2; xShift = (width - scroll_bar.width) / 2;
scroll_bar.from_left = int(xEdge); scroll_bar.from_left = xEdge;
} }
else if (mouse_over_button(button_save)) else if (mouse_over_button(button_save))
{ {
@@ -387,21 +400,21 @@ void mouseWheel(MouseEvent event)
{ {
// get the mouse movement and invert it // 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 // change the step of the mouse wheel depending on the reducer and time_format
if (time_format == "ms") if (time_format == "ms")
{ {
scroll_bar.from_left -= wheel * 50 * reducer; scroll_bar.from_left -= wheel * 50 * reducer;
} }
else if (time_format == "μs") //else if (time_format == "μs")
else
{ {
scroll_bar.from_left -= wheel * 50 * reducer * 0.1; scroll_bar.from_left -= wheel * 50 * reducer * 0.001;
} }
//move the graph //move the graph
if (scroll_bar.from_left < xEdge) if (scroll_bar.from_left < xEdge)
{ {
scroll_bar.from_left = int(xEdge); scroll_bar.from_left = xEdge;
} }
if (scroll_bar.from_left > width - scroll_bar.width) if (scroll_bar.from_left > width - scroll_bar.width)
{ {
@@ -450,7 +463,7 @@ void mouseMoved()
cursor(ARROW); cursor(ARROW);
} }
for (byte channel = 0; channel < 16; channel++) for (byte channel = 0; channel <= 16; channel++)
{ {
if (mouse_over_channel(channel)) if (mouse_over_channel(channel))
{ {