hakugin.gin at gmail.com
hakugin.gin at gmail.com
Mon Sep 14 14:53:32 CEST 2015
On Sunday, September 13, 2015 at 2:09:11 AM UTC-4, John McKenzie wrote:
> Hello, there.
> Hakugin, thank you you as well. I took the basic ideas you showed me for
> improvement and used them. The pulse settings variable was not liked by
> the interpreter, so I simplified it. I turned it into a hex value for
> each button press, then in the main loop I inserted the whole line for
> the LED pulse command, but put "pulse_settings" after "hex=" in the
> arguments. This worked.
I realized the error with my example after I got home and forgot to update it. The issue was with:
(red=255, green=0, blue=0, repeats=1, duration=2000, steps=50)
I had copied and pasted that and should have removed the "red=", "green=", etc. I'm glad you were able to work it out.
> I added a few green blinks of the LED to indicate the starting and
> stopping of the script. Also, I got the log files score print outs upon
> exit working. Very important, and also importantly, I have it so it stops
> after a certain amount of time. For testing, I have it at 60 seconds, but
> games will be 3600 seconds on average when really being used.
> The stopping after a certain amount of time was done in a way that
> apparently technically works, but seems very weird and probably wrong to
> me. You may freak out when you see it. I used an else statement inside a
> while loop and it just feels so strange. At least it works.
> Hoping I might be able to make it so I boot the Pi, it loads the script,
> script waits for the user to tell it how long to make a game, game
> starts, scripts ends game at appropriate time, saves dated log file with
> scores, then waits for user to enter new game length to start new game.
> This is probably way to much to hope to accomplish in time. For next year
> for sure though. It would be better for the referees to operate that way.
Having the game load when the Pi starts is fairly easy, but I'd recommend searching the official Raspberry Pi forums. Last time I was there I saw quite a few posts on various ways to accomplish this.
As for allowing someone to enter a game time limit you can change your "gamelength" variable assignment to something along the lines of:
gamelength = None
while not isinstance(gamelength, int):
gamelength = raw_input("Please enter a game time limit:\n")
gamelength = int(gamelength) # Converts to integer
print("Invalid entry. Time limit must be a number.\n")
pass # ignore error and allow the loop to start over
I was able to test this code, and you will want to add it before your main game loop.
> Next I will try and integrate wireless communications. If anyone here
> knows Synapse RF modules well, or at all, PLEASE contact me.
> Here is the code I did up most recently. Again, thanks for all the
> suggestions, code examples, and general help.
> while time.time() < gamestart + gamelength:
This is actually how I personally would have accomplished the task of having it end at a specific time. There may be other ways though.
More information about the Python-list