Random Screen saver movement

General FreeBASIC programming questions.
Dinosaur
Posts: 1368
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Random Screen saver movement

Postby Dinosaur » Aug 06, 2020 5:19

Hi All

Finally got tired of using XScreensaver on the Beaglebone Black which does not have keyboard or mouse and has Touchscreen disabled.
To cancel the XScreensaver I had to shell out and send a command to it.
Messy.

So wrote a simple Date/Time screensaver that can be included in my code.(and thus easy to stop/start)
It is basically a small CGUI window with the Title as the Day name and date, then bitmaps that look like keys of a keyboard to show the digits.

However I would like to move it around the screen in random directions but a few pixels every 100 msec.
I concluded that due to the size of the (moving) window that the minimum X,Y = 1,1 and the maximum X,Y = 470,525
In CGUI there is a "SetWindowPosition(X,Y) so easy to reposition it every 100 mSec.

What I have NO IDEA on, is how to come up with those numbers.(X,Y)
I know there are many on the forum whom thrive in this area and would love to hear some suggestions.

Regards
MrSwiss
Posts: 3785
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Random Screen saver movement

Postby MrSwiss » Aug 06, 2020 15:12

Funny, because you already have 'the solution' in the thread title.

Use a randomizer like Rnd(), to influence the new x, y position together
with a bit of math (to prevent that right/bottom gets 'off screen').
Remember that x, y represent: left/top (of image/bitmap).

For this, a ranging #Define may be useful, to limit min/max movement:

Code: Select all

#Define LngRng(l, h)   CLng(Int(Rnd * ((h) + 1 - (l)) + (l)))

A word of warning, about ScreenSavers:
since I assume, that the BeagleBone is used for speed, I would rather just
'blank' the screen, than using a ScreenSaver which is consuming CPU power.
Dinosaur
Posts: 1368
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: Random Screen saver movement

Postby Dinosaur » Aug 06, 2020 21:57

Hi All

Thanks for the reply MrSwiss.

I know that Screensavers are really no longer needed these days.
The screen has one rather large light bulb that is either On or Off.
They flick a single input switch (mechanical) to switch all the light in this museum.
That switch then cancels the screen saver so they can verify that all the lights changed.

Rather than the volenteers staring at a Light bulb all day , the screen saver comes in.
When I check the Wifi I simply ignore the screensaver and let it stop moving.

Will have some time to try this weekend.

Regards

Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests