Shop OBEX P1 Docs P2 Docs Learn Events
TV_text refresh — Parallax Forums

TV_text refresh

parskoparsko Posts: 501
edited 2006-07-28 19:49 in Propeller 1
I have the attached program that is working awesome except for one thing. Note - it outputs to TV using TV_Text. It refreshes the ADC 10bit value on the first line of the TV. I want to overwrite that every time, which it does. Problems arises when I go above 3 digits (aka >1000) then back down to 3 digits (<1000), it leaves the 4th digit (it does this when it goes to two or one digit too). I can overcome this by clearing the screen, but then the same value appears to blink at a rate of roughly 5-10Hz in a diagonal manner. I know this is due to the clear screen.

Is there a way I can keep it from having the refresh/blinking effect?

-Parsko

BTW - I feel this is my first (real) object. Much thanks to folks here for answering my questions.

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-27 22:42
    You can overcome this problem without refreshing if you pad the text with spaces when appropriate. So 1000 is displayed as "1000", 100 as " 100", 10 as " 10", etc.

    This can either be done by figuring out the value to be displayed and doing the padding, or you can just overwrite each time with 3 spaces at the origin of the number. If you do this·immediately before displaying the value, the blinking should be unnoticable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ...

    Post Edited (Paul Baker) : 7/27/2006 10:45:52 PM GMT
  • parskoparsko Posts: 501
    edited 2006-07-28 06:42
    Paul,

    I think I tried that and it didn't work. After having a night to sleep on it, I have determined, that using the existing objects and hardware, there is no diret route. You are right, I could "figure out" what the value is, then adjust accordingly. Not sure how fast that is though. Also not sure how fast I really need this to display right now either...

    On another note:
    "BS2.SHIFTIN" can be replaced by a "SERIN" command, right? I don't think it's a drag-n-drop situation, but it should work, right? I want to up the clock speed to get faster conversions...

    Thanks,

    -Parsko
  • Tom WalkerTom Walker Posts: 509
    edited 2006-07-28 12:52
    SHIFTIN is a synchronous ("with a clock") protocol which means that it uses two pins...one for data and one for the clock. SERIN is an asynchronous ("without a clock") which relies on agreed-upon standard timings so that data can be communicated without needing a separate clock signal...i.e. using only one pin. The two protocols do not work with each other.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-07-28 14:06
    Parsko... Here's something that might work... Now, I can't test this, I'v no propeller here to work it out, but it should be somewhat close.· Maybe others here can make it better.
    PUB JustifyDec(Value,Justify,Size, Filler) | NegFlag, Index, Counter, Offset, PIndex, HoldValue
      HoldValue := Value                                    'Hold the value for later resue
      NegFlag := false                                      'The Neg flag, needed for later usage as well
      Counter := 0                                          'Used to count the # of chars in the output
      PIndex := 0                                           'Used to build the output array
      
      IF Value < 0                                          'If it's a neg number
        -value                                              'make it a positive
        -HoldValue                                          'and make the hold value a positive
        NegFlag := true                                     'throw the neg flag for later usage
      Index := 1_000_000_000                                'Max number of digits
      REPEAT 10                                             'Repeat the max number of digits
        IF Value => Index                                   'Counting values until the loop exits
          Counter++                                         
          RESULT~~
        ELSEIF RESULT OR Index == 1
          Counter++
        Index /= 10
      Value := HoldValue                                    'Reset the value (for later)
      IF Size <= Counter                                    'If the value is bigger then the size then just output it and exit
        Dec(Value)
        RETURN
      Offset := Size - Counter                              'Determin the number of filler spaces needed
      IF Justify := 2                                       'If it's centered,
        Offset := Offset / 2                                'half the number of filler spaces needed
      IF NegFlag                                            'If it's a negitive number, subtract 1 from the filler count
        Offset := Offset - 1
        
      REPEAT Index FROM 0 TO 30                             'Max size is 30, so for all 30
        TempBuffer[noparse][[/noparse]Index] := 0                              'set to null (str print routine uses a null terminated string...)
      IF (Justify := 1) OR (Justify := 2)                   'Only if right or center do we add BEFORE the number
        REPEAT Index FROM 0 TO Offset                       'And we only add the number of filler spaces needed
          TempBuffer[noparse][[/noparse]Index] := Filler                       'by building the array with the filler char
          PIndex++                                          'and incrementing our index into the output array
        
      Index := 1_000_000_000                                'Reset the max number of digits (we recycle index all over...)
      IF NegFlag                                            'If it's a negitive number, add it into the output array
        TempBuffer[noparse][[/noparse]PIndex++] := "-"
        
      REPEAT 10                                             'This is a duplicate of the counting loop, only this time
        IF Value => Index                                   'we're outputing the actual values into the output array
          TempBuffer[noparse][[/noparse]PIndex++] := (value / Index + "0")
          Value //= Index
          RESULT~~
        ELSEIF RESULT OR Index == 1
          TempBuffer[noparse][[/noparse]Pindex++] := "0"
        Index /= 10
      IF (Justify :=0) OR (Justify :=2)                     'Only if it's left or center do we add AFTER the number
        REPEAT Index FROM 0 TO Offset                       'adding only the number of filler spaces needed
          TempBuffer[noparse][[/noparse]Index] := Filler                       
      STR(TempBuffer)                                       'Now its a null terminated, justified string... use STR to output!
    

    Notes:· This code would go into the TV_Text object file, not your application file and, up in the VAR section, add:
    BYTE TempBuffer[noparse][[/noparse]30]

    Hope this works.· As always, crits and comments on my code are welcome from all.
    KK


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Propeller + Hardware - extra bits for the bit bucket =· 1 Coffeeless KaosKidd

    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-28 16:43
    parsko said...
    Paul,

    I think I tried that and it didn't work. After having a night to sleep on it, I have determined, that using the existing objects and hardware, there is no diret route. You are right, I could "figure out" what the value is, then adjust accordingly. Not sure how fast that is though. Also not sure how fast I really need this to display right now either...

    Thanks,

    -Parsko
    Im puzzled over why it wouldn't work, its just filling in the appropriate value into the display buffer. You are using the object Chip released that is text only and not the TV_Terminal distributed with the Tool, right? Perhaps if you change the background color before writing the spaces you'll see if it is writing to the correct part of the screen.

    Ok I looked at your code, and I see you are using the home command, this should've worked, you could try using backspace, though I dont know offhand what the behaviour of baskspacing when you at home position does, alternatively you can try to do the goto commands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ...

    Post Edited (Paul Baker) : 7/28/2006 4:56:59 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-28 16:52
    Try this (where OBJ txt : "tv_text")
      txt.dec(x)
      repeat 3
        txt.out(" ")
    
    


    This blanks out just the left-over digits when the value displayed is shorter
    If you want a routine that right justifies a value in a field of fixed size, try
    PUB decFixed(value,width) | i, p, f, a, b, c
    '' Print a decimal number of fixed width
      p := @a
      f~
      if value < 0
        -value
        byte[noparse][[/noparse]p++] := "-"
      i := 1_000_000_000
      repeat 10
        if value => i
          byte[noparse][[/noparse]p++] := value / i + "0"
          value //= i
          f~~
        elseif f or i == 1
          byte[noparse][[/noparse]p++] := "0"
        i /= 10
      byte[noparse][[/noparse]p]~
      i := strsize(@a)
      if i < width
        repeat width - i
          txt.out(" ")
      txt.str(@a)
    
    
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-07-28 17:44
    Ok Mike, I conceede... your code is shorter, neater, better...
    But my code gives the option of left,center or right justification and width [noparse];)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Propeller + Hardware - extra bits for the bit bucket =· 1 Coffeeless KaosKidd

    ·
  • parskoparsko Posts: 501
    edited 2006-07-28 17:58
    Mike, you are a rock star. I added the repeat 3 loop with the spaces, and it works exactly as I wanted. Funny, the answer was right there.

    Now I have to spend some time with the lady... I have been on such a role this week, I hate to quit now! grrrr.....

    -Parsko
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-28 19:49
    parsko said...

    Now I have to spend some time with the lady... I have been on such a role this week, I hate to quit now! grrrr.....

    -Parsko
    Heh-heh, tell me about it. Im moving cross country in a month, without the fiancee. What time I don't spend packing, is spent with her. Im going crazy not having any time to do my own thing.

    Nice solution Mike, quick and elegant.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ...
Sign In or Register to comment.