Updated 2011-01-24 23:32:31 by AK

by Theo Verelst

Using bwise, we make a display block with the

procedure called from a bwise or tcl console, or with a right-click on the canvas. The resulting block has a 5x7 dot pattern on it, which however is static. To make each dot (little round oval in Tk) responsive to mouse clicks, the 'dot' tagged items are given a binding like:
 $mc bind dot <Button-1> {
    set i [$mc find withtag current];
    if {[$mc itemcget $i -fill] == "red"} {
       $mc itemco $i -fill yellow
    } {
       $mc itemco $i -fill red

Now clicking the left mouse button on the block makes the dots 'on' or 'off', see image below.

To clear all dots again:
 foreach i [tag_and {display dot}]  { $mc itemco $i -fill yellow }

This works because the dots on the yellow rectangle all have a common, unique tag, called 'dot', so the bwise provided procedure 'tag_and' can give us the items on the canvas which most likely are exactly all dots on the display block (all items in a block share the same first tag: the name of the block). The itemconfigure of all those items on the main bwise canvas pointed to by the variable mc makes the circles the same inner color as the background of theblock, and leaves the black outline in place.

To read the resulting pattern, the following little script is used, rendering the data in a way which leaves bit 0 zero, and reads columnwise:
 for {set i 4} {$i>=0} {incr i -1} {
    set o {};
    for {set j 7} {$j>=0} {incr j -1} {
       set k [tag_and "display dot x$i y$j"] ;
       if {[$mc itemcget $k -fill] == "red"} { set ii 1 } {set ii 0} ;
       append o $ii
    } ;
    puts [format {%x} [fromBinary $o]]
    puts -nonewline "0x[format {%x} [fromBinary $o]], "
 } ; puts {}

The result looks like:
   unsigned char dis57[8] = {0xf8, 0x24, 0x22, 0x24, 0xf8} ;

Minus the prepended unsigned char .... etc. The hex numbers are used in the Blackfin DSP interupt routine to respond to the row counter index coming from the Xilinx based display multiplexer I made, which writes the right column word back to the xilinx which drives the display with it.

The result is visible in the next image:

See also [1] and [2] where in a little while I''ll have added the Xilinx CPLD demo board and EZLITE BF533 DSP board (Open) Sources (Check back later, I'm a bit busy right now).

Who says Tcl sucks... I don't think so. If the Analog Devices VisualDSP environment would have more tcl included in it (it does some tcl scripting with the built in 8.3, but not so much, see VisualDSP builtin Tcl use), the whole process might be automated. And Xilinx can be programmed in VHDL, too, though the devenv (webpack) has no scripting possibility to my knowledge, which can also be automatically generated with tcl, and of course from bwise. That should prove powerfull enough for some real work.

The line at the bottom of the A in the actual display image is reversed because of a 'hardware' cursor running over the display, which happened to be there at the time of the picture-click...

In the last picture, the left big board is the DSP , the upper midddle one the Xilinx experimentors board, and the 5x7 display is visible on the lowermiddle breadboard, with the colored wires connected to the xilinx. The gray cable between the xilinx and the DSP board I've made myself, to make the setup possible.

Just for the reccord, the setup is not just intended to be used with tcl/bwise as a programmers language/environment, the idea is that for instance the displays and the rotary know (which now automatically shows incrementing and decrementing numbers on the 7 seg display) are to work in real life application linked with a pc, such as for sythesizer applications, and I want to use tk/bwise at user level, too. See also LED display driven by the parallel port under tcl control , this could be made better/easier/bigger by the xilinx setup, thoug hsome reasonable link would be needed with tcl, maybe I'll use a usb-to-serial chip, or a microcontroller with network connection.

See also Xilinx demo board pin names extractor, Xilinx Spartan 3 Demo rs232 clock set