![]() |
Forum Index : Microcontroller and PC projects : BIG NUMBERS
Author | Message | ||||
Gizmo![]() Admin Group ![]() Joined: 05/06/2004 Location: AustraliaPosts: 5110 |
Here's a little routine I wrote this afternoon to display numbers on the screen, 7 segment format, in any size and aspect. I'm writting a little program to display windmill/solar data, and wanted numbers bigger than the standard font size. The future font commands Geoff is adding to the Maximite might make this redundant. ![]() 10: CLS 20: FOR i=1 TO 1000 30: Num=i : h=150 : w=40 : x=250 : y=10 : r=5 : s=10 40: gosub 1000 50: h=6 : w=3 : x=200 : y=200 : r=1 : s=2 60: gosub 1000 70: h=40 : w=30 : x=200 : y=250 : r=3 : s=5 80: gosub 1000 90: pause 100 110: next 120: end 1000: 'h = Numeric Height in pixels 1010: 'w = Numeric Width in pixels 1020: 'x = X axis start position, right justified. 1030: 'y = Y axis position, top edge of number 1040: 'r = Decimal point radius in pixels. 1050: 's = Spacing between numbers in pixels 1060: Numeric$=STR$(Num) 1070: StringLength=LEN(Numeric$) 1080: FOR StringLoc=StringLength TO 1 STEP -1 1090: line(x,y)-(x+w,y+h),0,"BF" 1100: n$=MID$(Numeric$,StringLoc,1) 1110: IF n$="0" THEN LINE(x,y)-(x+w,y+h),1,"B" 1120: IF n$="1" THEN LINE(x+w,y)-(x+w,y+h),1 1130: IF n$="2" THEN LINE(x,y)-(x+w,y),1 : LINE(x+w,y)-(x+w,y+(h/2)),1 : LINE(x+w,y+(h/2))-(x,y+(h/2)),1 : LINE(x,y+(h/2))-(x,y+H),1 : LINE(x,y+h)-(x+w,y+h),1 1140: IF n$="3" THEN LINE(x,y)-(x+w,y),1 : LINE(x+w,y)-(x+w,y+h),1 : LINE(x+w,y+h)-(x,y+h),1 : LINE(x,y+(h/2))-(x+w,y+(h/2)),1 1150: IF n$="4" THEN LINE(x,y)-(x,y+(h/2)),1 : LINE(x,y+(h/2))-(x+w,y+(h/2)),1 : LINE(x+w,y)-(x+w,y+H),1 1160: IF n$="5" THEN LINE(x,y)-(x+w,y),1 : LINE(x,y)-(x,y+(h/2)),1 : LINE(x,y+(h/2))-(x+w,y+(h/2)),1 : LINE(x+w,y+(h/2))-(x+w,y+h),1 : LINE(x,y+h)-(x+w,y+h),1 1170: IF n$="6" THEN LINE(x+w,y)-(x,y),1 : LINE(x,y)-(x,y+(h/2)),1 : LINE(x,y+(h/2))-(x+w,y+h),1,"B" 1180: IF n$="7" THEN LINE(x,y)-(x+w,y),1 : LINE(x+w,y)-(x+w,y+h),1 1190: IF n$="8" THEN LINE(x,y)-(x+w,y+h),1,"B" : LINE(x,y+(h/2))-(x+w,y+(h/2)),1 1200: IF n$="9" THEN LINE(x,y+h)-(x+w,y+h),1 : LINE(x+w,y+h)-(x+w,y+(h/2)),1 : LINE(x,y)-(x+w,y+(h/2)),1,"B" 1210: IF n$="." THEN circle(x+(W/2),y+(h/2)),r 1220: x=x-w-S 1230: NEXT 1240: return You set the numbers width, height, spacing, etc. The x position is the left edge of the right most number, and the routine will right justify the number. The top few lines are just to increment the number for demo purposes. Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
VK6MRG![]() Guru ![]() Joined: 08/06/2011 Location: AustraliaPosts: 347 |
Can't wait to give it a try. But as i'm on night shift ![]() I may get another Maximite to play with while i'm at work ![]() ![]() Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Glenn This works really well thanks Seems to be 1 small bug if the number to be displayed changes from 3 to 2 digits or 2 to 1 digit the left most digit remains on the display. Ie if we display 99 then 100 then roll back 99 the display will be 199 Any thoughts or have I done something dumb Regards John |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Found a way around it. If we format the number to the max required length the blanks are added as per below numeric$ = format$(AFR,"%5.2f") Now all is good John Picture of the work in rogress |
||||
Gizmo![]() Admin Group ![]() Joined: 05/06/2004 Location: AustraliaPosts: 5110 |
Hi John Glad to see you worked it out. This is what I've been using it for. ![]() Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |