Changing the prompt / StationID¶
Date: | 2017-10-01 |
---|
Intro¶
In the RS485 bus project several boards are
connected to one bus. In order to see to which controller board
(station) exactly I am connected, I added the notion of a
stationID
, which is displayed in the ready prompt. Since version
6.3 all prompt words are deferred so we can quite easily change them
without resorting to assembly.
This is an item in the section because we can.
Also see Prompts in the Cookbook section.
Putting it all together¶
The station ID is a number ranging from 0
to 127
. This
limitation comes in, because addresses on the mentioned bus are 7
bit wide. The value itself is stored in EEPROM
#include avr-values.frt
$007f Evalue stationID
Then we define a replacement function to print out the prompt including the station ID (in hexadecimal notation):
: .stationID_ready
cr
[char] ~ emit
base @ $10 base ! stationID 2 u0.r base !
[char] > emit space
;
In order to activate this new prompt, we update the corresponding deferred word:
#include is.frt
: init
\ ...
['] .stationID_ready is .ready
;
The result looks like this:
> ' .stationID_ready is .ready
ok
~7F> words
.stationID_ready stationID ...
~7F> $0055 to stationID
ok
~55>