Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : GETSCANLINE
Author | Message | ||||
busa Regular Member Joined: 12/02/2015 Location: AustraliaPosts: 81 |
Have been searching for information on this function but so far the only reference to it that I have found is in the latest change log (5.03.02). Not sure how this works(I know it can reduce or prevent the display flickering) so if anyone can give me a few pointers I would really appreciate it. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
The function returns the current line that the TFT scan is writing to. So, for example, suppose you have a digital clock updating on a 800x480 screen and the digits are being written to the top left of the screen TEXT 0,0,TIME$ We can ensure that the update occurs without any flash (tearing) by doing something like the following: [code]do i=getscanline() while i>400 or i<= mm.fontheight text 0,0,TIME$[/code] What we have done is made sure the TFT scan is not about to write to our bit of the screen or is not already writing to it before we do the update. This is not an exact science and experimentation will be required for any given example but hopefully this explains the idea |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Peter, In your example above, is the WHILE statement correct? It seems like the 'OR i<=mm.fontheight' will draw the text IF the scanline is currently writing to that part of the screen. Also: With ScanLine, is the figure relating to the 'y-co-ord' irrespective of Portrait or Landscape? Maybe in manual - sorry if it is (but I don't recall seeing it) WW For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
busa Regular Member Joined: 12/02/2015 Location: AustraliaPosts: 81 |
Thanks matherp, I will play around with it and see how I go. Does the function return both the horizontal and vertical line the scan is writing to? Sorry if this seems like a dumb question but haven't got my head fully around this function yet. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
The pseudocode is correct although the Basic syntax is wrong. It sits in a tight loop if the conditions are met that it is towards the end of a scan or at the beginning of the next and only goes on to output the text once the scan is clear of the "danger area" Correct syntax could be [code]i=getscanline() do while i>400 or i<= mm.fontheight i=getscanline() loop[/code] Should always work with Y but I haven't checked as it depends on how the SSD controller is set up to do portrait |
||||
Zonker Guru Joined: 18/08/2012 Location: United StatesPosts: 761 |
I added a print statement to the loop to show the scan lines while in the loop.. It seems to be working ok while you are using the TEXT command to display the current time and date data. While modifying a number box control, the display seems to be updating correctly while the number keypad object is "on screen", all without any flickering on screen.. So far, so good... (sweet)..! Next I tried creating a display box control and changing the code to display the time and date data updates in this object. While testing out this method, I noticed that the screen flickering has returned... I am not sure if this is the correct way to do this while using just only GUI based objects... The example code has certain lines commented out and is operating with the TEXT command... You can change it quickly to enable the display box control... ' RTC Setup Test Option explicit Const time_display_box=1 Const yer_val_box=2 Const yer_label_box=3 Const mth_val_box=4 Const mth_label_box=5 Const day_val_box=6 Const day_label_box=7 Const hrs_val_box=8 Const hrs_label_box=9 Const min_val_box=10 Const min_label_box=11 'Dim old_date As string length 10 'Dim old_time As string length 10 'Dim not_touched =1 Dim refresh_line As integer CLS GUI setup 1 'GUI displaybox time_display_box,0,0,200,20,RGB(yellow),RGB(black) 'CtrlVal(time_display_box)="test" Font 5 GUI numberbox yer_val_box,20,30,100,50,RGB(yellow),RGB(blue) CtrlVal(yer_val_box)=Val(Mid$(Date$,7,4)) ' extract year data Font 1 GUI interrupt pen_down,pen_up SetTick 1000,check_time Do Loop Sub check_time refresh_line=GetScanLine() 'Do While refresh_line>400 Or refresh_line<=MM.FontHeight*2 'nd refresh_line<= Do While refresh_line<=MM.FontHeight*2 Print refresh_line refresh_line=GetScanLine() Loop Print Time$ 'CtrlVal(time_display_box)=Time$+" "+Date$ Text 0,0,Time$+" "+Date$ End Sub 'Sub MM.KEYPRESS ref As integer, caption As string 'Print caption ' If ref=yer_val_box And caption="Ent" Then ' If Val(CtrlVal(yer_val_box))>4000 Then CtrlVal(yer_val_box)="4000" ' If Val(CtrlVal(yer_val_box))<0 Then CtrlVal(yer_val_box)="0" ' EndIf 'End Sub Sub pen_down Print "down" End Sub Sub pen_up Print "up" End Sub Any feedback would be awesome..!! Thanks Gents..! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
It is all about playing with the numbers. Remember the display scan is going past very quickly so remove all statements between the test of the scanline and the call to output (i.e. the print statements) Then if it still flashes make the safe window bigger. At the moment we assume that if the scan isn't greater than 400 we have time to output the new control before it gets to 0 when it would start overlapping the new output. The GUI controls are slower than simple text output so try 350 rather than 400. To be really safe wait until the scanline is only just past the control to be drawn. Lets assume the GUI control is from line 0 to line 30 e.g. Do While refresh_line<=30 or refresh_line> 40 refresh_line=GetScanLine() Loop CtrlVal(time_display_box)=Time$+" "+Date$ Finally, when things need to be really fast remember every character that has to be parsed counts so [code] dim integer k k=getscanline() do while k<31 or k>40 k=getscanline() loop CtrlVal(time_display_box)=Time$+" "+Date$ [/code] will be considerably faster and will allow lots of time for the GUI command By the way, there is no flashing with your original GUI code on an MZ at 252MHz |
||||
Zonker Guru Joined: 18/08/2012 Location: United StatesPosts: 761 |
Thanks Peter..! I just have to get my thinking wrapped around what the graphics controller is doing.. Inside the GPI, I assume a few things can happen at the same time... While the GPU is almost always updating LCD pixels you can push the MM objects into GPU Ram at any time. Using the scanline function lets you make sure the 2 GPU operations never "bump" into each other... Nice..! So, I think what the next thing to do is to define a "safe" Y based "start" and "end" VAR's and refer to them when creating the display box control... Next, also refer to these VAR's in the "DO" loop part... If it works, we should be able to define more than one area of the screen if you have let's say a "top" and "bottom" status line being used in your program.... Thanks again for steering me in the right direction on this.. Will do some typing and be back later... |
||||
Print this page |