Example #1
0
/*!
    \brief      init the GPIO port of the SLCD and SLCD peripheral
    \param[in]  none
    \param[out] none
    \retval     none
*/
void slcd_seg_config(void)
{
    uint16_t i;

    /* configure the SLCD GPIO pins */
    slcd_gpio_config();

    /* enable the clock of SLCD */
    rcu_periph_clock_enable(RCU_SLCD);
    /* wait 2 RTC clock to write SLCD register */
    for(i = 0;i < 500;i++);
    /* config the prescaler and the divider of SLCD clock */
    slcd_clock_config(SLCD_PRESCALER_4,SLCD_DIVIDER_19);
    /* SLCD bias voltage select */
    slcd_bias_voltage_select(SLCD_BIAS_1_3);
    /* SLCD duty cycle select */
    slcd_duty_select(SLCD_DUTY_1_4);
    /* SLCD voltage source select */
    slcd_voltage_source_select(SLCD_VOLTAGE_EXTERNAL);
    /* SLCD pulse on duration config */
    slcd_pulse_on_duration_config(SLCD_PULSEON_DURATION_7);
    /* SLCD dead time duration config */
    slcd_dead_time_config(SLCD_DEADTIME_PERIOD_7);
    /* enable the permanent high drive */
    slcd_high_drive_config(ENABLE);
    /* wait for SLCD CFG register synchronization */
    while (!slcd_flag_get(SLCD_FLAG_SYNF));
    /* enable SLCD interface */
    slcd_enable();
    /* wait for SLCD controller on flag */
    while (!slcd_flag_get(SLCD_FLAG_ONF));
    /* wait for SLCD voltage ready flag */
    while (!slcd_flag_get(SLCD_FLAG_VRDYF));
}
Example #2
0
/**
* \brief Show all content of the LCD glass.
*
* This function sets all pixels and areas of the LCD glass XPRO_LCD.
*
*/
void xpro_lcd_show_all(void)
{
    slcd_disable();
    slcd_disable_blink();
    slcd_disable_circular_shift();
    slcd_set_display_memory();
    slcd_enable();
}
Example #3
0
/**
* \brief Stop blink a specific icon on the LCD glass.
*
* This function will stop blink a specific icon.
*
* \param icon_com  Pixel coordinate - COM - of the icon.
* \param icon_seg  Pixel coordinate - SEG - of the icon.
*
* \note Use the icon define in header file(with selected segments
* blinking feature).
*/
void xpro_lcd_blink_icon_stop(uint8_t icon_com, uint8_t icon_seg)
{
    if (icon_seg < 2) {
        slcd_disable_blink();
        slcd_disable();
        slcd_clear_blink_pixel(icon_com, icon_seg);
        slcd_enable_blink();
        slcd_enable();
    }
}
Example #4
0
void c42412a_init(void)
{
	struct slcd_config config;

	slcd_get_config_defaults(&config);
	slcd_init(&config);

	slcd_set_frame_counter(SLCD_FRAME_COUNTER_0,false,CONF_C42412A_FC0);
	slcd_set_frame_counter(SLCD_FRAME_COUNTER_1,false,CONF_C42412A_FC1);
	slcd_set_frame_counter(SLCD_FRAME_COUNTER_2,false,CONF_C42412A_FC2);
	slcd_set_contrast(CONF_C42412A_CONTRAST);
	slcd_enable();
}
Example #5
0
/**
* \brief Blink the current screen content.
*
* This function will make the current screen blink.
*
*/
void xpro_lcd_blink_screen(void)
{
    slcd_disable_blink();
    slcd_disable();
    struct slcd_blink_config blink_config;
    slcd_blink_get_config_defaults(&blink_config);
    blink_config.blink_all_seg = true;
    blink_config.fc = CONF_XPRO_LCD_BLINK_TIMER;
    slcd_blink_set_config(&blink_config);

    slcd_enable_frame_counter(CONF_XPRO_LCD_BLINK_TIMER);
    slcd_enable_blink();
    slcd_enable();
}
Example #6
0
void c42412a_circular_animation_start(uint8_t size, uint8_t data)
{
	struct slcd_circular_shift_config cfg;
	slcd_disable();
	slcd_circular_shift_get_config_defaults(&cfg);
	cfg.data = data;
	cfg.size = size;
	cfg.dir = C42412A_CSR_DIR;
	cfg.fc = CONF_C42412A_CIRCULAR_ANIMATION_TIMER;
	slcd_circular_shift_set_config(&cfg);
	slcd_enable_circular_shift();
	slcd_enable_frame_counter(CONF_C42412A_CIRCULAR_ANIMATION_TIMER);
	slcd_enable();
}
Example #7
0
/**
* \brief Blink a specific icon on the LCD glass.
*
* This function will blink a specific icon.
*
* \param icon_com  Pixel coordinate - COM - of the icon.
* \param icon_seg  Pixel coordinate - SEG - of the icon.
*
* \note Use the icon define in header file(with selected segments
* blinking feature).
*/
void xpro_lcd_blink_icon_start(uint8_t icon_com, uint8_t icon_seg)
{
    if (icon_seg < 2) {
        xpro_lcd_show_icon(icon_com,icon_seg);
        slcd_disable();
        struct slcd_blink_config blink_config;
        slcd_blink_get_config_defaults(&blink_config);
        blink_config.blink_all_seg = false;
        blink_config.fc = CONF_XPRO_LCD_BLINK_TIMER;
        slcd_blink_set_config(&blink_config);
        slcd_set_blink_pixel(icon_com, icon_seg);
        slcd_enable_frame_counter(CONF_XPRO_LCD_BLINK_TIMER);
        slcd_enable_blink();
        slcd_enable();
    }
}
Example #8
0
int main(void)
{
    uint8_t key = 0;
    /* Temporary buffer used for get the user input string */
    char user_str[] = {""};

    /* Initialize the SAM system */
    system_init();
    /* Set NVM wait state */
    NVMCTRL->CTRLB.bit.RWS = 3;
    board_init();

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

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

    printf("-----------------------------------------------\n\r");
    printf("\n\r");

    /* Turn on the backlight. */
    port_pin_set_output_level(SLCD_BACLKLIGHT,true);

    /* Initialize the XPRO_LCD LCD glass component. */
    xpro_lcd_init();

    /* Enable SLCD */
    slcd_enable();

    /* Enables all the segments in the SLCD */
    printf("Printing all of the SLCD segments.\n\n\r");
    xpro_lcd_show_all();

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

    /* Clear the SLCD and disables all the running modes */
    xpro_lcd_clear_all();

    /* Display menu */
    display_menu();

    while (1) {
        /* Get the user option */
        scanf("%c", (char *)&key);

        switch (key) {
        case 'c':
        case 'C':
            printf("c: Clear the SLCD screen \n\n\r");
            printf("Clearing... \n\r");
            xpro_lcd_clear_all();
            display_menu();
            break;

        case 'e':
        case 'E':
            printf("e: To change the user scrolling string input \n\n\r");
            xpro_lcd_clear_all();
            clear_buffer();
            get_userstr(user_str, 25);
            strcpy(user_scrolling_str, user_str);
            display_menu();
            break;

        case '1':
            printf("1: Display UART user input string in SLCD \n\n\r");
            get_userstr(user_str, 5);
            xpro_lcd_clear_all();
            printf("Printing -- [ %s ] \n\r", user_str);
            xpro_lcd_show_text((const uint8_t *)user_str);
            display_menu();
            break;

        case '2':
            xpro_lcd_clear_all();
            printf("2: Character mapping feature.\n\n\r");
            printf("Running... \n\r");
            xpro_lcd_show_text((const uint8_t *)"ATMEL");
            delay_s(2);

            xpro_lcd_clear_all();
            /* values range -199999 to 199999 */
            xpro_lcd_show_numeric_dec(-123456);
            delay_s(2);
            display_menu();
            break;

        case '3':
            xpro_lcd_clear_all();
            printf("3: Auto Character mapping feature.\n\n\r"
                   "Text scrolling...\n\n\r");
            is_scrolling = true;
            xpro_lcd_text_scrolling_start(user_scrolling_str);
            printf("Press 'c' to exit scrolling and clear display.\n\r"
                   "Otherwise it will exit automatically.\n\n\r");
            xpro_lcd_show_icon(XPRO_LCD_ICON_ATMEL);
            printf("-----------------------------------------------\n\r");
            break;

        case '4':
            xpro_lcd_clear_all();
            printf("4: Blinking feature.\n\n\r");
            printf("Blink screen...\n\r");
            xpro_lcd_show_text((const uint8_t *)"BLINK");
            xpro_lcd_blink_screen();
            delay_s(2);
            display_menu();
            break;

        case '5':
            xpro_lcd_clear_all();
            printf("5: Auto Bit mapping feature.\n\n\r"
                   "Select the user style\n\r"
                   "Press 0 for Style0\n\r"
                   "Press 1 for Style1\n\r"
                   "Press 2 for Style2\n\r"
                   "Press 3 for Style3\n\r"
                   "\n\r");
            is_bitmapping = true;
            /* Get the user option */
            scanf("%c", (char *)&key);
            switch (key) {
            case '0':
            case '1':
            case '2':
            case '3':
                printf("Style%c selected.\n\n\r", key);
                xpro_lcd_text_bitmapping_start(key);
                printf("Press 'c' to exit Auto bit mapping and"
                       "clear display. \n\r"
                       "Otherwise it will exit automatically\n\n\r");
                break;
            default:
                printf("Invalid input received.\n\n\r");
                display_menu();
                break;
            }
            break;

        default:
            break;
        }//switch
    }//while

}
Example #9
0
/**
* \brief Scrolling start.
*
* This function start the Bit mapping text.
*
* \param data Data string buffer.
* \param length Data string length.
*/
void xpro_lcd_text_bitmapping_start(uint8_t user_style)
{
    /* Default config for automated bit mapping */
    uint8_t config_user_style = (user_style & 0x03);
    uint8_t config_size = 0;
    uint8_t config_fc_value = 0;
    enum slcd_frame_counter config_fc = SLCD_FRAME_COUNTER_0;

    /* User buffer to load the user style. In this array new styles can be
     * added as a new row with the same column width.
     * At the end of the each style's array member value should be kept
     * as 0x0000FF00 to calculate the block_count.
     * The empty elements between the style members should be 0x0000FFFF.
     */
    uint16_t i=0;
    uint32_t user_style_buf[5][30] = {
        {
            /* STYLE 0 */
            0x00000040, 0x000600e0, 0x000C0070, 0x00120000, /*'A' 0x07e4 */
            0x00010005, 0x00070000, 0x000D0000, 0x00130008, /*'T' 0x8005 */
            0x00010085, 0x00070070, 0x000D0060, 0x00130008, /*'M' 0x0678 */
            0x00020004, 0x0008000a, 0x000E0003, 0x00140002, /*'E' 0x23a4 */
            0x00020004, 0x0008002a, 0x000E0023, 0x00140022, /*'L' 0x2220 */
            0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00
        },
        {
            /* STYLE 1 */
            0x00000040,0x00070000,0x000D0060,0x00140002,
            0x000600e0,0x000D0060,0x00130008,0x00020004,
            0x000C0070,0x00130008,0x00020004,0x0008000a,
            0x00120000,0x00010005,0x0008002a,0x000E0003,
            0x00010085,0x00070070,0x000E0023,0x00140022,
            0x0000FF00,0x0000FF00,0x0000FF00,0x0000FF00
        },
        {
            /* STYLE 2 */
            0x00000040,0x00010004,0x00020004,0x00010045,
            0x00060060,0x00070070,0x00010085,0x000600E0,
            0x00080022,0x0008002a,0x000C0010,0x000E0001,
            0x000C0070,0x000D0060,0x000E0023,0x00130008,
            0x00140022,0x0000FF00,0x0000FF00,0x0000FF00,
            0x0000FF00,0x0000FF00,0x0000FF00,0x0000FF00
        },
        {
            /* STYLE 3 */
            0x00000040,0x00010044,0x0000FFFF,0x0000FFFF,
            0x00020044,0x00080040,0x00000000,0x00010000,
            0x000E0040,0x00140022,0x00020000,0x00080000,
            0x00120020,0x00130022,0x000E0000,0x00140000,
            0x000C0020,0x00060020,0x00120000,0x00130000,
            0x00000040,0x000C0000,0x00060000,0x0000FF00
        },
        {
            /* SPARE x */
            0x00000040,0x00010004,0x00020004,0x00010045,
            0x00060060,0x00070070,0x00010085,0x000600E0,
            0x00080022,0x0008002a,0x000C0010,0x000E0001,
            0x000C0070,0x000D0060,0x000E0023,0x00130008,
            0x00140022,0x0000FF00,0x0000FF00,0x0000FF00,
            0x0000FF00,0x0000FF00,0x0000FF00,0x0000FF00
        }
    };

    /* Variable use to find the DMA transfer block count at runtime based
     * on the user input string/style.
     */
    dma_block_count = 0;

    /* Clears the previous values present in the dma_source_buf */
    clear_buffer();

    /* used to copy the user style to dma_source buffer for the DMA transfer.
     * The user style options are Style0, Style1, Style2 & Style3.
     */
    while (0x0000FF00 != user_style_buf[config_user_style][i]) {
        dma_source_buf[i] = user_style_buf[config_user_style][i];
        /* To find the user style number of segment data */
        dma_block_count++;
        i++;
    }

    /* user configurations for automated bit mapping */
    if ((uint8_t) 0x03 == config_user_style) {
        config_size = 1;
        config_fc_value = 0x01;
        bitmapping_repeat_count = 0x05;
    } else {
        config_size = 3;
        config_fc_value = 0x0F;
        bitmapping_repeat_count = 0x01;
    }
    config_fc = SLCD_FRAME_COUNTER_1;

    /* Disable SLCD to write the enable-protected registers */
    slcd_disable();
    /* write the SLCD ABM configurations in the respective registers */
    slcd_set_automated_bit(config_size, config_fc);

    /* Disable Frame counter to write the enable-protected registers */
    slcd_disable_frame_counter(config_fc);
    /* Set the frame counter configurations and enable it */
    slcd_set_frame_counter(config_fc, 1, config_fc_value);
    slcd_enable_frame_counter(config_fc);

    /* Enable SLCD */
    slcd_enable();

    /* Configure DMA */
    configure_dma();

    /* Start DMA transfer, once DMA gets the peripheral trigger from the ABM,
     * the data transfer starts.
     */
    dma_start_transfer_job(&example_resource);

    /* Enable ACM mode */
    slcd_enable_automated_bit();
}
Example #10
0
/**
* \brief Scrolling start.
*
* This function start the text scrolling.
*
* \param data Data string buffer.
* \param length Data string length.
*/
void xpro_lcd_text_scrolling_start(char *data)
{
    /* Structures for the ACM configurations */
    struct slcd_automated_char_config automated_char_config;

    uint16_t i=0;
    dma_block_count = 0;

    /* used to copy the user scrolling string into dma_source
     * buffer for the DMA transfer
     * The scrolling may be runtime user input string 25char max
     * or the default scrolling string in user_scrolling_str[].
     */
    while (*data != '\0') {
        /* Copying the scrolling string into DMA source buffer*/
        dma_source_buf[i++] = DIGI_LUT[*(data++) - 32];
        /* To find the scrolling string length */
        dma_block_count++;
    }

    if (true == is_scrolling) {
        /* configuration for Auto character mapping scrolling mode */
        /* Get default config for the ACM mode */
        slcd_automated_char_get_config_default(&automated_char_config);
        /* Segment mapping order. (CMCFG.DEC bit) */
        automated_char_config.order =
            SLCD_AUTOMATED_CHAR_START_FROM_BOTTOM_RIGHT;
        /* select the number of segment used per digit,
         * it equal to number of SEG line - 1. (CMCFG.DEC).
         */
        automated_char_config.seg_line_num = 3;

        /* Define the number of digit per row. (ACMCFG.NDROW) */
        automated_char_config.row_digit_num = XPRO_LCD_MAX_CHAR;
        /* Define the index of the first segment terminal of the digit
         * to display. (ACMCFG.STSEG).
         */
        automated_char_config.start_seg_line = XPRO_LCD_TXT_SEG_INDEX_S;
        /* Define the number of digit, it must be greater than 1.
         * (ACMCFG.NDIG).
         */
        automated_char_config.digit_num = XPRO_LCD_MAX_CHAR;

        /* STEPS = string length - digit_num + 1. (ACMCFG.STEPS) */
        automated_char_config.scrolling_step = dma_block_count - 5 + 1;
        /* Select the ACM mode (ACMCFG.MODE) */
        automated_char_config.mode  = SLCD_AUTOMATED_CHAR_SCROLL;
        /* Select the frame counter for the ACM mode. (ACMCFG.FCS) */
        automated_char_config.fc = SLCD_FRAME_COUNTER_1;

        /* Configure the mask value in the CMDMASK register */
        automated_char_config.data_mask = 0x00FF4002;
    }

    /* Disable SLCD to write the enable-protected registers */
    slcd_disable();
    /* write the SLCD ACM configurations in the respective registers */
    slcd_automated_char_set_config(&automated_char_config);

    /* Disable Frame counter to write the enable-protected registers */
    slcd_disable_frame_counter(automated_char_config.fc);
    slcd_dma_display_memory_update_fc_sel(automated_char_config.fc);

    /* Set the Frame counter configurations and enable it */
    slcd_set_frame_counter(automated_char_config.fc, 0, 0x1);
    slcd_enable_frame_counter(automated_char_config.fc);

    /* Enable SLCD */
    slcd_enable();

    /* Configure DMA */
    configure_dma();

    /* Start DMA transfer, once DMA gets the peripheral trigger from the ACM,
     * the data transfer starts.
     */
    dma_start_transfer_job(&example_resource);

    /* Enable ACM mode */
    slcd_enable_automated_character();
}