Update UI a bit

This commit is contained in:
Jeremy Rand 2012-07-20 10:58:55 -05:00
parent eecba58070
commit ceec9f3561

View File

@ -70,25 +70,27 @@ typedef int8_t tJoyPos;
#define SLIDER_Y_SPACING (SLIDER_HEIGHT + (2 * SLIDER_Y_OFFSET)) #define SLIDER_Y_SPACING (SLIDER_HEIGHT + (2 * SLIDER_Y_OFFSET))
static void printDigits(char *label, tDigit *digits, tDigitPos maxPos) static void printCounter(void)
{ {
tDigitPos pos; tDigitPos pos;
printf("%7s:", label); printf("Counter: ");
for(pos = maxPos - 1; pos >= 0; pos--) { for(pos = NUM_COUNTER_DIGITS - 1; pos >= 0; pos--) {
printf(" %d", digits[pos]); printf(" %d", GET_COUNTER_DIGIT(pos));
} }
printf("\n"); printf("\n");
} }
static void printState(void) static void printResult(void)
{ {
tDigitPos pos; tDigitPos pos;
printDigits("Counter", counter, NUM_COUNTER_DIGITS);
printDigits("Result", result, NUM_RESULT_DIGITS);
printf(" "); printf(" Result:");
for(pos = NUM_RESULT_DIGITS - 1; pos >= 0; pos--) {
printf(" %d", GET_RESULT_DIGIT(pos));
}
printf("\n ");
for(pos = 0; pos < NUM_RESULT_DIGITS - basePos; pos++) { for(pos = 0; pos < NUM_RESULT_DIGITS - basePos; pos++) {
printf(" "); printf(" ");
} }
@ -96,6 +98,13 @@ static void printState(void)
} }
static void printState(void)
{
printCounter();
printResult();
}
static void drawOperand(tDigitPos pos) static void drawOperand(tDigitPos pos)
{ {
char xPos; char xPos;
@ -190,11 +199,7 @@ static tAction getNextAction(void)
joyState = joy_read(JOY_1); joyState = joy_read(JOY_1);
joyPos = getJoyPos(joyState); joyPos = getJoyPos(joyState);
if ((JOY_BTN_FIRE2(oldJoyState) && if (joyPos == oldJoyPos) {
(!JOY_BTN_FIRE2(joyState)))) {
oldJoyState = joyState;
result = ACTION_CLEAR;
} else if (joyPos == oldJoyPos) {
oldJoyState = joyState; oldJoyState = joyState;
return result; return result;
} else if (oldJoyPos == JOY_POS_CENTER) { } else if (oldJoyPos == JOY_POS_CENTER) {
@ -216,6 +221,8 @@ static tAction getNextAction(void)
possibleActions = (1 << ACTION_OPERAND_INC); possibleActions = (1 << ACTION_OPERAND_INC);
if (JOY_BTN_FIRE(joyState)) { if (JOY_BTN_FIRE(joyState)) {
possibleActions |= (1 << ACTION_SUBTRACT); possibleActions |= (1 << ACTION_SUBTRACT);
} else if (JOY_BTN_FIRE2(joyState)) {
possibleActions |= (1 << ACTION_CLEAR);
} else { } else {
possibleActions |= (1 << ACTION_ADD); possibleActions |= (1 << ACTION_ADD);
} }
@ -285,6 +292,14 @@ static tAction getNextAction(void)
} else if (joyPos != oldJoyPos + 1) { } else if (joyPos != oldJoyPos + 1) {
possibleActions &= (~(1 << ACTION_SUBTRACT)); possibleActions &= (~(1 << ACTION_SUBTRACT));
} }
} else if (possibleActions & (1 << ACTION_CLEAR)) {
if ((joyPos == JOY_POS_DOWN) &&
(oldJoyPos == JOY_POS_DOWN_RIGHT)) {
result = ACTION_CLEAR;
possibleActions = 0;
} else if (joyPos != oldJoyPos + 1) {
possibleActions &= (~(1 << ACTION_CLEAR));
}
} }
if (joyPos == JOY_POS_CENTER) { if (joyPos == JOY_POS_CENTER) {