Jump to content

Digital Display (numeric readout)


RTFC
 Share

Recommended Posts

While developing a data visualisation tool I stumbled across >this awesome script by timmy2 and GDI grandwizard UEZ, and although I'm totally crap at graphics (craphics?), I had a stab at adapting it for more general use, incorporating some additional enhancements developed by more able graphics coders such as Beege, MrCreatoR and Malkey (acknowledgements and references to their relevant forum contributions are detailed in the script). Many thanks to you all! :bye: The result looks something like this:

DigitalDisplay_Example.png

So just to be absolutely clear: this is not my work, and I do not claim it to be my work. I've only repackaged it so you can easily create and maintain colourful displays like this with a few simple wrapper calls (see the example in the zip). Basically you create it once like a regular control (parse GUI handle, coordinates, size, and number of digits); that call then returns a display ID (1, 2, 3...). At this point the graphic is not yet visible. Internally, I've created specs storage for up to 100 displays; if you need more, just enlarge the array $DigiDispSpecs in the globals region.

Subsequently, once the GUI is itself visible, you can repeatedly update the displayed value (just make sure the value fits within the maximum number of digits specified when you created it; if parsing a value with fewer digits, these will be zero-padded). You can also change foreground colour, background colour, glow colour, and the intensity of that glow (range: 1-10; default 0 = off). You parse colour parameters either with colour strings ("red", "blue", "cyan", etc., easily expanded) or with their 6-digit hex RGB value (0xff0000 for red, for example). Remove individual readouts again by calling _DigitalDisplay_Remove($displayID). When you have removed the last digital display, you should call _DigitalDisplay_CleanUp() to avoid memory leaks. That's all, folks!

DigitalDisplay.7z beta version 0.9.

If it works, thank UEZ, timmy2, Beege, MrCreatoR and Malkey; if if breaks, blame me.

Hope you enjoy using it as much as I did cobbling it together! :)

RT

Edited by RTFC
Link to comment
Share on other sites

Nice work ;)

Works properly on Win 8.1. When using latest AutoIt version I'v to comment out several functions which are included now.

Btw, the zip archive seems to be corrupted.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Hi UEZ,

Thanks a lot, but you did most of it, and what you are able to achieve with GDI is absolutely mind-blowing! I'm a big fan. :thumbsup:

Fixed the zip.

I know, I should upgrade to the latest release, but I really like stable work environments (if it ain't broke, don't fix it, right?) Spent the last two days struggling to get a cross-compiler ported from Win7 to OpenSuse :x , so then coming back to AutoIt and everything just works, it's so nice that I'm afraid to jinx it. Pathetic, I know...

Anyway, I'm learning a lot from analysing your scripts, gaining at least a little understanding, just enough to get by.

Thanks for the inspiration.

Link to comment
Share on other sites

You are welcome. 

Nice to hear that at least somebody is inspired by the GDI+ stuff.  :thumbsup:

The latest beta should be stable regarding GDI+.

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@lorenkinzel: Totally agree.

@UEZ: Actually, I'm kinda curious, UEZ. Do you perhaps have a professional background related to graphics processing (if it's not too personal), or are there extensive GDI tutorials to get one up to speed on this, or is it just a question of knuckling down on the MSDN materials, which I often find unhelpful and confusing? All this context-creating, internal conversions, and multiple handles (or so it seems to the uninitiated)... But when it works, it looks great, of course.

Link to comment
Share on other sites

@RTFC: I'm only an hobbyist coder with interests in graphical stuff and have no pro background. Everything I learned in GDI+ is owed to this forum and its pioneers of GDI+ (monoceres, Malkey, Smashly, Authenticity, etc.). Prerequisites are some basic understandings in maths (vectors, trigonometry, etc.). MSDN is hard to understand at the beginning.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

updated to beta version 0.7.

Minor bug fixed: aspect ratio adjustments were implemented twice (i.e., adjustment was doubled).

Added: calling _DigitalDisplay_AspectRatio() without any arguments will reset $aspectratio to unity.

Note that calling DigitalDisplay_AspectRatio($value) will set $aspectratio to $value for all displays you subsequently define, until you reset it (see above), or parse it a new value.

Link to comment
Share on other sites

@RTFC: I'm only an hobbyist coder with interests in graphical stuff and have no pro background. Everything I learned in GDI+ is owed to this forum and its pioneers of GDI+ (monoceres, Malkey, Smashly, Authenticity, etc.). Prerequisites are some basic understandings in maths (vectors, trigonometry, etc.). MSDN is hard to understand at the beginning.

Br,

UEZ

My jaw just dropped! I would not have thought of you as merely a 'hobbyist coder' either!

I haven't been here in a few weeks, but the last thing I remember seeing in a search was this amazing looking clock  you did that even had gauges for CPU, Memory, etc.!  I was floored.  I'm still using the example clock that comes with Auto-it (with a little tweak). Haha!

You could probably write the manual on a GDI+!

In case I haven't said it recently, also thank you for all of your example scripts you contribute here! They've been a major help.

I wish I had more brain power...and minions....and a DeLorean. :-)

Link to comment
Share on other sites

coffeeturtle,

thanks for your compliments. Regarding GDI+ tutorials: well, when I was able to learn and use GDI+ from this forum and help file, everybody should be able to learn GDI+, too. ;)

To learn the basics in GDI+ the help file is a good place to start.

DeLorean? You wanna fly "back to the future"? ;)

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Great Scott!! :blink:

While I was writing this, I kept having this image in my head.

Strong meme, that.

RT

Edited by RTFC
Link to comment
Share on other sites

  • 2 weeks later...

Update: beta version 0.8 released, for AutoIt 3.3.12.1.

This version should run in the latest AutoIt stable release 3.3.12.1, in which several previously-defined GDI-related functions are now internal. I've left these in (commented out) at the moment, for easy switching between versions. I've also left version 0.7 available for download for now, as the new version will not run in legacy environments. However, these legacy accommodations may disappear in future (as Im' running low on storage space).

Link to comment
Share on other sites

Update: beta version 0.9 released., with thanks to @LegitStack.

After the discussion here I realised that DPI rescaling also affects the canvas size for the readouts this UDF produces. That means that if your GUIs appear 20% bigger, then the bottom and right edges of the display were being clipped commensurately. So I added a simple adjustment to take care of this, shamelessly copied from LegitStack's code in the other thread (thanks!).;)

No other bells and whistles added, I'm afraid; still too busy battling the forces of darkness to keep your planet safe.:zorro:

Link to comment
Share on other sites

  • 3 years later...

Welcome to the forums.:) I'm afraid you cannot expect much help on this unless you post a short test script that reproduces the error, so we can have a look at what might be the issue. If/when yo udo, please use the "code tags" button (looks like this: <>) above the text window to post your code. Thanks.

 

Link to comment
Share on other sites

Hi Sir,

Below is my code:

I have created a click button for reading "No09-Temp.txt" and the tool will auto click the button every 5 mins.

About "No09-Temp .txt", it just 2 line as below:

22.4
41.9

 The value would be updated every 3 mins from other tool provide.

Thank you

;MSS ;MSS ;MSS
;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp
;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp

GUICtrlCreateLabel("MSS Room Temp. / RH", 1045, 480, 170, 25)
GUICtrlSetFont(-1, 9, 1000)
GUICtrlCreateLabel("°C", 1105, 501, 170, 25)
GUICtrlSetFont(-1, 10, 1000)
GUICtrlCreateLabel("/", 1118, 510, 170, 60)
GUICtrlSetFont(-1, 22, 1000)
GUICtrlCreateLabel("%", 1167, 522, 170, 60)
GUICtrlSetFont(-1, 10, 1000)

$blackgui=False                 ; we'll need this flag later too
If $blackgui=True Then GUISetBkColor(0)     ; alternative view
$Clientvalue=Int(Round(FileReadLine("\\10.32.15.183\SmartPowerMeter$\No09-Temp.txt",1),3))
$Clientvalue2=Int(Round(FileReadLine("\\10.32.15.183\SmartPowerMeter$\No09-Temp.txt",2),3))
GUISetState()


; this display will vanish after its counter ($value) reaches 130
; red digits with orange glow on black background
$maxdigits=3
$top=30
$left=105
$size=45
$displayID1=_DigitalDisplay_Create($Form1_1,$left,$top,$size,$maxdigits)    ; calls initialisation func upon first call

;Temp.
_DigitalDisplay_AspectRatio(1.5)    ; change global setting for subsequent display definitions
$maxdigits=3    ; zero-padded, because the current value has fewer digits than maxdigits
$top=495
$left=1045
$size=16
$displayID3=_DigitalDisplay_Create($Form1_1,$left,$top,$size,$maxdigits)    ; calls initialisation func upon first call

;RH
_DigitalDisplay_AspectRatio(1.5)    ; change global setting for subsequent display definitions
$maxdigits=3    ; zero-padded, because the current value has fewer digits than maxdigits
$top=510
$left=1130
$size=10
$displayID4=_DigitalDisplay_Create($Form1_1,$left,$top,$size,$maxdigits)    ; calls initialisation func upon first call



_DigitalDisplay_AspectRatio()   ; reset to 1

_DigitalDisplay_Show($displayID3,$Clientvalue,"black","")
_DigitalDisplay_Show($displayID4,$Clientvalue2,"black","")

;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp
;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp

 

Link to comment
Share on other sites

 
 
 
 
1
 Advanced issue found
 
🙌
3
1 minute ago, MikePan said:

Hi Sir,

Below is my code:

I have created a click button for reading "No09-Temp.txt" and the tool will auto click the button every 5 mins.

About "No09-Temp .txt", it just 2 line as below:

22.4
41.9

 The value would be updated every 3 mins from other tool provide.

Thank you

The error message in consolewrite show as below:

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\TestStatusManagement\DigitalDisplay.au3" (407) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$DigiDispSpecs[$displayID][0]=$left
^ ERROR
->20:30:24 AutoIt3.exe ended.rc:1
+>20:30:24 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 9629

 

 

1 minute ago, MikePan said:
;MSS ;MSS ;MSS
;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp
;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp

GUICtrlCreateLabel("MSS Room Temp. / RH", 1045, 480, 170, 25)
GUICtrlSetFont(-1, 9, 1000)
GUICtrlCreateLabel("°C", 1105, 501, 170, 25)
GUICtrlSetFont(-1, 10, 1000)
GUICtrlCreateLabel("/", 1118, 510, 170, 60)
GUICtrlSetFont(-1, 22, 1000)
GUICtrlCreateLabel("%", 1167, 522, 170, 60)
GUICtrlSetFont(-1, 10, 1000)

$blackgui=False                 ; we'll need this flag later too
If $blackgui=True Then GUISetBkColor(0)     ; alternative view
$Clientvalue=Int(Round(FileReadLine("\\10.32.15.183\SmartPowerMeter$\No09-Temp.txt",1),3))
$Clientvalue2=Int(Round(FileReadLine("\\10.32.15.183\SmartPowerMeter$\No09-Temp.txt",2),3))
GUISetState()


; this display will vanish after its counter ($value) reaches 130
; red digits with orange glow on black background
$maxdigits=3
$top=30
$left=105
$size=45
$displayID1=_DigitalDisplay_Create($Form1_1,$left,$top,$size,$maxdigits)    ; calls initialisation func upon first call

;Temp.
_DigitalDisplay_AspectRatio(1.5)    ; change global setting for subsequent display definitions
$maxdigits=3    ; zero-padded, because the current value has fewer digits than maxdigits
$top=495
$left=1045
$size=16
$displayID3=_DigitalDisplay_Create($Form1_1,$left,$top,$size,$maxdigits)    ; calls initialisation func upon first call

;RH
_DigitalDisplay_AspectRatio(1.5)    ; change global setting for subsequent display definitions
$maxdigits=3    ; zero-padded, because the current value has fewer digits than maxdigits
$top=510
$left=1130
$size=10
$displayID4=_DigitalDisplay_Create($Form1_1,$left,$top,$size,$maxdigits)    ; calls initialisation func upon first call



_DigitalDisplay_AspectRatio()   ; reset to 1

_DigitalDisplay_Show($displayID3,$Clientvalue,"black","")
_DigitalDisplay_Show($displayID4,$Clientvalue2,"black","")

;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp
;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp ;Temp

 

 

Link to comment
Share on other sites

Two remarks:

  1. When we ask for a reproducer script, that means that we should be able to run that on our own machine to be able to analyse what might be going wrong. What you posted is a mere "snippet" that doesn't do much, and certainly cannot run for hours, and doesnt help to study the problem. But...
  2. Since this part of your code allegedly does run for hours before the error occurs, I am guessing that you just keep creating new displays without ever cleaning up the old ones. So you simply run out of storage space for defining new displays. In the DigitalDisplay UDF, you can find the following above #endregion globals:
    ; list of specs per display unit
    Global $DigiDispSpecs[1000][10]
    $DigiDispSpecs[0][0]=0
    
    #endregion Globals

    That number 1,000 defines 999 slots for such definitions (+1 for the total count), which should be plenty unless you would want to display over a thousand DigitalDislays at the same time on your screen. If you're going to keep defining new ones for hours on end, you'll need to clean up the old ones you're no longer using at some point, else you'll eventually run out of slots. If you study the UDF you'll see that calling _DD_Remove() clears one definition, but does not clear the slot in the list of DDs; for that you have to call _DD_RemoveAll():

    Func _DigitalDisplay_Remove($displayID,$background=$GUI_Bk_Color)
    ; used slot is blanked, but remains in the queue until _DigitalDisplay_RemoveAll()
    ; otherwise all subsequent references would shift

    Of course, you could simply edit the $DigiDispSpecs array definition (in the previous code section I quoted) with a much higher number (up to about 16 million max), but that would merely defer the problem till a later time if your code runs for long enough. The proper way of handling this is to clean up the list often so it never reaches its ceiling.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...