Quote Originally Posted by boroko View Post
Hi all,
I'm having trouble understanding something in this example code. Maybe someone can explain.
Code:
Main:
  FOR Value = 0 TO 999
    GOSUB SetDisp
    PAUSE 500
  NEXT Value
GOTO Main

'---[Set 7-seg patterns to WORD value]--------------------------------------
SetDisp:
  FOR Idx = 2 to 0 STEP -1
    Temp = Value DIG Idx
    LookUp Temp,[132,175,193,137,170,152,144,143,128,136,210,251],Temp
    SEGDEF(Idx) = Temp
  NEXT Idx
RETURN
The biggest question is why is there 12 data points in the table? I am assuming that the actual numbers are because of the wiring of the digits with this specific LED as I can not figure out a segment pattern. After that, I fall down on why 12 instead of 8 unless it involves positioning the decimal point somehow. I wonder, if with the original wiring, this would be clearer to me. I would think that you would line up the segments in order with the port pins in order.

Thanks
Mark
As I can not resist a challenge even if it is only an academic exercise to me.

------- GFEDCBA

0 132 10000100
1 175 10101111
2 193 11000001
3 137 10001001
4 170 10101010
5 152 10011000
6 144 10010000
7 143 10001111
8 128 10000000
9 136 10001000
F 210 11010010
- 251 11111011


Looking at the bit pattern for :-

0 the active segments are 0 and inactive 1 in a 0 the central cross bar is inactive therefore this is C
6 the only inactive segment is top right therefore this is E
5 the inactive segments are top right and bottom left so bottom left is D
9 confirms bottom left is D
3 top left and bottom left inactive so top left is A
2 top left and bottom right inactive so bottom right is G
7 top left centre bottom left and bottom inactive so bottom is B

which leaves F is the top segment giving this pattern

-F-
A E
-C-
D G
-B-


251 is the centre bar obviously used for - (minus)
210 converting the bit pattern gives F

Having decoded this pattern it makes no sense to me as the normal segment pattern is

Name:  Capture1.PNG
Views: 1523
Size:  9.7 KB

Leaving the question why connect a 7 segment display in this no standard way?