Skip to content
Browse files

implemented setRTC message

  • Loading branch information...
1 parent a909a60 commit bb6c4575df7f5e78511908abe302ba9157736b98 Kai Aras committed Oct 6, 2011
Showing with 36 additions and 1 deletion.
  1. +6 −1 MWKit/MWImageTools.m
  2. +1 −0 MWMetaWatch.h
  3. +29 −0 MWMetaWatch.m
View
7 MWKit/MWImageTools.m
@@ -473,7 +473,9 @@ +(NSData*)imageDataForHomeScreen:(NSDictionary*)dataDict{
style, NSParagraphStyleAttributeName,
[NSFont fontWithName:@"MetaWatch Small caps 8pt" size:8.0], NSFontAttributeName,nil]retain];
- [[NSString stringWithFormat:@"Connected to: %@",CSCopyMachineName() ] drawInRect:CGRectMake(45, 30, 51, 30) withAttributes:dict];
+
+
+ [[NSString stringWithFormat:@"%@",CSCopyMachineName() ] drawInRect:CGRectMake(45, 30, 51, 30) withAttributes:dict];
NSDictionary *weather = [dataDict objectForKey:@"weatherDict"];
NSString *condition = [weather objectForKey:@"condition"];
@@ -491,7 +493,10 @@ +(NSData*)imageDataForHomeScreen:(NSDictionary*)dataDict{
weatherIcon=[NSImage imageNamed:@"weather_sunny.bmp"];
}else if ([condition isEqualToString:@"Chance of Showers"]) {
weatherIcon=[NSImage imageNamed:@"weather_rain.bmp"];
+ }else if ([condition isEqualToString:@"Chance of Rain"]) {
+ weatherIcon=[NSImage imageNamed:@"weather_rain.bmp"];
}
+
[weatherIcon drawAtPoint:NSMakePoint(5, 42) fromRect:NSMakeRect(0, 0, 24, 24) operation:NSCompositeCopy fraction:1.0];
[condition drawAtPoint:CGPointMake(5, 37) withAttributes:dict];
View
1 MWMetaWatch.h
@@ -96,6 +96,7 @@
-(void)getDeviceType;
-(void)getRTC;
+-(void)setRTC;
-(void)enableButton:(unsigned char)mode index:(unsigned char)buttonIndex type:(unsigned char)buttonType;
-(void)disableButton:(unsigned char)mode index:(unsigned char)buttonIndex type:(unsigned char)buttonType;
View
29 MWMetaWatch.m
@@ -422,6 +422,35 @@ -(void)getRTC {
}
+
+-(void)setRTC {
+
+ NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0];
+ NSCalendar *cal = [NSCalendar currentCalendar];
+
+ NSDateComponents *components = [cal components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:date];
+
+ unsigned char data[10];
+
+
+
+ data[0]=components.year<<8;
+ data[1]=components.year;
+ data[2]=components.month;
+ data[3]=components.day;
+ data[4]=components.weekday;
+ data[5]=components.hour;
+ data[6]=components.minute;
+ data[7]=components.second;
+ data[8]=0x00;
+ data[9]=0x00;
+
+
+ [self tx:kMSG_TYPE_SET_RTC options:0x00 data:data len:10];
+
+}
+
+
-(void)buzz {
unsigned char data[] = { 0x01, 0xf4, 0x01 ,0xf4, 0x01, 0x01};
[self tx:kMSG_TYPE_SET_VIBRATE_MODE options:0x00 data:data len:6];

0 comments on commit bb6c457

Please sign in to comment.
Something went wrong with that request. Please try again.