karr/tlc5940/src/tlc5940.c
void compute_leds_values()
{
    uint32_t display_value = 0;
    uint8_t digit1_value;
    uint8_t digit2_value;
    uint8_t bar_n;
    uint16_t green_led;
    uint16_t red_led;

    // Reset the led values
    for (uint8_t i = 0; i < 48; i++)
        gs_data[i] = 0;

    display_value = segment_0;

    digit1_value = display_value % 10;
    digit2_value = (display_value / 10) % 10;

    // DIGIT 1 of line

    // Find the correct value for all the pins

    // Pin 0 (segment A)
    if (digit1_value != 1 && digit1_value != 4)
        set_pin_value(SEGMENT_A_NUM + 7, LED_ON_VALUE);

    // Pin 1 (segment B)
    if (digit1_value != 5 && digit1_value != 6)
        set_pin_value(SEGMENT_B_NUM + 7, LED_ON_VALUE);

    // Pin 2 (segment C)
    if (digit1_value != 2)
        set_pin_value(SEGMENT_C_NUM + 7, LED_ON_VALUE);

    // Pin 3 (segment D)
    if (digit1_value != 1 && digit1_value != 4 && digit1_value != 7)
        set_pin_value(SEGMENT_D_NUM + 7, LED_ON_VALUE);

    // Pin 4 (segment E)
    if (digit1_value == 0 || digit1_value == 2 || digit1_value == 6 || digit1_value == 8)
        set_pin_value(SEGMENT_E_NUM + 7, LED_ON_VALUE);

    // Pin 5 (segment F)
    if (digit1_value != 1 && digit1_value != 2 && digit1_value != 3 && digit1_value != 7)
        set_pin_value(SEGMENT_F_NUM + 7, LED_ON_VALUE);

    // Pin 6 (segment G)
    if (digit1_value != 0 && digit1_value != 1 && digit1_value != 7)
        set_pin_value(SEGMENT_G_NUM + 7, LED_ON_VALUE);

    // DIGIT 2 of line

    // Find the correct value for all the pins

    // Pin 0 (segment A)
    if (digit2_value != 1 && digit2_value != 4)
        set_pin_value(SEGMENT_A_NUM, LED_ON_VALUE);

    // Pin 1 (segment B)
    if (digit2_value != 5 && digit2_value != 6)
        set_pin_value(SEGMENT_B_NUM, LED_ON_VALUE);

    // Pin 2 (segment C)
    if (digit2_value != 2)
        set_pin_value(SEGMENT_C_NUM, LED_ON_VALUE);

    // Pin 3 (segment D)
    if (digit2_value != 1 && digit2_value != 4 && digit2_value != 7)
        set_pin_value(SEGMENT_D_NUM, LED_ON_VALUE);

    // Pin 4 (segment E)
    if (digit2_value == 0 || digit2_value == 2 || digit2_value == 6 || digit2_value == 8)
        set_pin_value(SEGMENT_E_NUM, LED_ON_VALUE);

    // Pin 5 (segment F)
    if (digit2_value != 1 && digit2_value != 2 && digit2_value != 3 && digit2_value != 7)
        set_pin_value(SEGMENT_F_NUM, LED_ON_VALUE);

    // Pin 6 (segment G)
    if (digit2_value != 0 && digit2_value != 1 && digit2_value != 7)
        set_pin_value(SEGMENT_G_NUM, LED_ON_VALUE);

    set_pin_value(0 + 16, 1000);
    set_pin_value(1 + 16, 1000);
    set_pin_value(2 + 16, 1000);

    if ((segment_0 % 26) < 13)
    {
        green_led = 4095;
        red_led = 1500;
    }
    else
    {
        green_led = 4095 / 10;
        red_led = 1500 / 10;
    }

    for (bar_n = 0; bar_n < 9; ++bar_n)
    {
        if (bar > bar_n)
            set_pin_value(bar_n + 3 + 16, green_led);
    }
    for (bar_n = 9; bar_n < 13; ++bar_n)
    {
        if (bar > bar_n)
            set_pin_value(bar_n + 3 + 16, red_led);
    }

}
// Compute the TLC5940 pin values to display the proper value
Compute the TLC5940 pin values to display the proper value
Compute the TLC5940 pin values to display the proper value
void compute_leds_values()
{
    uint32_t display_value = 0;
    uint8_t digit1_value;
    uint8_t digit2_value;
    uint8_t bar_n;
    uint16_t green_led;
    uint16_t red_led;
    for (uint8_t i = 0; i < 48; i++)
        gs_data[i] = 0;
    display_value = segment_0;
    digit1_value = display_value % 10;
    digit2_value = (display_value / 10) % 10;
    if (digit1_value != 1 && digit1_value != 4)
        set_pin_value(SEGMENT_A_NUM + 7, LED_ON_VALUE);
    if (digit1_value != 5 && digit1_value != 6)
        set_pin_value(SEGMENT_B_NUM + 7, LED_ON_VALUE);
    if (digit1_value != 2)
        set_pin_value(SEGMENT_C_NUM + 7, LED_ON_VALUE);
    if (digit1_value != 1 && digit1_value != 4 && digit1_value != 7)
        set_pin_value(SEGMENT_D_NUM + 7, LED_ON_VALUE);
    if (digit1_value == 0 || digit1_value == 2 || digit1_value == 6 || digit1_value == 8)
        set_pin_value(SEGMENT_E_NUM + 7, LED_ON_VALUE);
    if (digit1_value != 1 && digit1_value != 2 && digit1_value != 3 && digit1_value != 7)
        set_pin_value(SEGMENT_F_NUM + 7, LED_ON_VALUE);
    if (digit1_value != 0 && digit1_value != 1 && digit1_value != 7)
        set_pin_value(SEGMENT_G_NUM + 7, LED_ON_VALUE);
    if (digit2_value != 1 && digit2_value != 4)
        set_pin_value(SEGMENT_A_NUM, LED_ON_VALUE);
    if (digit2_value != 5 && digit2_value != 6)
        set_pin_value(SEGMENT_B_NUM, LED_ON_VALUE);
    if (digit2_value != 2)
        set_pin_value(SEGMENT_C_NUM, LED_ON_VALUE);
    if (digit2_value != 1 && digit2_value != 4 && digit2_value != 7)
        set_pin_value(SEGMENT_D_NUM, LED_ON_VALUE);
    if (digit2_value == 0 || digit2_value == 2 || digit2_value == 6 || digit2_value == 8)
        set_pin_value(SEGMENT_E_NUM, LED_ON_VALUE);
    if (digit2_value != 1 && digit2_value != 2 && digit2_value != 3 && digit2_value != 7)
        set_pin_value(SEGMENT_F_NUM, LED_ON_VALUE);
    if (digit2_value != 0 && digit2_value != 1 && digit2_value != 7)
        set_pin_value(SEGMENT_G_NUM, LED_ON_VALUE);
    set_pin_value(0 + 16, 1000);
    set_pin_value(1 + 16, 1000);
    set_pin_value(2 + 16, 1000);
    if ((segment_0 % 26) < 13)
    {
        green_led = 4095;
        red_led = 1500;
    }
    else
    {
        green_led = 4095 / 10;
        red_led = 1500 / 10;
    }
    for (bar_n = 0; bar_n < 9; ++bar_n)
    {
        if (bar > bar_n)
            set_pin_value(bar_n + 3 + 16, green_led);
    }
    for (bar_n = 9; bar_n < 13; ++bar_n)
    {
        if (bar > bar_n)
            set_pin_value(bar_n + 3 + 16, red_led);
    }
}
void compute_leds_values ( ) { uint32_t display_value = 0 ; uint8_t digit1_value ; uint8_t digit2_value ; uint8_t bar_n ; uint16_t green_led ; uint16_t red_led ; for ( uint8_t i = 0 ; i < 48 ; i ++ ) gs_data [ i ] = 0 ; display_value = segment_0 ; digit1_value = display_value % 10 ; digit2_value = ( display_value / 10 ) % 10 ; if ( digit1_value != 1 && digit1_value != 4 ) set_pin_value ( SEGMENT_A_NUM + 7 , LED_ON_VALUE ) ; if ( digit1_value != 5 && digit1_value != 6 ) set_pin_value ( SEGMENT_B_NUM + 7 , LED_ON_VALUE ) ; if ( digit1_value != 2 ) set_pin_value ( SEGMENT_C_NUM + 7 , LED_ON_VALUE ) ; if ( digit1_value != 1 && digit1_value != 4 && digit1_value != 7 ) set_pin_value ( SEGMENT_D_NUM + 7 , LED_ON_VALUE ) ; if ( digit1_value == 0 || digit1_value == 2 || digit1_value == 6 || digit1_value == 8 ) set_pin_value ( SEGMENT_E_NUM + 7 , LED_ON_VALUE ) ; if ( digit1_value != 1 && digit1_value != 2 && digit1_value != 3 && digit1_value != 7 ) set_pin_value ( SEGMENT_F_NUM + 7 , LED_ON_VALUE ) ; if ( digit1_value != 0 && digit1_value != 1 && digit1_value != 7 ) set_pin_value ( SEGMENT_G_NUM + 7 , LED_ON_VALUE ) ; if ( digit2_value != 1 && digit2_value != 4 ) set_pin_value ( SEGMENT_A_NUM , LED_ON_VALUE ) ; if ( digit2_value != 5 && digit2_value != 6 ) set_pin_value ( SEGMENT_B_NUM , LED_ON_VALUE ) ; if ( digit2_value != 2 ) set_pin_value ( SEGMENT_C_NUM , LED_ON_VALUE ) ; if ( digit2_value != 1 && digit2_value != 4 && digit2_value != 7 ) set_pin_value ( SEGMENT_D_NUM , LED_ON_VALUE ) ; if ( digit2_value == 0 || digit2_value == 2 || digit2_value == 6 || digit2_value == 8 ) set_pin_value ( SEGMENT_E_NUM , LED_ON_VALUE ) ; if ( digit2_value != 1 && digit2_value != 2 && digit2_value != 3 && digit2_value != 7 ) set_pin_value ( SEGMENT_F_NUM , LED_ON_VALUE ) ; if ( digit2_value != 0 && digit2_value != 1 && digit2_value != 7 ) set_pin_value ( SEGMENT_G_NUM , LED_ON_VALUE ) ; set_pin_value ( 0 + 16 , 1000 ) ; set_pin_value ( 1 + 16 , 1000 ) ; set_pin_value ( 2 + 16 , 1000 ) ; if ( ( segment_0 % 26 ) < 13 ) { green_led = 4095 ; red_led = 1500 ; } else { green_led = 4095 / 10 ; red_led = 1500 / 10 ; } for ( bar_n = 0 ; bar_n < 9 ; ++ bar_n ) { if ( bar > bar_n ) set_pin_value ( bar_n + 3 + 16 , green_led ) ; } for ( bar_n = 9 ; bar_n < 13 ; ++ bar_n ) { if ( bar > bar_n ) set_pin_value ( bar_n + 3 + 16 , red_led ) ; } }
Compute the TLC5940 pin values to display the proper value
Compute the TLC5940 pin values to display the proper value
// Reset the led values // DIGIT 1 of line // Find the correct value for all the pins // Pin 0 (segment A) // Pin 1 (segment B) // Pin 2 (segment C) // Pin 3 (segment D) // Pin 4 (segment E) // Pin 5 (segment F) // Pin 6 (segment G) // DIGIT 2 of line // Find the correct value for all the pins // Pin 0 (segment A) // Pin 1 (segment B) // Pin 2 (segment C) // Pin 3 (segment D) // Pin 4 (segment E) // Pin 5 (segment F) // Pin 6 (segment G)