FACER Community

Slow down rand function

I’m needing to generate a random number but need to be able to control the interval. Currently it just zooms along and makes a new number every millisecond it seems. Is there a way to slow it down so it gives me a new number every, say, 3 seconds? Tried to come up with some clever way of using waves to get it to happen, but I can’t math it out to get it to work right.

2 Likes

Sounds like a cool idea, and I’m sure the math experts should be here soon to assist, but can you please share what you’ve come up with so far, to give everyone an idea :bulb:

1 Like

Nothing useful, unfortunately. Nothing seems to affect the speed of things. I’d paste some stuff, but I’ve been erasing expressions and starting from scratch whenever something doesn’t work :stuck_out_tongue:

2 Likes

I have something somewhere. I am on my Tablet at the moment. I will get back when I have found something. It is a matter of calling the Random with a timer or other.

2 Likes

That would be perfect! I feel like I’m missing something obvious, but all my poking around isn’t showing me anything.

2 Likes

Sorry I need a bit more Time like you I am poking around a bit. Obviously wakeRand is no use to you. Hopeless trying to do anything on my Tablet. I can look on the Laptop tomorrow. Someone else might join in you never know :slightly_smiling_face:

1 Like

Hey, no worries. I can’t believe its not just a simple argument to the rand function to set an update interval :frowning:

2 Likes

@adamalbee1984 I hope you don’t find this a little Lame but that is me . If this will get no where near what you are looking for I can do a bit more. I did a search on the community and it seems no one has come up with a really good answer.
See an inspectable test I have made . You will see I delete nothing Keep the test layers and just switch them off . You will be surprised how near you were to a solution Pogging around .
I have used a division of the Seconds hand to split a minute up into 3 we can use other time bases . I used that for example and simplicity.
To see the change on Creator you will have to run the Time Machine and click the ACTIVE button to simulate wake .
To inspect the watch click on the Title then look for the little Rocket on the Left of the Window. You can make changes to the Face but you can not save them . The Draft File lives on my account . You can copy and paste the code to a new Creation of your own .
I am sure you can find 4 images or gifs for your tests . If you want the set of those horrid numbers let me know . Funny how you can spend so much time making something and Hate it .

3 Likes

Thanks for all your work!
I’ll explain more what I’m trying to do. Essentially what I’m trying to do is choose a random image every 3 seconds.
If I could get a number, it would be easy enough. Problem is, even doing something like stacking the images and setting opacity to something like:
$(rand(1,100))<=10?100:0$
gets me something, but it still flickers rapidly and I want each image to have a more or less equal chance of appearing, which can’t happen with this method as the top layers will have a greater chance of being visible since they are on top. For now the closest I’ve gotten is using wakeRand to change the image on every wake, but I want it to change as the watch is awake, in a random pattern.

I’m not sure this gets me to where I want, but it does inspire some ideas for other projects. And now that I think about it, I might be able to “fake” what I’m trying to do by adapting this method. My thought is to have an essentially randomized order to the layers, maybe having many duplicates, and use your formula to choose a random starting point in that pattern on wake. Not quite what I’m after, but a decent emulation of it if I can’t find another way.

Again, thanks for taking the time to help. Maybe if people keep posting about this, Facer will just give us the ability to control the speed :stuck_out_tongue:

2 Likes

Good to have a clearet Idea of what you are trying to achive.
Facer are not going to devlope something because you and I have had a chat about it.
Unfortunatly Random stuff on a Computer is always Fake. If you were rich enough to go Premium you could use random to set flags.
Now I know what you are trying to do I Might be able to come up with something. I often this kind of thing comes up imy sleep.

2 Likes

Haha, I thought about looking at premium, but not sure its worth it. And I’m pretty sure there’s a limit to the number of vars if I’m not mistaken (documentation for the premium features is sadly very skimpy), which would hinder what I’m trying to do anyways. The more I try to force Facer to do what I want, the more I think I just need to learn how to make a standalone watch face.

2 Likes

And also, yeah, I get pseudo-random etc. I code for my job/as a hobby :laughing: which is why this is so darned frustrating! Pseudo-random numbers is basic level junk and its stumping me, haha.

2 Likes

What is your Hobby code ? I like to play with Arduinos and BBC Microbits these days . I actually code Microbits in Blocky just for fun . Like doing Jigsaw Puzzles .

If you Set your number generating line to make 0-8 then you can mix up the Call to your images with ( OR ) || I think you can have a few on a line .
I am certain you know what I am talking about .
I am very like you . I enjoy the limitation of Facer Free . I also enjoy the Open Source Code I find on here . Often Topics are very busy with Lots of helpers . I think a Few are having a Community Holiday at the moment .

I will do a little bit of work on the test . You can go back there any time to monitor my changes . I will not post the link again till I have to .
Not sure what you mean by stand alone watch face . Your Nixie Face stands very well on its own Merit.

1 Like

I change hobby projects all the time, and usually have a few things going at once. Currently I’m working on learning the ins and outs of the 8bitcade (tiny arduino powered gaming handheld). My son is interested in Game Development so I figure that would be a good jumping off point.

For stand alone, I mean building a watchface from scratch, without using an engine like Facer. You can do it in Android Studio with a bit of setup.

2 Likes

So close to getting what I need! Looked up how to generate my own pseudo-random numbers, but they all rely on performing the formula on the previous result. So right now I’m just passing #Ds# in, but ideally I need to pass in whatever the previous result was. It does “look” kinda random and it gives me a new pattern on each wake, but isn’t quite there.

Just put this into a text layer to see the output:
(((((wakeRand(1,20))*#Ds#)+3)%20)+1)

3 Likes

Looks like you and I are coming to a similar conclusion .
Nice bit of work .
Tiny Arduino Great fun . I just found them short on IO .
I have made a couple of faces for Tizen on Galaxy Watch Studio which is completely different but the platform looks similar.
On GWS there are no Curved Progress Bars . All these different platforms have changes .

I have done a bit of work on the test .
I will tidy up and leave it alone.
Please note I have come up with something that changes every 3 seconds as you mentioned . Obviously if your range is 1 to 20 you have less chance of repeats.

BTW good luck with Hard Coding everything on the watch .
I will be more than interested to see the results .

2 Likes

Thanks for the work. In the end, looks like I can’t do what I want here, but not the end of the world. I went with 1 to 20 because smaller numbers didn’t give the same random “feel” it would just bounce between 2 numbers most of the time.

3 seconds was kind of an arbitrary number, but I like your method of doing it.

Again, even if I can’t do what I was originally looking for, this gives me a lot of tools to use for other effects, so still, thank you for brainstorming with me!

2 Likes

As long as we are on a Learning Curve we are going in the Right Direction . Thanks for creating the opportunity for me to test what I know.

1 Like

Ok, last update from me, but I was thinking, hey, you know what has random numbers built in? Pi and e!

So take a look at this monster (so many parentheses):

(round((((pi*(exp((floor((((#Ds#+wakeRand(0,100)))/3))))))%10)+1)))

The “3” is how many seconds between updates, the 10 is the maximum number you want, the one is the minimum! The wakeRand in the middle is just to make sure you have a slightly different pattern to the “random” numbers on each wakeup. I think this is sufficient for my needs, time to get to work on the rest of the watch!

Edit: and just realized it glitches sometimes and gives me an 11, haha. I think I can make it work though.

3 Likes

Yeah 10 + 1 will give you 11 . I could live with that : ) : ) Nice bit of creative maths pi*exp : ) I remember asking what the opposite of square root was . Well done . We should leave it at that so people can find this Gem . Great topic . Good Follow-up . That is the Spirit of a Decent Community .

2 Likes