Exemplo n.º 1
0
void digitalClockDisplay() {
    if (sync) {
        Serial.println("DCF sync good");
        sync = false;
    }

    Serial.print(day());
    Serial.print('.');
    Serial.print(month());
    Serial.print('.');
    Serial.print(year());
    Serial.print(' ');
    Serial.print(' ');


    const uint8_t minutes = minute();
    const uint8_t hours = hour();

    print_2_digits(hours);
    Serial.print(':');
    print_2_digits(minutes);
    Serial.print(':');
    print_2_digits(second());

    display_digit(minutes % 10, bit0_pin + 0, 4);
    display_digit(minutes / 10, bit0_pin + 5, 3);

    display_digit(hours % 10, bit0_pin +  9, 4);
    display_digit(hours / 10, bit0_pin + 14, 2);

    Serial.println();
}
Exemplo n.º 2
0
int handle_init()
{
    if (wiringPiSetup() == -1)
        return -1;
    int i = 0;
    for (; i < 8; i++)
    {
        pinMode (i + LED_START, OUTPUT);
    }
    display_digit(8);
}
Exemplo n.º 3
0
int handle(char* command)
{
    char c;
    if (command == NULL || strcmp(command, "exit\n") == 0)
    {
        printf("exit\n");
        return 0;
    }
    for (c = *command; c != '\0'; c = *(++command))
    {
        if (c >= '0' && c <= '9')
        {
            display_digit(c - '0');
            delay(500);
        }
    }
    printf("finished displaying\n");
    return 1;
}
Exemplo n.º 4
0
void main (void)
{
    int i, j;

    setup_display_abcdef_dp ();
    setup_set_digit         ();

    for (;;)
    for (i = 0;; i = (i + 1) % 4)
    {
        set_digit (i + 1);

        for (j = 0; j < 16; j++)
        {
            display_digit (j);
            delay (10);
        }
    }
}
/**
 * Display the basic layout of the screen (done only once).
 */
static void display_initial_screen(uint32_t pin_length)
{
    if (g_initial_screen_displayed == true)
		return;

    fb_config = fbcon_display();

    if (fb_config)
	{
		fbcon_clear();

		if (display_error_message())
		    display_error_msg(); /* This will never return */
		display_initial_delay();

		mdelay(INITIAL_DELAY_MSECONDS);

		g_pin_frames_y_location = ((fb_config->height)*PIN_RELATIVE_Y_LOCATION);

		uint32_t total_pin_length = pin_length*MDTP_PIN_DIGIT_WIDTH + DIGIT_SPACE*(pin_length - 1);
		uint32_t complete_pin_centered = (fb_config->width - total_pin_length)/2;

		for (uint32_t i=0; i<pin_length; i++)
		{
			g_pin_frames_x_location[i] = complete_pin_centered + i*(DIGIT_SPACE+MDTP_PIN_DIGIT_WIDTH);
		}

		for (uint32_t i=0; i<pin_length; i++)
		{
			display_digit(g_pin_frames_x_location[i], g_pin_frames_y_location, 0);
		}

		display_ok_button();

		g_initial_screen_displayed = true;
	}
	else
	{
	    dprintf(CRITICAL,"ERROR: fbcon_config struct is NULL\n");
	    display_error_msg(); /* This will never return */
	}
}
/**
 * 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);
		}
	}
}