Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit 1b76039

Browse files
Merge pull request #96 from AlanisMria/main
agregar apuntes AlanisMria
2 parents c778fbc + b3726af commit 1b76039

File tree

4 files changed

+468
-269
lines changed

4 files changed

+468
-269
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include "Arduino_LED_Matrix.h"
2+
#include "gallery.h"
3+
#include "PushButton.h"
4+
#include "Nivel4.h"
5+
6+
// Código de referencia del repositorio de la Sofi Etchepare
7+
// lenguaje de c++ para detectar posibles errores en el código y valores
8+
//por lo que lo usamos ahora para definir los estados de nuestro dispopsitivo
9+
enum State {
10+
// estado de reposo
11+
STANDBY,
12+
// primer nivel introductorio
13+
NIVEL_PUNTO,
14+
// segundo nivel introductorio
15+
NIVEL_LINEA,
16+
// en este nivel el usuario debera mantener presionado o clikear el boton, respectivamente para escribir una letra M en morse
17+
NIVEL1,
18+
// en este nivel el usuario debera mantener presionado o clikear el boton, respectivamente para escribir una letra O en morse
19+
NIVEL2,
20+
// en este nivel el usuario debera mantener presionado o clikear el boton, respectivamente para escribir una letra R en morse
21+
NIVEL3,
22+
// en este nivel el usuario debera mantener presionado o clikear el boton, respectivamente para escribir una letra s en morse
23+
NIVEL4,
24+
// en este nivel el usuario debera mantener presionado o clikear el boton, respectivamente para escribir una letra A en morse
25+
NIVEL5,
26+
// al lograr pasar todos los niveles, el usuario visualizara una pequeña morsa guiñando el ojo en felicitación
27+
NIVEL_FINAL
28+
};
29+
30+
31+
// el pin es donde se conecta el botón al arduino, en este casi en la ranura número 2
32+
const int BOTON_ENTRADA = 2;
33+
34+
35+
//estado actual en espera
36+
State currentState = STANDBY;
37+
38+
39+
// comandos utilizados de edgar pon para usar botones en arduino con if-else https://edgarpons.com/botones-en-arduino-y-comandos-if-else/
40+
41+
42+
void setup() {
43+
// configurar las entradas
44+
pinMode(BOTON_ENTRADA, INPUT_PULLUP);
45+
Serial.begin(9600);
46+
}
47+
// aqui se ponen todos los comandos que el ardino debe de ejecutar haciandolos que esten en continua funcionamiento, que pase mas de una vez
48+
void loop() {
49+
//sirve para leer un valor (o poner en un estado) un pin digital.
50+
switch (currentState) {
51+
// en este estado esperamos la accion del usuario
52+
// 'presionar cualquie boton para que empiece el juego' y asi cambie a un estado activo
53+
case STANDBY:
54+
{
55+
Serial.println("En estado STANDBY");
56+
int lecturaA = digitalRead(BOTON_ENTRADA);
57+
58+
// presiona cualquier boton para salir del estado standby y pasa a estado NIVEL4
59+
if (!lecturaA) {
60+
currentState = NIVEL4;
61+
}
62+
break;
63+
}
64+
case NIVEL4:
65+
{
66+
Serial.println("En estado NIVEL4");
67+
//if (animacionA) aparece en la pantalla{
68+
//se presiona lecturaA
69+
//}
70+
BOTON_ENTRADA.update(2);
71+
72+
if bool(BOTON_ENTRADA.isClicked(3);)
73+
74+
matrix.loadFrame(Nivel4);
75+
};
76+
//if (animacionA) aparece en la pantalla{
77+
//se presiona lecturaA
78+
//}
79+
//}else{} (quizas) si no lo hace en el tiempo establecido pierde vida
80+
break;
81+
}
82+
};
83+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const uint32_t animation[][4] = {
2+
{
3+
0x1f81f819,
4+
0x81981f81,
5+
0x98198198,
6+
250
7+
},
8+
{
9+
0x0,
10+
0x1600,
11+
0x0,
12+
250
13+
}
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2018 Kristian Klein Jacobsen
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
#ifndef PUSHBUTTON_H
26+
#define PUSHBUTTON_H
27+
28+
class PushButton
29+
{
30+
public:
31+
PushButton(int pin);
32+
void update();
33+
bool isActive();
34+
bool isClicked();
35+
bool isDoubleClicked();
36+
bool isHeld();
37+
bool isReleased();
38+
void disableDoubleClick();
39+
void enableDoubleClick();
40+
void setDebounceTime(int ms);
41+
void setHoldTime(int ms);
42+
void setDoubleClickTime(int ms);
43+
void setActiveLogic(int high_or_low);
44+
private:
45+
int state_;
46+
long lastClickTime_;
47+
long lastReleaseTime_;
48+
int pin_;
49+
bool doubleClickable_;
50+
bool activeLogic_;
51+
bool debounced_;
52+
int debounceTime_;
53+
int holdTime_;
54+
int doubleClickTime_;
55+
};
56+
57+
#endif

0 commit comments

Comments
 (0)