# binwatch - Tiny binary wristwatch. {{{ # # Copyright (C) 2010 Nicolas Schodet # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Contact : # Web: http://ni.fr.eu.org/ # Email: # }}} */ """RTC control.""" import struct import dev2.twi class ProtocolError (RuntimeError): pass class RTC: REGS = [ ('control1', 0xff), ('control2', 0xbf), ('second', 0xff), ('minute', 0x7f), ('hour', 0x3f), ('day', 0x3f), ('weekday', 0x07), ('month_century', 0x9f), ('year', 0xff), ('alarm_minute', 0xff), ('alarm_hour', 0xbf), ('alarm_day', 0xbf), ('alarm_weekday', 0x87), ('clkout', 0x83), ('timer_control', 0x83), ('timer', 0xff), ] def __init__ (self, address, serial): """Initialise and set address and serial object to use.""" self.address = address self.twi = dev2.twi.Twi (serial) def init (self): s = struct.pack ('> sys.stderr, e.message sys.exit (1) if __name__ == '__main__': command ()