product assembled
This commit is contained in:
parent
ff0b593007
commit
3ea87b42fc
|
@ -6,9 +6,9 @@ WiFiMulti wifiMulti;
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
|
|
||||||
#define buttonPin 26
|
#define buttonPin 26
|
||||||
#define led1 25
|
#define ledA 32
|
||||||
#define led2 255
|
#define ledB 25
|
||||||
#define retractPin 0
|
#define retractPin 33
|
||||||
|
|
||||||
#define longPressThreshhold 150
|
#define longPressThreshhold 150
|
||||||
|
|
||||||
|
@ -21,10 +21,9 @@ bool pressed = false;
|
||||||
|
|
||||||
void initRandomSeed()
|
void initRandomSeed()
|
||||||
{
|
{
|
||||||
wifiMulti.addAP("boost-v2", "crystalize");
|
|
||||||
wifiMulti.addAP("AIRPORT-FREE-WIFI-NEW", "alexalex");
|
wifiMulti.addAP("AIRPORT-FREE-WIFI-NEW", "alexalex");
|
||||||
wifiMulti.addAP("Next-Guest", "");
|
|
||||||
wifiMulti.addAP("boost-v2", "crystalize");
|
wifiMulti.addAP("boost-v2", "crystalize");
|
||||||
|
wifiMulti.addAP("Next-Guest", "");
|
||||||
|
|
||||||
long startStartedWifi = millis();
|
long startStartedWifi = millis();
|
||||||
|
|
||||||
|
@ -61,11 +60,11 @@ void enterWinLoop(){
|
||||||
digitalWrite(retractPin, LOW);
|
digitalWrite(retractPin, LOW);
|
||||||
while (true){
|
while (true){
|
||||||
delay(250);
|
delay(250);
|
||||||
digitalWrite(led1, LOW);
|
digitalWrite(ledB, LOW);
|
||||||
digitalWrite(led2, LOW);
|
analogWrite(ledA, 0);
|
||||||
delay(250);
|
delay(250);
|
||||||
digitalWrite(led1, HIGH);
|
digitalWrite(ledB, HIGH);
|
||||||
digitalWrite(led2, HIGH);
|
analogWrite(ledA, 25);
|
||||||
|
|
||||||
if (!pressed && digitalRead(buttonPin) == HIGH)
|
if (!pressed && digitalRead(buttonPin) == HIGH)
|
||||||
{
|
{
|
||||||
|
@ -100,8 +99,8 @@ void setup()
|
||||||
pinMode(39, INPUT_PULLDOWN);
|
pinMode(39, INPUT_PULLDOWN);
|
||||||
pinMode(buttonPin, INPUT_PULLDOWN);
|
pinMode(buttonPin, INPUT_PULLDOWN);
|
||||||
|
|
||||||
pinMode(led1, OUTPUT_OPEN_DRAIN);
|
pinMode(ledB, OUTPUT_OPEN_DRAIN);
|
||||||
pinMode(led2, OUTPUT_OPEN_DRAIN);
|
pinMode(ledA, OUTPUT_OPEN_DRAIN);
|
||||||
pinMode(retractPin, OUTPUT_OPEN_DRAIN);
|
pinMode(retractPin, OUTPUT_OPEN_DRAIN);
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
@ -120,13 +119,13 @@ void loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lightA)
|
if (lightA)
|
||||||
digitalWrite(led1, LOW);
|
digitalWrite(ledB, LOW);
|
||||||
else
|
else
|
||||||
digitalWrite(led1, HIGH);
|
digitalWrite(ledB, HIGH);
|
||||||
if (lightB)
|
if (lightB)
|
||||||
digitalWrite(led2, LOW);
|
analogWrite(ledA, 0);
|
||||||
else
|
else
|
||||||
digitalWrite(led2, HIGH);
|
analogWrite(ledA, 25);
|
||||||
|
|
||||||
if (!pressed && digitalRead(buttonPin) == HIGH)
|
if (!pressed && digitalRead(buttonPin) == HIGH)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,14 +12,7 @@ enum class Operator{
|
||||||
};
|
};
|
||||||
|
|
||||||
void initRandomSeed(){
|
void initRandomSeed(){
|
||||||
M5.Imu.Init();
|
randomSeed(millis());
|
||||||
float accX, accY, accZ;
|
|
||||||
delay(250); // Wait for imu init
|
|
||||||
M5.IMU.getAccelData(&accX, &accY, &accZ);
|
|
||||||
float accelSum = accX + accY + accZ;
|
|
||||||
|
|
||||||
unsigned long seed = accelSum * 1000000;
|
|
||||||
randomSeed(seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String generateQuestion(){
|
String generateQuestion(){
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define UseMQTT
|
//#define UseMQTT
|
||||||
#ifdef UseMQTT
|
#ifdef UseMQTT
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WebSocketsClient.h> // include before MQTTPubSubClient.h
|
#include <WebSocketsClient.h> // include before MQTTPubSubClient.h
|
||||||
|
@ -15,8 +15,8 @@ MQTTPubSubClient mqtt;
|
||||||
#include "InputSystem.h"
|
#include "InputSystem.h"
|
||||||
#include "MathSystem.h"
|
#include "MathSystem.h"
|
||||||
|
|
||||||
#define extenderPin 26
|
#define extenderPin 32
|
||||||
#define buttonPin 37
|
#define buttonPin 25
|
||||||
|
|
||||||
#define UIRefreshDelay 250
|
#define UIRefreshDelay 250
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ void onInputDone(int inputNum){
|
||||||
|
|
||||||
if (inputNum == targetResult){
|
if (inputNum == targetResult){
|
||||||
hasWon = true;
|
hasWon = true;
|
||||||
|
#ifdef UseMQTT
|
||||||
mqtt.publish("/DDUStatusPing", "winMath");
|
mqtt.publish("/DDUStatusPing", "winMath");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasWon){
|
if (!hasWon){
|
||||||
|
@ -88,15 +90,16 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
M5.begin();
|
M5.begin();
|
||||||
M5.Lcd.setRotation(1);
|
M5.Lcd.setRotation(3);
|
||||||
|
|
||||||
initRandomSeed();
|
initRandomSeed();
|
||||||
|
|
||||||
digitalWrite(extenderPin, HIGH); // Push out
|
|
||||||
|
|
||||||
pinMode(extenderPin, OUTPUT_OPEN_DRAIN);
|
pinMode(extenderPin, OUTPUT_OPEN_DRAIN);
|
||||||
pinMode(buttonPin, INPUT_PULLUP);
|
pinMode(buttonPin, INPUT_PULLUP);
|
||||||
|
|
||||||
|
digitalWrite(extenderPin, HIGH); // Push out
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
mathExpression = generateQuestion();
|
mathExpression = generateQuestion();
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include <M5StickCPlus.h>
|
#include <M5StickCPlus2.h>
|
||||||
#include "MorsePart.h"
|
#include "MorsePart.h"
|
||||||
|
|
||||||
#define refreshDelay 1000
|
#define refreshDelay 1000
|
||||||
|
|
||||||
#define BTN_A 37
|
#define BTN_A 25
|
||||||
#define BTN_B 39
|
#define BTN_B 26
|
||||||
|
|
||||||
#define extenderPin 26
|
#define extenderPin 32
|
||||||
|
|
||||||
int currentlySelected = 1000;
|
int currentlySelected = 1000;
|
||||||
|
|
||||||
|
@ -24,12 +24,14 @@ bool hasWon = false;
|
||||||
|
|
||||||
void initRandomSeed()
|
void initRandomSeed()
|
||||||
{
|
{
|
||||||
M5.IMU.Init();
|
M5.Imu.init();
|
||||||
float accX, accY, accZ;
|
float accX, accY, accZ;
|
||||||
delay(250); // Wait for imu init
|
delay(250); // Wait for imu init
|
||||||
M5.IMU.getAccelData(&accX, &accY, &accZ);
|
M5.Imu.getAccelData(&accX, &accY, &accZ);
|
||||||
float accelSum = accX + accY + accZ;
|
float accelSum = accX + accY + accZ;
|
||||||
|
|
||||||
|
M5.Imu.sleep();
|
||||||
|
|
||||||
unsigned long seed = accelSum * 1000000;
|
unsigned long seed = accelSum * 1000000;
|
||||||
randomSeed(seed);
|
randomSeed(seed);
|
||||||
}
|
}
|
||||||
|
@ -37,11 +39,12 @@ void initRandomSeed()
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
M5.begin();
|
M5.begin();
|
||||||
M5.Lcd.setRotation(1);
|
M5.Lcd.setRotation(3);
|
||||||
M5.Lcd.fillScreen(BLACK);
|
M5.Lcd.fillScreen(BLACK);
|
||||||
|
|
||||||
pinMode(BTN_A, INPUT_PULLDOWN);
|
pinMode(BTN_A, INPUT_PULLUP);
|
||||||
pinMode(BTN_B, INPUT_PULLDOWN);
|
pinMode(BTN_B, INPUT_PULLUP);
|
||||||
|
pinMode(extenderPin, OUTPUT_OPEN_DRAIN);
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <M5StickCPlus.h>
|
#include <M5StickCPlus2.h>
|
||||||
|
|
||||||
#define nextItemDelayTime 500
|
#define nextItemDelayTime 500
|
||||||
|
|
||||||
|
|
|
@ -86,14 +86,6 @@ void handleDDUStatusPing(const String &payload, const size_t size){
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
WiFi.begin(ssid, pass);
|
|
||||||
|
|
||||||
// initialize mqtt client
|
|
||||||
mqtt.begin(client);
|
|
||||||
|
|
||||||
// connect to wifi, host and mqtt broker
|
|
||||||
connect();
|
|
||||||
|
|
||||||
M5.begin();
|
M5.begin();
|
||||||
M5.Lcd.begin();
|
M5.Lcd.begin();
|
||||||
M5.Lcd.fillScreen(TFT_BLACK); // Set initial background color
|
M5.Lcd.fillScreen(TFT_BLACK); // Set initial background color
|
||||||
|
@ -103,6 +95,14 @@ void setup()
|
||||||
M5.Lcd.println("Loading...");
|
M5.Lcd.println("Loading...");
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
WiFi.begin(ssid, pass);
|
||||||
|
|
||||||
|
// initialize mqtt client
|
||||||
|
mqtt.begin(client);
|
||||||
|
|
||||||
|
// connect to wifi, host and mqtt broker
|
||||||
|
connect();
|
||||||
|
|
||||||
startTime = millis();
|
startTime = millis();
|
||||||
|
|
||||||
// subscribe topic and callback which is called when /hello has come
|
// subscribe topic and callback which is called when /hello has come
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#define correctWirePin 26
|
#define correctWirePin 26
|
||||||
#define wrongWirePin 25
|
#define wrongWirePin 25
|
||||||
#define extenderPin 0
|
#define extenderPin 32
|
||||||
|
|
||||||
bool hasWon, hasLost = false;
|
bool hasWon, hasLost = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue