mirror of
https://github.com/aster94/logic-analyzer.git
synced 2026-05-01 15:10:43 +03:00
Fixed problems.
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
//uncomment the line where your board is connected
|
||||
//String LA_port = "/dev/ttyACM0"; //linux DFU
|
||||
//String LA_port = "/dev/ttyUSB0"; //linux Serial
|
||||
//String LA_port = "COM11"; //windows
|
||||
String LA_port = "COM5"; //windows
|
||||
|
||||
//Uncomment the board that you are using
|
||||
//String board = "MEGA";
|
||||
String board = "MEGA";
|
||||
//String board = "UNO";
|
||||
//String board = "STM32F1";
|
||||
//String board = "ESP8266";
|
||||
@@ -74,7 +74,7 @@ String image_format = ".jpg"; // supported jpt, tif
|
||||
35 -------> OFF -------> DigitalPIN 32 -------> OFF -------> OFF
|
||||
36 -------> OFF -------> DigitalPIN 31 -------> OFF -------> OFF
|
||||
37 -------> OFF -------> DigitalPIN 30 -------> OFF -------> OFF
|
||||
Any other -----> OFF -------> OFF -------> OFF -------> OFF
|
||||
Any other -------> OFF -------> OFF -------> OFF -------> OFF
|
||||
*/
|
||||
|
||||
// import needed modules
|
||||
@@ -155,6 +155,9 @@ 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
|
||||
@@ -163,9 +166,9 @@ Box box_graph = new Box(); // box for the core of this program
|
||||
|
||||
class Button
|
||||
{
|
||||
int from_left;
|
||||
float from_left;
|
||||
int from_top;
|
||||
int width;
|
||||
float width;
|
||||
int height;
|
||||
int corners = 5;
|
||||
String text;
|
||||
@@ -179,6 +182,8 @@ class Button
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Button button_start = new Button();
|
||||
Button button_time_draw = new Button();
|
||||
Button button_time_format = new Button();
|
||||
@@ -285,7 +290,7 @@ void setup()
|
||||
|
||||
scroll_bar.width = 20;
|
||||
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;
|
||||
|
||||
//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
|
||||
translate(xEdge, 0);
|
||||
drawCursorChannel(IsAnyChannelMarked);
|
||||
updatepos(); // Se encarga de decir que segmento de tiempos se va a escribir
|
||||
updatepos(); // Update the positions that will be draw
|
||||
DrawChannelSignals();
|
||||
popMatrix();
|
||||
|
||||
@@ -522,13 +527,13 @@ void draw()
|
||||
|
||||
draw_boxes();
|
||||
}
|
||||
ScrollingBarPressed();
|
||||
ScrollingBarPressed();
|
||||
}
|
||||
|
||||
void getChannelCursorCurrentEvent(int index)
|
||||
{
|
||||
float compare1;
|
||||
CurrentEventFloat = -(xShift * 100000 - mouseX * 100000 + xEdge * 100000);
|
||||
CurrentEventFloat = -(xShift - mouseX + xEdge );
|
||||
ChannelCursor1CurrentEvent0[1] = index;
|
||||
if (index != 16)
|
||||
{
|
||||
@@ -537,13 +542,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] * 100000)
|
||||
if (CurrentEventFloat < 0 || CurrentEventFloat > xTime[samples - 1] )
|
||||
{
|
||||
if (CurrentEventFloat <= 0)
|
||||
{
|
||||
ChannelCursor1CurrentEvent0[0] = 0;
|
||||
}
|
||||
if (CurrentEventFloat >= xTime[samples - 1] * 100000)
|
||||
if (CurrentEventFloat >= xTime[samples - 1] )
|
||||
{
|
||||
ChannelCursor1CurrentEvent0[0] = samples - 1;
|
||||
}
|
||||
@@ -552,7 +557,7 @@ void getChannelCursorCurrentEvent(int index)
|
||||
{
|
||||
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 (state[i][index1][index2])
|
||||
@@ -591,7 +596,7 @@ void updatepos()
|
||||
void movepos()
|
||||
{
|
||||
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;
|
||||
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")
|
||||
{
|
||||
|
||||
@@ -41,8 +41,8 @@ void draw_boxes()
|
||||
line(x, y - 20, xEdge, y - 20);
|
||||
line(x, y + 10, xEdge, y + 10);
|
||||
stroke(#EF7F1A);
|
||||
dashline(xEdge, y - 23, width, y - 23, spacing);
|
||||
dashline(xEdge, y + 13, width, y + 13, spacing);
|
||||
dashline(xEdge, y - 23, width, y - 23, spacinggrid);
|
||||
dashline(xEdge, y + 13, width, y + 13, spacinggrid);
|
||||
stroke(white);
|
||||
if (board == "STM32F1")
|
||||
{
|
||||
@@ -68,17 +68,19 @@ void draw_boxes()
|
||||
}
|
||||
y += 36;
|
||||
}
|
||||
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.
|
||||
{
|
||||
rect(0, yBottom - 12, width - xEdge, 34);
|
||||
rect(0, yBottom - 36, width - xEdge, 34);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -145,10 +147,8 @@ void DrawChannelSignals()
|
||||
}
|
||||
|
||||
// finally we draw the lines
|
||||
stroke(green);
|
||||
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
|
||||
}
|
||||
@@ -172,6 +172,7 @@ void DrawChannelSignals()
|
||||
textCovered = !textCovered;
|
||||
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
|
||||
stroke(green);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,7 +183,7 @@ void ScrollingBarPressed()
|
||||
{
|
||||
scroll_bar.from_left = mouseX - scroll_bar.width / 2;
|
||||
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)
|
||||
scroll_bar.from_left = width - scroll_bar.width;
|
||||
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)
|
||||
{
|
||||
float distance = dist(x0, y0, x1, y1);
|
||||
|
||||
@@ -12,13 +12,25 @@ boolean mouse_over_button(Button b)
|
||||
|
||||
boolean mouse_over_channel(byte c)
|
||||
{
|
||||
if (mouseX > xEdge && mouseX < width && mouseY > yEdge + 36 * c && mouseY < yEdge + 36 * c + 30 && PinAssignment[c] != 0)
|
||||
{
|
||||
return true;
|
||||
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
|
||||
{
|
||||
return false;
|
||||
else{
|
||||
if (mouseX > xEdge && mouseX < width && mouseY > yBottom - 36 && mouseY < yBottom)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +151,7 @@ void keyPressed()
|
||||
scroll_bar.from_left -= 1;
|
||||
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)
|
||||
{
|
||||
@@ -152,7 +164,7 @@ void keyPressed()
|
||||
scroll_bar.from_left += 1;
|
||||
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)
|
||||
{
|
||||
@@ -165,18 +177,19 @@ 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++)
|
||||
{
|
||||
for (byte channel = 0; channel <= 16; channel++)
|
||||
{
|
||||
if (mouse_over_channel(channel))
|
||||
{
|
||||
getChannelCursorCurrentEvent(channel);
|
||||
IsAnyChannelMarked = true;
|
||||
movepos();
|
||||
// exit from the for loop
|
||||
break;
|
||||
dataComplete = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (mouseX > xEdge && mouseX < width && mouseY > yEdge && mouseY < yEdge + 30 && PinAssignment[0] != 0)
|
||||
{
|
||||
@@ -288,7 +301,7 @@ void mouseClicked()
|
||||
println("new data coming");
|
||||
board_port.clear();
|
||||
xShift = (width - scroll_bar.width) / 2;
|
||||
scroll_bar.from_left = int(xEdge);
|
||||
scroll_bar.from_left = xEdge;
|
||||
}
|
||||
else if (mouse_over_button(button_save))
|
||||
{
|
||||
@@ -362,8 +375,8 @@ void mouseClicked()
|
||||
}
|
||||
else
|
||||
{
|
||||
IsAnyChannelMarked = false;
|
||||
dataComplete = true;
|
||||
IsAnyChannelMarked = false;
|
||||
dataComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,22 +399,22 @@ 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")
|
||||
{
|
||||
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
|
||||
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)
|
||||
{
|
||||
@@ -450,7 +463,7 @@ void mouseMoved()
|
||||
cursor(ARROW);
|
||||
}
|
||||
|
||||
for (byte channel = 0; channel < 16; channel++)
|
||||
for (byte channel = 0; channel <= 16; channel++)
|
||||
{
|
||||
if (mouse_over_channel(channel))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user