Loom 4 v4.5
Arduino library for Internet of Things Rapid Prototyping in environmental sensing
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Loom_Hypnos Class Reference

#include <Loom_Hypnos.h>

Inheritance diagram for Loom_Hypnos:
Inheritance graph
[legend]
Collaboration diagram for Loom_Hypnos:
Collaboration graph
[legend]

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 ()
 
SDManagergetSDManager ()
 
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
 

Detailed Description

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.

Author
Will Richards

Constructor & Destructor Documentation

◆ Loom_Hypnos()

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

Parameters
manReference to the manager
versionThe version of the Hypnos in use, this changes which pin is used as and SD chip select
timezoneThe current timezone the clock was set to
use_custom_timeUse a specific time set by the user that is different than the compile time
useSDWhether or not SD card functionality should be enabled

◆ ~Loom_Hypnos()

Loom_Hypnos::~Loom_Hypnos ( )

Cleanup any dynamically allocated pointers

Member Function Documentation

◆ disable()

void Loom_Hypnos::disable ( )

Disables the Hypnos Board Disables the Power Rails and sets the SPI pins to INPUT which effectively disables them

◆ enable()

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

Parameters
enable33whether or not to enable the 3.3v rails
enable5whether or not to enable the 5v and 12v rails

◆ getCurrentTime()

DateTime Loom_Hypnos::getCurrentTime ( )

Get the current time from the RTC

◆ getDefaultFilename()

const char * Loom_Hypnos::getDefaultFilename ( )
inline

Get the default SD card file name

◆ getSDManager()

SDManager * Loom_Hypnos::getSDManager ( )
inline

Get an instance of the SD manager, used for batch SD

◆ getSleepIntervalFromSD()

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

Parameters
fileNameName of the file to pull information from
Returns
TimeSpan with the parsed data

◆ getTimeZoneFromSD()

void Loom_Hypnos::getTimeZoneFromSD ( const char *  fileName)

Get and set the timezone for the Hypnos from the SD card

Parameters
fileNameName of the file to pull information from

◆ initialize()

void Loom_Hypnos::initialize ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ logToSD()

bool Loom_Hypnos::logToSD ( )

Log the current sensor data to a file on the SD card

◆ measure()

void Loom_Hypnos::measure ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ package()

void Loom_Hypnos::package ( )
overrideprotectedvirtual

Implements Module.

◆ power_down()

void Loom_Hypnos::power_down ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ power_up()

void Loom_Hypnos::power_up ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ readFile()

char * Loom_Hypnos::readFile ( const char *  fileName)
inline

Read file from SD

Parameters
fileNameFile to read from

◆ reattachRTCInterrupt()

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

Parameters
interruptPinPin to reattach the interrupt to for RTC this doesn't need to be changed

◆ registerInterrupt()

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

Parameters
isrFuncfunction to callback to when the interrupt is triggered
interruptPinDefaults to RTC pin on Hypnos can be changed to reflect other interrupts
interruptTypeType of the interrupt to register (SLEEP or OTHER)
triggerStateWhen the interrupt should trigger

◆ set_custom_time()

void Loom_Hypnos::set_custom_time ( )

Set a custom time on startup for the RTC to use

◆ setInterruptDuration()

void Loom_Hypnos::setInterruptDuration ( const TimeSpan  duration)

Set the next interrupt to be triggered at a set interval in the future

Parameters
durationThe time that will elapse before the next interrupt is triggered

◆ setLogName()

void Loom_Hypnos::setLogName ( const char *  name)
inline

Set an alternative name to log data to

◆ sleep()

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

Parameters
waitForSerialWhether or not we should wait for the user to open the serial monitor before continuing execution

◆ wakeup()

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


The documentation for this class was generated from the following files: