Changeset 4 for trunk/Arduino/projects/OT_slave
- Timestamp:
- Jun 22, 2019, 10:54:21 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/Arduino/projects/OT_slave/OT_slave.ino (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Arduino/projects/OT_slave/OT_slave.ino
r3 r4 4 4 #define THERMOSTAT_OUT 4 5 5 6 OpenthermData message; 6 class OT_V2R2_Slave { 7 7 8 void setup() { 8 protected: 9 static OpenthermData message; 10 11 12 public: 13 OT_V2R2_Slave (); 14 15 virtual void Setup (); 16 virtual void Loop (); 17 18 private: 19 static void ListenAfterResponse (); 20 21 }; 22 23 static OpenthermData OT_V2R2_Slave::message; 24 25 OT_V2R2_Slave::OT_V2R2_Slave () 26 { 27 } 28 29 void OT_V2R2_Slave::Setup () 30 { 9 31 pinMode(THERMOSTAT_IN, INPUT); 10 32 digitalWrite(THERMOSTAT_OUT, HIGH); 11 33 pinMode(THERMOSTAT_OUT, OUTPUT); // low output = high current, high output = low current 12 13 Serial.begin(19200); 34 14 35 } 15 36 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() { 37 void OT_V2R2_Slave::Loop () 38 { 21 39 if (OPENTHERM::getMessage(message)) { 22 40 Serial.print("-> "); … … 27 45 message.valueHB = 0; 28 46 message.valueLB = 0; 29 OPENTHERM::send(THERMOSTAT_OUT, message, listenAfterResponse); // send some response and wait for antoher request from thermostat set by callback47 OPENTHERM::send(THERMOSTAT_OUT, message, OT_V2R2_Slave::ListenAfterResponse); // send some response and wait for antoher request from thermostat set by callback 30 48 } 31 49 else if (OPENTHERM::isSent() || OPENTHERM::isIdle() || OPENTHERM::isError()) { // wait for request from thermostat … … 34 52 } 35 53 36 void listenAfterResponse() { 54 void OT_V2R2_Slave::ListenAfterResponse() 55 { 37 56 Serial.print("<- "); 38 57 OPENTHERM::printToSerial(message); … … 41 60 OPENTHERM::listen(THERMOSTAT_IN, -1); 42 61 } 62 63 OT_V2R2_Slave boiler; 64 65 void 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 */ 75 void loop() 76 { 77 boiler.Loop(); 78 }
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/trac/Paradigma/chrome/site/paradigma.png)