Temporary Connector Reversed Version

Dependencies:   UniGraphic mbed vt100

afero_poc15_180403R , J1 のピン配置を反転させたヴァージョンです。

Color2系を使用するためには以下のピンをジャンパで接続してください。
J1-D7 <-> J1-D0
J1-D6 <-> J1-D1

(調査中) また、こちらでテストした範囲では、
FRDM-KL25Z の V3.3 を、Modulo2 の VCC_3V3 ピンに接続してやる必要がありました。

尚、J1-D1, D0 を使用するために UART を無効にしているため
ログは表示されません。

TFTモジュールについて 
aitendoのTFTモジュールはデフォルトでは8bit bus モードになっています。
/media/uploads/Rhyme/img_2364.jpg

半田のジャンパを変えて、SPIの設定にしてください。
/media/uploads/Rhyme/img_2363.jpg

サーミスタについて
POC1.5 では サーミスタは 25℃の時に抵抗値が 50.0kΩになる502AT-11 が
4.95kΩのプルアップ(実際は10kΩx2の並列)で使用されていました。

今回の試作では抵抗値が 10.0kΩの 103AT-11 が
5.1kΩのプルアップで使用されていますので、係数を合わせるために
SMTC502AT-11 のコンストラクタを 
R0 = 10.0
R1 = 5.1
B = 3435
T0 = 298.15
で呼ぶように変更しました。

Committer:
Rhyme
Date:
Tue Apr 24 12:18:10 2018 +0000
Revision:
1:6c54dc8acf96
Parent:
0:0b6732b53bf4
to adjust with 103AT-11 with 5.1k pull-up, the constructor of 502AT-11 is called with R0=10.0, R1=5.1, B=3435, T0=298.15

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:0b6732b53bf4 1 #include "mbed.h"
Rhyme 0:0b6732b53bf4 2 #include "edge_time.h"
Rhyme 0:0b6732b53bf4 3
Rhyme 0:0b6732b53bf4 4 static const uint8_t daysInMonth[12] = {
Rhyme 0:0b6732b53bf4 5 31, 28, 31, 30,
Rhyme 0:0b6732b53bf4 6 31, 30, 31, 31,
Rhyme 0:0b6732b53bf4 7 30, 31, 30, 31
Rhyme 0:0b6732b53bf4 8 } ;
Rhyme 0:0b6732b53bf4 9
Rhyme 0:0b6732b53bf4 10 const char *nameOfDay[7] = {
Rhyme 0:0b6732b53bf4 11 "Sunday", "Monday", "Tuesday", "Wednesday",
Rhyme 0:0b6732b53bf4 12 "Thursday", "Friday", "Saturday"
Rhyme 0:0b6732b53bf4 13 } ;
Rhyme 0:0b6732b53bf4 14
Rhyme 0:0b6732b53bf4 15 uint32_t edge_time = 0 ;
Rhyme 0:0b6732b53bf4 16 uint32_t utc_offset = 9 * 60 * 60 ;
Rhyme 0:0b6732b53bf4 17 tm current_time ;
Rhyme 0:0b6732b53bf4 18 Ticker *tokei = 0 ;
Rhyme 0:0b6732b53bf4 19
Rhyme 0:0b6732b53bf4 20 void inc_sec(void)
Rhyme 0:0b6732b53bf4 21 {
Rhyme 0:0b6732b53bf4 22 __disable_irq() ; // Disable Interrupts
Rhyme 0:0b6732b53bf4 23 edge_time++ ;
Rhyme 0:0b6732b53bf4 24 __enable_irq() ; // Enable Interrupts
Rhyme 0:0b6732b53bf4 25 }
Rhyme 0:0b6732b53bf4 26
Rhyme 0:0b6732b53bf4 27 void init_timer(void)
Rhyme 0:0b6732b53bf4 28 {
Rhyme 0:0b6732b53bf4 29 tokei = new Ticker() ;
Rhyme 0:0b6732b53bf4 30 tokei->attach(inc_sec, 1.0) ;
Rhyme 0:0b6732b53bf4 31 }
Rhyme 0:0b6732b53bf4 32
Rhyme 0:0b6732b53bf4 33 void set_time(const uint16_t valueLen, const uint8_t *value)
Rhyme 0:0b6732b53bf4 34 {
Rhyme 0:0b6732b53bf4 35 uint32_t tmp_timestamp = 0 ;
Rhyme 0:0b6732b53bf4 36 for (int i = 0 ; i < valueLen ; i++ ) {
Rhyme 0:0b6732b53bf4 37 tmp_timestamp |= (value[i] & 0xFF) << (i * 8) ;
Rhyme 0:0b6732b53bf4 38 }
Rhyme 0:0b6732b53bf4 39 edge_time = tmp_timestamp ;
Rhyme 0:0b6732b53bf4 40 ts2tm(edge_time, &current_time) ;
Rhyme 0:0b6732b53bf4 41 // ts2time(edge_time, &current_time) ;
Rhyme 0:0b6732b53bf4 42 }
Rhyme 0:0b6732b53bf4 43
Rhyme 0:0b6732b53bf4 44 void ts2time(uint32_t timestamp, struct tm *tm)
Rhyme 0:0b6732b53bf4 45 {
Rhyme 0:0b6732b53bf4 46 uint32_t seconds, minutes, hours, days, month, year ;
Rhyme 0:0b6732b53bf4 47 uint32_t dayOfWeek ;
Rhyme 0:0b6732b53bf4 48
Rhyme 0:0b6732b53bf4 49 // timestamp += (3600 * 9) ; /* +9 hours for JST */
Rhyme 0:0b6732b53bf4 50 timestamp += utc_offset ;
Rhyme 0:0b6732b53bf4 51
Rhyme 0:0b6732b53bf4 52 seconds = timestamp % 60 ;
Rhyme 0:0b6732b53bf4 53 minutes = timestamp / 60 ;
Rhyme 0:0b6732b53bf4 54 hours = minutes / 60 ; /* +9 for JST */
Rhyme 0:0b6732b53bf4 55 minutes -= hours * 60 ;
Rhyme 0:0b6732b53bf4 56 days = hours / 24 ;
Rhyme 0:0b6732b53bf4 57 hours -= days * 24 ;
Rhyme 0:0b6732b53bf4 58
Rhyme 0:0b6732b53bf4 59 tm->tm_sec = seconds ;
Rhyme 0:0b6732b53bf4 60 tm->tm_min = minutes ;
Rhyme 0:0b6732b53bf4 61 tm->tm_hour = hours ;
Rhyme 0:0b6732b53bf4 62 tm->tm_mday = days + 1 ;
Rhyme 0:0b6732b53bf4 63 // tm->tm_mon = month ;
Rhyme 0:0b6732b53bf4 64 // tm->tm_year = year ;
Rhyme 0:0b6732b53bf4 65 // tm->tm_wday = dayOfWeek ;
Rhyme 0:0b6732b53bf4 66 }
Rhyme 0:0b6732b53bf4 67
Rhyme 0:0b6732b53bf4 68 void ts2tm(uint32_t timestamp, struct tm *tm)
Rhyme 0:0b6732b53bf4 69 {
Rhyme 0:0b6732b53bf4 70 uint32_t seconds, minutes, hours, days, month, year ;
Rhyme 0:0b6732b53bf4 71 uint32_t dayOfWeek ;
Rhyme 0:0b6732b53bf4 72
Rhyme 0:0b6732b53bf4 73 // timestamp += (3600 * 9) ; /* +9 hours for JST */
Rhyme 0:0b6732b53bf4 74 timestamp += utc_offset ;
Rhyme 0:0b6732b53bf4 75
Rhyme 0:0b6732b53bf4 76 seconds = timestamp % 60 ;
Rhyme 0:0b6732b53bf4 77 minutes = timestamp / 60 ;
Rhyme 0:0b6732b53bf4 78 hours = minutes / 60 ; /* +9 for JST */
Rhyme 0:0b6732b53bf4 79 minutes -= hours * 60 ;
Rhyme 0:0b6732b53bf4 80 days = hours / 24 ;
Rhyme 0:0b6732b53bf4 81 hours -= days * 24 ;
Rhyme 0:0b6732b53bf4 82
Rhyme 0:0b6732b53bf4 83 /* Unix timestamp start 1-Jan-1970 Thursday */
Rhyme 0:0b6732b53bf4 84 year = 1970 ;
Rhyme 0:0b6732b53bf4 85 dayOfWeek = 4 ; /* Thursday */
Rhyme 0:0b6732b53bf4 86
Rhyme 0:0b6732b53bf4 87 while(1) {
Rhyme 0:0b6732b53bf4 88 bool isLeapYear =
Rhyme 0:0b6732b53bf4 89 (((year % 4) == 0)
Rhyme 0:0b6732b53bf4 90 &&(((year % 100) != 0)
Rhyme 0:0b6732b53bf4 91 || ((year % 400) == 0))) ;
Rhyme 0:0b6732b53bf4 92 uint16_t daysInYear = isLeapYear ? 366 : 365 ;
Rhyme 0:0b6732b53bf4 93 if (days >= daysInYear) {
Rhyme 0:0b6732b53bf4 94 dayOfWeek += isLeapYear ? 2 : 1 ;
Rhyme 0:0b6732b53bf4 95 days -= daysInYear ;
Rhyme 0:0b6732b53bf4 96 if (dayOfWeek >= 7) {
Rhyme 0:0b6732b53bf4 97 dayOfWeek -= 7 ;
Rhyme 0:0b6732b53bf4 98 }
Rhyme 0:0b6732b53bf4 99 year++ ;
Rhyme 0:0b6732b53bf4 100 } else {
Rhyme 0:0b6732b53bf4 101 tm->tm_yday = days ;
Rhyme 0:0b6732b53bf4 102 dayOfWeek += days ;
Rhyme 0:0b6732b53bf4 103 dayOfWeek %= 7 ;
Rhyme 0:0b6732b53bf4 104
Rhyme 0:0b6732b53bf4 105 /* calc the month and the day */
Rhyme 0:0b6732b53bf4 106 for (month = 0 ; month < 12 ; month++) {
Rhyme 0:0b6732b53bf4 107 uint8_t dim = daysInMonth[month] ;
Rhyme 0:0b6732b53bf4 108
Rhyme 0:0b6732b53bf4 109 /* add a day to feburary if this is a leap year */
Rhyme 0:0b6732b53bf4 110 if ((month == 1) && (isLeapYear)) {
Rhyme 0:0b6732b53bf4 111 dim++ ;
Rhyme 0:0b6732b53bf4 112 }
Rhyme 0:0b6732b53bf4 113
Rhyme 0:0b6732b53bf4 114 if (days >= dim) {
Rhyme 0:0b6732b53bf4 115 days -= dim ;
Rhyme 0:0b6732b53bf4 116 } else {
Rhyme 0:0b6732b53bf4 117 break ;
Rhyme 0:0b6732b53bf4 118 }
Rhyme 0:0b6732b53bf4 119 }
Rhyme 0:0b6732b53bf4 120 break ;
Rhyme 0:0b6732b53bf4 121 }
Rhyme 0:0b6732b53bf4 122 }
Rhyme 0:0b6732b53bf4 123 tm->tm_sec = seconds ;
Rhyme 0:0b6732b53bf4 124 tm->tm_min = minutes ;
Rhyme 0:0b6732b53bf4 125 tm->tm_hour = hours ;
Rhyme 0:0b6732b53bf4 126 tm->tm_mday = days + 1 ;
Rhyme 0:0b6732b53bf4 127 tm->tm_mon = month ;
Rhyme 0:0b6732b53bf4 128 tm->tm_year = year ;
Rhyme 0:0b6732b53bf4 129 tm->tm_wday = dayOfWeek ;
Rhyme 0:0b6732b53bf4 130 }
Rhyme 0:0b6732b53bf4 131
Rhyme 0:0b6732b53bf4 132 void print_time(struct tm *tm)
Rhyme 0:0b6732b53bf4 133 {
Rhyme 0:0b6732b53bf4 134 printf("%02d:%02d:%02d",
Rhyme 0:0b6732b53bf4 135 tm->tm_hour,
Rhyme 0:0b6732b53bf4 136 tm->tm_min,
Rhyme 0:0b6732b53bf4 137 tm->tm_sec ) ;
Rhyme 0:0b6732b53bf4 138 }
Rhyme 0:0b6732b53bf4 139
Rhyme 0:0b6732b53bf4 140 void print_time(uint32_t thetime)
Rhyme 0:0b6732b53bf4 141 {
Rhyme 0:0b6732b53bf4 142 struct tm timestruct ;
Rhyme 0:0b6732b53bf4 143 ts2time(thetime, &timestruct) ;
Rhyme 0:0b6732b53bf4 144 print_time(&timestruct) ;
Rhyme 0:0b6732b53bf4 145 }
Rhyme 0:0b6732b53bf4 146
Rhyme 0:0b6732b53bf4 147 void print_time(void)
Rhyme 0:0b6732b53bf4 148 {
Rhyme 0:0b6732b53bf4 149 struct tm timestruct ;
Rhyme 0:0b6732b53bf4 150 ts2time(edge_time, &timestruct) ;
Rhyme 0:0b6732b53bf4 151 print_time(&timestruct) ;
Rhyme 0:0b6732b53bf4 152 }
Rhyme 0:0b6732b53bf4 153
Rhyme 0:0b6732b53bf4 154 void print_date(struct tm *tm)
Rhyme 0:0b6732b53bf4 155 {
Rhyme 0:0b6732b53bf4 156 printf("%d/%d/%d %02d:%02d:%02d",
Rhyme 0:0b6732b53bf4 157 tm->tm_year,
Rhyme 0:0b6732b53bf4 158 tm->tm_mon + 1,
Rhyme 0:0b6732b53bf4 159 tm->tm_mday,
Rhyme 0:0b6732b53bf4 160 tm->tm_hour,
Rhyme 0:0b6732b53bf4 161 tm->tm_min,
Rhyme 0:0b6732b53bf4 162 tm->tm_sec
Rhyme 0:0b6732b53bf4 163 ) ;
Rhyme 0:0b6732b53bf4 164 }
Rhyme 0:0b6732b53bf4 165
Rhyme 0:0b6732b53bf4 166 void print_date_wd(struct tm *tm)
Rhyme 0:0b6732b53bf4 167 {
Rhyme 0:0b6732b53bf4 168 printf("%d/%d/%d %02d:%02d:%02d (%s)",
Rhyme 0:0b6732b53bf4 169 tm->tm_year,
Rhyme 0:0b6732b53bf4 170 tm->tm_mon + 1,
Rhyme 0:0b6732b53bf4 171 tm->tm_mday,
Rhyme 0:0b6732b53bf4 172 tm->tm_hour,
Rhyme 0:0b6732b53bf4 173 tm->tm_min,
Rhyme 0:0b6732b53bf4 174 tm->tm_sec,
Rhyme 0:0b6732b53bf4 175 nameOfDay[tm->tm_wday]
Rhyme 0:0b6732b53bf4 176 ) ;
Rhyme 0:0b6732b53bf4 177 }
Rhyme 0:0b6732b53bf4 178
Rhyme 0:0b6732b53bf4 179 void time2str(struct tm *tm, char *timestr)
Rhyme 0:0b6732b53bf4 180 {
Rhyme 0:0b6732b53bf4 181 sprintf(timestr, "%02d:%02d:%02d",
Rhyme 0:0b6732b53bf4 182 tm->tm_hour,
Rhyme 0:0b6732b53bf4 183 tm->tm_min,
Rhyme 0:0b6732b53bf4 184 tm->tm_sec ) ;
Rhyme 0:0b6732b53bf4 185 }
Rhyme 0:0b6732b53bf4 186
Rhyme 0:0b6732b53bf4 187 void time2str(char *timestr)
Rhyme 0:0b6732b53bf4 188 {
Rhyme 0:0b6732b53bf4 189 struct tm timestruct ;
Rhyme 0:0b6732b53bf4 190 ts2time(edge_time, &timestruct) ;
Rhyme 0:0b6732b53bf4 191 time2str(&timestruct, timestr) ;
Rhyme 0:0b6732b53bf4 192 }
Rhyme 0:0b6732b53bf4 193
Rhyme 0:0b6732b53bf4 194 int32_t time2seq(uint32_t timestamp)
Rhyme 0:0b6732b53bf4 195 {
Rhyme 0:0b6732b53bf4 196 struct tm timestruct ;
Rhyme 0:0b6732b53bf4 197 int32_t result ;
Rhyme 0:0b6732b53bf4 198 ts2time(timestamp, &timestruct) ;
Rhyme 0:0b6732b53bf4 199 result = timestruct.tm_hour * 10000
Rhyme 0:0b6732b53bf4 200 + timestruct.tm_min * 100
Rhyme 0:0b6732b53bf4 201 + timestruct.tm_sec ;
Rhyme 0:0b6732b53bf4 202 return(result) ;
Rhyme 0:0b6732b53bf4 203 }
Rhyme 0:0b6732b53bf4 204
Rhyme 0:0b6732b53bf4 205 void time2seq(uint32_t timestamp, char *timestr)
Rhyme 0:0b6732b53bf4 206 {
Rhyme 0:0b6732b53bf4 207 struct tm timestruct ;
Rhyme 0:0b6732b53bf4 208 ts2tm(timestamp, &timestruct) ;
Rhyme 0:0b6732b53bf4 209 sprintf(timestr, "%d%02d%02d%02d%02d%02d",
Rhyme 0:0b6732b53bf4 210 timestruct.tm_year,
Rhyme 0:0b6732b53bf4 211 timestruct.tm_mon + 1,
Rhyme 0:0b6732b53bf4 212 timestruct.tm_mday,
Rhyme 0:0b6732b53bf4 213 timestruct.tm_hour,
Rhyme 0:0b6732b53bf4 214 timestruct.tm_min,
Rhyme 0:0b6732b53bf4 215 timestruct.tm_sec
Rhyme 0:0b6732b53bf4 216 ) ;
Rhyme 0:0b6732b53bf4 217 }
Rhyme 0:0b6732b53bf4 218
Rhyme 0:0b6732b53bf4 219 void time2date(struct tm *tm, char *datestr)
Rhyme 0:0b6732b53bf4 220 {
Rhyme 0:0b6732b53bf4 221 sprintf(datestr, "%d/%d/%d %02d:%02d:%02d (%s)",
Rhyme 0:0b6732b53bf4 222 tm->tm_year,
Rhyme 0:0b6732b53bf4 223 tm->tm_mon + 1,
Rhyme 0:0b6732b53bf4 224 tm->tm_mday,
Rhyme 0:0b6732b53bf4 225 tm->tm_hour,
Rhyme 0:0b6732b53bf4 226 tm->tm_min,
Rhyme 0:0b6732b53bf4 227 tm->tm_sec,
Rhyme 0:0b6732b53bf4 228 nameOfDay[tm->tm_wday]
Rhyme 0:0b6732b53bf4 229 ) ;
Rhyme 0:0b6732b53bf4 230 }