panky
Guru
Joined: 02/10/2012 Location: AustraliaPosts: 1097 |
Posted: 06:31pm 20 Apr 2017 |
Copy link to clipboard |
Print this post |
|
@jimcanty
Hi Mate,
As suggested above, MMEdit is a good way to go to edit programs.
The code below is for a horizontal graph showing some sample voltages and currents over a 6 hour period updated every 2 seconds - it's just an example of how you might draw a running horizontal graph.
I use a similar display in my caravan battery monitor program.
Hope this helps, Cheers, Doug.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' vangraph.bas ' Mode 3,7 ' 8 colour mode white printing Colour 7,0 ' confirming white on black ' Call subroutine to display all static data DisplayStatic ' all the labels, borders etc. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Main program loop ' Main: Do AverageBV = 12.8 AverageSV = 18.5 AverageIC = 15.25 AverageLC = 12.8 AverageBC = AverageIC - AverageLC ' Now paint out running graph ' - first work out the current minute hour combo in minutes rg_mins = (((Val(Mid$(Time$,1,2)) Mod 6)*60))+(Val(Mid$(Time$,4,2))) rg_mins = rg_mins + 30 ' offset to start of graph rg_abv = 413 - Int((AverageBV-7.5) * 20) if rg_abv > 413 then rg_abv = 413 rg_asv = 413 - Int((AverageSV-7.5) * 20) if rg_asv > 413 then rg_asv = 413 if rg_asv < 163 then rg_asv = 163 rg_aic = 413 - Int(AverageIC * 5) rg_alc = 413 - Int(AverageLC * 5) If (Sgn(AverageBC) = +1) Then rg_abc = 413 - Int(AverageBC * 5) Else rg_abc = 413 + Int(AverageBC * 5) EndIf For rg_y = 163 To 413 Step 1 If rg_abc = rg_y Then If (Sgn(AverageBC) = +1) Then Pixel(rg_mins,rg_y) = 2 ' 2=green Else Pixel(rg_mins,rg_y) = 4 ' 4=red EndIf Else Pixel(rg_mins,rg_y) = 0 ' 0=black EndIf If rg_abv = rg_y Then Pixel(rg_mins,rg_y) = 7 ' 7=white EndIf If rg_asv = rg_y Then Pixel(rg_mins,rg_y) = 1 ' 1=blue EndIf If rg_aic = rg_y Then Pixel(rg_mins,rg_y) = 6 ' 6=yellow EndIf If rg_alc = rg_y Then Pixel(rg_mins,rg_y) = 5 ' 5=magenta EndIf Next rg_y For rg_y = 163 To 413 Step 1 Pixel(rg_mins+1,rg_y) = 0 Pixel(rg_mins+2,rg_y) = 0 Pixel(rg_mins+3,rg_y) = 0 Next rg_y pause 2000 loop ' End of main program loop '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Set up terminal display with static data (field names etc.) Sub DisplayStatic Cls Colour 7,0 volts=20 amps = 50 For ry =163 to 403 step 10 Print @(400,ry)Format$(amps,"%2.0fA") amps=amps-2 next ry For ry =163 to 403 step 20 Print @(2,ry)Format$(volts,"%2.0fV") volts=volts-1 next ry Line(29,163)-(29,413) Line(391,163)-(391,413) For yrg = 163 To 413 Step 10 'major ticks both sides Pixel(28,yrg)=7 Pixel(27,yrg)=7 Pixel(392,yrg)=7 Pixel(393,yrg)=7 Next yrg For yrg = 163 To 413 Step 20 'minor ticks on volts side Pixel(27,yrg)=7 Next yrg Line(30,414)-(390,414) For xrg = 30 To 390 Step 5 Pixel(xrg,415)=7 Next xrg For xrg = 30 To 390 Step 15 Pixel(xrg,415)=7 Pixel(xrg,416)=7 Next xrg For xrg = 30 To 390 Step 30 Pixel(xrg,415)=7 Pixel(xrg,416)=7 Pixel(xrg,417)=7 Next xrg For xrg = 30 To 390 Step 60 Pixel(xrg,415)=7 Pixel(xrg,416)=7 Pixel(xrg,417)=7 Pixel(xrg,418)=7 Next xrg x_label=1 for bx = 88 to 388 step 60 Print @(bx,418)STr$(x_label) ' running graph x labels - hours - x_label=x_label+1 ' so we display a running 6 hour window next bx End Sub
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
jincamty
Newbie
Joined: 10/07/2011 Location: New ZealandPosts: 21 |
Posted: 07:10pm 20 Apr 2017 |
Copy link to clipboard |
Print this post |
|
Wow, Thanks Doug.
I have no idea how to comprehend that. I can only cope with 4 or 5 lines at a time. (extreme novice) :-) This is what I came up with. It will display the water temperature with a sliding bar underneath. Scaling and positioning take a bit of trial and error
line number Font#2,1,0 Print@(20,30) "WATER" DS18B20(15) barval = DS18B20(15) 'store temperature sensor to barval barval = barval * 1.2 'scale value to fit bar graph length col=2 'set color If barval > 120 then col=4 'bar changes color after certain value Line (225,50)-((225-barval,80),7,bf 'the numbers position and size the bar, (7 is the background color) Line (20,50)-((barval+20),80),(col),bf goto line number
That took me all night :-)
Cheers Cam.
Edited by jincamty 2017-04-22 |