Ignore:
Timestamp:
Jun 22, 2019, 10:54:21 AM (7 years ago)
Author:
markus
Message:

Prototyp for virtual OT-Slave (OT_V2R2_Slave)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Arduino/projects/OT_slave/OT_slave.ino

    r3 r4  
    44#define THERMOSTAT_OUT 4
    55
    6 OpenthermData message;
     6class OT_V2R2_Slave {
    77
    8 void setup() {
     8protected:
     9  static OpenthermData message;
     10 
     11
     12public:
     13  OT_V2R2_Slave ();
     14
     15  virtual void  Setup ();
     16  virtual void  Loop ();
     17
     18private:
     19  static void ListenAfterResponse ();
     20
     21};
     22
     23static OpenthermData  OT_V2R2_Slave::message;
     24
     25OT_V2R2_Slave::OT_V2R2_Slave ()
     26{
     27}
     28
     29void  OT_V2R2_Slave::Setup ()
     30{
    931  pinMode(THERMOSTAT_IN, INPUT);
    1032  digitalWrite(THERMOSTAT_OUT, HIGH);
    1133  pinMode(THERMOSTAT_OUT, OUTPUT); // low output = high current, high output = low current
    12 
    13   Serial.begin(19200);
     34 
    1435}
    1536
    16 /**
    17  * Loop will act as boiler (slave) connected to Opentherm thermostat.
    18  * It will wait for requests from thermostat and response with unknown data id as a fake response.
    19  */
    20 void loop() {
     37void  OT_V2R2_Slave::Loop ()
     38{
    2139  if (OPENTHERM::getMessage(message)) {
    2240    Serial.print("-> ");
    … …  
    2745    message.valueHB = 0;
    2846    message.valueLB = 0;
    29     OPENTHERM::send(THERMOSTAT_OUT, message, listenAfterResponse); // send some response and wait for antoher request from thermostat set by callback
     47    OPENTHERM::send(THERMOSTAT_OUT, message, OT_V2R2_Slave::ListenAfterResponse); // send some response and wait for antoher request from thermostat set by callback
    3048  }
    3149  else if (OPENTHERM::isSent() || OPENTHERM::isIdle() || OPENTHERM::isError()) { // wait for request from thermostat
    … …  
    3452}
    3553
    36 void listenAfterResponse() {
     54void  OT_V2R2_Slave::ListenAfterResponse()
     55{
    3756  Serial.print("<- ");
    3857  OPENTHERM::printToSerial(message);
    … …  
    4160  OPENTHERM::listen(THERMOSTAT_IN, -1);
    4261}
     62
     63OT_V2R2_Slave boiler;
     64
     65void setup()
     66{
     67  boiler.Setup();
     68  Serial.begin(19200);
     69}
     70
     71/**
     72 * Loop will act as boiler (slave) connected to Opentherm thermostat.
     73 * It will wait for requests from thermostat and response with unknown data id as a fake response.
     74 */
     75void loop()
     76{
     77  boiler.Loop();
     78}
Note: See TracChangeset for help on using the changeset viewer.