XRAD'S DECA CHALLENGE GAME
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
XRAD'S DECA CHALLENGE GAME
Here is a sneak peek at another one of my ADD projects. Using an adafruit music maker feather wing for sounds, teensy 3.2 for main processor, and a bunch of Ada parts. Basically a 4 player countdown timer challenge. Time set by Auto or Player mode. Object is to find correct pattern in time allowed. Should be a cool integration of timer codes, audio, score keeping, and sound/light effects!
currrently, I have the timer countdown , 1.2 seven segment display, piezo buzzer, rotary encoder, and neopixel ring functioning. Next challenge is to write the game modes and add the real cool audio/light effects. Unit will also operate as a BT portable boom box so also waiting on some amp and speaker parts.
will post code when done.....
see timer controller vid:
https://www.youtube.com/watch?v=FwnSg6b ... e=youtu.be
it might not appear as much now, but there is a lot of work in just getting the timer code operational. I suspect that player modes will also be challenging...... :)
currrently, I have the timer countdown , 1.2 seven segment display, piezo buzzer, rotary encoder, and neopixel ring functioning. Next challenge is to write the game modes and add the real cool audio/light effects. Unit will also operate as a BT portable boom box so also waiting on some amp and speaker parts.
will post code when done.....
see timer controller vid:
https://www.youtube.com/watch?v=FwnSg6b ... e=youtu.be
it might not appear as much now, but there is a lot of work in just getting the timer code operational. I suspect that player modes will also be challenging...... :)
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
- adafruit_support_mike
- Posts: 68250
- Joined: Thu Feb 11, 2010 2:51 pm
Re: XRAD'S DECA CHALLENGE GAME
Looks good.. thanks for posting the progress shots.
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Thx Mike! Just got the code together for 2x8 pin matrix. Reads 28 combos and tells you how many and which connections have been made. Now to combine codes with timer and the game modes.....
....and add audio and light effects
basically, the code runs through these combos and logs connections, then does something for the correct count and correct pins....just need to compare to preset combos...
....and add audio and light effects
basically, the code runs through these combos and logs connections, then does something for the correct count and correct pins....just need to compare to preset combos...
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Modified fona keypad for game GUI, on a 3.5 TFT feather...
One of several game screens...
left button columns to match the 1/4" connection jacks...
One of several game screens...
left button columns to match the 1/4" connection jacks...
- adafruit_support_mike
- Posts: 68250
- Joined: Thu Feb 11, 2010 2:51 pm
Re: XRAD'S DECA CHALLENGE GAME
Looking good!
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Thx Mike! These are rough draft GUI's for getting the basic ideas in place. Having a few challenges creating the EEPROM code for 'player 1' set wiring connections compared to the 'player 2' guessed connections. But that is the fun in coding....
The one thing I noticed is that the touch 'buffer' holds last press of 'current page' through the next 'page' causing any buttons in same touch area to 'activate'
there are a few ways around this, but I have not had luck. Is there a functional STMPE ts.clearBuffer() in the library? or something else that works??
I have tried :
and some other variants. maybe I can get buffer size and if greater than 0, make it zero
not sure how to do this....
any help appreciated!
The one thing I noticed is that the touch 'buffer' holds last press of 'current page' through the next 'page' causing any buttons in same touch area to 'activate'
there are a few ways around this, but I have not had luck. Is there a functional STMPE ts.clearBuffer() in the library? or something else that works??
I have tried :
Code: Select all
TS_Point p=ts.getPoint();
while(ts.touched())
p= ts.getPoint();
Code: Select all
uint8_t Adafruit_STMPE610::bufferSize(void) {
return readRegister8(STMPE_FIFO_SIZE);
}
any help appreciated!
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
tried clearing the buffer with:
this works, but for some reason last touch data carried over into next screen field.
Any ideas?
Code: Select all
if ( ! ts.bufferEmpty() ) {
ts.writeRegister8(STMPE_INT_STA, 0xFF); // reset all ints
}
Any ideas?
- adafruit_support_mike
- Posts: 68250
- Joined: Thu Feb 11, 2010 2:51 pm
Re: XRAD'S DECA CHALLENGE GAME
That's what we use.XRAD wrote:I have tried :Code: Select all
TS_Point p=ts.getPoint(); while(ts.touched()) p= ts.getPoint();
Check the surrounding code to see if the value in the variable 'p' carries over from one pass to the next. That's a common source of repeating data.
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Thx Mike. I did try that, but I have no touch x,y with the above provided code. I think you are correct about carrying over. I can see that the 'button' GUI resets after screen changes, so some data carryover. I know GUI (revert) and touch data are different. If I clear the touch 'buffer' right after the home screen button press, it will cycle the 'revert' gui on the home page, but obviously not go on to next page. I just have to figure out the logic.....It's not crucial to the function of the project, just another puzzle.
Currently this works fine except for 'p' carry-over:
Currently this works fine except for 'p' carry-over:
Code: Select all
// Start w/Home Screen
TS_Point p;
if (ts.bufferSize()) {
p = ts.getPoint();
} else {
// this is our way of tracking touch 'release'!
p.x = p.y = p.z = -1;
}
- adafruit_support_mike
- Posts: 68250
- Joined: Thu Feb 11, 2010 2:51 pm
Re: XRAD'S DECA CHALLENGE GAME
The TS_Point is an object, which means it's allocated on the heap, and may continue to hang around to avoid reallocation. It will definitely hang around if execution never leaves the function where the object is created.
Try setting p.x = py = p.z = 0 before calling ts.bufferSize(). That will start each pass with known default values.
Try setting p.x = py = p.z = 0 before calling ts.bufferSize(). That will start each pass with known default values.
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Thx Mike. that makes sense as to why I could set the 'p' as:
Will try your suggestion.
Code: Select all
p = 0;
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Tried a few things but never got the 'touch buffer' to clear before loading next screen touch controls. No biggie. I'll figure it out later. I did get the 'port connection' scan code and the TFT display/touch merged. Now to code for the comparison of the actual 'chosen' connections by challenger against the 'set' connections by game 'player' (or conversely).
So currently, one player chooses any of 28 connection options to make 1 to 4 real connections. Then sets the timer, Then hits ARM and the counter begins. Now the challenger has to decode the configuration in the allotted time or else......
So currently, one player chooses any of 28 connection options to make 1 to 4 real connections. Then sets the timer, Then hits ARM and the counter begins. Now the challenger has to decode the configuration in the allotted time or else......
- adafruit_support_mike
- Posts: 68250
- Joined: Thu Feb 11, 2010 2:51 pm
Re: XRAD'S DECA CHALLENGE GAME
Sounds interesting. It's fun to see how the build is coming along!
- XRAD
- Posts: 762
- Joined: Sat Nov 19, 2016 3:28 pm
Re: XRAD'S DECA CHALLENGE GAME
Thx Mike, Appreciate your interest! So here is my current coding challenge.The primary opponent has just entered 'ONE' pin connection on the TFT as '12'(1/4 jack #1 to 1/4 jack #2). Say the challenge player connects jack '1' and '2' and then tests to see if correct. I can read the 1/4 jack connections and that gives me TWO total combinations for one connection. The logged 'jack' numerical values are 12 and 21. Without having to literally line by line code for all 64 total combinations, I need an easy way to check the challenger's '12' or '21' to the initial entered value of '12'. so basically i need a simpler way to code the comparisons instead of below (not real code):
3 challenges:
1) easier way to code the comparisons? there are 64 total numerical values.......(8 x1/4 jacks w/two way numerical values, but only physically 28 possible connections)
2) each additional TFT entered connection requires running through all the possibilities for the first connection, and then all the possibilities for second connection, etc, to a max of four.
3) although structured in order in above code example, it should be for example, possible that the challengers 3rd connection is correct, but the timer does not defuse. The music maker voice sample will say ONE CORRECT, and then the challenger has to re-wire until he/she finds solution....
any thoughts / ideas appreciated. I am only good with very basic code and have made a few structs and arrays to shorten my code, but is is already 1100 lines.......
Code: Select all
if (there is 'one' connection){ //as entered by the TFT opponent
run the matching function()
if (TFT entered value 12 == challenger 1/4 jack connection 12 || 21){ // this is my stumbling block, not sure of better way to do all the comparisons.....
musicMaker (play track "ONE CORRECT' );
defuse Timer();
}
else{
musicMaker (play track "NONE CORRECT' );
keep timer counting down;
}
}
if (there are 'two' connections){ /// etc, for four maximum number of connections
run the matching function()
if (TFT entered value 12 == challenger 1/4 jack connection 12 || 21){
oneConnectionCorrect = true;
and if (TFT entered value 34 == challenger 1/4 jack connection 34 || 43){
twoConnectionCorrect = true;
defuse Timer();
}
}
}
else{
if(oneConnectionCorrect = true){
musicMaker (play track "ONE CORRECT' or similar);
}
keep timer counting down;
}
1) easier way to code the comparisons? there are 64 total numerical values.......(8 x1/4 jacks w/two way numerical values, but only physically 28 possible connections)
2) each additional TFT entered connection requires running through all the possibilities for the first connection, and then all the possibilities for second connection, etc, to a max of four.
3) although structured in order in above code example, it should be for example, possible that the challengers 3rd connection is correct, but the timer does not defuse. The music maker voice sample will say ONE CORRECT, and then the challenger has to re-wire until he/she finds solution....
any thoughts / ideas appreciated. I am only good with very basic code and have made a few structs and arrays to shorten my code, but is is already 1100 lines.......
Please be positive and constructive with your questions and comments.