FAQ | Points | Add... | Recent posts | Search | Register | Log in


Problem z przeróbką programu Bascom


Post new topic  This topic is locked      Main Page -> Forum Index -> Microcontrollers Generally -> AVR Microcontrollers -> Problem z przeróbką programu Bascom
Author
Message
lukashb
Poziom 24
Poziom 24


Joined: 06 Nov 2004
Posts: 4485
Location: -!

Post#1 Post from the author of the topic 04 Mar 2010 21:58   

Problem z przeróbką programu Bascom


Witam! Mam problem z kompilacją programu stąd:
http://evertdekker.com/Joomla/index.php?option=com_content&task=view&id=49&Itemid=84
mianowicie chodzi o typ wyświetlacza, ja mam w sprzęcie KS108 i tylko taki mogę użyć. Tak wygląda moja przeróbka tylko dla czcionki 8x8
Code:

regfile = "m8def.DAT"
$crystal = 7372800
'$baud = 19200
'$hwstack = 100
'$swstack = 120
'$framesize = 100

Config Graphlcd = 128 * 64sed , Dataport = Portd , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 4 , Rd = 3 , Reset = 2 , Enable = 5
Cursor Off
Cls


Declare 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 , 1 , 0 , 0

Cls
Loop
End



'=== 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 variables
Local A As Byte , Pixels As Byte , Count As Byte , Carcount As Byte , Lus As Byte
Local Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As Byte
Local Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As Byte
Local Xpos As Byte , Ypos As Byte , Pixel As Byte , Pixelcount As Byte
If Inverse > 1 Then Inverse = 0                             'Inverse can't be greater then 1
If Rotation > 3 Then Rotation = 0                           'There are only 4 rotation's
Stringsize = Len(s) - 1                                     'Size of the text string -1 because we must start with 0
For 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,
                      'right on top.

 Temp = Carcount + 1                                        'Cut the text string in seperate caracters
Tempstring = Mid(s , Temp , 1)
Read Row : Read Byteseach : Read Blocksize : Read Dummy     'Read the first 4 bytes from the font file
Temp = Asc(tempstring) - 32                                 'Font files start with caracter 32
For Lus = 1 To Temp                                         'Do dummie read to point to the correct line in the fontfile
   For Count = 1 To Blocksize
    Read Pixels
   Next Count
Next Lus
Colums = Blocksize / Row                                    'Calculate the numbers of colums
Row = 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 1
Colums = Colums - 1                                         'Same for the colums
Select 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 Rowcount
End Select
Next Carcount
End Sub                                                     'End of this amazing subroutine


'=== Includes ===
$include "Font8x8.font"   
i to się nie kompiluje ponieważ zmieniłem linijkę konfiguracji lcd z:
Code:

Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 3 , Cd = 0 , Wr = 2 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6

na
Code:
Config Graphlcd = 128 * 64sed , Dataport = Portd , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 4 , Rd = 3 , Reset = 2 , Enable = 5
dałem taką ponieważ taka mi funkcjonuje przy prostym sprawdzeniu wyświetlacza linijką lcdat 0,0, "text" więc sądziłem, że i tu podpasuje. Hardware: Atmega8, 8MHz rezonator, podłączenie lcd do portd jako data i portc 0-5 jako control. Proszę o pomoc co nie tak. Błąd to oczywiście error 222 in line 227 a cały kod zamyka się w 137 linijce co już dziwnie brzmi. Pozdrawiam i proszę o rade co zmienic by ruszyć tego KS-ka.
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 04 Mar 2010 21:58   





Back to top
   
adambehnke
Poziom 19
Poziom 19


Joined: 06 Jun 2008
Posts: 625
Location: Gdańsk

Post#2 05 Mar 2010 02:02   

Re: Problem z przeróbką programu Bascom


Musisz użyć biblioteki :
Code:
   $lib "glcdKS108.LBX"    lub    $lib "glcdSED1520.lbx"

I na początku programu :
Code:
$regfile = "m8def.DAT"
zamiast
Code:
regfile = "m8def.DAT"
ale to pewnie literówka.
Back to top
   
Google

Google Adsense


Post# 05 Mar 2010 02:02   





Back to top
   
lukashb
Poziom 24
Poziom 24


Joined: 06 Nov 2004
Posts: 4485
Location: -!

Post#3 Post from the author of the topic 05 Mar 2010 07:26   

Re: Problem z przeróbką programu Bascom


Witam! Ale mi wstyd!!, siedziałem nad tym do nocy i nie zauważyłem braku biblioteki!! Przepraszam :D, teraz najpewniej będzie śmigać wszystko. A tam, jest literówka, zgadza się. Dziękuje za pomoc!
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 05 Mar 2010 07:26   





Back to top
   
lukashb
Poziom 24
Poziom 24


Joined: 06 Nov 2004
Posts: 4485
Location: -!

Post#4 Post from the author of the topic 05 Mar 2010 14:14   

Re: Problem z przeróbką programu Bascom


Witam ponownie! po dodaniu biblioteki oczywiście zadziałało i nawet chodzi czccionka 16x16 z którą miałem problem ale jest kłoot z funkcją rotation, po zmianie na obrót 90 stopni latają śmieci na ekranie, często widać jak przemiata całą czcionke (wszystkie znaki się przewijają). Czy miałby ktoś jeszcze pomysł co może być nie tak? Zależy mi na tym trybie 90 stopni bo muszę właśnie tak wyświetlać zmienną. Dziękuje za pomoc!
DODANO
Więc po problemie, okazało się, że kłopoty wynikały ze starego kompilatora. Sciągnołem nową wersję i ruszyło...tylko te 4kB kodu :cry:
Back to top
   
Post new topic  This topic is locked      Main Page -> Forum Index -> Microcontrollers Generally -> AVR Microcontrollers -> Problem z przeróbką programu Bascom
Page 1 of 1
Similar topics
BASCOM-AVR problem z wysłaniem programu do procka. (22)
Bascom problem z załadowaniem programu błąd (8)
[attiny2313][bascom]problem z działaniem programu. (4)
Mega8[Bascom] Problem z Menu programu (8)
Atmega8 / bascom / Problem z działaniem programu (4)
DS89C430 + BASCOM 51 = problem z szybkością programu (4)
BASCOM: Problem z wgraniem programu (10)
[BASCOM][LCD 16x1] Problem z napisaniem programu (6)
Termometr-Bascom-Problem z DS18B20(przerobienie programu) (3)
[Bascom][Atmega8] Problem z opóźnieniem wykonania programu (12)

Page generation time: 0.095 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed