A simple single digit seven segment display

Please feel free to use i

Something like this is basically unusable in a real application. Its timing, critical to such an implementation is loop dependent and its scalability (to add more digits) is poor.

What you should do is to implement it inside of a timer. So all the user application does is to update the display buffer and the display routine will update the display in the background.