Glcd Anzeigefehler

#2929338
Lesenswert?

Hallo,
ich bin bisschen am Verzweifeln mit meinem (Glcd 128x64 Pixel) von 
Pollin 
(http://www.pollin.de/shop/dt/NTc1OTc4OTk-/Bauelemente_Bauteile/Aktive_Bauelemente/Displays/LCD_Modul_TG12864B_03.html) 
Wenn ich das Programm drauf lade ( Bascom ):
1
$lib "glcdKS108.lbx"
2
$regfile "m16def.dat"
3
$crystal = 4000000
4

5
Print "Config"
6

7
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , _
8
Ce = 2 , Ce2 = 3 , Cd = 6 , Rd = 5 , Reset = 0 , Enable = 4
9

10
Config Pinc.0 = Input
11
Config Pinc.1 = Input
12
Config Pinc.2 = Input
13

14

15

16
Dim X As Byte
17
Dim Y As Byte
18
Dim Z As Byte
19
Dim Z1 As Byte
20

21
Setfont Font8x8
22

23
Print "Cls"
24
Cls
25

26
Wait 1
27

28
Lcd "Hello World"
29
Locate 32 , 48
30

31
Wait 2
32

33
Cls
34

35
Line(0 , 7) -(128 , 7) , 255
36
Line(0 , 57) -(128 , 57) , 255
37

38

39

40
End
41
$include "Font8x8.font"

werden genau in der Mitte des Displays die Striche versetzt.(Im Anhang)
Ich benutzte einen Atmega16. Die Kabel zum Display sind 15cm lang, ich 
habe es mit einem Schnelleren bzw. Langsameren internen Takt versucht 
und mit einem Atmega32 und einem Externen Resonator. Jedoch kam bei 
allem das gleiche Problem heraus... Habt ihr eine Idee ?

Mfg Salex.
Angehängte Dateien:
#2929542
Lesenswert?

Hallo Sascha,
erstmal Danke für die Antwort, aber Ich hab das "Hello World" Extra auf 
diese Koordinaten Platziert, um zu schauen ob das auch verzerrt wird, 
wie diese Linien welche 2 Sekunden später erscheinen. Das "Hello World" 
wird etwas nach Links verschoben Angezeigt. Jedoch ,da die Striche aber 
durch den Display durchgezogen sind werden die genau in der Mitte 
Verzerrt, und wenn man sich den Schaltplan des Displays anschaut 
(http://www.pollin.de/shop/downloads/D120424D.PDF) Sieht man das für den 
einen Teil ein anderer Controller benutzt wird. Kann das daran liegen, 
das der Controller Kaputt ist oder so etwas ?
#2929676
Lesenswert?

Teste mal den Code hier must nur für dich anpassen.

$regfile = "m8def.dat"                   ' Mega8
$crystal = 8000000

$lib "glcdks108.lbx"
$include "Font6x8.font"

' Disable JTAG interface
Dim Bz As Byte
Bz = Mcucsr                         'READ VALUE OF &H34
Bz = Bz Or &H80                       'SET UPPER BIT
Mcucsr = Bz                         'WRITE TWICE TO DISABLE JTAG
Mcucsr = Bz
'for Glcd Ks108
Config Graphlcd = 128 * 64sed , Dataport = Portd , Controlport = Portc , 
Ce = 3 , Ce2 = 2 , Reset = 4 , Rd = 5 , Cd = 0 , Enable = 1


'The dataport is the portname that is connected to the data lines of 
the LCD
'The controlport is the portname which pins are used to control the 
lcd
'CE   = CS1 Chip select
'CE2  = CS2 Chip select second chip
'CD   = DI Data/instruction
'RD   = R/W Read/Write
'RESET = RST reset
'ENABLE = E Chip Enable
Waitms 500
Do
 Cls
 Setfont Font6x8
 Lcdat 1 , 0 , "SETUP MENU 123456"
 Lcdat 2 , 1 , "Wait ....."
 Lcdat 3 , 1 , "Wait ....." , 1
 Lcdat 4 , 1 , "Wait ....."
 Wait 1
 Loop
End
Gast #2929728
Lesenswert?

>Die Hexdatei klappt leider nicht, sie zeigt nur zufällige Pixel am
>Display an. Trotzdem vielen Dank !

Die war übrigends für einen ATmega16.
Habs vergessen zu erwähnen.
Ich kontrolliere die Pinbelegung gleich noch mal.
Deine da oben stimmt doch?
Gast #2929822
Lesenswert?

>Naja Jetzt gehts, könntest du vielleicht den
>Code hier reinschreiben ?

Besser nicht;) War auch kein Bascom sondern C.

Wenn ein Ks108 Display so komische Sachen macht, dann hat
man in der Regel zu schnell darauf zugegriffen. Bei dir hatte
sich dadurch die Display Start Line auf dem linken Controller
verschoben.

>$crystal = 4000000

Dein Takt wird wohl doch irgendwie schneller als 4MHz gewesen sein.
Gast #2929883
Lesenswert?

>>>$crystal = 4000000
>> Dein Takt wird wohl doch irgendwie schneller als 4MHz gewesen sein.
>
>Naja jetzt sollte er 8 MHZ sein und müßte auch laufen oder hast Probleme
>damit.

Ja, nur weil du da

$crystal = 8000000

hinschreibst ändert sich der CPU Takt dadurch nicht.
Das ist ein Hinweis für Bascom das du einen 8MHz Takt
hast. Einstellen musst du diesen schon selber über die
Fuses.

Mit welchem Takt deine CPU läuft kannst du ganz schnell
selber testen. Einfach eine LED im (angeblichen) Sekundentakt
ein/aus machen. Dann siehst du was wirklich Sache ist.
Gast #2929896
Lesenswert?

>Ich habs über die Fuses und im Code geändert, jedoch ist nichts
>passiert.

Falsches HEX File geflasht? Das Programm geändert aber nicht
neu übersetzt? Passiert doch jedem mal;) Ich weiss
aber nicht wie Bascom da tickt.

Kaum hast du das Programm von Ronny oder mein HEX File
da reingebrutzelt gehts dann komischerweise.

Dein Takt hat einfach nicht gestimmt.
Gast #2929917
Lesenswert?

>Ronny S. schrieb:
>> @ holger,
>>
>> mal OT hast Du zufällig für mich auch einen Guten Tip Sed1335 640*200 in
>>
>> Bascom nur Text Ausgabe würde reichen.

Tut mir leid da hab ich keinen Tip.

@Sabri

>Dein Takt hat einfach nicht gestimmt.

Im Anhang mal eine HEX Datei die von 4MHz Takt ausgeht.
Da kannst du ja gerne mal mit rumspielen und an deinem Takt rumdrehen
bis das Display was vernünftiges anzeigt.
Angehängte Dateien:
#2930399
Lesenswert?

Hier ist das Bild, am Anfang werden die Linien ganz normal gezeichnet, 
doch wenn der Text dazukommt verschiebt sich ab dem 64 Pixel, alles um 1 
Pixel, in den Fuses habe ich 4MhZ eingestellt jedoch passiert nichts. 
Hier nochmal der Code für Bascom :
1
$regfile = "m16def.dat"
2
$crystal = 4000000
3

4
$lib "glcdks108.lbx"
5
$include "Font8x8.font"
6

7
Dim Bz As Byte
8
Bz = Mcucsr
9
Bz = Bz Or &H80
10
Mcucsr = Bz
11
Mcucsr = Bz
12

13

14

15
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , _
16
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4
17

18

19
Waitms 500
20

21
 Cls
22
 Line(0 , 10) -(127 , 10) , 255
23
 Line(0 , 54) -(127 , 54) , 255
24

25

26
 Wait 3
27

28
 Setfont Font8x8
29
 Lcdat 4 , 0 , "Hello World"
30
 Wait 1
31

32
End

Wisst ihr vielleicht woran das liegen könnte ?
Mfg Salex
Angehängte Dateien:
#2931084
Lesenswert?

$regfile = "m16def.dat"                                     ' specify 
the used micro
$crystal = 8000000                                          ' used 
crystal frequency
$baud = 9600                                                ' use baud 
rate
$hwstack = 32                                               ' default 
use 32 for the hardware stack
$swstack = 10                                               ' default 
use 10 for the SW stack
$framesize = 40                                             ' default 
use 40 for the frame space

$lib "glcdks108.lbx"
$include "Font6x8.font"
Angehängte Dateien:
#2931104
Lesenswert?

Danke Ronny für die Fonts und den Code,

Ich habe den jetzt übernommen jetzt kann ich sogar Linien und Text 
anzeigen lassen, ohne Probleme. Jedoch wenn ich jetzt ein Menü schreibe 
und mit 2 Tastern durch das Menü Navigiere verschieben sich die Linien 
wieder um einen Pixel nach unten, schon wieder genau in der Mitte des 
Displays...

Mfg Salex
#2931131
Lesenswert?

1
$regfile = "m16def.dat"
2
$crystal = 8000000
3
$baud = 9600
4
$hwstack = 32
5
$swstack = 10
6
$framesize = 40
7

8
$lib "glcdks108.lbx"
9
$include "Font6x8.font"
10

11
Config Pinc.0 = Input
12
Config Pinc.1 = Input
13
Config Pinc.2 = Input
14

15
Dim X As Integer
16
X = 5
17
Dim Y As Integer
18
Y = 0
19
Dim A As Integer
20

21

22
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , _
23
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4
24

25

26
Cls
27

28

29
Do
30

31
 Line(0 , 10) -(127 , 10) , 255
32
 Line(0 , 54) -(127 , 54) , 255
33

34
 If Pinc.2 = 1 Then
35
 Y = X + 1
36
 End If
37

38
 If Pinc.0 = 1 Then
39
 Y = X - 1
40
 End If
41

42
 If Y > 4 Then
43
 Y = 4
44
 End If
45

46
 If Y > 5 Then
47
 Y = 5
48
 End If
49

50

51
 If Pinc.0 = 1 Then
52
 Cls
53
 Lcdat 5 , 15 , "Optionen"
54
 Lcdat 4 , 15 , "Start"
55
 Lcdat 4 , 0 , "->"
56
 End If
57

58
 If Pinc.2 = 1 Then
59
 Cls
60
 Lcdat 5 , 15 , "Optionen"
61
 Lcdat 4 , 15 , "Start"
62
 Lcdat 5 , 0 , "->"
63
 End If
64

65

66

67

68
 Setfont Font6x8
69
 Lcdat 5 , 15 , "Optionen"
70
 Lcdat 4 , 15 , "Start"
71

72

73
 Loop
74

75
End

Ich weiss dass es "etwas" außergewöhnlich Programmiert ...
Und in den Fuses hab ich den Takt auf 8Mhz hoch !

Mfg Salex
#2931147
Lesenswert?

$regfile = "m16def.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 32
$swstack = 10
$framesize = 40

$lib "glcdks108.lbx"
$include "Font6x8.font"

Config Pinc.0 = Input
Config Pinc.1 = Input
Config Pinc.2 = Input

Dim X As Integer
X = 5
Dim Y As Integer
Y = 0
Dim A As Integer


Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd ,
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4


Cls

Waitms 500

Do

 Line(0 , 10) -(127 , 10) , 255
 Line(0 , 54) -(127 , 54) , 255

Waitms 200

 If Pinc.2 = 1 Then
 Y = X + 1
 End If

 If Pinc.0 = 1 Then
 Y = X - 1
 End If

 If Y > 4 Then
 Y = 4
 End If

 If Y > 5 Then
 Y = 5
 End If



 If Pinc.0 = 1 Then

 Cls

 Waitms 200

 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Start"
 Lcdat 4 , 0 , "->"
 End If

 If Pinc.2 = 1 Then

 Cls

 Waitms 200

 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Start"
 Lcdat 5 , 0 , "->"
 End If




 Setfont Font6x8

 Waitms 200

 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Start"


 Loop

End
#2931225
Lesenswert?

$regfile = "m16def.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 40
$swstack = 40
$framesize = 40
$lib "glcdks108.lbx"

Config Pinc.0 = Input
Config Pinc.1 = Input
Config Pinc.2 = Input

Dim X As Integer
X = 5
Dim Y As Integer
Y = 0
Dim A As Integer


Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd ,
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4


Cls

Waitms 500

Do

 Line(0 , 10) -(127 , 10) , 255
 Line(0 , 54) -(127 , 54) , 255

Waitms 200

 If Pinc.2 = 1 Then
 Y = X + 1
 End If

 If Pinc.0 = 1 Then
 Y = X - 1
 End If

 If Y > 4 Then
 Y = 4
 End If

 If Y > 5 Then
 Y = 5
 End If



 If Pinc.0 = 1 Then

 Cls

 Waitms 200

 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Start"
 Lcdat 4 , 0 , "->"
 End If

 If Pinc.2 = 1 Then

 Cls

 Waitms 200

 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Start"
 Lcdat 5 , 0 , "->"
 End If




 Setfont Font6x8

 Waitms 200

 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Start"
 Loop
End
$include "Font6x8.font"
#2931765
Lesenswert?

Kaum ist das Erste Problem gelöst kommt schon das Zweite ...
Nun wenn ich z.b eine Ladeleiste mache und nach 2 Sekunden einen Text 
Darüber erscheinen soll, zeigt das Komplette Display nurnoch zufällige 
Pixel an und nach dem Text sollte das Menü kommen, welches Komplett 
Verschoben ist.
1
$regfile = "m16def.dat"
2
$crystal = 8000000
3
$baud = 9600
4
$hwstack = 32
5
$swstack = 10
6
$framesize = 40
7

8
$lib "glcdks108.lbx"
9
$include "Font6x8.font"
10

11
Config Pinc.0 = Input
12
Config Pinc.1 = Input
13
Config Pinc.2 = Input
14

15

16
Dim X As Integer
17
X = 5
18
Dim Y As Integer
19
Y = 0
20

21

22

23

24
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , _
25
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4
26

27

28
 Cls
29

30
 Box(43 , 45) -(88 , 52) , 255
31

32

33
 Waitms 750
34

35
 Line(44 , 45) -(54 , 45) , 255
36
 Line(44 , 46) -(54 , 46) , 255
37
 Line(44 , 47) -(54 , 47) , 255
38
 Line(44 , 48) -(54 , 48) , 255
39
 Line(44 , 49) -(54 , 49) , 255
40
 Line(44 , 50) -(54 , 50) , 255
41
 Line(44 , 51) -(54 , 51) , 255
42
 Line(44 , 52) -(54 , 52) , 255
43

44
 Waitms 750
45

46
 Line(55 , 45) -(65 , 45) , 255
47
 Line(55 , 46) -(65 , 46) , 255
48
 Line(55 , 47) -(65 , 47) , 255
49
 Line(55 , 48) -(65 , 48) , 255
50
 Line(55 , 49) -(65 , 49) , 255
51
 Line(55 , 50) -(65 , 50) , 255
52
 Line(55 , 51) -(65 , 51) , 255
53
 Line(55 , 52) -(65 , 52) , 255
54

55
 Waitms 750
56

57
 Line(66 , 45) -(76 , 45) , 255
58
 Line(66 , 46) -(76 , 46) , 255
59
 Line(66 , 47) -(76 , 47) , 255
60
 Line(66 , 48) -(76 , 48) , 255
61
 Line(66 , 49) -(76 , 49) , 255
62
 Line(66 , 50) -(76 , 50) , 255
63
 Line(66 , 51) -(76 , 51) , 255
64
 Line(66 , 52) -(76 , 52) , 255
65

66
 Waitms 750
67

68
 Line(77 , 45) -(87 , 45) , 255
69
 Line(77 , 46) -(87 , 46) , 255
70
 Line(77 , 47) -(87 , 47) , 255
71
 Line(77 , 48) -(87 , 48) , 255
72
 Line(77 , 49) -(87 , 49) , 255
73
 Line(77 , 50) -(87 , 50) , 255
74
 Line(77 , 51) -(87 , 51) , 255
75
 Line(77 , 52) -(87 , 52) , 255
76

77
 Waitms 1500
78

79

80
 Lcdat 2 , 44 , "Hallo"
81

82
 Wait 2
83

84
 Cls
85

86

87
 Do
88

89
 Line(0 , 10) -(127 , 10) , 255
90
 Line(0 , 54) -(127 , 54) , 255
91

92
 If Pinc.2 = 1 Then
93
 Y = X + 1
94
 End If
95

96
 If Pinc.0 = 1 Then
97
 Y = X - 1
98
 End If
99

100

101
 If Y > 4 Then
102
 Y = 4
103
 End If
104

105
 If Y > 5 Then
106
 Y = 5
107
 End If
108

109

110

111
 If Pinc.0 = 1 Then
112
 Cls
113
 Lcdat 5 , 15 , "Optionen"
114
 Lcdat 4 , 15 , "Start"
115
 Lcdat 4 , 1 , "->"
116
 End If
117

118
 If Pinc.2 = 1 Then
119
 Cls
120
 Lcdat 5 , 15 , "Optionen"
121
 Lcdat 4 , 15 , "Start"
122
 Lcdat 5 , 1 , "->"
123
 End If
124

125

126

127

128
 Setfont Font6x8
129
 Lcdat 5 , 15 , "Optionen"
130
 Lcdat 4 , 15 , "Start"
131

132
 Loop
133

134
End

Ich weiss die Ladeleiste ist wieder Etwas Komisch geschrieben aber 
anders will es der GLCD einfach nicht anzeigen .
Gast #2931849
Lesenswert?

Hallo,

ich habe Dein Programm getestet und folgendes gändert:

Setfont Font6x8 muss vor Deiner ersten Textausgabe stehen, ich habe es 
z.B.
direkt nach Deiner Config Graphlcd geschrieben.
Dann wird Text und Grafik einwandfrei dargestellt.

Deine Tastereingänge konnte ich nicht testen, da bei mir eine völlig 
andere Belegung vorliegt.

Sepp
#2933458
Lesenswert?

Hallo,

ich programmiere gerade ein Menü, aber da die Testversion von Bascom nur 
4096 Bytes frei hat ist das nicht gerade Vorteilhaft, da ich nicht 
gerade "sparend" Programmiere..

Kann man dies irgendwie umgehen Ohne die Vollversion zu kaufen, z.B den 
Code Platzsparender zu schreiben ?

Hier der Code, ich weiss dass es wahrscheinlich "Sehr Schlimm" 
geschrieben ist aber ich Programmiere erst Seit Kurzem mit Bascom...
1
$regfile = "m16def.dat"
2
$crystal = 8000000
3
$baud = 9600
4
$hwstack = 32
5
$swstack = 10
6
$framesize = 40
7

8
$lib "glcdks108.lbx"
9
$include "Font6x8.font"
10

11
Config Pinc.0 = Input
12
Config Pinc.1 = Input
13
Config Pinc.2 = Input
14

15

16
Dim X As Integer
17
X = 4
18
Dim Y As Integer
19
Y = 0
20
Dim Z As Bit
21

22

23

24

25

26
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , _
27
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4
28
Setfont Font6x8
29

30

31
 Cls
32

33
 Box(43 , 45) -(88 , 52) , 255
34

35
 Lcdat 4 , 27 , "Konfiguriere."
36

37
 Waitms 750
38

39
 Line(44 , 45) -(54 , 45) , 255
40
 Line(44 , 46) -(54 , 46) , 255
41
 Line(44 , 47) -(54 , 47) , 255
42
 Line(44 , 48) -(54 , 48) , 255
43
 Line(44 , 49) -(54 , 49) , 255
44
 Line(44 , 50) -(54 , 50) , 255
45
 Line(44 , 51) -(54 , 51) , 255
46
 Line(44 , 52) -(54 , 52) , 255
47

48
 Waitms 750
49

50
 Lcdat 4 , 27 , "Konfiguriere.."
51

52

53
 Line(55 , 45) -(65 , 45) , 255
54
 Line(55 , 46) -(65 , 46) , 255
55
 Line(55 , 47) -(65 , 47) , 255
56
 Line(55 , 48) -(65 , 48) , 255
57
 Line(55 , 49) -(65 , 49) , 255
58
 Line(55 , 50) -(65 , 50) , 255
59
 Line(55 , 51) -(65 , 51) , 255
60
 Line(55 , 52) -(65 , 52) , 255
61

62
 Waitms 750
63
 Lcdat 4 , 27 , "Konfiguriere..."
64

65
 Line(66 , 45) -(76 , 45) , 255
66
 Line(66 , 46) -(76 , 46) , 255
67
 Line(66 , 47) -(76 , 47) , 255
68
 Line(66 , 48) -(76 , 48) , 255
69
 Line(66 , 49) -(76 , 49) , 255
70
 Line(66 , 50) -(76 , 50) , 255
71
 Line(66 , 51) -(76 , 51) , 255
72
 Line(66 , 52) -(76 , 52) , 255
73

74
 Waitms 750
75

76
 Line(77 , 45) -(87 , 45) , 255
77
 Line(77 , 46) -(87 , 46) , 255
78
 Line(77 , 47) -(87 , 47) , 255
79
 Line(77 , 48) -(87 , 48) , 255
80
 Line(77 , 49) -(87 , 49) , 255
81
 Line(77 , 50) -(87 , 50) , 255
82
 Line(77 , 51) -(87 , 51) , 255
83
 Line(77 , 52) -(87 , 52) , 255
84

85
 Waitms 1500
86

87
 Cls
88

89
 Lcdat 4 , 53 , "DRINK"
90

91
 Wait 3
92

93
 Cls
94

95
 Do
96

97
 Line(0 , 10) -(127 , 10) , 255
98
 Line(0 , 54) -(127 , 54) , 255
99

100
 If Pinc.2 = 1 Then
101
 Y = X + 1
102
 End If
103

104
 If Pinc.0 = 1 Then
105
 Y = X - 1
106
 End If
107

108
 If Pinc.1 = 1 Then
109
 Z = 1
110
 End If
111

112
If Z = 0 Then
113

114
 If Y < 4 Then
115
 Y = 4
116
 End If
117

118
 If Y > 5 Then
119
 Y = 5
120
 End If
121
End If
122

123
If Z = 1 Then
124

125
 If Y < 3 Then
126
 Y = 3
127
 End If
128

129
 If Y > 7 Then
130
 Y = 7
131
 End If
132

133
End If
134

135

136
 If Pinc.0 = 1 Then
137
 Waitms 100
138
 Cls
139
 Lcdat 5 , 15 , "Optionen"
140
 Lcdat 4 , 15 , "Getraenke"
141
 Lcdat 4 , 1 , "->"
142
 End If
143

144
 If Pinc.2 = 1 Then
145
 Waitms 100
146
 Cls
147
 Lcdat 5 , 15 , "Optionen"
148
 Lcdat 4 , 15 , "Getraenke"
149
 Lcdat 5 , 1 , "->"
150
 End If
151

152
 If Y = 4 And Pinc.1 = 1 Then
153
 Waitms 100
154
 X = 3
155
 Cls
156
 Lcdat 3 , 15 , "Cola"
157
 Lcdat 4 , 15 , "Fanta"
158
 Lcdat 5 , 15 , "Sprite"
159
 Lcdat 6 , 15 , "Ice Tea"
160
 Lcdat 7 , 15 , "Wasser"
161
 Lcdat 3 , 0 , "->"
162

163
   If Pinc.2 = 1 And X = 3 Then
164
   Waitms 100
165
   Cls
166
   Lcdat 3 , 15 , "Cola"
167
   Lcdat 4 , 15 , "Fanta"
168
   Lcdat 5 , 15 , "Sprite"
169
   Lcdat 6 , 15 , "Ice Tea"
170
   Lcdat 7 , 15 , "Wasser"
171
   Lcdat 4 , 0 , "->"
172
   End If
173

174
   If Pinc.2 = 1 And X = 4 Then
175
   Waitms 100
176
   Cls
177
   Lcdat 3 , 15 , "Cola"
178
   Lcdat 4 , 15 , "Fanta"
179
   Lcdat 5 , 15 , "Sprite"
180
   Lcdat 6 , 15 , "Ice Tea"
181
   Lcdat 7 , 15 , "Wasser"
182
   Lcdat 5 , 0 , "->"
183
   End If
184

185
   If Pinc.2 = 1 And X = 5 Then
186
   Waitms 100
187
   Cls
188
   Lcdat 3 , 15 , "Cola"
189
   Lcdat 4 , 15 , "Fanta"
190
   Lcdat 5 , 15 , "Sprite"
191
   Lcdat 6 , 15 , "Ice Tea"
192
   Lcdat 7 , 15 , "Wasser"
193
   Lcdat 6 , 0 , "->"
194
   End If
195

196
   If Pinc.2 = 1 And X = 6 Then
197
   Waitms 100
198
   Cls
199
   Lcdat 3 , 15 , "Cola"
200
   Lcdat 4 , 15 , "Fanta"
201
   Lcdat 5 , 15 , "Sprite"
202
   Lcdat 6 , 15 , "Ice Tea"
203
   Lcdat 7 , 15 , "Wasser"
204
   Lcdat 7 , 0 , "->"
205
   End If
206

207

208

209
 End If
210

211

212
 Lcdat 5 , 15 , "Optionen"
213
 Lcdat 4 , 15 , "Getraenke"
214

215
 Loop
216

217
End
#2933530
Lesenswert?

Hallo,

so was ...
> Line(44 , 45) -(54 , 45) , 255
> Line(44 , 46) -(54 , 46) , 255
> Line(44 , 47) -(54 , 47) , 255
> Line(44 , 48) -(54 , 48) , 255
> Line(44 , 49) -(54 , 49) , 255
> Line(44 , 50) -(54 , 50) , 255
> Line(44 , 51) -(54 , 51) , 255
> Line(44 , 52) -(54 , 52) , 255
kann man ja locker mit einer Schleife machen
for x=45 to 52
 Line(44 , x) -(54 , x) , 255
next
oder gibts auch einen Befehl für ein gefülltes Rechteck?

bei den Menüpunkten kannst du mal abgesehen davon das ein derartiger 
Menüaufbau extrem unübersichtlich wird, sparen indem du wiederholende 
Sachen zusammenfasst. Du hast z.B. immer ein Wait (zum Entprellen?!!?) 
und ein CLS.
Frage ob ab sich irgendwas an den Eingabeelementen geändert hat, wenn ja 
dann mach das wait und cls und entscheide dann was neu darzustellen ist.

Sascha
#2933733
Lesenswert?

Ich hab jetzt die Ladeleiste abgeändert und schonmal ein bisschen 
Speicher gewinnen können.

Ja das Wait ist zum Entprellen da...

Wie gesagt ich bin ein ziemlicher Anfänger in Bascom, das Menü hätte ich 
jetzt "logisch" aufgebaut mit 10.000.000 von If schleifen ...

Salex
Gast #2933908
Lesenswert?

Hallo,

ich habe mal versucht etwas zu optimieren, werde Dir aber nicht fertigen 
Code liefern.
Du hast wieder bei LCDAT für X eine 0 genommen, was Du aber bereits 
wissen solltest das geht nicht.

$regfile = "m16def.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 32
$swstack = 10
$framesize = 40

$lib "glcdks108.lbx"
$include "Font6x8.font"

Config Pinc.0 = Input
Config Pinc.1 = Input
Config Pinc.2 = Input


Dim X As Integer
X = 4
Dim Y As Integer
Y = 0
Dim Z As Bit
Dim N As Byte
Dim X0 As Byte
Dim Y0 As Byte
Dim X1 As Byte







Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , 
_
Ce = 3 , Ce2 = 2 , Reset = 0 , Rd = 5 , Cd = 6 , Enable = 4
Setfont Font6x8


 Cls

 Box(43 , 45) -(88 , 52) , 255

 Lcdat 4 , 27 , "Konfiguriere."

 Waitms 750
 X0 = 44
 X1 = 54
 For N = 1 To 4
   For Y0 = 45 To 52
      Line(x0 , Y0) -(x1 , Y0) , 255
   Next
   Waitms 750
   Lcdat 4 , 27 , "Konfiguriere.."
   X0 = X0 + 11
   X1 = X1 + 11
 Next N
 Waitms 750



 Cls

 Lcdat 4 , 53 , "DRINK"

 Wait 3

 Cls

 Do

 Line(0 , 10) -(127 , 10) , 255
 Line(0 , 54) -(127 , 54) , 255

 If Pinc.2 = 1 Then
 Y = X + 1
 End If

 If Pinc.0 = 1 Then
 Y = X - 1
 End If

 If Pinc.1 = 1 Then
 Z = 1
 End If

If Z = 0 Then

 If Y < 4 Then
 Y = 4
 End If

 If Y > 5 Then
 Y = 5
 End If
End If

If Z = 1 Then

 If Y < 3 Then
 Y = 3
 End If

 If Y > 7 Then
 Y = 7
 End If

End If


 If Pinc.0 = 1 Then
 Gosub Delay_100ms
 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Getraenke"
 Lcdat 4 , 1 , "->"
 End If

 If Pinc.2 = 1 Then
 Gosub Delay_100ms
 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Getraenke"
 Lcdat 5 , 1 , "->"
 End If

 If Y = 4 And Pinc.1 = 1 Then
 Gosub Delay_100ms
 X = 3
 Cls
 Gosub Text
 Lcdat 3 , 1 , "->"

   If Pinc.2 = 1 And X = 3 Then
   Gosub Delay_100ms
   Gosub Text
   Lcdat 4 , 1 , "->"
   End If

   If Pinc.2 = 1 And X = 4 Then
   Gosub Delay_100ms
   Gosub Text
   Lcdat 5 , 1 , "->"
   End If

   If Pinc.2 = 1 And X = 5 Then
   Gosub Delay_100ms
   Gosub Text
   Lcdat 6 , 1 , "->"
   End If

   If Pinc.2 = 1 And X = 6 Then
   Gosub Delay_100ms
   Gosub Text
   Lcdat 7 , 1 , "->"
   End If



 End If


 Lcdat 5 , 15 , "Optionen"
 Lcdat 4 , 15 , "Getraenke"

 Loop

End

Text:
   Lcdat 3 , 15 , "Cola"
   Lcdat 4 , 15 , "Fanta"
   Lcdat 5 , 15 , "Sprite"
   Lcdat 6 , 15 , "Ice Tea"
   Lcdat 7 , 15 , "Wasser"
Return

Delay_100ms:
   Waitms 100
   Cls
Return
#2933925
Lesenswert?

Ist verständlich und finde ich auch besser so dass du mir nicht den 
fertigen Code lieferst, ich will schließlich auch was lernen. Oh das mit 
der 0 habe ich völligst übersehen, danke !
Jedoch verstehe ich diesen Teil nicht in deinem Code
1
 X0 = 44
2
 X1 = 54
3
 For N = 1 To 4
4
   For Y0 = 45 To 52
5
      Line(x0 , Y0) -(x1 , Y0) , 255
6
   Next
7
   Waitms 750
8
   Lcdat 4 , 27 , "Konfiguriere.."
9
   X0 = X0 + 11
10
   X1 = X1 + 11
11
 Next N

Mfg Salex
#2934999
Lesenswert?

was gibts da nicht zu verstehen?

die innere Schleife (Y0) zeichnet ein gefülltes Rechteck, wie ich schon 
vorgeschlagen hatte. Die äußere Schleife (N) sorgt dafür, das vier 
dieser Rechtecke gezeichnet werden. Wobei die Textausgabe innerhalb der 
Schleife sinnlos ist, da der Text so mehrmals an der selben Stelle 
ausgegeben wird - in deinem Code hast du den Text aber auch 3x an der 
selben Stelle ausgegeben?!

Sascha
#2935214
Lesenswert?

Achso Ok,
danke !
Jetzt zu noch einer Frage, könnte man das Vielleicht zusammenfassen ?
1
If Y = 4 And Pinc.1 = 1 Then
2
 Gosub Delay_100ms
3
 X = 3
4
 Cls
5
 Gosub Text
6
 Lcdat 3 , 1 , "->"
7

8
   If Pinc.2 = 1 And X = 3 Then
9
   Gosub Delay_100ms
10
   Gosub Text
11
   Lcdat 4 , 1 , "->"
12
   End If
13

14
   If Pinc.2 = 1 And X = 4 Then
15
   Gosub Delay_100ms
16
   Gosub Text
17
   Lcdat 5 , 1 , "->"
18
   End If
19

20
   If Pinc.2 = 1 And X = 5 Then
21
   Gosub Delay_100ms
22
   Gosub Text
23
   Lcdat 6 , 1 , "->"
24
   End If
25

26
   If Pinc.2 = 1 And X = 6 Then
27
   Gosub Delay_100ms
28
   Gosub Text
29
   Lcdat 7 , 1 , "->"
30
   End If
Da bei mir jetzt schon manchmal die Anzeige kommt, dass ich mehr als 
4096 Bytes benutzte.
Gast #2935272
Lesenswert?

Zum Beispiel so:

'Deinen ersten Block habe ich nicht eingefügt, da hier ein anderer Pin 
'abgefragt wird, und wo ist das END IF ?

   If Pinc.2 = 1 Then
      Select Case X
         Case 3 : Y1 = 4
         Gosub Text
         Case 4 : Y1 = 5
         Gosub Text
         Case 5 : Y1 = 6
         Gosub Text
         Case 6 : Y1 = 7
         Gosub Text
      End Select
   End If

Text:
   Gosub Delay_100ms
   Lcdat 3 , 15 , "Cola"
   Lcdat 4 , 15 , "Fanta"
   Lcdat 5 , 15 , "Sprite"
   Lcdat 6 , 15 , "Ice Tea"
   Lcdat 7 , 15 , "Wasser"
   Lcdat Y1 , 1 , "->"
Return

Delay_100ms:
   Waitms 100
   Cls
Return

'Wobei Du natürlich Y1 erst als Variable (Byte) deklarieren musst.

'@Sascha

'Ich habe das Programm sinnfrei etwas optimiert, wollte die 
grundsätzliche 'Programmierung nicht in Frage stellen.


'Sepp
#2935400
Lesenswert?

Ja das Endif habe ich vergessen mit herauszukopieren ...
Das mit den Cases kapier ich noch nichts richtig, da ich noch Bascom 
Neuling bin ...

Und wie kürtzt man sowas, darüber zerbreche ich mir seit 2 Stunden den 
Kopf und komme einfach auf keine Sinnvolle Lösung ...
1
 If Y = 3 And Pinc.1 = 1 Then
2
 Compare2 = 40
3
 Gosub Progress
4
 End If
5

6
 If Y = 4 And Pinc.1 = 1 Then
7
 Compare2 = 80
8
 Gosub Progress
9
 End If
10

11
 If Y = 5 And Pinc.1 = 1 Then
12
 Compare2 = 120
13
 Gosub Progress
14
 End If
15

16
 If Y = 6 And Pinc.1 = 1 Then
17
 Compare2 = 160
18
 Gosub Progress
19
 End If
20

21
 If Y = 7 And Pinc.1 = 1 Then
22
 Compare2 = 200
23
 Gosub Progress
24
 End If
25

26
 If Y = 8 And Pinc.1 = 1 Then
27
 Compare2 = 240
28
 Gosub Progress
29
 End If

Mfg Salex
Gast #2935413
Lesenswert?

Hi

>Und wie kürtzt man sowas, darüber zerbreche ich mir seit 2 Stunden den
>Kopf und komme einfach auf keine Sinnvolle Lösung ...

Ob das BASCOM so versteht weiß ich nicht

 If Y => 3 And  Y<=8 and Pinc.1 = 1 Then
 Compare2 = 40*(Y-2)
 Gosub Progress
 End If

MfG Spess
Gast #2936831
Lesenswert?

>Und wie kürtzt man sowas

Genau wie ich es Dir im letzten Beispiel gezeigt habe,
nur das dieses mal als Bedingung PinC.1 eine logische 1 haben muss.

Das Y kannst Du wieder mit Select Case Y abfragen.

Ich würde Dir empfehlen, die Beispiele von Bascom anzusehen, auch in der 
Hilfe gibt es jede Menge Informationen.

Da Du dich aber so knapp an der 4K Grenze bewegst, wirst Du um eine 
Vollversion nicht herumkommen.

Das Speicheraufwendigste ist das Graphische Display + Zeichensatz.


Sepp

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren