Shop OBEX P1 Docs P2 Docs Learn Events
Testing percent prefix — Parallax Forums

Testing percent prefix

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2012-03-13 11:06 in General Discussion
OBJ

  PST    :  "FullDuplexSerial"
  GPS    :  "FullDuplexSerial"

CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  GetLat   = $05
  GetLong  = $06

PUB main 

  PST.start(31, 30, 0, 115200)
  GPS.start(0, 0, %1100, 9600)                ' GPS connected to pin0
   
  repeat
    GPS.str(string("!GPS"))                   ' GPS command header
    GPS.tx(GetLat)                            '  for latitude  
    WriteVal
   
    PST.str(string(",")) 
    GPS.str(string("!GPS"))                   ' GPS command header
    GPS.tx(GetLong)                           '  for longitude 
    WriteVal
    PST.str(string(13))
    WaitCnt(ClkFreq + Cnt)                    ' Wait 1 second
  
PRI  WriteVal | Degrees, Minutes, MinutesD, Dir, workVal

  WaitCnt(ClkFreq / 10 + Cnt)                 ' 1/10 second wait

  Degrees := GPS.rx                           ' Retrieve bytes from GPS
  Minutes := GPS.rx
  MinutesD := (GPS.rx << 8) | GPS.rx
  Dir := GPS.rx==1
  
  if dir == -1                                ' If Dir = -1, prepend - sign
    PST.str(string("-"))
  PST.dec(Degrees)
  PST.str(string("."))

  workVal := (Minutes * 1000 / 6) + (MinutesD / 60)
  PST.dec(workVal)

Comments

  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-03-12 15:58
    Copy and pasted from Notepad:
    OBJ
    
      PST    :  "FullDuplexSerial"
      GPS    :  "FullDuplexSerial"
    
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      GetLat   = $05
      GetLong  = $06
    
    PUB main 
    
      PST.start(31, 30, 0, 115200)
      GPS.start(0, 0, %1100, 9600)                ' GPS connected to pin0
       
      repeat
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLat)                            '  for latitude  
        WriteVal
       
        PST.str(string(",")) 
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLong)                           '  for longitude 
        WriteVal
        PST.str(string(13))
        WaitCnt(ClkFreq + Cnt)                    ' Wait 1 second
      
    PRI  WriteVal | Degrees, Minutes, MinutesD, Dir, workVal
    
      WaitCnt(ClkFreq / 10 + Cnt)                 ' 1/10 second wait
    
      Degrees := GPS.rx                           ' Retrieve bytes from GPS
      Minutes := GPS.rx
      MinutesD := (GPS.rx << 8) | GPS.rx
      Dir := GPS.rx==1
      
      if dir == -1                                ' If Dir = -1, prepend - sign
        PST.str(string("-"))
      PST.dec(Degrees)
      PST.str(string("."))
    
      workVal := (Minutes * 1000 / 6) + (MinutesD / 60)
      PST.dec(workVal)
    
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-03-12 15:59
    Copy and pasted from WordPad (can support Unicode)
    OBJ
    
      PST    :  "FullDuplexSerial"
      GPS    :  "FullDuplexSerial"
    
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      GetLat   = $05
      GetLong  = $06
    
    PUB main 
    
      PST.start(31, 30, 0, 115200)
      GPS.start(0, 0, %1100, 9600)                ' GPS connected to pin0
       
      repeat
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLat)                            '  for latitude  
        WriteVal
       
        PST.str(string(",")) 
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLong)                           '  for longitude 
        WriteVal
        PST.str(string(13))
        WaitCnt(ClkFreq + Cnt)                    ' Wait 1 second
      
    PRI  WriteVal | Degrees, Minutes, MinutesD, Dir, workVal
    
      WaitCnt(ClkFreq / 10 + Cnt)                 ' 1/10 second wait
    
      Degrees := GPS.rx                           ' Retrieve bytes from GPS
      Minutes := GPS.rx
      MinutesD := (GPS.rx << 8) | GPS.rx
      Dir := GPS.rx==1
      
      if dir == -1                                ' If Dir = -1, prepend - sign
        PST.str(string("-"))
      PST.dec(Degrees)
      PST.str(string("."))
    
      workVal := (Minutes * 1000 / 6) + (MinutesD / 60)
      PST.dec(workVal) 
    
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-03-12 16:00
    And now copied and pasted, then edited
    OBJ
    
      PST    :  "FullDuplexSerial"
      GPS    :  "FullDuplexSerial"
    
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      GetLat   = $05
      GetLong  = $06
    
    PUB main 
    
      PST.start(31, 30, 0, 115200)
      GPS.start(0, 0, 00, 9600)                ' GPS connected to pin0
       
      repeat
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLat)                            '  for latitude  
        WriteVal
       
        PST.str(string(",")) 
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLong)                           '  for longitude 
        WriteVal
        PST.str(string(13))
        WaitCnt(ClkFreq + Cnt)                    ' Wait 1 second
      
    PRI  WriteVal | Degrees, Minutes, MinutesD, Dir, workVal
    
      WaitCnt(ClkFreq / 10 + Cnt)                 ' 1/10 second wait
    
      Degrees := GPS.rx                           ' Retrieve bytes from GPS
      Minutes := GPS.rx
      MinutesD := (GPS.rx << 8) | GPS.rx
      Dir := GPS.rx==1
      
      if dir == -1                                ' If Dir = -1, prepend - sign
        PST.str(string("-"))
      PST.dec(Degrees)
      PST.str(string("."))
    
      workVal := (Minutes * 1000 / 6) + (MinutesD / 60)
      PST.dec(workVal) 
    
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-03-12 16:02
    Posts without editing: OK.
    Posts with editing: Seems to drop characters, at least for me.

    Using Firefox 10.0.2 under Windows XP SP3.

    -- Gordon
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-03-12 18:34
    Per Phil's suggestion I'm now using the forum's plain text editor. After posting this I will edit it, to see if the percent prefix goes awry.
    OBJ
    
      PST    :  "FullDuplexSerial"
      GPS    :  "FullDuplexSerial"
    
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      GetLat   = $05
      GetLong  = $06
    
    PUB main 
    
      PST.start(31, 30, 0, 115200)
      GPS.start(0, 0, %1100, 9600)                ' GPS connected to pin0
       
      repeat
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLat)                            '  for latitude  
        WriteVal
       
        PST.str(string(",")) 
        GPS.str(string("!GPS"))                   ' GPS command header
        GPS.tx(GetLong)                           '  for longitude 
        WriteVal
        PST.str(string(13))
        WaitCnt(ClkFreq + Cnt)                    ' Wait 1 second
      
    PRI  WriteVal | Degrees, Minutes, MinutesD, Dir, workVal
    
      WaitCnt(ClkFreq / 10 + Cnt)                 ' 1/10 second wait
    
      Degrees := GPS.rx                           ' Retrieve bytes from GPS
      Minutes := GPS.rx
      MinutesD := (GPS.rx << 8) | GPS.rx
      Dir := GPS.rx==1
      
      if dir == -1                                ' If Dir = -1, prepend - sign
        PST.str(string("-"))
      PST.dec(Degrees)
      PST.str(string("."))
    
      workVal := (Minutes * 1000 / 6) + (MinutesD / 60)
      PST.dec(workVal)
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-12 19:19
    'Looks like it worked! I wonder what the fancy editor thinks when it sees %nn? Hex codes, maybe?

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-13 11:06
    Testing percent prefix using the WYSIWYG editor: %40, A, B, C.
    [noparse]
    %40, A, B, C
    [/noparse]
    

    I entered the hex codes for "@", "A", "B", and "C". It interpreted all but the %40. In the code section, I even included a [noparse][noparse][/noparse] tag, but to no avail. This is seriously screwed up and needs to be fixed.

    -Phil
Sign In or Register to comment.