0.2.1.2 - Timer now complete

This commit is contained in:
61616
2022-05-20 14:23:50 -04:00
parent f160a7fadd
commit 8838f763ce
3 changed files with 36 additions and 17 deletions

View File

@@ -55,7 +55,8 @@ void draw(){
//mode.display(); //mode.display();
//clock.display(); //clock.display();
st.display(); //st.display();
timer.display();
//point(-15,0); //point(-15,0);
} }
@@ -70,10 +71,6 @@ void mouseReleased(){mh.cascade('r', mh.sMouseX(), mh.sMouseY(), mouseButton);}
void mouseWheel(MouseEvent event){mh.cascade('w', mh.sMouseX(), mh.sMouseY(), event.getCount());} void mouseWheel(MouseEvent event){mh.cascade('w', mh.sMouseX(), mh.sMouseY(), event.getCount());}
void mouseDragged(){mh.cascade('d', mh.sMouseX(), mh.sMouseY(), mouseButton);} void mouseDragged(){mh.cascade('d', mh.sMouseX(), mh.sMouseY(), mouseButton);}
void call(String _call){
method(_call);
}
void changeMode(){ void changeMode(){
if(calc == null){ if(calc == null){
//clock = null; //clock = null;
@@ -92,10 +89,6 @@ void reset(){
calc.ex.clear(); calc.ex.clear();
} }
void test(){
background(255,0,0);
}
void crossMark(){ void crossMark(){
line(offset.x,0,offset.x,height); line(offset.x,0,offset.x,height);
line(0,offset.y,width,offset.y); line(0,offset.y,width,offset.y);

View File

@@ -6,14 +6,18 @@ class Timer{
boolean setTime; boolean setTime;
int cursorPos; int cursorPos;
STime48 time; STime48 time;
Time48 target;
TimeDisplay td; TimeDisplay td;
boolean running;
Timer(MouseHandler _mh){ Timer(MouseHandler _mh){
pos = new PVector(0,0); pos = new PVector(0,0);
mh = _mh; mh = _mh;
time = new STime48().setTime(new Time48(0));; time = new STime48().setTime(new Time48(0));;
td = new TimeDisplay(time); target = new Time48(0);
setTime = false; td = new TimeDisplay(new Time48(0));
setTime = true;
running = false;
cursorPos = 0; cursorPos = 0;
initialize(); initialize();
} }
@@ -37,7 +41,7 @@ class Timer{
buttons = (Button[])append(buttons, new B12Button(mh ,new B12Digit(i)).setPos(bPos).setDim(new PVector(20,20)).setFunction(new MethodRelay(this, "addChar", B12Digit.class)).setColor(220,150)); buttons = (Button[])append(buttons, new B12Button(mh ,new B12Digit(i)).setPos(bPos).setDim(new PVector(20,20)).setFunction(new MethodRelay(this, "addChar", B12Digit.class)).setColor(220,150));
} }
// Create other buttons // Create other buttons
buttons = (Button[])append(buttons, new Button(mh).setText("Set").setPos(new PVector(pos.x - 43,pos.y + 22*3 + 2)).setDim(new PVector(27,20)).setFunction(new MethodRelay(this, "lockTime")).setColor(220,150)); buttons = (Button[])append(buttons, new Button(mh).setText("Start").setPos(new PVector(pos.x - 43,pos.y + 22*3 + 2)).setDim(new PVector(27,20)).setFunction(new MethodRelay(this, "lockTime")).setColor(220,150));
buttons = (Button[])append(buttons, new Button(mh).setText("Clear").setPos(new PVector(pos.x + 29 - 43,pos.y + 22*3 + 2)).setDim(new PVector(28,20)).setFunction(new MethodRelay(this, "clearTime")).setColor(220,150)); buttons = (Button[])append(buttons, new Button(mh).setText("Clear").setPos(new PVector(pos.x + 29 - 43,pos.y + 22*3 + 2)).setDim(new PVector(28,20)).setFunction(new MethodRelay(this, "clearTime")).setColor(220,150));
buttons = (Button[])append(buttons, new Button(mh).setText("Cancel").setPos(new PVector(pos.x + 59 - 43,pos.y + 22*3 + 2)).setDim(new PVector(27,20)).setFunction(new MethodRelay(this, "cancelSetTime")).setColor(220,150)); buttons = (Button[])append(buttons, new Button(mh).setText("Cancel").setPos(new PVector(pos.x + 59 - 43,pos.y + 22*3 + 2)).setDim(new PVector(27,20)).setFunction(new MethodRelay(this, "cancelSetTime")).setColor(220,150));
@@ -68,21 +72,25 @@ class Timer{
} }
void lockTime(){ void lockTime(){
time.setTime(td.getTime()); target = new Time48(td.getTime());
td.setTime(time); time.setTime(new Time48(0));
td.setTime(new Time48().setTsec(target.tsec() - time.tsec()));
cursorPos = 0; cursorPos = 0;
setTime = false; setTime = false;
running = true;
} }
void triggerSetTime(){ void triggerSetTime(){
clearTime(); clearTime();
setTime = true; setTime = true;
running = false;
} }
void cancelSetTime(){ void cancelSetTime(){
td.setTime(time); //td.setTime(time);
cursorPos = 0; cursorPos = 0;
setTime = false; setTime = false;
running = true;
} }
void display(){ void display(){
@@ -95,6 +103,18 @@ class Timer{
}else{ }else{
setTimeButton.display(); setTimeButton.display();
} }
if(running == true){
td.setTime(new Time48().setTsec(target.tsec() - time.tsec()));
}
td.display(); td.display();
if(td.getTime().tsec() < 0){
fill(255,0,0);
rectMode(CORNERS);
rect(-13*5,-20,13*5,0);
fill(0);
textSize(16);
textAlign(CENTER,BOTTOM);
text("Timer Done!",0,0);
}
} }
} }

View File

@@ -3,7 +3,7 @@
Beta version of a clock in base 12. Beta version of a clock in base 12.
by Nayan Sawyer by Nayan Sawyer
started Mar 2022 started Mar 2022
version 0.2.1.2 May 19 2022 version 0.2.1.3 May 19 2022
Characters are a variation of Kaktovik Inupiaq numerals Characters are a variation of Kaktovik Inupiaq numerals
reversed and in base 12 instead of 20. I take no credit reversed and in base 12 instead of 20. I take no credit
@@ -11,10 +11,16 @@
Includes method relay code by Quark - see https://forum.processing.org/two/discussion/13093/how-to-call-function-by-string-content.html Includes method relay code by Quark - see https://forum.processing.org/two/discussion/13093/how-to-call-function-by-string-content.html
for more details. for more details.
// TODO finish clock applications // DONE finish clock applications
// TODO assemble clock application
// TODO combine clock and calcualtor into final app
// TODO add throwing exceptions to all contructors // TODO add throwing exceptions to all contructors
// MAYBE add additional operations like power, log, and trig functions // MAYBE add additional operations like power, log, and trig functions
changelog 0.2.1.3
- Finished timer. All clock apps are now complete. Some
assembly required :P
changelog 0.2.1.2 changelog 0.2.1.2
- Finished Stopwatch - Finished Stopwatch