Example #1
0
void draw_IEEE() {
    display_draw_number(ETCH_I_NUMBER);
    draw_I_character();
    turn_servo_horizontal_etch_distance(0.568*ETCH_UNIT);

    display_draw_number(ETCH_E1_NUMBER);
    draw_E_character_from_bottom();
    turn_servo_horizontal_etch_distance(0.568*ETCH_UNIT);

    display_draw_number(ETCH_E2_NUMBER);
    draw_E_character_from_top();
    turn_servo_horizontal_etch_distance(0.568*ETCH_UNIT);

    display_draw_number(ETCH_E3_NUMBER);
    draw_E_character_from_bottom();
}
Example #2
0
// Count seconds for detrmining when to leave Simon
void _ISRFAST _T5Interrupt (void) {
    u16_milliSeconds++;
    if (u16_milliSeconds >= (SIMON_DURATION * 1000)) {
        u8_simonFinished = 1;
    }
    display_draw_number(u16_milliSeconds / 1000);
    _T5IF = 0;  //clear interrupt flag
}
Example #3
0
/**
 * Rendering of a variable number/char (single digit with
 * up/down arrows above/below it).
 *
 * @param item should be an ITEM_TYPE_VARNUM
 * @param selected if cursor should be on that particular digit
 */
void render_item_varnum(screen_item &item, bool selected) {

  // Position on screen where to draw the digit
  uint8_t x = item.val1;
  uint8_t y = item.val2;

  int len = strlen(item.text);
  int colon_pos=-1;
  // Text can be with this format:
  // "NAME:char1,char2,char..." to let user select
  // non-numeric values, we detect this below:
  for(int n=0;n<len;n++) {
    if(item.text[n] == ':') colon_pos=n;
  }

  bool nonnumeric = false;
  char selitem[10][10];
  // We have a non-numeric variable, initialize the
  // possible values (comma-separated string following ":"
  // in the item.text. For instance: "SIGN:-,+,"
  if(colon_pos != -1) {
    nonnumeric=true;

    char current[10];
    int  current_pos=0;
    int  cselitem=0;
    for(int n=colon_pos+1;n<len;n++) {

      if(item.text[n] != ',') {
        current[current_pos  ] = item.text[n];
        current[current_pos+1] = 0;
        current_pos++;
      } else {
        strcpy(selitem[cselitem],current);
        current_pos=0;
        current[0]=0;
        cselitem++;
      }
    }
  }

  // Retrieve the current value of this VARNUM
  uint8_t val = get_item_state_varnum(item.text);

  uint16_t color;
  if(selected) color = 0xcccc; else color = FOREGROUND_COLOR;
  display_draw_equtriangle(x,y,9,color);
  display_draw_equtriangle_inv(x,y+33,9,color);
  if(nonnumeric == false) {
    display_draw_number(x-4,y+9,val,1,FOREGROUND_COLOR);
  } else {
    display_draw_text(x-4,y+9,selitem[val],FOREGROUND_COLOR);
  }
}
Example #4
0
void update_item_delay(screen_item &item,const void *value) {

  if(first_render == true) {
    // parse out delay time
    delay_time = str_to_uint(item.text+8);

  }

  if(delay_time >= 1) delay_time--;
  delay_us(1000000);
  display_draw_number(item.val1,item.val2,delay_time,3,FOREGROUND_COLOR);
}
Example #5
0
void play_simon_infinitely() {
    display_draw_number(SIMON_NUMBER);
    #ifdef DEBUG_BUILD
    printf("\n*** Playing Simon ***\n");
    #endif

    // Grab the Simon and calibrate the sensors
    game_arm_pull_simon();
    simon_hover_buttons();
    DELAY_MS(PLATFORM_WAIT);
    platform_rubiks();
    twist_rubiks_clock();
    DELAY_MS(PLATFORM_WAIT);
    calibrate_sensors(); // I don't think we need calibration with the new transistors

    // Stop playing if we exceed 5 rounds
    while (1) {
        #ifdef DEBUG_BUILD
        printf("\nROUND %i\n", u8_roundNum);
        #endif

        // If it's the first round, hit the start button
        if (u8_roundNum == 1) {
            // Push the start button and record the colors
            simon_push_button(START_SIMON_BUTTON);
            record_colors(u8_roundNum);

            u8_simonFinished = 0;
            u16_milliSeconds = 0;
            simon_hover_button(YELLOW_BUTTON);
        } else {
            // Record a certain number of colors
            record_colors(u8_roundNum);
        }
        // Play back the buttons
        DELAY_MS(500);
        play_buttons(u8_roundNum);
        u8_roundNum++;
    }

    // Let go of the simon and pull the arms back
    twist_rubiks_counter();
    DELAY_MS(PLATFORM_WAIT);
    platform_up();
    DELAY_MS(PLATFORM_WAIT);
    simon_retract_buttons();
}
Example #6
0
void render_item_varnum(screen_item &item, bool selected) {

  uint8_t x = item.val1;
  uint8_t y = item.val2;

  int len = strlen(item.text);
  int colon_pos=-1;
  for(int n=0;n<len;n++) {
    if(item.text[n] == ':') colon_pos=n;
  }
  
  bool nonnumeric = false;
  char selitem[10][10];
  if(colon_pos != -1) {
    nonnumeric=true;

    char current[10];
    int  current_pos=0;
    int  cselitem=0;
    for(int n=colon_pos+1;n<len;n++) {
 
      if(item.text[n] != ',') {
        current[current_pos  ] = item.text[n];
        current[current_pos+1] = 0;
        current_pos++;
      } else {
        strcpy(selitem[cselitem],current);
        current_pos=0;
        current[0]=0;
        cselitem++;
      }
    }
  }

  uint8_t val = get_item_state_varnum(item.text);

  uint16_t color;
  if(selected) color = 0xcccc; else color = FOREGROUND_COLOR;
  display_draw_equtriangle(x,y,9,color);
  display_draw_equtriangle_inv(x,y+33,9,color);
  if(nonnumeric == false) {
    display_draw_number(x-4,y+9,val,1,FOREGROUND_COLOR);
  } else {
    display_draw_text(x-4,y+9,selitem[val],FOREGROUND_COLOR);
  }
}
Example #7
0
void play_rubiks() {
    display_draw_number(RUBIKS_NUMBER);
    #ifdef DEBUG_BUILD
    printf("\n*** Spinng Rubiks ***\n");
    #endif

    // Pull in Rubiks
    game_arm_pull_rubiks();


    // Lower platform
    platform_rubiks();

    // Twist Rubiks
    twist_rubiks_clock();
    DELAY_MS(WAIT_TIME)

    // Reset platform
    platform_up();
    DELAY_MS(WAIT_TIME)
    twist_rubiks_counter();
}
Example #8
0
void play_etch() {
    display_draw_number(ETCH_NUMBER);
    #ifdef DEBUG_BUILD
    printf("\n*** Drawing 'IEEE' ***\n");
    #endif

    // Pull in etch/get arm out of the way
    game_arm_pull_etch();

    // Lower knobs on etch
    platform_etch();

    // Hold in the etch
    game_arm_hold_etch();

    // Draw
    draw_IEEE();

    // Release the etch
    game_arm_release();

    // Reset the platform
    platform_etch_undo();
}
Example #9
0
void render_item_delay(screen_item &item,bool selected) {
  display_draw_number(item.val1,item.val2,delay_time,3,FOREGROUND_COLOR);
}
Example #10
0
void play_simon() {
    display_draw_number(SIMON_NUMBER);
    #ifdef DEBUG_BUILD
    printf("\n*** Playing Simon ***\n");
    #endif

    // Grab the Simon and calibrate the sensors
    game_arm_pull_simon();
    simon_hover_buttons();
    DELAY_MS(PLATFORM_WAIT);
    platform_down();
    twist_rubiks_clock();
    DELAY_MS(PLATFORM_WAIT);
    calibrate_sensors(); // I don't think we need calibration with the new transistors

    // Stop playing if we exceed 5 rounds
    while (u8_roundNum < 5) {
        #ifdef DEBUG_BUILD
        printf("\nROUND %i\n", u8_roundNum);
        #endif

        // If it's the first round, hit the start button
        if (u8_roundNum == 1) {
            // Push the start button and record the colors
            u8_started = 1;
            simon_push_button(START_SIMON_BUTTON);
            record_colors(u8_roundNum);
            u8_started = 0;

            if (u8_simonFinished == 1) {
                #ifdef DEBUG_BUILD
                printf("Giving up\n");
                #endif

                twist_rubiks_counter();
                platform_up();
                DELAY_MS(PLATFORM_WAIT);
                simon_retract_buttons();
                return;
            }

            #ifdef DEBUG_BUILD
            printf("Starting Simon time\n");
            #endif

            u8_simonFinished = 0;
            u16_milliSeconds = 0;
            T5CONbits.TON = 1;     // Turn on the timer
            simon_hover_button(YELLOW_BUTTON);
        } else {
            // Record a certain number of colors
            record_colors(u8_roundNum);
        }
        // If we've surpassed 15 seconds, leave Simon
        if (u8_simonFinished) {
            #ifdef DEBUG_BUILD
            printf("Stopping Simon Time\n");
            #endif
            u8_simonFinished = 0;
            u16_milliSeconds = 0;
            u8_roundNum = 1;

            break;
        }
        // Play back the buttons
        DELAY_MS(500);
        play_buttons(u8_roundNum);
        u8_roundNum++;
    }

    // Let go of the simon and pull the arms back
    T5CONbits.TON = 0;
    twist_rubiks_counter();
    platform_up();
    DELAY_MS(PLATFORM_WAIT);
    simon_retract_buttons();
}