Ejemplo n.º 1
0
//----
void seg_display(int value) //coba-coba gak jelas
{
	  int digit;
		digit = value / 1000;
		close_seven_segment();
		show_seven_segment(3,digit);
		//DrvSYS_Delay(5000);

		value = value - digit * 1000;
		digit = value / 100;
		close_seven_segment();
		show_seven_segment(2,digit);
		//DrvSYS_Delay(5000);

		value = value - digit * 100;
		digit = value / 10;
		close_seven_segment();
		show_seven_segment(1,digit);
		//delay(5000);

		value = value - digit * 10;
		digit = value;
		close_seven_segment();
		show_seven_segment(0,digit);
		//DrvSYS_Delay(5000);
}
Ejemplo n.º 2
0
void display(float number)
{
    int one, two, three;

    if(number < 10) {																													// Two decimal points

        number = number * 10;
        one = get_digit_in_place(number, 1);
        two = get_digit_in_place(number, 10);
        three = get_digit_in_place(number, 100);

        if(digit == 1) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(2);

            activate_digit(1);
            activate_decimal();
            show_seven_segment(three);
        }
        else if(digit == 2) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(3);

            activate_digit(2);
            show_seven_segment(two);
        }
        else if(digit == 3) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(1);

            activate_digit(3);
            show_seven_segment(one);
        }
        else if(digit == 4) {
            activate_degree();
        }

    }
    else if(number > 10 && number < 100) {																			// One decimal point

        number = number;
        one = get_digit_in_place(number, 1);
        two = get_digit_in_place(number, 10);
        three = get_digit_in_place(number, 100);

        if(digit == 1) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(2);

            activate_digit(1);
            show_seven_segment(three);
        }
        else if(digit == 2) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(3);

            activate_digit(2);
            activate_decimal();
            show_seven_segment(two);
        }
        else if(digit == 3) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(1);

            activate_digit(3);
            show_seven_segment(one);
        }
        else if(digit == 4) {
            activate_degree();
        }

    }
    else if(number > 100) {																										// No decimal point

        number = number/10;
        one = get_digit_in_place(number, 1);
        two = get_digit_in_place(number, 10);
        three = get_digit_in_place(number, 100);

        if(digit == 1) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(2);

            activate_digit(1);
            show_seven_segment(three);
        }
        else if(digit == 2) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(3);

            activate_digit(2);
            show_seven_segment(two);
        }
        else if(digit == 3) {
            clear_all_segments();
            deactivate_degree();
            deactivate_digit(1);

            activate_digit(3);
            show_seven_segment(one);
        }
        else if(digit == 4) {
            clear_all_segments();
            activate_degree();
        }
    }

}