Clock with Real-Time Clock (RTC-8564) and I2C LCD module(SB1062B).

Dependencies:   DebouncedEdgeIn I2cLCD_cursor Rtc8564 mbed beep

/media/uploads/togayan/imgp0004s.jpg /media/uploads/togayan/lcdclock_circuit_rev4.png

Committer:
togayan
Date:
Sun Feb 09 09:05:25 2014 +0000
Revision:
0:86ab67787717
Child:
1:f8713c387a68
Working to change to the clock

Who changed what in which revision?

UserRevisionLine numberNew contents of line
togayan 0:86ab67787717 1 #include "ClockViewModel.h"
togayan 0:86ab67787717 2
togayan 0:86ab67787717 3 using ViewModel::ClockViewModel;
togayan 0:86ab67787717 4
togayan 0:86ab67787717 5 // Icon Name ----
togayan 0:86ab67787717 6 // Mark
togayan 0:86ab67787717 7 // Battery_1
togayan 0:86ab67787717 8 // Battery_2
togayan 0:86ab67787717 9 // Battery_3
togayan 0:86ab67787717 10 // Battery_4
togayan 0:86ab67787717 11 // NoSound
togayan 0:86ab67787717 12 // Lock
togayan 0:86ab67787717 13 // ArrowDown
togayan 0:86ab67787717 14 // ArrowUp
togayan 0:86ab67787717 15 // Input
togayan 0:86ab67787717 16 // Alarm
togayan 0:86ab67787717 17 // Tell
togayan 0:86ab67787717 18 // Antenna
togayan 0:86ab67787717 19 // --------------
togayan 0:86ab67787717 20
togayan 0:86ab67787717 21 ClockViewModel::ClockViewModel(I2cLCD& i2clcd)
togayan 0:86ab67787717 22 :m_i2clcd(i2clcd),
togayan 0:86ab67787717 23 m_sec(0)
togayan 0:86ab67787717 24 {
togayan 0:86ab67787717 25 }
togayan 0:86ab67787717 26
togayan 0:86ab67787717 27 void ClockViewModel::initialize()
togayan 0:86ab67787717 28 {
togayan 0:86ab67787717 29 // print ICON
togayan 0:86ab67787717 30 m_i2clcd.seticon( I2cLCD::Mark );
togayan 0:86ab67787717 31 m_i2clcd.seticon( I2cLCD::Battery_1 );
togayan 0:86ab67787717 32 m_i2clcd.seticon( I2cLCD::Battery_2 );
togayan 0:86ab67787717 33 m_i2clcd.seticon( I2cLCD::Battery_3 );
togayan 0:86ab67787717 34 m_i2clcd.seticon( I2cLCD::Battery_4 );
togayan 0:86ab67787717 35 m_i2clcd.seticon( I2cLCD::NoSound );
togayan 0:86ab67787717 36 m_i2clcd.seticon( I2cLCD::Lock );
togayan 0:86ab67787717 37 m_i2clcd.seticon( I2cLCD::ArrowDown );
togayan 0:86ab67787717 38 m_i2clcd.seticon( I2cLCD::ArrowUp );
togayan 0:86ab67787717 39 m_i2clcd.seticon( I2cLCD::Input );
togayan 0:86ab67787717 40 m_i2clcd.seticon( I2cLCD::Alarm );
togayan 0:86ab67787717 41 m_i2clcd.seticon( I2cLCD::Tell );
togayan 0:86ab67787717 42 m_i2clcd.seticon( I2cLCD::Antenna );
togayan 0:86ab67787717 43 }
togayan 0:86ab67787717 44
togayan 0:86ab67787717 45 void ClockViewModel::renew()
togayan 0:86ab67787717 46 {
togayan 0:86ab67787717 47 m_i2clcd.seticon( I2cLCD::Antenna );
togayan 0:86ab67787717 48 m_i2clcd.locate(0, 0);
togayan 0:86ab67787717 49 m_i2clcd.printf(" 2015 / 02 / 08\n 17 : 02 : %02d", m_sec);
togayan 0:86ab67787717 50 m_sec = (++m_sec == 60)? 0 : m_sec;
togayan 0:86ab67787717 51 }
togayan 0:86ab67787717 52
togayan 0:86ab67787717 53 void ClockViewModel::informHalfSec()
togayan 0:86ab67787717 54 {
togayan 0:86ab67787717 55 m_i2clcd.clearicon( I2cLCD::Antenna );
togayan 0:86ab67787717 56 }
togayan 0:86ab67787717 57