Document fait avec Nvu Document made with Nvu




Emulator bar graph driver

FORTH mini system

Instructions
Use
Example

Principle

If the bar graph of the emulator is an addressable register in the extension registers area of the FORTH core described as follows:

277 (0x115):

write: value[15..0]
bit 0 is corresponding to the left green indicator
bit 15 is corresponding to the right red indicator

lit indicator if value=1


The driver will allow to facilitate the use of this registes while making use of the real-time kernel. The principle consists in making i possible the developer to indicate the desired level without to have to manage the peak value memory effect.

For the FORTH mini system emulator, the 16 indicators of the bar graph are wired on the components PCF8574 and PCF8574A of I2C port numero 2. The bit 7 of the PCF8574 is corresponding to the left green indicator and the bit 0 of the PCF8574A to the right red indicator. The electrical schematic is the following:




Instructions

- CW_BARRE_GRAPHE 277

Numero of the bar graph extension register.
This instruction does not exist in the FORTH mini system,

The access to the indicators is made with the instructions I2C_PCF8574_C@,
I2C_PCF8574_C!, I2C_PCF8574A_C@ and I2C_PCF8574A_C! numero 2.

niveau BARRE_GRAPHE -

Displaying of the desired level.
niveau is the value of the desired level (0 minimum to 16 maximum).
If niveau is negative, the driver task is cleared.


Use

The driver not being integrated into the kernel, it is initially necessary to compile the source file barre_graphe.txt before being able to use it.

For the FORTH mini system, it is initialy necessary to compile first the I2C drivers described in the source files pcf8574.txt and pcf8574a.txt then compile barre_graphe.txt.

The following sequence is corresponding to the displaying of level 10:

10 BARRE_GRAPHE

The driver manages automaticaly the task installation which memorizes the maximum level during 250 ms. This is realized with priority 49152. This task is cleared when the level is negative.

Example

The following program uses the analogical input output of the emulator and needs also the installation of the source file analogique.txt before to be able to use it:

DECIMAL

: PROG_ANALOGIQUE
 ( Absolute value of the input and division by 8 for the bar graph )
 ABS DUP 4/ 2/ BARRE_GRAPHE
;

FIND PROG_ANALOGIQUE 2000 SYNC_ANALOGIQUE

To remove this program, it is enough to make:

0 DUP BARRE_GRAPHE DUP SYNC_ANALOGIQUE

Here is a video: