Page 96 - MDP2020-2
P. 96
| 인천전자마이스터고등학교 ·············································································································
90
제2장 소프트웨어 설계
[시계 Display]
#include "Wire.h"
#include "U8glib.h"
#include "swRTC.h"
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST);
// Dev 0, Fast I2C / TWI
//***************************************************************************
void display_month(void);
void display_day(void);
void display_date(void);
void display_time(void);
void draw(void);
//***************************************************************************
extern volatile unsigned long timer0_millis; //타이머변수
unsigned long timeVal; //이전시간
unsigned long readTime; //현재타이머시간
int Hour=17, Min=26, Sec=32; //시간 Setting
//***************************************************************************
int year=2020, month=11, day=16, date=1; //날짜 Setting
//***************************************************************************
void setup(void) {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255);
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3);
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1);
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}
}//End setup