Loom 4 v4.5
Arduino library for Internet of Things Rapid Prototyping in environmental sensing
|
#include <Loom_Hypnos.h>
Public Member Functions | |
Loom_Hypnos (Manager &man, HYPNOS_VERSION version, TIME_ZONE zone, bool use_custom_time=false, bool useSD=true) | |
~Loom_Hypnos () | |
void | enable (bool enable33=true, bool emable5=true) |
void | disable () |
bool | logToSD () |
bool | registerInterrupt (InterruptCallbackFunction isrFunc=nullptr, int interruptPin=12, HypnosInterruptType interruptType=SLEEP, int triggerState=LOW) |
void | wakeup () |
bool | reattachRTCInterrupt (int interruptPin=12) |
void | setInterruptDuration (const TimeSpan duration) |
void | sleep (bool waitForSerial=false) |
DateTime | getCurrentTime () |
void | set_custom_time () |
TimeSpan | getSleepIntervalFromSD (const char *fileName) |
void | getTimeZoneFromSD (const char *fileName) |
char * | readFile (const char *fileName) |
const char * | getDefaultFilename () |
SDManager * | getSDManager () |
void | setLogName (const char *name) |
bool | isRTCInitialized () |
Public Member Functions inherited from Module | |
Module (const char *modName) | |
void | setModuleName (const char *modName) |
virtual const char * | getModuleName () |
virtual void | printModuleName (const char *message) |
virtual void | initialize ()=0 |
virtual void | measure ()=0 |
virtual void | package ()=0 |
virtual void | power_up ()=0 |
virtual void | power_down ()=0 |
virtual void | display_data () |
Public Attributes | |
volatile bool | shouldPowerUp = true |
Public Attributes inherited from Module | |
bool | moduleInitialized = true |
int | module_address = -1 |
Protected Member Functions | |
void | measure () override |
void | initialize () override |
void | power_up () override |
void | power_down () override |
void | package () override |
All in one driver for the Hypnos board. This allows users to use the Hypnos board in a more modularized manner not requiring all the Loom stuff.
Loom_Hypnos::Loom_Hypnos | ( | Manager & | man, |
HYPNOS_VERSION | version, | ||
TIME_ZONE | zone, | ||
bool | use_custom_time = false , |
||
bool | useSD = true |
||
) |
Constructs a new Hypnos Instance using the manager to hold information about the device
man | Reference to the manager |
version | The version of the Hypnos in use, this changes which pin is used as and SD chip select |
timezone | The current timezone the clock was set to |
use_custom_time | Use a specific time set by the user that is different than the compile time |
useSD | Whether or not SD card functionality should be enabled |
Loom_Hypnos::~Loom_Hypnos | ( | ) |
Cleanup any dynamically allocated pointers
void Loom_Hypnos::disable | ( | ) |
Disables the Hypnos Board Disables the Power Rails and sets the SPI pins to INPUT which effectively disables them
void Loom_Hypnos::enable | ( | bool | enable33 = true , |
bool | emable5 = true |
||
) |
Enable the Hypnos board Sets the power rail pins to OUTPUT mode and then enables them
enable33 | whether or not to enable the 3.3v rails |
enable5 | whether or not to enable the 5v and 12v rails |
DateTime Loom_Hypnos::getCurrentTime | ( | ) |
Get the current time from the RTC
|
inline |
Get the default SD card file name
|
inline |
Get an instance of the SD manager, used for batch SD
TimeSpan Loom_Hypnos::getSleepIntervalFromSD | ( | const char * | fileName | ) |
Get a custom sleep interval specified in a file on the SD card If there was an error reading the file the sleep interval will be set to 20 minutes
fileName | Name of the file to pull information from |
void Loom_Hypnos::getTimeZoneFromSD | ( | const char * | fileName | ) |
Get and set the timezone for the Hypnos from the SD card
fileName | Name of the file to pull information from |
|
inlineoverrideprotectedvirtual |
Implements Module.
bool Loom_Hypnos::logToSD | ( | ) |
Log the current sensor data to a file on the SD card
|
inlineoverrideprotectedvirtual |
Implements Module.
|
overrideprotectedvirtual |
Implements Module.
|
inlineoverrideprotectedvirtual |
Implements Module.
|
inlineoverrideprotectedvirtual |
Implements Module.
|
inline |
Read file from SD
fileName | File to read from |
bool Loom_Hypnos::reattachRTCInterrupt | ( | int | interruptPin = 12 | ) |
Called when the user wants to reattach the interrupt handler to the RTC interrupt to collect subsequent interrupts
interruptPin | Pin to reattach the interrupt to for RTC this doesn't need to be changed |
bool Loom_Hypnos::registerInterrupt | ( | InterruptCallbackFunction | isrFunc = nullptr , |
int | interruptPin = 12 , |
||
HypnosInterruptType | interruptType = SLEEP , |
||
int | triggerState = LOW |
||
) |
Enables RTC based interrupts using the DS3231 on the Hypnos
isrFunc | function to callback to when the interrupt is triggered |
interruptPin | Defaults to RTC pin on Hypnos can be changed to reflect other interrupts |
interruptType | Type of the interrupt to register (SLEEP or OTHER) |
triggerState | When the interrupt should trigger |
void Loom_Hypnos::set_custom_time | ( | ) |
Set a custom time on startup for the RTC to use
void Loom_Hypnos::setInterruptDuration | ( | const TimeSpan | duration | ) |
Set the next interrupt to be triggered at a set interval in the future
duration | The time that will elapse before the next interrupt is triggered |
|
inline |
Set an alternative name to log data to
void Loom_Hypnos::sleep | ( | bool | waitForSerial = false | ) |
Drops the Feather M0 and Hypnos board into a low power sleep waiting for an interrupt to wake it up and pull it out of sleep
waitForSerial | Whether or not we should wait for the user to open the serial monitor before continuing execution |
void Loom_Hypnos::wakeup | ( | ) |
Called when the user wants to wake the Hypnos back out of the sleep state This detaches the interrupt AND re-enables the power rails