Shop OBEX P1 Docs P2 Docs Learn Events
HMC5883L Compass Module with Parallax Serial LCD — Parallax Forums

HMC5883L Compass Module with Parallax Serial LCD

MakerDinoMakerDino Posts: 19
edited 2012-11-21 04:36 in Propeller 1
I've completed a new project and video with the Compass Module connected to the BOE. Check out the video and see what you think of the way I modded the demo code to work with the LCD. [video=youtube_share;3joOzwHa-Uw]

The code is here: http://hackaweek.com/hacks/?attachment_id=1004

I invite any and all feedback on how this code can be cleaned up to work better. I'm a code hacker, not a real programmer.

Keep On Hackin!

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2012-11-19 23:33
    Sure you need those waiting-times at the beginning? I never added a wait time for FullDuplexSerial so far, maybe needed for the LCD to initialize? But next line waittime is a remains of starting the compass before?

    Headinglcd:
    lcd.str( string( 17, "Heading:", 13 ) ) would do the whole job

    aziadjust & Heading:
    Instead of having 4 byte variables NW,NE,SE,SW and t1 I'd use one direction byte with bits N, E, S, W. Then you can use a case statement in Heading
    case direction
    N:
    backspace( 5 )
    lcd.str( @NORTH )
    N | W:
    lcd.tx( 32 )
    lcd.str( @N )
    ....
    W:
    ...

    Header:
    As you can already see in the case statement, I'd write a function for lcd.tx( 8 ) ....
    Same thing for the code in NE,SE,SW and NW

    PUB dirOut(t, d1, d2)
    lcd.tx( 32 )
    lcd.str( d1 )
    lcd.dec( t )
    lcd.str( d2 )
    lcd.tx(32)
    lcd.tx(32)

    In the case statement you can call:
    case direction:
    N | E:
    dirOut( aziadjust, @N, @E )
    S | E:
    dirOut(||(aziadjust-180), @S, @E)
    S | W:
    ....


    GetRaw:
    What this is good for
    x := x
    z := z
    y := y
    I can't tell ;o)
  • MakerDinoMakerDino Posts: 19
    edited 2012-11-21 04:36
    Thanks MagIO2. I'll chew on that this weekend.
Sign In or Register to comment.