void waiting_for_card() { interface_hardware.send(display_enter_card()); incoming.wait() .handle<card_inserted>( [&](card_inserted const & msg) { account = msg.account; pin = ""; interface_hardware.send(display_enter_pin()); state = &atm::getting_pin; } ); }
/** * Display the recovery PIN screen and set received buffer * with the PIN the user has entered. * The entered PIN will be validated by the calling function. */ static void display_get_pin_interface(char *entered_pin, uint32_t pin_length) { uint32_t previous_position = 0, current_position = 0; display_initial_screen(pin_length); display_enter_pin(); // Convert ascii to digits for (uint32_t i=0; i<pin_length; i++) { entered_pin[i] -= '0'; } display_selected_digit(g_pin_frames_x_location[0], g_pin_frames_y_location, entered_pin[0]); display_digits_instructions(); while (1) { if (target_volume_up()) { // current position is the OK button if (current_position == pin_length) { // Convert digits to ascii and // validate entered PIN in the calling function for (uint32_t i=0; i<pin_length; i++) { entered_pin[i] += '0'; } return; } // current position is a PIN slot entered_pin[current_position] = (entered_pin[current_position]+1) % 10; display_selected_digit(g_pin_frames_x_location[current_position], g_pin_frames_y_location, entered_pin[current_position]); mdelay(MDTP_PRESSING_DELAY_MSEC); } if (target_volume_down()) { previous_position = current_position; current_position = (current_position+1) % (pin_length+1); // previous position was the OK button if (previous_position == pin_length) { clear_pin_message(); display_ok_button(); display_digits_instructions(); display_selected_digit(g_pin_frames_x_location[current_position], g_pin_frames_y_location, entered_pin[current_position]); } // current position is the OK button else if (current_position == pin_length) { display_digit(g_pin_frames_x_location[previous_position], g_pin_frames_y_location, entered_pin[previous_position]); clear_digits_instructions(); display_selected_ok_button(); display_pin_instructions(); } // both the previous and the current positions are PIN slots else { display_digit(g_pin_frames_x_location[previous_position], g_pin_frames_y_location, entered_pin[previous_position]); display_selected_digit(g_pin_frames_x_location[current_position], g_pin_frames_y_location, entered_pin[current_position]); } mdelay(MDTP_PRESSING_DELAY_MSEC); } } }