|
Class: DigitalLedDisplay
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
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.
copyrightCOPYRIGHT (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.
image specs
-
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.
].
].
|
-
led0
-
Icon flushCachedIcons
self led0
-
led1
-
Icon flushCachedIcons.
self led1
-
led2
-
Icon flushCachedIcons.
self led2
-
led3
-
Icon flushCachedIcons.
self led3
-
led4
-
Icon flushCachedIcons.
self led4
-
led5
-
Icon flushCachedIcons.
self led5
-
led6
-
Icon flushCachedIcons.
self led6
-
led7
-
Icon flushCachedIcons.
self led7
-
led8
-
Icon flushCachedIcons.
self led8
-
led9
-
Icon flushCachedIcons.
self led9
-
ledA
-
Icon flushCachedIcons.
self ledA
-
ledC
-
Icon flushCachedIcons.
self ledC
-
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
|
-
ledConstructFromSegments: segments named: name
-
Icon flushCachedIcons
-
ledE
-
Icon flushCachedIcons
self ledE
-
ledF
-
Icon flushCachedIcons
self ledF
-
ledG
-
Icon flushCachedIcons
self ledG
-
ledH
-
Icon flushCachedIcons
self ledH
-
ledI
-
Icon flushCachedIcons
self ledI
-
ledJ
-
Icon flushCachedIcons
self ledJ
-
ledL
-
Icon flushCachedIcons
self ledL
-
ledMinus
-
Icon flushCachedIcons.
self ledMinus
-
ledO
-
Bitmaps := nil
Icon flushCachedIcons
self ledO
-
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
|
-
ledOffForConstruction
-
KEEP colormap and depth. Used to construct other bitmaps
-
ledP
-
Icon flushCachedIcons
self ledP
-
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
|
-
ledS
-
Icon flushCachedIcons
self ledS
-
ledZ
-
Icon flushCachedIcons
self ledZ
-
ledb
-
Icon flushCachedIcons.
self ledb
-
ledd
-
Icon flushCachedIcons.
self ledd
-
ledh
-
Icon flushCachedIcons
self ledh
-
ledm
-
Icon flushCachedIcons.
self ledm
-
ledn
-
Icon flushCachedIcons
self ledn
-
ledo
-
Icon flushCachedIcons.
self ledo
-
ledq
-
Icon flushCachedIcons.
self ledq
-
ledr
-
Icon flushCachedIcons.
self ledr
-
ledt
-
Icon flushCachedIcons
self ledt
-
ledu
-
Icon flushCachedIcons
self ledu
-
ledv
-
Icon flushCachedIcons
self ledv
-
ledw
-
Icon flushCachedIcons.
self ledw
-
ledy
-
Icon flushCachedIcons
self ledy
-
segmentA
-
KEEP colormap and depth. Used to construct other bitmaps
-
segmentB
-
KEEP colormap and depth. Used to construct other bitmaps
-
segmentC
-
KEEP colormap and depth. Used to construct other bitmaps
-
segmentD
-
KEEP colormap and depth. Used to construct other bitmaps
-
segmentE
-
KEEP colormap and depth. Used to construct other bitmaps
-
segmentF
-
KEEP colormap and depth. Used to construct other bitmaps
-
segmentG
-
KEEP colormap and depth. Used to construct other bitmaps
initialization
-
bitmapFor: aCharacter
-
Bitmaps := nil
self bitmapFor:$a
self bitmapFor:$Y
self bitmapFor:$y
-
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) **
-
initBitmap: symbol
-
queries - plugin
-
aspectSelectors
-
accessing
-
numberOfDigits
-
return the number of digits to display
-
numberOfDigits: n
-
specify the number of digits to display
-
numberScale
-
return the number of post-decimal-point digits
-
numberScale: n
-
define the number of post-decimal-point digits
-
radix
-
return the number radix;
2..16 are supported; 10 is the default
-
radix: tenOrSixteen
-
set the number radix;
2..16 are supported; 10 is the default
-
showLeadingZeros
-
return true if leading zeros are shown
-
showLeadingZeros: aBoolean
-
controls if leading zeros are shown
accessing channels
-
ledColorChannel
-
-
ledColorChannel: aValueHolder
-
accessing-color & font
-
foregroundColor: aColor
-
change the led's color
change & update
-
update: something with: aParameter from: changedObject
-
redraw myself, when the model changes
drawing
-
redrawX: rx y: ry width: rw height: rh
-
update my view
events
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
initialization
-
fetchDeviceResources
-
fetch device colors, to avoid reallocation at redraw time
-
initialize
-
(comment from inherited method)
must be called if redefined
queries
-
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.
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
|
|