Elektroda.pl
Elektroda.pl
X
Please add exception to AdBlock for elektroda.pl.
If you watch the ads, you support portal and users.

BASCOM AVR i wyświetlanie zmiennych na LCD

Tasior 05 Dec 2002 20:45 3528 5
  • #1
    Tasior
    Level 15  
    ello
    jestem tu całkowice nowy ale mam nadzieje że mnie nia zignorujecie , bo mam dosyć dziwaczny problemik z bascomam avr i obsługą wyświetlacza 16*2
    Chodzi o to ze gdy chce na nim wyświetlić swykły napis to wszystko jest ok ale schody zaczynają się gdy wyświetlam tekst i zmienną ...
    wtedy zaczyna wyświetlać jakieś dziwne znaczki i nie wiem za bardzo jak to obejść .

    Pomocy !!!!
  • #2
    Jaca
    Level 31  
    Czy w swoim programie stosujesz komendę LCD w składni podanej niżej ?
    LCD "tekst" ; zmienna1 ; zmienna2
    Najlepiej będzie jeśli podasz kod źródłowy swojego programu oraz numer wersji BASCOMa AVR.
    I jeszcze jedno, możesz spróbować zrobić to w taki sposób:
    LCD "tekst"+STR(zmienna1)+STR(zmienna2)
    z tym, że w tym przypadku zmienna1 i zmienna2 muszą być zmiennymi numerycznymi.
  • #3
    Tasior
    Level 15  
    nie wiem czy to pomoze albo nie zatka forum ale prosze :
    ten program jest jeszcze niedorobiony ale powinien wyświetlać zmienne
    wrsja bascoma to 1.11.6.2

    Config Lcdpin = Pin , Db4 = Porta.5 , Db5 = Porta.4 , Db6 = Porta.3 , Db7 = Porta.2 , E = Porta.6 , Rs = Porta.7
    Config Lcd = 16 * 2
    Config Rc5 = Pind.2
    Dim Adress As Byte
    Dim R As Byte
    Dim Command As Byte
    Dim Var As Byte
    Dim Reg As Byte
    Dim Vol As Byte
    Dim Bass As Byte
    Dim Treb As Byte
    Dim Ef As Byte
    Dim Stereo As Bit
    Dim Pseudo As Bit
    Dim Spatial As Bit
    Dim X As Byte
    Declare Sub Volume
    Declare Sub Bass
    Declare Sub Treble
    Declare Sub Wysyl
    Declare Sub Effect
    Declare Sub Pilot
    Declare Sub Wysw
    Declare Sub Klaw
    Config Sda = Portc.1
    Config Scl = Portc.2
    Speaker Alias Portc.0
    Cls
    Lcd " zaraz odpale"
    Wait 1
    Cls
    Lcd "cos tam pisze"
    Vol = 5
    Call Volume
    Bass = 10
    Call Bass
    Treb = 10
    Call Treble
    Call Effect
    Stereo = 1
    Wait 2
    Set Speaker
    Lowerline
    Lcd " no juz hehe "
    Enable Interrupts

    Do
    Getrc5(adress , Command)
    If Adress = 19 Then
    Disable Interrupts
    Command = Command And &B10111111
    Call Pilot
    End If
    I2cstart
    I2cwbyte 113
    I2crbyte X , 9
    I2cstop
    If X < 255 Then
    Call Klaw
    End If
    Loop



    Volume:
    Reg = 0
    Var = 218 + Vol
    Call Wysyl
    Reg = 1
    Var = 218 + Vol
    Call Wysyl
    Return

    Bass:
    Reg = 2
    Var = 241 + Bass
    Call Wysyl
    Return

    Treble:
    Reg = 3
    Var = 241 + Treb
    Call Wysyl
    Return

    Effect:
    Reg = 8
    Ef = &B11000000
    If Spatial = 1then
    Ef = Ef + &B11011000
    End If
    If Pseudo = 1 Then
    Ef = Ef + &B11001000
    End If
    If Stereo = 1 Then
    Ef = Ef + &B11010000
    End If
    Var = Ef
    Call Wysyl
    Return

    Wysyl:
    I2cstart
    I2cwbyte 130
    I2cwbyte Reg
    I2cwbyte Var
    I2cstop
    Return

    Pilot:
    If Command = 16 Then
    Incr Vol
    If Vol > 35 Then
    Vol = 35
    End If
    End If
    If Command = 17 Then
    Decr Vol
    If Vol < 1 Then
    Vol = 1
    End If
    End If
    Call Volume
    If Command = 24 Then
    Incr Treb
    If Treb > 11 Then
    Treb = 11
    End If
    End If
    If Command = 25 Then
    Decr Treb
    If Treb < 1 Then
    Treb = 1
    End If
    End If
    Call Treble
    If Command = 22 Then
    Incr Bass
    If Bass > 12 Then
    Bass = 12
    End If
    End If
    If Command = 23 Then
    Decr Bass
    If Bass < 1 Then
    Bass = 1
    End If
    End If
    Call Bass
    If Command = 1 Then
    If Stereo = 1 Then
    Reset Stereo
    Set Spatial
    Else
    Set Stereo
    Reset Spatial
    End If
    Call Effect
    End If
    Call Wysw
    Command = 255
    Return

    Wysw:
    Cls
    Upperline
    Lcd " Volume: " ; Vol
    Lowerline
    Lcd "Bass " ; Bass ; " Treb " ; Treb
    Waitms 100
    Enable Interrupts
    Return

    Klaw:
    If X = &B11111110 Then
    Command = 16
    End If
    If X = &B11111101 Then
    Command = 17
    End If

    Call Pilot
    Return
  • #4
    Jaca
    Level 31  
    Hi !
    Czy na symulatorze wszystko wyświetla prawidłowo ? Ja posiadam BASCOMa AVR w wersji 1.11.6.4 i u mnie na symulatorze jest wszystko OK. Skompilowałem dla Ciebie ten program (AVR 1.11.6.4) i zamieszczam go niżej. Sprawdź czy będzie chodził prawidłowo.
  • #5
    Tasior
    Level 15  
    dzieki
    pózniej to sprawdze bo musze grzać do szkoły
    ps
    w symulacj mi to działa
    i nie mam pojęcia o co mu chodzi
    pózniej napisze coś więcej bo teraz sie spiesze
    dzięki
    nara
  • #6
    Tasior
    Level 15  
    zauwazyłem ze tak sie nie dzieje jak treble jest ustawione na 9
    nie wiem co to ma do gadania ale moze to coś komuś pomoze
    po prostu wystarczy ustawic z pilita treb na 9 i cała reszta pózniej działa a jak sie zmieni z 9 na 10 albo 8 to znowu kupa

    jakieś sugestie ???