Skip to content

Commit

Permalink
fix 7 seg in common cathode/anode mode in printable mode (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalstad committed Oct 27, 2024
1 parent 28669ed commit 4d347a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/com/lushprojects/circuitjs1/client/SevenSegElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ void stepFinished() {
}

void setColor(Graphics g, int p) {
boolean whiteBkg = sim.printableCheckItem.getState();
if (diodeDirection == 0) {
g.setColor(pins[p].value ? Color.red :
sim.printableCheckItem.getState() ? lightgray : darkred);
whiteBkg ? lightgray : darkred);
return;
}
// 10mA current = max brightness
Expand All @@ -289,9 +290,11 @@ void setColor(Graphics g, int p) {
w = 255*(1+.2*Math.log(w));
if (w > 255)
w = 255;
if (w < 30)
w = 30;
Color cc = new Color((int) w, 0, 0);
double minw = (whiteBkg) ? 5 : 30;
if (w < minw)
w = minw;
int wi = (int) w;
Color cc = whiteBkg ? new Color(255, 255-wi, 255-wi) : new Color(wi, 0, 0);
g.setColor(cc);
}
int getPostCount() { return pinCount; }
Expand Down

0 comments on commit 4d347a8

Please sign in to comment.