Example #1
0
void c42364a_show_numeric_dec(int32_t value)
{
	uint8_t lcd_num[5];

	Assert(value > -20000);
	Assert(value < 20000);

	if(value < 0) {
		lcdca_set_pixel(C42364A_ICON_MINUS);
	} else {
		lcdca_clear_pixel(C42364A_ICON_MINUS);
	}

	value = Abs(value);

	if(value > 9999) {
		value -= 10000;
		lcdca_set_pixel(C42364A_ICON_MINUS_SEG1);
		lcdca_set_pixel(C42364A_ICON_MINUS_SEG2);
	} else {
		lcdca_clear_pixel(C42364A_ICON_MINUS_SEG1);
		lcdca_clear_pixel(C42364A_ICON_MINUS_SEG2);
	}

	sprintf((char*)lcd_num, "%4d", (int)value);

	c42364a_write_num_packet((uint8_t const*)&lcd_num);
}
Example #2
0
/**
 * \brief User Interface LCD Refresh Alphanumeric area.
 * \param ui_lcd_refresh boolean to refresh or not Alphanumeric area.
 * \param event_qtouch_slider_position set slider position in Alphanumeric area.
 */
void ui_lcd_refresh_alphanum(bool ui_lcd_refresh,
	int32_t event_qtouch_slider_position)
{
	char  string_info[8];
	if (ui_lcd_refresh == true ) {
		sprintf(string_info, "%d", (int)event_qtouch_slider_position);
		if (event_qtouch_slider_position < 100) {
			string_info[2] = ' ';
			string_info[3] = ' ';
			string_info[4] = '\0';
		}
		// display slider position on segment LCD
		c42364a_write_num_packet((uint8_t const*)&string_info);
	} else {
		// Clear digit area
		string_info[0] = ' ';
		string_info[1] = ' ';
		string_info[2] = ' ';
		string_info[3] = ' ';
		string_info[4] = '\0';
		// display slider position on segment LCD
		c42364a_write_num_packet((uint8_t const*)&string_info);
	}
}
Example #3
0
/**
 * \brief Application entry point for LCDCA example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	/* LCDCA configuration */
	struct lcdca_config lcdca_cfg;
	/* Automated display configuration */
	struct lcdca_automated_char_config automated_char_cfg;
	/* String for sequential display */
	uint8_t const sequential_str[] = \
		"Sequen tial   string display,Press PB0 to Cont.  ";
	/* String for scrolling display */
	uint8_t const scrolling_str[] = \
		"Scrolling string display, Press PB0 to cont.  ";

	/* String for lowpower display */
#define MAX_NUM_LOWPOWER_STR    4
	uint8_t const lowpower_str[MAX_NUM_LOWPOWER_STR][7] = {
		"In     ",
		"Power  ",
		"Save   ",
		"Mode   ",
	};
	uint32_t str_id = 0;

	struct lcdca_blink_config blink_cfg;
	struct lcdca_circular_shift_config cs_cfg;

	/* Initialize the SAM system */
	sysclk_init();
	board_init();
	sleepmgr_init();

	/* Initialize the console uart */
	configure_console();

	/* Output example information */
	printf("-- LCDCA Controller Example --\r\n");
	printf("-- %s\n\r", BOARD_NAME);
	printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

	/*
	 * LCDCA Controller initialization
	 * - Clock,
	 * - Connect to C42364A glass LCD component,
	 * - Timing:  64 Hz frame rate & low power waveform, FC0, FC1, FC2
	 * - Interrupt: off
	 */
	lcdca_clk_init();
	lcdca_cfg.port_mask = PORT_MASK;
	lcdca_cfg.x_bias = false;
	lcdca_cfg.lp_wave = true;
	lcdca_cfg.duty_type = LCD_DUTY;
	lcdca_cfg.lcd_pres = false;
	lcdca_cfg.lcd_clkdiv = 3;
	lcdca_cfg.fc0 = 16;
	lcdca_cfg.fc1 = 2;
	lcdca_cfg.fc2 = 6;
	lcdca_cfg.contrast = LCD_CONTRAST_LEVEL;
	lcdca_set_config(&lcdca_cfg);
	lcdca_enable();
	lcdca_enable_timer(LCDCA_TIMER_FC0);
	lcdca_enable_timer(LCDCA_TIMER_FC1);
	lcdca_enable_timer(LCDCA_TIMER_FC2);

	/* Turn on LCD back light */
	ioport_set_pin_level(LCD_BL_GPIO, IOPORT_PIN_LEVEL_HIGH);

	/* Display some texts and icon on segment LCD */
	lcdca_set_pixel(ICON_ARM);
	c42364a_write_num_packet((const uint8_t *)"0123");
	c42364a_write_alpha_packet((const uint8_t *)"Welcome");

	/* Blink "error" icon */
	blink_cfg.lcd_blink_timer = LCDCA_TIMER_FC1;
	blink_cfg.lcd_blink_mode = LCDCA_BLINK_SELECTED;
	lcdca_blink_set_config(&blink_cfg);
	lcdca_set_pixel(ICON_ERROR);
	lcdca_set_blink_pixel(ICON_ERROR);
	lcdca_blink_enable();

	/* Autonomous segment animation of 7-pixels area of the LCD */
	cs_cfg.lcd_csr_timer = LCDCA_TIMER_FC1;
	cs_cfg.lcd_csr_dir = LCDCA_CSR_RIGHT;
	cs_cfg.size = 7;    /* Total 7-pixels */
	cs_cfg.data = 0x03; /* Display 2 pixel at one time */
	lcdca_circular_shift_set_config(&cs_cfg);
	lcdca_circular_shift_enable();

	/* Automated sequential character string display */
	automated_char_cfg.automated_mode = LCDCA_AUTOMATED_MODE_SEQUENTIAL;
	automated_char_cfg.automated_timer = LCDCA_TIMER_FC2;
	automated_char_cfg.lcd_tdg = LCDCA_TDG_14SEG4COM;
	automated_char_cfg.stseg = FIRST_14SEG_4C;
	automated_char_cfg.dign = WIDTH_14SEG_4C;
	automated_char_cfg.steps = 0;
	automated_char_cfg.dir_reverse = LCDCA_AUTOMATED_DIR_REVERSE;
	lcdca_automated_char_set_config(&automated_char_cfg);
	lcdca_automated_char_start(sequential_str, strlen((char const *)sequential_str));
	printf("Press PB0 to stop automated sequential mode and continue.\n\r");
	wait_for_switches();
	lcdca_automated_char_stop();

	/* Automated scrolling of character string display */
	automated_char_cfg.automated_mode = LCDCA_AUTOMATED_MODE_SCROLLING;
	automated_char_cfg.automated_timer = LCDCA_TIMER_FC2;
	automated_char_cfg.lcd_tdg = LCDCA_TDG_14SEG4COM;
	automated_char_cfg.stseg = FIRST_14SEG_4C;
	automated_char_cfg.dign = WIDTH_14SEG_4C;
	/* STEPS = string length - DIGN + 1 */
	automated_char_cfg.steps = sizeof(scrolling_str) - WIDTH_14SEG_4C + 1;
	automated_char_cfg.dir_reverse = LCDCA_AUTOMATED_DIR_REVERSE;
	lcdca_automated_char_set_config(&automated_char_cfg);
	lcdca_automated_char_start(scrolling_str, strlen((char const *)scrolling_str));
	printf("Press PB0 to stop automated scrolling mode and continue.\n\r");
	wait_for_switches();
	lcdca_automated_char_stop();

	/* Set callback for LCDCA interrupt */
	lcdca_set_callback(lcdca_callback, LCDCA_IRQn, 1);

	/* Enable LCDCA wakeup */
	lcdca_enable_wakeup();

	printf("Enter power save mode.\n\r");
	printf("It'll display power save string sequence and"
			"blink wireless icon when every wake up.\n\r");
	while (1) {
		/* Display lowpower string repeatly */
		c42364a_write_alpha_packet(lowpower_str[str_id]);
		str_id = (str_id + 1) % MAX_NUM_LOWPOWER_STR;

		/* Toggle wireless icon */
		lcdca_toggle_pixel(ICON_WLESS);

		/* Enter in sleep mode */
		sleepmgr_enter_sleep();
	}
}
Example #4
0
/**
 * \brief main function : do init and loop
 */
int main(void)
{
    uint8_t key;
    uint8_t const scrolling_str[] = "C42364A Example  ";
    int32_t value = -12345;

    /* Initialize the SAM system */
    sysclk_init();
    board_init();

    /* Initialize the console uart */
    configure_console();

    /* Output example information */
    printf("-- C42364A Example --\r\n");
    printf("-- %s\n\r", BOARD_NAME);
    printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

    /* Turn on the backlight. */
    ioport_set_pin_level(LCD_BL_GPIO, LCD_BL_ACTIVE_LEVEL);

    /* Initialize the C42364A LCD glass component. */
    c42364a_init();

    printf("Show all the components on the glass.\r\n");
    c42364a_show_all();

    printf("Press any key to continue.\r\n");
    scanf("%c", (char *)&key);

    c42364a_clear_all();

    /* Display menu */
    display_menu();

    while (1) {
        scanf("%c", (char *)&key);

        switch (key) {
        case 'h':
            display_menu();
            break;

        case 'c':
            printf("Clear all the screen.\r\n");
            c42364a_clear_all();
            break;

        case '1':
            printf("Show icons, number and string.\r\n");
            c42364a_show_icon(C42364A_ICON_ARM);
            c42364a_show_numeric_dec(value);
            c42364a_show_text((const uint8_t *)"Welcome");
            c42364a_show_battery(C42364A_BATTERY_TWO);
            break;

        case '2':
            printf("Blink colon icon, show a time.\r\n");
            c42364a_clear_icon(C42364A_ICON_MINUS);
            c42364a_clear_icon(C42364A_ICON_MINUS_SEG1);
            c42364a_clear_icon(C42364A_ICON_MINUS_SEG2);
            c42364a_write_num_packet((const uint8_t *)"1023");
            c42364a_show_icon(C42364A_ICON_AM);
            c42364a_blink_icon_start(C42364A_ICON_COLON);
            break;

        case '3':
            printf("Show the two dots circular animation.\r\n");
            c42364a_circular_animation_start(C42364A_CSR_RIGHT, 7, 0x03);
            break;

        case '4':
            printf("Text scrolling.\r\n");
            c42364a_text_scrolling_start(scrolling_str,
                                         strlen((char const *)scrolling_str));
            break;

        default:
            break;
        }
    }

}