PCB lives now in its own git repo https://git.la10cy.net/DeltaLima/CanGrow-12V-PCB
46 lines
1.4 KiB
C
46 lines
1.4 KiB
C
/*
|
|
*
|
|
* include/Sensor/00_Example.h - example sensor header I2C device
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
|
|
#include <Adafruit_WhateverLib.h>
|
|
|
|
#define SENSOR_00_NAME "Example sensor"
|
|
|
|
const byte Sensor_00_Example_Addr[] = { 0x00, 0x01 };
|
|
|
|
Adafruit_WhateverLib Whatever[sizeof(Sensor_00_Example_Addr)];
|
|
|
|
/* Create main data array specifying max amount of readings */
|
|
float Sensor_00_Example[sizeof(Sensor_00_Example_Addr)][4];
|
|
|
|
void Sensor_00_Example_Update(const byte AddrId) {
|
|
/* keep the same order as in SensorIndex[].read[] !! */
|
|
Sensor_00_Example[AddrId][0] = Whatever[AddrId].temperature();
|
|
Sensor_00_Example[AddrId][1] = Whatever[AddrId].humidity();
|
|
Sensor_00_Example[AddrId][2] = Whatever[AddrId].raw1();
|
|
Sensor_00_Example[AddrId][3] = Whatever[AddrId].raw2();
|
|
}
|
|
|
|
bool Sensor_00_Example_Init(const byte AddrId) {
|
|
/* Sensor Init function
|
|
*
|
|
* returns true (1) when Init was successful
|
|
* returns false (0) if not.
|
|
*/
|
|
const static char LogLoc[] PROGMEM = "[Sensor:00_Example:Init]";
|
|
bool returnCode;
|
|
|
|
if(Whatever[AddrId].begin(Sensor_00_Example_Addr[AddrId])) {
|
|
Log.notice(F("%s found at addr 0x%x" CR), LogLoc, Sensor_00_Example_Addr[AddrId]);
|
|
Sensor_00_Example_Update(AddrId);
|
|
returnCode = true;
|
|
} else {
|
|
Log.error(F("%s FAILED! Not found at addr 0x%x" CR), LogLoc, Sensor_00_Example_Addr[AddrId]);
|
|
returnCode = false;
|
|
}
|
|
return returnCode;
|
|
}
|