mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
moved includes to headerfile, general cleanup
This commit is contained in:
parent
fd16803d2a
commit
ea1374fca0
2 changed files with 50 additions and 59 deletions
86
src/main.cpp
86
src/main.cpp
|
@ -1,17 +1,4 @@
|
||||||
#include <Arduino.h>
|
#include "main.hpp"
|
||||||
#include <SPI.h>
|
|
||||||
#include <Wire.h>
|
|
||||||
#include <Adafruit_GFX.h>
|
|
||||||
#include <Adafruit_SSD1306.h>
|
|
||||||
#include <MFRC522.h>
|
|
||||||
#include <FS.h>
|
|
||||||
#include <LittleFS.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "TeaTimer.hpp"
|
|
||||||
#include "ContinuousServo.hpp"
|
|
||||||
#include "SmartDial.hpp"
|
|
||||||
#include "SmartDisplay.hpp"
|
|
||||||
|
|
||||||
#define WIRE Wire
|
#define WIRE Wire
|
||||||
|
|
||||||
|
@ -43,11 +30,6 @@ enum State
|
||||||
};
|
};
|
||||||
State state = State::DISPLAY_SCANNED_TEA_CONFIG;
|
State state = State::DISPLAY_SCANNED_TEA_CONFIG;
|
||||||
|
|
||||||
void serial_dump_byte_array(byte *buffer, byte bufferSize);
|
|
||||||
void oled_dump_byte_array(byte *buffer, byte bufferSize);
|
|
||||||
void printMsg(const String &s);
|
|
||||||
void printMsg(unsigned long l);
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
@ -57,9 +39,6 @@ void setup()
|
||||||
|
|
||||||
Serial.println("Initializing RFID...");
|
Serial.println("Initializing RFID...");
|
||||||
mfrc522.PCD_Init();
|
mfrc522.PCD_Init();
|
||||||
/*Serial.print(F("Ver: 0x"));
|
|
||||||
byte readReg = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
|
|
||||||
Serial.println(readReg, HEX);*/
|
|
||||||
mfrc522.PICC_HaltA();
|
mfrc522.PICC_HaltA();
|
||||||
|
|
||||||
Serial.println("Initializing OLED...");
|
Serial.println("Initializing OLED...");
|
||||||
|
@ -74,41 +53,10 @@ void setup()
|
||||||
key.keyByte[i] = 0xFF;
|
key.keyByte[i] = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println(F("Scan a MIFARE Classic PICC to demonstrate basic recognition."));
|
|
||||||
Serial.print(F("Using key (for A and B):"));
|
|
||||||
serial_dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE);
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// teaTimer.init(&contServo);
|
|
||||||
|
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
pinMode(TOUCH_BTN_PIN, INPUT);
|
pinMode(TOUCH_BTN_PIN, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printMsg(const String &s)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0, 10);
|
|
||||||
display.println(s);
|
|
||||||
display.display();
|
|
||||||
}
|
|
||||||
void printMsg(unsigned long l)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0, 10);
|
|
||||||
display.println(l);
|
|
||||||
display.display();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isBtnPressed()
|
|
||||||
{
|
|
||||||
return digitalRead(TOUCH_BTN_PIN) == HIGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
int steepingSeconds = 60;
|
int steepingSeconds = 60;
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
@ -136,11 +84,6 @@ void loop()
|
||||||
display.display();
|
display.display();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
// PICC type, e.g. "MIFARE 1K0"
|
|
||||||
// Serial.print(F("PICC type: "));
|
|
||||||
// MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
|
|
||||||
// Serial.println(mfrc522.PICC_GetTypeName(piccType));
|
|
||||||
|
|
||||||
// Halt PICC
|
// Halt PICC
|
||||||
mfrc522.PICC_HaltA();
|
mfrc522.PICC_HaltA();
|
||||||
|
|
||||||
|
@ -195,6 +138,11 @@ void toggle_led()
|
||||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBtnPressed()
|
||||||
|
{
|
||||||
|
return digitalRead(TOUCH_BTN_PIN) == HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper routine to dump a byte array as hex values to Serial.
|
* Helper routine to dump a byte array as hex values to Serial.
|
||||||
*/
|
*/
|
||||||
|
@ -206,6 +154,9 @@ void serial_dump_byte_array(byte *buffer, byte bufferSize)
|
||||||
Serial.print(buffer[i], HEX);
|
Serial.print(buffer[i], HEX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Helper routine to dump a byte array as hex values to OLED.
|
||||||
|
*/
|
||||||
void oled_dump_byte_array(byte *buffer, byte bufferSize)
|
void oled_dump_byte_array(byte *buffer, byte bufferSize)
|
||||||
{
|
{
|
||||||
for (byte i = 0; i < bufferSize; i++)
|
for (byte i = 0; i < bufferSize; i++)
|
||||||
|
@ -213,4 +164,23 @@ void oled_dump_byte_array(byte *buffer, byte bufferSize)
|
||||||
display.print(buffer[i] < 0x10 ? " 0" : " ");
|
display.print(buffer[i] < 0x10 ? " 0" : " ");
|
||||||
display.print(buffer[i], HEX);
|
display.print(buffer[i], HEX);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printMsg(const String &s)
|
||||||
|
{
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setCursor(0, 10);
|
||||||
|
display.println(s);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
void printMsg(unsigned long l)
|
||||||
|
{
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setCursor(0, 10);
|
||||||
|
display.println(l);
|
||||||
|
display.display();
|
||||||
}
|
}
|
23
src/main.hpp
23
src/main.hpp
|
@ -1 +1,22 @@
|
||||||
bool toggle_led(void *);
|
#include <Arduino.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_SSD1306.h>
|
||||||
|
#include <MFRC522.h>
|
||||||
|
#include <FS.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "TeaTimer.hpp"
|
||||||
|
#include "ContinuousServo.hpp"
|
||||||
|
#include "SmartDial.hpp"
|
||||||
|
#include "SmartDisplay.hpp"
|
||||||
|
|
||||||
|
bool toggle_led(void *);
|
||||||
|
void printMsg(const String &s);
|
||||||
|
void printMsg(unsigned long l);
|
||||||
|
bool isBtnPressed();
|
||||||
|
|
||||||
|
void serial_dump_byte_array(byte *buffer, byte bufferSize);
|
||||||
|
void oled_dump_byte_array(byte *buffer, byte bufferSize);
|
Loading…
Add table
Reference in a new issue