Skip to content

Class Instantiation

Arnd edited this page Apr 20, 2017 · 2 revisions

Cubigel(&Serial,[&Serial]);

The Cubigel class accepts one or two parameters to instantiate, depending upon how many compressors are attached. The parameters passed in are pointers to either an already instantiated SoftwareSerial instance or a HardwareSerial port in the form of "Serial", "Serial1", etc. depending upon which port is chosen. Unlike SoftwareSerial ports, any hardware serial ports do not need to be explicitly instantiated.

As part of class instantiation, the library will create an interrupt using TIMER0_COMPA which will trigger roughly every millisecond, but at a different point in time to the interrupt used on the same timer for the millis() function. If there is data in any of the receive buffers they will will be read and processed as part of the interrupt handler.


Example:

// Example for a fridge/freezer using an ATMega 2560 and software ports //
//  52 and 53 for the fridgeand hardware serial 1 for the freezer data  //
const uint8_t  FRIDGE_RX_PIN = 52; // Pin for fridge serial receive     //
const uint8_t  FRIDGE_TX_PIN = 53; // Pin for fridge serial transmit    //
SoftwareSerial FridgeSerial(FRIDGE_RX_PIN,// Instantiate Fridge software//
                           FRIDGE_TX_PIN);// serial port                //
CubigelClass   Cubigel(&FridgeSerial,&Serial1);// Instantiate Cubigel   //

...

void loop() {
  Cubigel.readValues(0,RPM,mA,CommsErrors,CubigelError);// get readings //
} // of main loop
Clone this wiki locally