Browse Source

fix multi platform support

master
iansun2 2 years ago
parent
commit
fecc79b6e0
  1. 7
      platformio.ini
  2. 16
      src/config.hpp
  3. 31
      src/main.cpp

7
platformio.ini

@ -26,3 +26,10 @@ board_build.filesystem = littlefs
upload_protocol = espota upload_protocol = espota
upload_port = 192.168.4.1 upload_port = 192.168.4.1
monitor_speed = 9600 monitor_speed = 9600
[env:arduino_uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 9600
lib_deps = sstaub/Ticker@^4.4.0

16
src/config.hpp

@ -9,8 +9,8 @@
#endif #endif
// do not edit this // DO NOT EDIT THIS !!
#if PLATFORM == ESP32 || PLATFORM == ESP8266 #if PLATFORM != NO_WIFI
#define WIRELESS_SUPPORT #define WIRELESS_SUPPORT
#endif #endif
@ -20,12 +20,12 @@
/*===== Pin =====*/ /*===== Pin =====*/
#define HEAT_GUN_FAN_PIN D2 #define HEAT_GUN_FAN_PIN 1
#define HEATER1_PIN D0 #define HEATER1_PIN 1
#define HEATER2_PIN D5 #define HEATER2_PIN 1
#define CONNECTION_LED_PIN D5 #define CONNECTION_LED_PIN 1
#define HEATER1_LED_PIN D4 #define HEATER1_LED_PIN 1
#define HEATER2_LED_PIN D5 #define HEATER2_LED_PIN 1
#define HEATER1_THERMISTOR_PIN A0 #define HEATER1_THERMISTOR_PIN A0
#define HEATER2_THERMISTOR_PIN A0 #define HEATER2_THERMISTOR_PIN A0

31
src/main.cpp

@ -18,13 +18,6 @@
/*===== Object =====*/
Ticker heater;
Ticker serial_reporter;
/*===== Variable =====*/ /*===== Variable =====*/
//-300: off //-300: off
double temp1_current = 0; double temp1_current = 0;
@ -37,7 +30,6 @@ boolean stringComplete = false; // whether the string is complete
/*===== Function =====*/ /*===== Function =====*/
double getTemperature(uint8_t thermistor_pin){ double getTemperature(uint8_t thermistor_pin){
@ -152,6 +144,18 @@ void heat_handler(){
#endif #endif
/*===== Object =====*/
#ifdef WIRELESS_SUPPORT
Ticker heater;
Ticker serial_reporter;
#else
Ticker heater(heat_handler, 100);
Ticker serial_reporter(serial_report_handler, 500);
#endif
/*===== Main =====*/ /*===== Main =====*/
void setup() { void setup() {
@ -170,10 +174,18 @@ void setup() {
#endif #endif
/*[Ticker Init]*/ /*[Ticker Init]*/
#ifdef WIRELESS_SUPPORT
heater.attach(0.1, heat_handler); heater.attach(0.1, heat_handler);
#ifndef SERIAL_DEBUG #ifndef SERIAL_DEBUG
serial_reporter.attach(0.5, serial_report_handler); serial_reporter.attach(0.5, serial_report_handler);
#endif #endif
#else
heater.start();
#ifndef SERIAL_DEBUG
serial_reporter.start();
#endif
#endif
} }
@ -183,6 +195,9 @@ void loop() {
//delay(100); //delay(100);
#ifdef WIRELESS_SUPPORT #ifdef WIRELESS_SUPPORT
wireless_handler(); wireless_handler();
#else
heater.update();
serial_reporter.update();
#endif #endif
#ifndef SERIAL_DEBUG #ifndef SERIAL_DEBUG

Loading…
Cancel
Save