eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'DigitalLedDisplay':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: DigitalLedDisplay


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--DigitalLedDisplay

Package:
stx:libwidg3
Category:
Views-Misc
Version:
rev: 1.45 date: 2024/04/22 17:08:53
user: stefan
file: DigitalLedDisplay.st directory: libwidg3
module: stx stc-classLibrary: libwidg3

Description:


a simple fun-view, displaying a numeric value as a 7-Segment LED-line.
The model is a simple ValueHolder, holding a number.
This widget can be used as a component in calculator-like applications.

copyright

COPYRIGHT (c) 1997 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

image specs
o  constructFromSegments: segmentList
(self constructFromSegments:#(A B C)) inspect

Usage example(s):

     |v|
     v := TopView new extent:100@100.
     v openAndWaitUntilVisible.
     View drawingOnClosedDrawableSignal catch:[
         [true] whileTrue:[
            3 timesRepeat:[    
                #(A B C D E F) do:[:seg |
                    (self constructFromSegments:{seg}) displayOn:v at:0@0.
                    Delay waitForSeconds:0.1.
                ].
            ].    
            (self constructFromSegments:#(A B C D E F G)) displayOn:v at:0@0.
            Delay waitForSeconds:0.5.
            self ledOff displayOn:v at:0@0.
            Delay waitForSeconds:0.5.
            (self constructFromSegments:#(A B C D E F G)) displayOn:v at:0@0.
            Delay waitForSeconds:0.5.
            self ledOff displayOn:v at:0@0.
         ].
     ].

o  led0
Icon flushCachedIcons
self led0

o  led1
Icon flushCachedIcons.
self led1

o  led2
Icon flushCachedIcons.
self led2

o  led3
Icon flushCachedIcons.
self led3

o  led4
Icon flushCachedIcons.
self led4

o  led5
Icon flushCachedIcons.
self led5

o  led6
Icon flushCachedIcons.
self led6

o  led7
Icon flushCachedIcons.
self led7

o  led8
Icon flushCachedIcons.
self led8

o  led9
Icon flushCachedIcons.
self led9

o  ledA
Icon flushCachedIcons.
self ledA

o  ledC
Icon flushCachedIcons.
self ledC

o  ledCol
This resource specification was automatically generated
by the ImageEditor of ST/X.

Usage example(s):

     self ledCol inspect
     ImageEditor openOnClass:self andSelector:#ledCol
     Icon flushCachedIcons

o  ledConstructFromSegments: segments named: name
Icon flushCachedIcons

o  ledE
Icon flushCachedIcons
self ledE

o  ledF
Icon flushCachedIcons
self ledF

o  ledG
Icon flushCachedIcons
self ledG

o  ledH
Icon flushCachedIcons
self ledH

o  ledI
Icon flushCachedIcons
self ledI

o  ledJ
Icon flushCachedIcons
self ledJ

o  ledL
Icon flushCachedIcons
self ledL

o  ledMinus
Icon flushCachedIcons.
self ledMinus

o  ledO
Bitmaps := nil
Icon flushCachedIcons
self ledO

o  ledOff
This resource specification was automatically generated
by the ImageEditor of ST/X.

Usage example(s):

     self ledOff inspect
     ImageEditor openOnClass:self andSelector:#ledOff
     Icon flushCachedIcons

o  ledOffForConstruction
KEEP colormap and depth. Used to construct other bitmaps

o  ledP
Icon flushCachedIcons
self ledP

o  ledPeriod
This resource specification was automatically generated
by the ImageEditor of ST/X.

Usage example(s):

     self ledPeriod inspect
     ImageEditor openOnClass:self andSelector:#ledPeriod
     Icon flushCachedIcons

o  ledS
Icon flushCachedIcons
self ledS

o  ledZ
Icon flushCachedIcons
self ledZ

o  ledb
Icon flushCachedIcons.
self ledb

o  ledd
Icon flushCachedIcons.
self ledd

o  ledh
Icon flushCachedIcons
self ledh

o  ledm
Icon flushCachedIcons.
self ledm

o  ledn
Icon flushCachedIcons
self ledn

o  ledo
Icon flushCachedIcons.
self ledo

o  ledq
Icon flushCachedIcons.
self ledq

o  ledr
Icon flushCachedIcons.
self ledr

o  ledt
Icon flushCachedIcons
self ledt

o  ledu
Icon flushCachedIcons
self ledu

o  ledv
Icon flushCachedIcons
self ledv

o  ledw
Icon flushCachedIcons.
self ledw

o  ledy
Icon flushCachedIcons
self ledy

o  segmentA
KEEP colormap and depth. Used to construct other bitmaps

o  segmentB
KEEP colormap and depth. Used to construct other bitmaps

o  segmentC
KEEP colormap and depth. Used to construct other bitmaps

o  segmentD
KEEP colormap and depth. Used to construct other bitmaps

o  segmentE
KEEP colormap and depth. Used to construct other bitmaps

o  segmentF
KEEP colormap and depth. Used to construct other bitmaps

o  segmentG
KEEP colormap and depth. Used to construct other bitmaps

initialization
o  bitmapFor: aCharacter
Bitmaps := nil
self bitmapFor:$a
self bitmapFor:$Y
self bitmapFor:$y

o  bitmaps
marked as obsolete by demo at 03-04-2023

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  initBitmap: symbol

queries - plugin
o  aspectSelectors


Instance protocol:

accessing
o  numberOfDigits
return the number of digits to display

o  numberOfDigits: n
specify the number of digits to display

o  numberScale
return the number of post-decimal-point digits

o  numberScale: n
define the number of post-decimal-point digits

o  radix
return the number radix;
2..16 are supported; 10 is the default

o  radix: tenOrSixteen
set the number radix;
2..16 are supported; 10 is the default

o  showLeadingZeros
return true if leading zeros are shown

o  showLeadingZeros: aBoolean
controls if leading zeros are shown

accessing channels
o  ledColorChannel

o  ledColorChannel: aValueHolder

accessing-color & font
o  foregroundColor: aColor
change the led's color

change & update
o  update: something with: aParameter from: changedObject
redraw myself, when the model changes

drawing
o  redrawX: rx y: ry width: rw height: rh
update my view

events
o  sizeChanged: how from: oldExtentOrNil
my view has changed the size (not the contents)

initialization
o  fetchDeviceResources
fetch device colors, to avoid reallocation at redraw time

o  initialize
(comment from inherited method)
must be called if redefined

queries
o  computePreferredExtent
(comment from inherited method)
return my computed preferred extent - this is the minimum size I would like to have.
If there are any components, a rectangle enclosing them
is returned. Otherwise, the actual extent is returned.


Examples:


displaying integers:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := 12345 asValue).
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
HEX display (integers only):
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds radix:16.
  leds model:(valueHolder := 12345 asValue).
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
binary display (integers only):
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds radix:2.
  leds model:(valueHolder := 345 asValue).
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
octal display (integers only):
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds radix:8.
  leds model:(valueHolder := 345 asValue).
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
displaying floats:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := 12345.123 asValue).
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
displaying fixedPoint numbers:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := 12345.888 asValue).
  leds numberScale:2.
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 0.01)
      ]
  ] fork
scientific numbers:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := -3.1415e15 asValue).
  leds numberOfDigits:12.
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 10000)
      ]
  ] fork
number too big:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := 9995 asValue).
  leds numberScale:2.
  leds numberOfDigits:4.
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
changing the color (above 100):
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := 95 asValue).
  leds numberScale:2.
  leds numberOfDigits:4.
  leds foregroundColor:Color green.
  top openAndWaitUntilVisible.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1).
          valueHolder value >= 100 ifTrue:[
              leds foregroundColor:Color red.
          ]
      ]
  ] fork
displaying strings:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := Time now printString asValue).
  top openAndWaitUntilVisible.
displaying strings:
  |top leds valueHolder|

  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := ' ' asValue).
  top openAndWaitUntilVisible.

  [
      [:exit |
          #('AAAAA'
            'bbbbb'
            'CCCCC'
            'ddddd'
            'EEEEE'
            'FFFFF'
            'uuuuu'
            'PPPPP'
            'rrrrr'
            'ooooo'
          ) do:[:s |
              top realized ifFalse:[exit value:nil].
              valueHolder value:s.
              Delay waitForSeconds:1.
          ]
      ] loopWithExit.
  ] fork
animated string:
  |top leds valueHolder|

  Bitmaps := nil.
  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds model:(valueHolder := ' ' asValue).
  top openAndWaitUntilVisible.

  [
      |s d i|

      s := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
      i := 1.
      [:exit |
          d := (s, s) copyFrom:i count:(s size).
          top realized ifFalse:[exit value:nil].
          valueHolder value:d.
          Delay waitForSeconds:1.
          i := i + 1.
          i >= s size ifTrue:[ i := 1 ].
      ] loopWithExit.
  ] fork
  |top leds valueHolder text|

  text := ' Hello : open : close : play : shuffle : no disc : start : stop : run : fail : error : setup : help : on : off : yes : no : hot : cold : '.
  
  top := StandardSystemView extent:200@200.
  leds := DigitalLedDisplay origin:0.0@0.0 corner:1.0@30 in:top.
  leds numberOfDigits:10.
  leds model:(valueHolder := '' asValue).
  top openAndWaitUntilVisible.

  [
      [:exit |
          1 to:text size do:[:start |
              |subString|

              subString := (text,text) copyFrom:start to:start+9.
              top realized ifFalse:[exit value:nil].
              valueHolder value:subString.
              Delay waitForSeconds:0.25.
          ]
      ] loopWithExit.
  ] fork


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 23 Nov 2024 13:06:47 GMT