Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Handling user input from The Wall


Edit: This post concerns “The Wall”, a discontinued project.

Please read this first. This post shows how detect mouse input in The Wall.

The Wall provides functionality for displaying data on a screen, an important component for anyone building an intelligent home. The system relies on the user’s ability use VBScript to collect data he or she wants to display, but there are some built in functions for simplifying this. I will cover these functions later. Finally, it has a very simple mechanism for detecting clicks or touch screen activity, demonstrated here.

To activate click detection, call the RegisterClickCallback function and pass the name of the function that will be called when a click is detected, “ClickCallback” in this case.

The following code will register a text item for displaying the current date and time, a numeric item for displaying the number of detected clicks, and another text item for displaying the coordinate of the click (in characters):

'Blueish background color.
BackgroundColor = "#334499"

'The background grid can be useful when designing the screen.
BackgroundGrid = True

'Every 60 seconds, display the current date and time.
RegisterTextItem 60, "DateAndTime", 0, 0, "#00ffff", "UpdateDateAndTime"

'For the fun of it, a click counter updated each second.
RegisterNumericItem 1, "Counter", 0, 2, "#ffff00", "UpdateCounter"
Set Item=GetItem("Counter")

Dim ClickCounter

'And a string that displays the coordinates.
RegisterTextItem 1, "Coordinates", 0, 4, "#ff88ff", "UpdateCoordinates"

Dim LastX
Dim LastY
LastX = -1
LastY = -1

'This is the magic: Activate a callback for each click.
RegisterClickCallback "ClickCallback"

'Callback: Display date and time.
Sub UpdateDateAndTime(ByVal Item)
   Item.Value = "Date: " & GetDate() & " Time: " & GetShortTime()
End Sub

'Callback: Display the click counter.
Sub UpdateCounter(ByVal Item)
   Item.Value = ClickCounter
End Sub

'Callback: Display the coordinates where the click occured.
Sub UpdateCoordinates(ByVal Item)
   Item.Value = LastX & ", " & LastY
End Sub

'This callback is not called on a given interval, but
'when the user clicks (or points at the touch screen).
Sub ClickCallback(ByVal X, ByVal Y)
   'Save the coordinates and increase the counter.
   ClickCounter = ClickCounter + 1
   LastX = X
   LastY = Y
End Sub

The result might look like this after 7 clicks:

Categories: Programs

Tags: The Wall

Leave a Reply

Your email address will not be published. Required fields are marked *

En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!


Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   |   |   |   Filmtips