Source code for pyupm_ds1307

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.





from sys import version_info
if version_info >= (2, 6, 0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_pyupm_ds1307', [dirname(__file__)])
        except ImportError:
            import _pyupm_ds1307
            return _pyupm_ds1307
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_ds1307', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_ds1307 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_ds1307
del version_info
try:
    _swig_property = property
except NameError:
    pass  # Python < 2.2 doesn't have 'property'.


def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
    if (name == "thisown"):
        return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name, None)
    if method:
        return method(self, value)
    if (not static):
        if _newclass:
            object.__setattr__(self, name, value)
        else:
            self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)


def _swig_setattr(self, class_type, name, value):
    return _swig_setattr_nondynamic(self, class_type, name, value, 0)


def _swig_getattr_nondynamic(self, class_type, name, static=1):
    if (name == "thisown"):
        return self.this.own()
    method = class_type.__swig_getmethods__.get(name, None)
    if method:
        return method(self)
    if (not static):
        return object.__getattr__(self, name)
    else:
        raise AttributeError(name)

def _swig_getattr(self, class_type, name):
    return _swig_getattr_nondynamic(self, class_type, name, 0)


def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object:
        pass
    _newclass = 0



def getVersion():
    return _pyupm_ds1307.getVersion()
getVersion = _pyupm_ds1307.getVersion

_pyupm_ds1307.DS1307_I2C_BUS_swigconstant(_pyupm_ds1307)
DS1307_I2C_BUS = _pyupm_ds1307.DS1307_I2C_BUS

_pyupm_ds1307.DS1307_I2C_ADDR_swigconstant(_pyupm_ds1307)
DS1307_I2C_ADDR = _pyupm_ds1307.DS1307_I2C_ADDR

_pyupm_ds1307.DS1307_DAY_MON_swigconstant(_pyupm_ds1307)
DS1307_DAY_MON = _pyupm_ds1307.DS1307_DAY_MON

_pyupm_ds1307.DS1307_DAY_TUE_swigconstant(_pyupm_ds1307)
DS1307_DAY_TUE = _pyupm_ds1307.DS1307_DAY_TUE

_pyupm_ds1307.DS1307_DAY_WED_swigconstant(_pyupm_ds1307)
DS1307_DAY_WED = _pyupm_ds1307.DS1307_DAY_WED

_pyupm_ds1307.DS1307_DAY_THU_swigconstant(_pyupm_ds1307)
DS1307_DAY_THU = _pyupm_ds1307.DS1307_DAY_THU

_pyupm_ds1307.DS1307_DAY_FRI_swigconstant(_pyupm_ds1307)
DS1307_DAY_FRI = _pyupm_ds1307.DS1307_DAY_FRI

_pyupm_ds1307.DS1307_DAY_SAT_swigconstant(_pyupm_ds1307)
DS1307_DAY_SAT = _pyupm_ds1307.DS1307_DAY_SAT

_pyupm_ds1307.DS1307_DAY_SUN_swigconstant(_pyupm_ds1307)
DS1307_DAY_SUN = _pyupm_ds1307.DS1307_DAY_SUN
[docs]class DS1307(_object): """ API for the DS1307 Real-Time CLock. ID: ds1307 Name: Real Time Clock (RTC) Module Other Names: DS1307 RTC Category: time Manufacturer: seeed Connection: i2c Link:https://www.maximintegrated.com/en/products/digital/real-time- clocks/DS1307.html UPM module for the DS1307-based real-time clock. The clock can provide information about seconds, minutes, hours, day of the week, day of the month, month, and year. It can operate in either a 24-hour or a 12-hour format. This device can also output a square wave at 1Khz, 4Khz, 8Khz, and 32Khz. However, this capability is not implemented in this module. C++ includes: ds1307.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, DS1307, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, DS1307, name) __repr__ = _swig_repr def __init__(self, bus): """ DS1307(int bus) DS1307 constructor Parameters: ----------- bus: I2C bus to use """ this = _pyupm_ds1307.new_DS1307(bus) try: self.this.append(this) except Exception: self.this = this
[docs] def loadTime(self): """ bool loadTime() Loads all the time values True if time data loaded successfully """ return _pyupm_ds1307.DS1307_loadTime(self)
[docs] def setTime(self): """ bool setTime() Sets the time. You should call loadTime() beforehand to maintain consistency True if time is set successfully """ return _pyupm_ds1307.DS1307_setTime(self)
[docs] def enableClock(self): """ mraa::Result enableClock() Enables an oscillator on the clock. 0 (mraa::SUCCESS) if successful; non-zero otherwise """ return _pyupm_ds1307.DS1307_enableClock(self)
[docs] def disableClock(self): """ mraa::Result disableClock() Disables the oscillator on the clock. This prevents the clock from updating any time/date values 0 (mraa::SUCCESS) if successful; non-zero otherwise """ return _pyupm_ds1307.DS1307_disableClock(self)
[docs] def writeBytes(self, reg, buffer, len): """ mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, int len) Writes value(s) into registers Parameters: ----------- reg: Register location to start writing into buffer: Buffer for data storage len: Number of bytes to write 0 (mraa::SUCCESS) if successful; non-zero otherwise """ return _pyupm_ds1307.DS1307_writeBytes(self, reg, buffer, len)
[docs] def readBytes(self, reg, buffer, len): """ int readBytes(uint8_t reg, uint8_t *buffer, int len) Reads value(s) from registers Parameters: ----------- reg: Register location to start reading from buffer: Buffer for data storage len: Number of bytes to read Number of bytes read """ return _pyupm_ds1307.DS1307_readBytes(self, reg, buffer, len)
[docs] def bcdToDec(self, val): """ unsigned int bcdToDec(uint8_t val) Converts a BCD value into decimal Parameters: ----------- val: BCD value to convert Converted decimal value """ return _pyupm_ds1307.DS1307_bcdToDec(self, val)
[docs] def decToBcd(self, val): """ uint8_t decToBcd(unsigned int val) Converts a decimal value into BCD Parameters: ----------- val: Decimal value to convert Converted BCD value """ return _pyupm_ds1307.DS1307_decToBcd(self, val)
__swig_setmethods__["seconds"] = _pyupm_ds1307.DS1307_seconds_set __swig_getmethods__["seconds"] = _pyupm_ds1307.DS1307_seconds_get if _newclass: seconds = _swig_property(_pyupm_ds1307.DS1307_seconds_get, _pyupm_ds1307.DS1307_seconds_set) __swig_setmethods__["minutes"] = _pyupm_ds1307.DS1307_minutes_set __swig_getmethods__["minutes"] = _pyupm_ds1307.DS1307_minutes_get if _newclass: minutes = _swig_property(_pyupm_ds1307.DS1307_minutes_get, _pyupm_ds1307.DS1307_minutes_set) __swig_setmethods__["hours"] = _pyupm_ds1307.DS1307_hours_set __swig_getmethods__["hours"] = _pyupm_ds1307.DS1307_hours_get if _newclass: hours = _swig_property(_pyupm_ds1307.DS1307_hours_get, _pyupm_ds1307.DS1307_hours_set) __swig_setmethods__["dayOfWeek"] = _pyupm_ds1307.DS1307_dayOfWeek_set __swig_getmethods__["dayOfWeek"] = _pyupm_ds1307.DS1307_dayOfWeek_get if _newclass: dayOfWeek = _swig_property(_pyupm_ds1307.DS1307_dayOfWeek_get, _pyupm_ds1307.DS1307_dayOfWeek_set) __swig_setmethods__["dayOfMonth"] = _pyupm_ds1307.DS1307_dayOfMonth_set __swig_getmethods__["dayOfMonth"] = _pyupm_ds1307.DS1307_dayOfMonth_get if _newclass: dayOfMonth = _swig_property(_pyupm_ds1307.DS1307_dayOfMonth_get, _pyupm_ds1307.DS1307_dayOfMonth_set) __swig_setmethods__["month"] = _pyupm_ds1307.DS1307_month_set __swig_getmethods__["month"] = _pyupm_ds1307.DS1307_month_get if _newclass: month = _swig_property(_pyupm_ds1307.DS1307_month_get, _pyupm_ds1307.DS1307_month_set) __swig_setmethods__["year"] = _pyupm_ds1307.DS1307_year_set __swig_getmethods__["year"] = _pyupm_ds1307.DS1307_year_get if _newclass: year = _swig_property(_pyupm_ds1307.DS1307_year_get, _pyupm_ds1307.DS1307_year_set) __swig_setmethods__["amPmMode"] = _pyupm_ds1307.DS1307_amPmMode_set __swig_getmethods__["amPmMode"] = _pyupm_ds1307.DS1307_amPmMode_get if _newclass: amPmMode = _swig_property(_pyupm_ds1307.DS1307_amPmMode_get, _pyupm_ds1307.DS1307_amPmMode_set) __swig_setmethods__["pm"] = _pyupm_ds1307.DS1307_pm_set __swig_getmethods__["pm"] = _pyupm_ds1307.DS1307_pm_get if _newclass: pm = _swig_property(_pyupm_ds1307.DS1307_pm_get, _pyupm_ds1307.DS1307_pm_set) __swig_destroy__ = _pyupm_ds1307.delete_DS1307 __del__ = lambda self: None
DS1307_swigregister = _pyupm_ds1307.DS1307_swigregister DS1307_swigregister(DS1307) # This file is compatible with both classic and new-style classes.