product assembled

This commit is contained in:
BOT Alex 2024-05-16 18:26:40 +02:00
parent ff0b593007
commit 3ea87b42fc
7 changed files with 45 additions and 47 deletions

View File

@ -6,9 +6,9 @@ WiFiMulti wifiMulti;
HTTPClient http;
#define buttonPin 26
#define led1 25
#define led2 255
#define retractPin 0
#define ledA 32
#define ledB 25
#define retractPin 33
#define longPressThreshhold 150
@ -21,10 +21,9 @@ bool pressed = false;
void initRandomSeed()
{
wifiMulti.addAP("boost-v2", "crystalize");
wifiMulti.addAP("AIRPORT-FREE-WIFI-NEW", "alexalex");
wifiMulti.addAP("Next-Guest", "");
wifiMulti.addAP("boost-v2", "crystalize");
wifiMulti.addAP("Next-Guest", "");
long startStartedWifi = millis();
@ -61,11 +60,11 @@ void enterWinLoop(){
digitalWrite(retractPin, LOW);
while (true){
delay(250);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(ledB, LOW);
analogWrite(ledA, 0);
delay(250);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(ledB, HIGH);
analogWrite(ledA, 25);
if (!pressed && digitalRead(buttonPin) == HIGH)
{
@ -100,8 +99,8 @@ void setup()
pinMode(39, INPUT_PULLDOWN);
pinMode(buttonPin, INPUT_PULLDOWN);
pinMode(led1, OUTPUT_OPEN_DRAIN);
pinMode(led2, OUTPUT_OPEN_DRAIN);
pinMode(ledB, OUTPUT_OPEN_DRAIN);
pinMode(ledA, OUTPUT_OPEN_DRAIN);
pinMode(retractPin, OUTPUT_OPEN_DRAIN);
Serial.begin(115200);
@ -120,13 +119,13 @@ void loop()
}
if (lightA)
digitalWrite(led1, LOW);
digitalWrite(ledB, LOW);
else
digitalWrite(led1, HIGH);
digitalWrite(ledB, HIGH);
if (lightB)
digitalWrite(led2, LOW);
analogWrite(ledA, 0);
else
digitalWrite(led2, HIGH);
analogWrite(ledA, 25);
if (!pressed && digitalRead(buttonPin) == HIGH)
{

View File

@ -12,14 +12,7 @@ enum class Operator{
};
void initRandomSeed(){
M5.Imu.Init();
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);
randomSeed(millis());
}
String generateQuestion(){

View File

@ -1,4 +1,4 @@
#define UseMQTT
//#define UseMQTT
#ifdef UseMQTT
#include <WiFi.h>
#include <WebSocketsClient.h> // include before MQTTPubSubClient.h
@ -15,8 +15,8 @@ MQTTPubSubClient mqtt;
#include "InputSystem.h"
#include "MathSystem.h"
#define extenderPin 26
#define buttonPin 37
#define extenderPin 32
#define buttonPin 25
#define UIRefreshDelay 250
@ -67,7 +67,9 @@ void onInputDone(int inputNum){
if (inputNum == targetResult){
hasWon = true;
#ifdef UseMQTT
mqtt.publish("/DDUStatusPing", "winMath");
#endif
}
if (!hasWon){
@ -88,15 +90,16 @@ void setup() {
#endif
M5.begin();
M5.Lcd.setRotation(1);
M5.Lcd.setRotation(3);
initRandomSeed();
digitalWrite(extenderPin, HIGH); // Push out
pinMode(extenderPin, OUTPUT_OPEN_DRAIN);
pinMode(buttonPin, INPUT_PULLUP);
digitalWrite(extenderPin, HIGH); // Push out
Serial.begin(115200);
mathExpression = generateQuestion();

View File

@ -1,12 +1,12 @@
#include <M5StickCPlus.h>
#include <M5StickCPlus2.h>
#include "MorsePart.h"
#define refreshDelay 1000
#define BTN_A 37
#define BTN_B 39
#define BTN_A 25
#define BTN_B 26
#define extenderPin 26
#define extenderPin 32
int currentlySelected = 1000;
@ -24,12 +24,14 @@ bool hasWon = false;
void initRandomSeed()
{
M5.IMU.Init();
M5.Imu.init();
float accX, accY, accZ;
delay(250); // Wait for imu init
M5.IMU.getAccelData(&accX, &accY, &accZ);
M5.Imu.getAccelData(&accX, &accY, &accZ);
float accelSum = accX + accY + accZ;
M5.Imu.sleep();
unsigned long seed = accelSum * 1000000;
randomSeed(seed);
}
@ -37,11 +39,12 @@ void initRandomSeed()
void setup()
{
M5.begin();
M5.Lcd.setRotation(1);
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
pinMode(BTN_A, INPUT_PULLDOWN);
pinMode(BTN_B, INPUT_PULLDOWN);
pinMode(BTN_A, INPUT_PULLUP);
pinMode(BTN_B, INPUT_PULLUP);
pinMode(extenderPin, OUTPUT_OPEN_DRAIN);
Serial.begin(115200);
updateUI();

View File

@ -1,4 +1,4 @@
#include <M5StickCPlus.h>
#include <M5StickCPlus2.h>
#define nextItemDelayTime 500

View File

@ -86,14 +86,6 @@ void handleDDUStatusPing(const String &payload, const size_t size){
void setup()
{
WiFi.begin(ssid, pass);
// initialize mqtt client
mqtt.begin(client);
// connect to wifi, host and mqtt broker
connect();
M5.begin();
M5.Lcd.begin();
M5.Lcd.fillScreen(TFT_BLACK); // Set initial background color
@ -103,6 +95,14 @@ void setup()
M5.Lcd.println("Loading...");
Serial.begin(115200);
WiFi.begin(ssid, pass);
// initialize mqtt client
mqtt.begin(client);
// connect to wifi, host and mqtt broker
connect();
startTime = millis();
// subscribe topic and callback which is called when /hello has come

View File

@ -2,7 +2,7 @@
#define correctWirePin 26
#define wrongWirePin 25
#define extenderPin 0
#define extenderPin 32
bool hasWon, hasLost = false;