0.1.5.0 - Basic input implemented

version update to 0.1.5 as the structure of the code has changed significantly again. Got MathPad and MathDisplay working, and created the Calculator container class to hold them all. Calculator will eventually be the "widget" if you will for calculator functionality. Version numbers are now going to update every commit.
This commit is contained in:
61616
2022-05-05 21:17:02 -04:00
parent 81423f79e1
commit 22035e0ab7
6 changed files with 86 additions and 50 deletions

View File

@@ -3,7 +3,7 @@
Beta version of a clock in base 12.
by Nayan Sawyer
started Mar 2022
version 0.1.4.3 April 30 2022
version 0.1.5.0 April 30 2022
Characters are a variation of Kaktovik Inupiaq numerals
reversed and in base 12 instead of 20. I take no credit
@@ -11,6 +11,17 @@
Includes method relay code be Quark - see https://forum.processing.org/two/discussion/13093/how-to-call-function-by-string-content.html
for more details.
changelog 0.1.5.0
- Quite a few changes by this point. The readme has been
fixed, the button class has gone through many revisions
and now allows dynamic calls defined at object creation,
the MathPad now works and inputs B12Digits into a
B12Expression, MathDisplay now works and displays the
contents of a B12Expression, and many miscellaneous bugs
and inefficiencies have been fixed. I still need to get
better at version numbering, but it is slowly getting
better.
changelog 0.1.4.0
- Added MethodRelay code from Quark. Some fixes and
changes as well. Condesed some things into fewer files
@@ -35,22 +46,15 @@ float sMouseY;
public static final int DECIMAL = 65;
ClickHandler ch; // Mouse event handler
Clock clock; //<>//
B12Digit p;
B12Digit t;
MathPad m;
Calculator calc; //<>//
void setup(){
size(400,400);
offset = new PVector(width/2, height/2);
ch = new ClickHandler();
m = new MathPad(ch,new B12Math());
calc = new Calculator(ch);
clock = new Clock(new STime48());
println("waiting");
p = new B12Digit('+');
t = new B12Digit('/');
}
void draw(){
@@ -59,12 +63,8 @@ void draw(){
sMouseY = (mouseY - offset.y)/scale;
translate(offset.x,offset.y);
scale(scale);
point(0,0);
m.display();
clock.display();
//p.display();
t.display();
//println( + " " + ;
calc.display();
}
void mouseClicked(){

View File

@@ -0,0 +1,28 @@
class B12Expression {
private B12Digit[] expression;
B12Expression(){
expression = new B12Digit[0];
}
B12Digit getDigit(int index){ return expression[index]; }
int length(){return expression.length;}
void setChar(int ind, B12Digit _digit){
expression = (B12Digit[])append(expression, _digit); // Add the new digit
if(ind < expression.length - 1){ // Swap new digit
for(int i = expression.length - 1; i > ind; i--){ // Start at second to last digit
expression[i] = expression[i-1]; // Swap object one index below i up into index i
}
expression[ind] = _digit;
}
}
void addChar(B12Digit _digit){
expression = (B12Digit[])append(expression, _digit);
}
void evaluate(){
//TODO set expression to evaluation of expression
}
}

View File

@@ -1,15 +0,0 @@
class B12Math {
ArrayList <B12Digit> expression;
B12Math(){
expression = new ArrayList<B12Digit>();;
}
void delete(int pos){
expression.remove(pos);
}
void evaluate(){
//TODO set expression to evaluation of expression
}
}

View File

@@ -0,0 +1,16 @@
class Calculator{
B12Expression ex;
MathPad m;
MathDisplay d;
Calculator(ClickHandler _ch){
ex = new B12Expression();
m = new MathPad(_ch,ex);
d = new MathDisplay(ex);
}
void display(){
m.display();
d.display();
}
}

View File

@@ -1,14 +1,24 @@
class MathDisplay {
B12Math math;
PVector pos;
B12Expression ex;
MathDisplay(B12Math _math){
math = _math;
MathDisplay(B12Expression _ex){
ex = _ex;
pos = new PVector(0,0);
}
// TODO take expression from math and display it in whatever state it is in
PVector getPos(){ return pos; }
void setPos(PVector _pos){ pos = _pos; }
void display(){
for(int i = 0; i < math.expression.size(); i++){
}
pushMatrix();
translate(pos.x,pos.y);
int count = 0;
for(int i = ex.length() - 1; i >= 0 ; i--){
ex.getDigit(i).setRefPos((-12 * (count+1)), 0);
ex.getDigit(i).display();
count++;
}
popMatrix();
}
}

View File

@@ -1,11 +1,11 @@
class MathPad{
B12Math math;
B12Expression ex;
ClickHandler ch;
B12Button[] buttons;
PVector pos;
MathPad(ClickHandler _ch, B12Math _math){
math = _math;
MathPad(ClickHandler _ch, B12Expression _ex){
ex = _ex;
ch = _ch;
pos = new PVector(0,0);
buttons = new B12Button[12];
@@ -19,15 +19,12 @@ class MathPad{
buttons[i].setColor(220,150);
}
}
// DONE draw a grid for buttons
// DONE draw characters in grid
// DONE detect mousepresses on the buttons (maybe a global mouse handler?)
// TODO send characters to math
void addChar(B12Digit digit){
//math.addChar(digit);
//math.expression.add(new B12Char('/'));
println("clicked " + digit.getValue());
// TODO send characters to display
void addChar(B12Digit _digit){
ex.addChar(_digit);
println("clicked " + _digit.getValue());
}
void display(){