Sari la conținut
ELFORUM - Forumul electronistilor

Afisare text mare pe un lcd graphic cod bascom si numarator!


Postări Recomandate

1.Am tot invatat sa folosesc un lcd graphic, de la afisare lini, patrate,cercuri,text normal, configurare!

Insa nu am gasit in helpul bascomului cum sa scriu un text de marime dupla ,tripla, etc.

Pe google nu am gasit nimik de genu.

La un display de 240x128 si MODE 8 am 16 randuri, eu de exemplu vreau sa afisez un text care sa ocupe 2,3.... randuri.

Imi puteti da niste exemple?

 

2. Vreau sa fac un numartor, adik cand detecteaza semnal pe un port sa imi afiseze 1 , cand mai detecteaza iara sa afiseze 2, dar in acelasi timp vreau sa aflu daca este posibil sa il modific, de exemplu la 10 inpulsuri sa afiseze 1 sau la 3 inpulsuri sa afiseze 5, adik vreau sa stiu mai multe tipare, nu doar unul, mai exact un counter, prima varianta am ceva in cap: cod mai jos:

Count:Na= portd.1Na = Na + 1If Na > 999999 ThenNa = 0End If
Ma gandesc ca pentru 2 inpulsuri si sa afiseze 1 in loc de Na+1 sa pun Na+0.5.

Este corect?

Codul mai sus lam scris bine?

Si inca o intrebare, eu poate o sa am ceva frecventa mare sa zic cam 50hz, o sa imi indice bine daca cristalul este de 8hmz?, sau sa pun cristal mai mare?

Link spre comentariu
  • Răspunsuri 73
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

Top autori în acest subiect

Imagini postate

Am facut o simulare cu urmatorul cod si functioneaza dar afisajul este nasol:

$regfile = "m8def.dat"$crystal = 8000000Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.3 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7Config Lcd = 16 * 2Cursor Off NoblinkClsConfig Portd.5 = InputDim Na As SingleNa = 0DoDebounce Pind.5 , 1 , Count , Sub   Locate 1 , 1   Lcd Fusing(na , "##.#")LoopEndCount:Na = Na + 1If Na > 29 ThenNa = 0End If

Si afiseaza asa:

Pleaca de la 0.0

Un inpuls afiseaza 1.00.0

Al doilea inpuls 2.01.0

Al treilea inpuls 3.02.0

Al 9-lea inpuls 9.08.0

Al 10-lea inpuls 10.00.0

Eu vreau sa afiseze 0.0, 1.0 , 2.0, 30.0, 100.0 , nu cu celelalte zerouri din coada!

Un pic de ajutor?

Link spre comentariu

Mersi mult de ajutor, am rasfoit in mare, iar la prima vedere, am impresia ca este complicata afisarea unui text in litere mari (pe mai multe randuri).Din fisierul bas, codul care este scris , trebuie tot? sau acolo am mai multe exemple de afisari?Nu am stat sal rasfoiesc in amanunt!Dar ma voi ocupa de asta! :da Mersi inca o data!

Link spre comentariu

m-ar interesa si pe mine fonturi, dar eu lucrez in C.

Nu stiu opentru ce display iti trebuie, da' intr-un topic de la pic (al lui wolfei) sunt fisierele necesare pentru afisatul pe lcd-uri nokia 3310. Incearca sa vezi cum e facut acolo si eventual adapteaza-l pentru displayul tau.LE Fisierele au fost sterse cu ocazia Marii Curatenii, asa ca le atasez aici (le aveam pe undeva pe calculator).

3310_elforum.zip

Link spre comentariu

SalutPoate te ajuta

Am incercat dar tot nimik, deci nu vrea de nici o culoare, prima oara mia zis ca am depasit marimea, am scapat de celelalte 3 fonduri de la INCLUDES si am scos si comenzile de mai sus . Mia facut hexul fara nici o eroare dar nu merge.Separa tu din acel fisier bascom, de exemplu , vreau doar un text afisat 8x8 si atat, nu cu rotiri , vertical , iversat sau altceva.Scoate te rog din codul respectiv doar partea de afisare a unui text in marime 8x8, ma chinui de ceva timp si tot nui dau de cap.
Link spre comentariu

Tu pana la urma ai display grafic, sau 16 * 2?Pentru ca tu in exemplul din al doilea post ai

Am facut o simulare cu urmatorul cod si functioneaza dar afisajul este nasol:

Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.3 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7Config Lcd = 16 * 2Cursor Off NoblinkCls
In exemplul din link lcd-ul e definit ca grafic:
Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 3 , Cd = 0 , Wr = 2 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6Cursor OffCls
Tot din bucatile astea de cod se vede ca nu folosesti aceleasi porturi cu cele din exemplu.Nici frecventa ceasului nu e aceeasi - 8 MHz la tine, 7.3728MHz in exemplul grafic si nici controllerul nu e acelasi ($regfile = "m8def.dat" la tine, $regfile = "m128def.DAT" in link).Altfel, daca reusesti sa convingi proiectele sa se potriveasca hard, ar trebui sa fie suficient ceva de genul
'------------------------------------------------------------------'                           GRAPHIC FONT'     Use the Bascom font file's for all the graphic display's,'              include inverted and/or rotated text.'        By Evert Dekker 2007 GraphicFont@Evertdekker dotje com'                   Created with Bascom-Avr: 1.11.8.8'------------------------------------------------------------------$regfile = "controllerul_tau_def.DAT" 'de scris fisierul corescpunzator controllerului$crystal = frecventa_ta 'de scris cea reala$baud = 19200$hwstack = 100$swstack = 120$framesize = 100Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 3 , Cd = 0 , Wr = 2 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6Cursor OffClsDeclare Sub Lcdtext(byval S As String , Byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Inverse As Byte , Byval Rotation As Byte)'SYNTAX  Lcdtest String , Xoffset , Yoffset , Fontset , Inverse , Rotation''* Xoffset and Yoffset is in pixels, so you can place text on every spot on the display'* You determin yourself in the subroutine witch font belongs to the fontset'=== Your main prog here ====DoLcdtext "8X8 Font" , 1 , 1 , 1 , 0 , 0Wait 10ClsLoopEnd'=== Sub Routines ===Sub Lcdtext(byval S As String , Xoffset As Byte , Yoffset As Byte , Fontset As Byte , Inverse As Byte , Rotation As Byte)Local Tempstring As String * 1 , Temp As Byte               'Dim local the variablesLocal A As Byte , Pixels As Byte , Count As Byte , Carcount As Byte , Lus As ByteLocal Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As ByteLocal Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As ByteLocal Xpos As Byte , Ypos As Byte , Pixel As Byte , Pixelcount As ByteIf Inverse > 1 Then Inverse = 0                             'Inverse can't be greater then 1If Rotation > 3 Then Rotation = 0                           'There are only 4 rotation'sStringsize = Len(s) - 1                                     'Size of the text string -1 because we must start with 0For Carcount = 0 To Stringsize                              'Loop for the numbers of caracters that must be displayed If Fontset = 1 Then Restore Font8x8                        'Add or remove here fontset's that you need or not, If Fontset = 2 Then Restore Font16x16                      'this is the name that you gave to the font, NOT the filename If Fontset = 3 Then Restore Font6x8                        'If you dont know the name, open the font file in wordpad, and there it is, If Fontset = 4 Then Restore Font5x5                        'right on top. Temp = Carcount + 1                                        'Cut the text string in seperate caractersTempstring = Mid(s , Temp , 1)Read Row : Read Byteseach : Read Blocksize : Read Dummy     'Read the first 4 bytes from the font fileTemp = Asc(tempstring) - 32                                 'Font files start with caracter 32For Lus = 1 To Temp                                         'Do dummie read to point to the correct line in the fontfile   For Count = 1 To Blocksize    Read Pixels   Next CountNext LusColums = Blocksize / Row                                    'Calculate the numbers of columsRow = Row * 8                                               'Row is always 8 pixels high = 1 byte, so working with row in steps of 8.Row = Row - 1                                               'Want to start with row=0 instead of 1Colums = Colums - 1                                         'Same for the columsSelect Case Rotation    Case 0                                                  '0 degrees rotation            For Rowcount = 0 To Row Step 8                  'Loop for numbers of rows                  A = Rowcount + Yoffset                  For Columcount = 0 To Colums              'Loop for numbers of Colums                      Read Pixels : If Inverse = 1 Then Toggle Pixels       'Read the byte from the file and if inverse = true then invert de byte                      Xpos = Columcount                     'Do some calculation to get the caracter on the correct Xposition                      Temp = Carcount * Byteseach                      Xpos = Xpos + Temp                      Xpos = Xpos + Xoffset                          For Pixelcount = 0 To 7           'Loop for 8 pixels to be set or not                             Ypos = A + Pixelcount          'Each pixel on his own spot                             Pixel = Pixels.0               'Set the pixel (or not)                             Pset Xpos , Ypos , Pixel       'Finaly we can set the pixel                             Shift Pixels , Right           'Shift the byte 1 bit to the right so the next pixel comes availible                          Next Pixel                  Next Columcount            Next Rowcount    Case 1                                                  '90 degrees rotation            For Rowcount = Row To 0 Step -8                 'Loop is now counting down                  A = Rowcount + Xoffset                  A = A - 15                                'Correction to set Xpos on Xoffset with rotation                  For Columcount = 0 To Colums                      Read Pixels : If Inverse = 1 Then Toggle Pixels                      Xpos = Columcount                      Temp = Carcount * Byteseach                      Xpos = Xpos + Temp                      Xpos = Xpos + Yoffset                 'We want that Xoffset is still Xoffset, so we need here the change from x to y                             For Pixelcount = 7 To 0 Step -1                                Ypos = A + Pixelcount                                Pixel = Pixels.0                                Pset Ypos , Xpos , Pixel                                Shift Pixels , Right                             Next Pixel                  Next Columcount            Next Rowcount    Case 2                                                  '180 degrees rotation            For Rowcount = Row To 0 Step -8                  A = Rowcount + Yoffset                  A = A - 7                                 'Correction to set Xpos on Xoffset with rotation                  For Columcount = Colums To 0 Step -1                      Read Pixels : If Inverse = 1 Then Toggle Pixels                      Xpos = Columcount                      Temp = Carcount * Byteseach                      Xpos = Xpos - Temp                      Xpos = Xpos - 8                       'Correction to set Xpos on Xoffset with rotation                      Xpos = Xpos + Xoffset                          For Pixelcount = 7 To 0 Step -1                             Ypos = A + Pixelcount                             Pixel = Pixels.0                             Pset Xpos , Ypos , Pixel                             Shift Pixels , Right                          Next Pixel                  Next Columcount            Next Rowcount    Case 3                                                  '270 degrees rotation            For Rowcount = 0 To Row Step 8                  A = Rowcount + Xoffset                    For Columcount = Colums To 0 Step -1                      Read Pixels : If Inverse = 1 Then Toggle Pixels                      Xpos = Columcount                      Temp = Carcount * Byteseach                      Xpos = Xpos - Temp                      Xpos = Xpos - 8                       'Correction to set Xpos on Xoffset with rotation                      Xpos = Xpos + Yoffset                             For Pixelcount = 0 To 7                                Ypos = A + Pixelcount                                Pixel = Pixels.0                                Pset Ypos , Xpos , Pixel                                Shift Pixels , Right                             Next Pixel                  Next Columcount            Next RowcountEnd SelectNext CarcountEnd Sub                                                     'End of this amazing subroutine'=== Includes ===$include "Font8x8.font"                       'Includes here your font files
Pentru a afisa

8X8 Font

in coltul din stanga sus (presupun). Cel putin asa cred.Nu uita sa copiezi fisierul Font8x8.font in directorul de lucru si sa configurezi conform hardwareului tau
Link spre comentariu

Mersi inca o data de ajutor, o sa simulez codurile sa vad ce rezulta, codul de counter este pe lcd 2x 16, pentru afisare am 240x128.De mutat fisierul .font in folderul unde am fisierul .bas am facut.In simularea care am facuto prima oara am lasat doar .fontul care am vrut, da in acelasi timp am pus si comanda asta :Locate 1,1Lcd "Helolo"wait 1Aici am continuat cu codul din main program!si de afisat helolo afisa dar cand trecea sa afiseze restul nu afisa!Deci configurarea hardwere este bine.O sa vad acuma daca merge, ce am observat eu este ca la configurarea lcd-ului este MODE 6 , eu am pus MODE 8!Poate asta era devina!

Link spre comentariu

Ma nenorocit atmega8535!

Nu vrea sa mearga, am lasat totul identic, inafar de controler, orice afiseaza dar partea de fond nu afiseaza.

Ori e de la proteus, ori nu stiu ce sa zic, cu atmega 128, merge, acum nu am incercat cu atmega 8 sa vad!

$regfile = "m8535.dat"                                      ' specify the used micro$crystal = 8000000$baud = 19200$hwstack = 100$swstack = 120$framesize = 100Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 3 , Cd = 0 , Wr = 2 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6Cursor OffClsDeclare Sub Lcdtext(byval S As String , Byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Inverse As Byte , Byval Rotation As Byte)'SYNTAX  Lcdtest String , Xoffset , Yoffset , Fontset , Inverse , Rotation''* Xoffset and Yoffset is in pixels, so you can place text on every spot on the display'* You determin yourself in the subroutine witch font belongs to the fontset'=== Your main prog here ====Do'Lcdtext "5X5 Font" , 10 , 2 , 4 , 0 , 0'Lcdtext "8X8 Font" , 2 , 120 , 2 , 1 , 3Lcdtext "8X8 font" , 10 , 30 , 2 , 0 , 0'Lcdtext "6X8 Font" , 10 , 20 , 3 , 0 , 0'Lcdtext "16X16 font" , 10 , 30 , 2 , 0 , 0'Lcdtext "Inverted" , 10 , 85 , 2 , 1 , 0'Lcdtext "If you can't read this then incr. Swstack" , 1 , 120 , 4 , 0 , 0Wait 10Cls'Lcdtext "0 deg.Rotation" , 10 , 10 , 1 , 0 , 0Lcdtext "90 deg.Rotation" , 170 , 1 , 1 , 0 , 1'Lcdtext "180 deg.Rotation" , 120 , 20 , 1 , 0 , 2'Lcdtext "270 deg.Rotation" , 200 , 120 , 1 , 0 , 3'Lcdtext "Also inverted" , 150 , 80 , 1 , 1 , 2'Lcdtext "Every font" , 150 , 100 , 2 , 0 , 2Wait 10ClsLoopEnd'=== Sub Routines ===Sub Lcdtext(byval S As String , Xoffset As Byte , Yoffset As Byte , Fontset As Byte , Inverse As Byte , Rotation As Byte)Local Tempstring As String * 1 , Temp As Byte               'Dim local the variablesLocal A As Byte , Pixels As Byte , Count As Byte , Carcount As Byte , Lus As ByteLocal Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As ByteLocal Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As ByteLocal Xpos As Byte , Ypos As Byte , Pixel As Byte , Pixelcount As ByteIf Inverse > 1 Then Inverse = 0                             'Inverse can't be greater then 1If Rotation > 3 Then Rotation = 0                           'There are only 4 rotation'sStringsize = Len(s) - 1                                     'Size of the text string -1 because we must start with 0For Carcount = 0 To Stringsize                              'Loop for the numbers of caracters that must be displayed If Fontset = 1 Then Restore Font8x8                        'Add or remove here fontset's that you need or not, If Fontset = 2 Then Restore Font8x8                        'this is the name that you gave to the font, NOT the filename If Fontset = 3 Then Restore Font8x8                        'If you dont know the name, open the font file in wordpad, and there it is, If Fontset = 4 Then Restore Font8x8                        'right on top. Temp = Carcount + 1                                        'Cut the text string in seperate caractersTempstring = Mid(s , Temp , 1)Read Row : Read Byteseach : Read Blocksize : Read Dummy     'Read the first 4 bytes from the font fileTemp = Asc(tempstring) - 32                                 'Font files start with caracter 32For Lus = 1 To Temp                                         'Do dummie read to point to the correct line in the fontfile   For Count = 1 To Blocksize    Read Pixels   Next CountNext LusColums = Blocksize / Row                                    'Calculate the numbers of columsRow = Row * 8                                               'Row is always 8 pixels high = 1 byte, so working with row in steps of 8.Row = Row - 1                                               'Want to start with row=0 instead of 1Colums = Colums - 1                                         'Same for the columsSelect Case Rotation    Case 0                                                  '0 degrees rotation            For Rowcount = 0 To Row Step 8                  'Loop for numbers of rows                  A = Rowcount + Yoffset                  For Columcount = 0 To Colums              'Loop for numbers of Colums                      Read Pixels : If Inverse = 1 Then Toggle Pixels       'Read the byte from the file and if inverse = true then invert de byte                      Xpos = Columcount                     'Do some calculation to get the caracter on the correct Xposition                      Temp = Carcount * Byteseach                      Xpos = Xpos + Temp                      Xpos = Xpos + Xoffset                          For Pixelcount = 0 To 7           'Loop for 8 pixels to be set or not                             Ypos = A + Pixelcount          'Each pixel on his own spot                             Pixel = Pixels.0               'Set the pixel (or not)                             Pset Xpos , Ypos , Pixel       'Finaly we can set the pixel                             Shift Pixels , Right           'Shift the byte 1 bit to the right so the next pixel comes availible                          Next Pixel                  Next Columcount            Next Rowcount    Case 1                                                  '90 degrees rotation            For Rowcount = Row To 0 Step -8                 'Loop is now counting down                  A = Rowcount + Xoffset                  A = A - 15                                'Correction to set Xpos on Xoffset with rotation                  For Columcount = 0 To Colums                      Read Pixels : If Inverse = 1 Then Toggle Pixels                      Xpos = Columcount                      Temp = Carcount * Byteseach                      Xpos = Xpos + Temp                      Xpos = Xpos + Yoffset                 'We want that Xoffset is still Xoffset, so we need here the change from x to y                             For Pixelcount = 7 To 0 Step -1                                Ypos = A + Pixelcount                                Pixel = Pixels.0                                Pset Ypos , Xpos , Pixel                                Shift Pixels , Right                             Next Pixel                  Next Columcount            Next Rowcount    Case 2                                                  '180 degrees rotation            For Rowcount = Row To 0 Step -8                  A = Rowcount + Yoffset                  A = A - 7                                 'Correction to set Xpos on Xoffset with rotation                  For Columcount = Colums To 0 Step -1                      Read Pixels : If Inverse = 1 Then Toggle Pixels                      Xpos = Columcount                      Temp = Carcount * Byteseach                      Xpos = Xpos - Temp                      Xpos = Xpos - 8                       'Correction to set Xpos on Xoffset with rotation                      Xpos = Xpos + Xoffset                          For Pixelcount = 7 To 0 Step -1                             Ypos = A + Pixelcount                             Pixel = Pixels.0                             Pset Xpos , Ypos , Pixel                             Shift Pixels , Right                          Next Pixel                  Next Columcount            Next Rowcount    Case 3                                                  '270 degrees rotation            For Rowcount = 0 To Row Step 8                  A = Rowcount + Xoffset                    For Columcount = Colums To 0 Step -1                      Read Pixels : If Inverse = 1 Then Toggle Pixels                      Xpos = Columcount                      Temp = Carcount * Byteseach                      Xpos = Xpos - Temp                      Xpos = Xpos - 8                       'Correction to set Xpos on Xoffset with rotation                      Xpos = Xpos + Yoffset                             For Pixelcount = 0 To 7                                Ypos = A + Pixelcount                                Pixel = Pixels.0                                Pset Ypos , Xpos , Pixel                                Shift Pixels , Right                             Next Pixel                  Next Columcount            Next RowcountEnd SelectNext CarcountEnd Sub                                                     'End of this amazing subroutine'=== Includes ===$include "Font8x8.font"                                     'Includes here your font files'$include "Font16x16.font"                                   'If you don't need the files in your program, don't include them,'$include "Font6x8.font"                                     'these are flash memory eaters.'$include "Font5x5.font"
Link spre comentariu

Am decarcat arhiva lui iulian2010, si merge perfect cu atmega 128, am inlocuit cu atmega 8535 si am modificat doar primul cod, atat. Nu vrea sa fiseze partea cu fond, daca las asa codul si dupa DO scriu LCD "helocome", afiseaza si dupaia dispare ca urma sa afiseze fondul, dar nul afiseaza , am incercat pe atmega8 si nici acolo nu vrea, deci textul normal afiseaza dar cel cu fond nu, cu aceleasi conexiuni si configurari ale lcd-ului!Poza mai jos cu schema si dar PLAY la rulare simulare cu atmega 8535!

post-15533-139829290536_thumb.jpg

Link spre comentariu

Ai postat schema gresita, ai VDD si VSS scurtcircuitate (si legate la masa). Ar trebui ca VDD sa fie la 5V (sau 3V, dupa caz) si VSS la masa.

In rest pinii sunt conectati corect (ca in programul din penultimul tau post), ar trebui sa mearga.

Ce intelegi tu prin fond? Scris "alb pe negru"? Atunci cred ca trebuie sa activezi "inverse" (1 pe penultima pozitie) in linia

Lcdtext "8X8 font" , 10 , 30 , 2 , 0 , 0
adica

Lcdtext "8X8 font" , 10 , 30 , 2 , 1 , 0
Link spre comentariu

Alătură-te conversației

Poți posta acum și să te înregistrezi mai târziu. Dacă ai un cont, autentifică-te acum pentru a posta cu contul tău.
Notă: Postarea ta va necesita aprobare moderator înainte de a fi vizibilă.

Vizitator
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Răspunde la acest subiect...

×   Alipit ca text avansat.   Restituie formatare

  Doar 75 emoji sunt permise.

×   Linkul tău a fost încorporat automat.   Afișează ca link în schimb

×   Conținutul tău precedent a fost resetat.   Curăță editor

×   Nu poți lipi imagini direct. Încarcă sau inserează imagini din URL.




×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări