Es gibt in
Bascom keine Bit-Variablen.
Das ist nicht ganz richtig, wie den Bascom Language-Fundamentals zu entnehmen ist:
Data Types
Every variable in Bascom has a data type that determines what can be stored in the variable. The next section summarizes the elementary data types.
Elementary Data Types• |
Bit (1/8 byte). A bit can hold only the value 0 or 1. A group of 8 bits is called a byte. |
• |
Byte (1 byte). Bytes are stores as unsigned 8-bit binary numbers ranging in value from 0 to 255. |
• |
Integer (two bytes). Integers are stored as signed sixteen-bit binary numbers ranging in value from -32,768 to +32,767. |
(usw...)
Die Lösung von Radbruch zum Erfassen des aktuellen Taster-Status hat (mit Verlaub) den Fallstrick, dass zu der If-Abfrage in diesem Fall auch eine Else-Anweisung gehört:
Wenn z.B. PINC.0 Low ist, wird zwar das Bit status_taster.0 auf 1 gesetzt. Ist der Eingang aber irgendwann wieder High, wird die If-Anweisung einfach übersprungen, aber das Bit bleibt gesetzt! Man müsste es also mindestens mal so schreiben:
Code:
If PINC.0 = 0 then status_taster.0 = 1 else status_taster.0 = 0
If PINC.1 = 0 then status_taster.1 = 1 else status_taster.1 = 0
...
Einfacher wäre es natürlich so:
Code:
status_taster.0 = NOT PINC.0
status_taster.1 = NOT PINC.1
...
Und noch einfacher wäre es, wenn die 16 Taster an zwei "ganzen" Ports liegen (also z.B. PINC.0 - PINC.7 und PIND.0 - PIND.7):
Code:
Dim status_taster as Word
status_taster = PINC
shift status_taster, left, 8
status_taster = status_taster + PIND
Dann werde ich mich mal nach einer anderen Lösung umsehen
Vielleicht sind das ja ein paar Denkanstöße
Lesezeichen