0.2.1.1 - Finished Clock

This commit is contained in:
61616
2022-05-19 15:27:58 -04:00
parent 0ad49da001
commit ceb9c11c9c
5 changed files with 46 additions and 14 deletions

View File

@@ -145,7 +145,7 @@ class B12Int implements Number {
PVector getPos(){ return pos; }
B12Float toFloat(){return new B12Float(float(value)); }
B12Digit[] getDigits(){
loadArray(); //<>//
loadArray();
B12Digit[] out = digits;
return out;
}

View File

@@ -27,7 +27,7 @@ void setup(){
ex = new B12Expression();
//ca = new ClockApp(mh, time).setPos(-43,0);
clock = new Clock(mh, time);
clock = new Clock(mh, time);//.setPos(40,20);
calc = new Calculator(mh, ex);
mode = new Button(mh).setPos(new PVector(-20,-100), new PVector(40,20)).setRadius(2).setColor(#8B687F).autoHighlight().setText("Mode").setFunction(new MethodRelay(this, "changeMode"));
@@ -51,6 +51,7 @@ void draw(){
//mode.display();
clock.display();
//point(-15,0);
}
@@ -86,6 +87,10 @@ void reset(){
calc.ex.clear();
}
void test(){
background(255,0,0);
}
void crossMark(){
line(offset.x,0,offset.x,height);
line(0,offset.y,width,offset.y);

View File

@@ -25,7 +25,7 @@ class Clock{
void initialize(){
buttons = new Button[0];
td.setPos(pos.x,pos.y);
td.setPos(pos.x + 13*4 + 2,pos.y-2);
// Create numpad buttons
for(int i = 0; i < 12; i++){
/* Button position must contain it's absolute position relative to sketch 0,0 for mouseOver to work.
@@ -33,30 +33,44 @@ class Clock{
absolute position of the button */
// x = pos.x + (width + gap) * (i%cols)
// y = pos.y + (height + gap) * b2rows - (height + gap) * row
PVector bPos = new PVector(pos.x + 22 * int(i%4),pos.y + 22 * 2 - 22 * floor(i/4));
PVector bPos = new PVector(pos.x + 22 * int(i%4) - 43,pos.y + 22 * 2 - 22 * floor(i/4) + 2);
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
buttons = (Button[])append(buttons, new Button(mh).setText("Set").setPos(new PVector(pos.x,pos.y + 22*3)).setDim(new PVector(42,20)).setFunction(new MethodRelay(this, "lockTime")).setColor(220,150));
buttons = (Button[])append(buttons, new Button(mh).setText("Clear").setPos(new PVector(pos.x + 22*2,pos.y + 22*3)).setDim(new PVector(42,20)).setFunction(new MethodRelay(this, "clearTime")).setColor(220,150));
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("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));
setTimeButton = new Button(mh).setText("Set Time").setPos(new PVector(pos.x+21,pos.y)).setDim(new PVector(42,13)).setFunction(new MethodRelay(this, "triggerSetTime")).setColor(220,150);
setTimeButton = new Button(mh).setText("Set Time").setPos(new PVector(pos.x-21,pos.y + 2)).setDim(new PVector(42,13)).setFunction(new MethodRelay(this, "triggerSetTime")).setColor(220,150);
}
/*
void addChar(B12Digit digit){
switch(cursorPos){
case 0:
td.setTime(new Time48().setHour(digit.getValue() * 12)); cursorPos += 1; break;
case 1:
td.setTime(new Time48(td.getTime().tsec()).setHour(digit.getValue() + td.getTime().hours())); cursorPos += 2; break;
case 3:
td.setTime(new Time48(td.getTime().tsec()).setMin(digit.getValue() * 12)); cursorPos += 1; break;
case 4:
td.setTime(new Time48(td.getTime().tsec()).setMin(digit.getValue() + td.getTime().mins())); cursorPos += 2; break;
case 6:
td.setTime(new Time48(td.getTime().tsec()).setSec(digit.getValue() * 12)); cursorPos += 1; break;
case 7:
td.setTime(new Time48(td.getTime().tsec() + digit.getValue())); cursorPos += 1; break;
}
}
cursorPos
}*/
void clearTime(){
td.setTime(new Time48(0));
cursorPos = 0;
}
void lockTime(){
time.setTime(td.getTime());
td.setTime(time);
cursorPos = 0;
setTime = false;
}
@@ -65,11 +79,19 @@ class Clock{
setTime = true;
}
void cancelSetTime(){
td.setTime(time); //<>//
cursorPos = 0;
setTime = false;
}
void display(){
if(setTime){
for(int i = 0; i < buttons.length; i++){
buttons[i].display();
}
stroke(0);
if(cursorPos < 8)line(pos.x - 13 * (4-cursorPos) + 2, pos.y, pos.x - 13 * (4-cursorPos) + 10, pos.y);
}else{
setTimeButton.display();
}

View File

@@ -57,8 +57,9 @@ class TimeDisplay {
digits = (B12Digit[])append(digits,new B12Digit(':'));
digits = (B12Digit[])concat(digits,hours.getDigits());
// Position
for(int i = 0; i < digits.length; i++){
digits[i].setPos(i*-13 + pos.x,pos.y).display();
digits[i].setPos(i*-13 + pos.x - 13,pos.y).display();
}
// Position

View File

@@ -3,7 +3,7 @@
Beta version of a clock in base 12.
by Nayan Sawyer
started Mar 2022
version 0.2.1.0 May 18 2022
version 0.2.1.1 May 18 2022
Characters are a variation of Kaktovik Inupiaq numerals
reversed and in base 12 instead of 20. I take no credit
@@ -11,12 +11,16 @@
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.
// TODO switch B12Int from ArrayList to Array
// DONE add actual math evaluation to B12Expression // Once thiss is done we hit version 0.2.0.0 //
// DONE get clock input to work properly
// TODO finish clock applications
// DONE switch B12Int from ArrayList to Array
// TODO add throwing exceptions to all contructors
// MAYBE start clock widget structure
// MAYBE add additional operations like power, log, and trig functions
changelog 0.2.1.1
- Finished clock implementation
changelog 0.2.1.0
- Changes to the base code and the beginning of the clock
applications. File condensing (will be reversed)