Skip to content

Commit

Permalink
[ADD] spa/error MQTT channel while error occurred in spa
Browse files Browse the repository at this point in the history
[REMOVE] unnecessary temp debug
[WIP] Partial support for SJB-HS-XX-1G spa - spa/state/jet topic added
  • Loading branch information
YorffoeG committed Jun 18, 2020
1 parent dd45d98 commit 1bc14b5
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
8 changes: 7 additions & 1 deletion include/CTRLPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "CFGSettings.h"
#include "Arduino.h"

#include "config.h"

class CTRLPanel {

public:
Expand All @@ -37,14 +39,18 @@ class CTRLPanel {
uint8_t isHeaterOn();
uint8_t isHeatReached();

#ifdef SJB_HS
uint8_t isJetOn();
#endif

bool hasError();
uint16_t getError();

bool setDesiredTemperatureCelsius(uint16_t temp);
bool setPowerOn(bool v);
bool setFilterOn(bool v);
bool setHeaterOn(bool v);

bool isSetupModeTriggered();

private:
Expand Down
11 changes: 10 additions & 1 deletion include/MQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
#include "Arduino.h"
#include <ESP8266WiFi.h>

#define MAX_PUBLISHER 10
#include "config.h"

#ifdef SSP_H
#define MAX_PUBLISHER 11
#endif

#ifdef SJB_HS
#define MAX_PUBLISHER 12
#endif

#define MAX_SUBSCRIBER 6

#define MQTT_HOSTNAME_MAX HOST_LEN_MAX
Expand Down
2 changes: 1 addition & 1 deletion include/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

#include <stdint.h>

const char* FW_VERSION = "1.3.0";
const char* FW_VERSION = "1.4.0";

#endif // VERSION_H
24 changes: 24 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@
#define OTA_ENABLED
#define DBG_TCP_ENABLED
#define DBG_SERIAL_ENABLED


/* PCB DESIGN */
#define PCB_DESIGN_1
//#define PCB_DESIGN_2


/* SPA MODEL */
#define SSP_H // SSP-H-20-1/SSP-H-20-1C/SSP-H20-2
//#define SJB_HS // SJB-HS-20-1G/SJB-HS-30-1G/SJB-HS-22-1G/SJB-HS-33-1G



#define DBG_TCP_PORT 8888
#define SERIAL_DEBUG_SPEED 115200

Expand Down Expand Up @@ -46,4 +57,17 @@
#define WIFI_STA_HOSTNAME "diyscip"
#define WIFI_AP_NAME "DYISCIP_Setup"



/****** DO NOT MODIFY FROM HERE *******/
#if (defined(PCB_DESIGN_1) && defined(PCB_DESIGN_2)) || (!defined(PCB_DESIGN_1) && !defined(PCB_DESIGN_2))
#error "YOU MUST DEFINE ONE AND ONE ONLY PCB DESIGN"
#endif


#if (defined(SSP_H) && defined(SJB_HS)) || (!defined(SSP_H) && !defined(SJB_HS))
#error "YOU MUST DEFINE ONE AND ONE SPA MODEL"
#endif


#endif // CONFIG_H
17 changes: 16 additions & 1 deletion src/CTRLPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,24 @@
#define FRAME_DISPLAY_DIGITC (FRAME_DISPLAY_FRAGMENT_A|FRAME_DISPLAY_FRAGMENT_F|FRAME_DISPLAY_FRAGMENT_E|FRAME_DISPLAY_FRAGMENT_D)
#define FRAME_DISPLAY_DIGITE (FRAME_DISPLAY_FRAGMENT_A|FRAME_DISPLAY_FRAGMENT_F|FRAME_DISPLAY_FRAGMENT_E|FRAME_DISPLAY_FRAGMENT_D|FRAME_DISPLAY_FRAGMENT_G)
#define FRAME_DISPLAY_DIGITF (FRAME_DISPLAY_FRAGMENT_E|FRAME_DISPLAY_FRAGMENT_F|FRAME_DISPLAY_FRAGMENT_A|FRAME_DISPLAY_FRAGMENT_G)
#define FRAME_DISPLAY_DIGITH (FRAME_DISPLAY_FRAGMENT_B|FRAME_DISPLAT_FRAGMENT_C|FRAME_DISPLAY_FRAGMENT_E|FRAME_DISPLAY_FRAGMENT_F|FRAME_DISPLAY_FRAGMENT_G)

#define FRAME_LED 0x4000
#define FRAME_LED_POWER 0x0001
#define FRAME_LED_BUBBLE 0x0400
#define FRAME_LED_FILTER 0x1000
#define FRAME_LED_HEATER 0x0080
#define FRAME_LED_HEATREACHED 0x0200

#ifdef SSP_H
#define FRAME_LED_BUBBLE 0x0400
#endif


#ifdef SJB_HS
#define FRAME_LED_BUBBLE 0x0002
#define FRAME_LED_JET 0x0400
#endif

#define FRAME_BEEP_BIT 0x0100

#define DISPLAY_DROP_FRAME_DELAY 100
Expand Down Expand Up @@ -214,6 +224,11 @@ uint8_t CTRLPanel::isHeatReached() {
return (ledStatus != UNSET_VALUE) ? ((ledStatus & FRAME_LED_HEATREACHED) ? UINT8_TRUE : UINT8_FALSE) : UNSET_VALUEUINT8;
}

#ifdef SJB_HS
uint8_t CTRLPanel::isJetOn() {
return (ledStatus != UNSET_VALUE) ? ((ledStatus & FRAME_LED_JET) ? UINT8_TRUE : UINT8_FALSE) : UNSET_VALUEUINT8;
}
#endif

boolean CTRLPanel::setDesiredTemperatureCelsius(uint16_t temp) {
if ((temp >= MIN_SET_DESIRED_TEMPERATURE) && (temp <= MAX_SET_DESIRED_TEMPERATURE)) {
Expand Down
2 changes: 0 additions & 2 deletions src/TEMPSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ uint16_t TEMPSensor::getAverageTemperatureCelsius() {
Rth = (VCC * R2 / Vout) - R2;
temp = (1 / ((log(Rth / NTC_R25) / NTC_BETA) + (1 / (NTC_T25 + T_0)) )) - T_0;

DBG("readADC=%f, temp=%f", adcValue, temp);

if (!initialized) {
// initialize temperature samples with current temp.
for (int i=0; i<TEMP_SAMPLE_MAX; i++) {
Expand Down
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,19 @@ void setup() {
mqttClient->addPublisher("spa/temp/board", []() -> uint16_t { return tempSensor->getAverageTemperatureCelsius(); });
mqttClient->setLastAddedPublisherUpdateInterval(TEMP_UPDATE_INTERVAL);

mqttClient->addPublisher("spa/error", []() -> uint16_t { return controlPanel->getError(); });

mqttClient->addPublisher("spa/temp/water", []() -> uint16_t { return controlPanel->getWaterTemperatureCelsius(); });
mqttClient->addPublisher("spa/temp/desired", []() -> uint16_t { return controlPanel->getDesiredTemperatureCelsius(); });
mqttClient->addPublisher("spa/state/power", []() -> uint8_t { return controlPanel->isPowerOn(); });
mqttClient->addPublisher("spa/state/filter", []() -> uint8_t { return controlPanel->isFilterOn(); });
mqttClient->addPublisher("spa/state/heater", []() -> uint8_t { return controlPanel->isHeaterOn(); });
mqttClient->addPublisher("spa/state/bubble", []() -> uint8_t { return controlPanel->isBubbleOn(); });

#ifdef SJB_HS
mqttClient->addPublisher("spa/state/jet", []() -> uint8_t { return controlPanel->isJetOn(); });
#endif

mqttClient->addPublisher("spa/state/heatreached", []() -> uint8_t { return controlPanel->isHeatReached(); });
mqttClient->addPublisher("spa/state", []() -> uint16_t { return controlPanel->getRawStatus(); });

Expand Down

0 comments on commit 1bc14b5

Please sign in to comment.