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 モードになっています。

半田のジャンパを変えて、SPIの設定にしてください。

サーミスタについて
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
で呼ぶように変更しました。
edge_utils/edge_time.cpp
- Committer:
- Rhyme
- Date:
- 2018-04-24
- Revision:
- 0:0b6732b53bf4
File content as of revision 0:0b6732b53bf4:
#include "mbed.h"
#include "edge_time.h"
static const uint8_t daysInMonth[12] = {
31, 28, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
} ;
const char *nameOfDay[7] = {
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
} ;
uint32_t edge_time = 0 ;
uint32_t utc_offset = 9 * 60 * 60 ;
tm current_time ;
Ticker *tokei = 0 ;
void inc_sec(void)
{
__disable_irq() ; // Disable Interrupts
edge_time++ ;
__enable_irq() ; // Enable Interrupts
}
void init_timer(void)
{
tokei = new Ticker() ;
tokei->attach(inc_sec, 1.0) ;
}
void set_time(const uint16_t valueLen, const uint8_t *value)
{
uint32_t tmp_timestamp = 0 ;
for (int i = 0 ; i < valueLen ; i++ ) {
tmp_timestamp |= (value[i] & 0xFF) << (i * 8) ;
}
edge_time = tmp_timestamp ;
ts2tm(edge_time, ¤t_time) ;
// ts2time(edge_time, ¤t_time) ;
}
void ts2time(uint32_t timestamp, struct tm *tm)
{
uint32_t seconds, minutes, hours, days, month, year ;
uint32_t dayOfWeek ;
// timestamp += (3600 * 9) ; /* +9 hours for JST */
timestamp += utc_offset ;
seconds = timestamp % 60 ;
minutes = timestamp / 60 ;
hours = minutes / 60 ; /* +9 for JST */
minutes -= hours * 60 ;
days = hours / 24 ;
hours -= days * 24 ;
tm->tm_sec = seconds ;
tm->tm_min = minutes ;
tm->tm_hour = hours ;
tm->tm_mday = days + 1 ;
// tm->tm_mon = month ;
// tm->tm_year = year ;
// tm->tm_wday = dayOfWeek ;
}
void ts2tm(uint32_t timestamp, struct tm *tm)
{
uint32_t seconds, minutes, hours, days, month, year ;
uint32_t dayOfWeek ;
// timestamp += (3600 * 9) ; /* +9 hours for JST */
timestamp += utc_offset ;
seconds = timestamp % 60 ;
minutes = timestamp / 60 ;
hours = minutes / 60 ; /* +9 for JST */
minutes -= hours * 60 ;
days = hours / 24 ;
hours -= days * 24 ;
/* Unix timestamp start 1-Jan-1970 Thursday */
year = 1970 ;
dayOfWeek = 4 ; /* Thursday */
while(1) {
bool isLeapYear =
(((year % 4) == 0)
&&(((year % 100) != 0)
|| ((year % 400) == 0))) ;
uint16_t daysInYear = isLeapYear ? 366 : 365 ;
if (days >= daysInYear) {
dayOfWeek += isLeapYear ? 2 : 1 ;
days -= daysInYear ;
if (dayOfWeek >= 7) {
dayOfWeek -= 7 ;
}
year++ ;
} else {
tm->tm_yday = days ;
dayOfWeek += days ;
dayOfWeek %= 7 ;
/* calc the month and the day */
for (month = 0 ; month < 12 ; month++) {
uint8_t dim = daysInMonth[month] ;
/* add a day to feburary if this is a leap year */
if ((month == 1) && (isLeapYear)) {
dim++ ;
}
if (days >= dim) {
days -= dim ;
} else {
break ;
}
}
break ;
}
}
tm->tm_sec = seconds ;
tm->tm_min = minutes ;
tm->tm_hour = hours ;
tm->tm_mday = days + 1 ;
tm->tm_mon = month ;
tm->tm_year = year ;
tm->tm_wday = dayOfWeek ;
}
void print_time(struct tm *tm)
{
printf("%02d:%02d:%02d",
tm->tm_hour,
tm->tm_min,
tm->tm_sec ) ;
}
void print_time(uint32_t thetime)
{
struct tm timestruct ;
ts2time(thetime, ×truct) ;
print_time(×truct) ;
}
void print_time(void)
{
struct tm timestruct ;
ts2time(edge_time, ×truct) ;
print_time(×truct) ;
}
void print_date(struct tm *tm)
{
printf("%d/%d/%d %02d:%02d:%02d",
tm->tm_year,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec
) ;
}
void print_date_wd(struct tm *tm)
{
printf("%d/%d/%d %02d:%02d:%02d (%s)",
tm->tm_year,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec,
nameOfDay[tm->tm_wday]
) ;
}
void time2str(struct tm *tm, char *timestr)
{
sprintf(timestr, "%02d:%02d:%02d",
tm->tm_hour,
tm->tm_min,
tm->tm_sec ) ;
}
void time2str(char *timestr)
{
struct tm timestruct ;
ts2time(edge_time, ×truct) ;
time2str(×truct, timestr) ;
}
int32_t time2seq(uint32_t timestamp)
{
struct tm timestruct ;
int32_t result ;
ts2time(timestamp, ×truct) ;
result = timestruct.tm_hour * 10000
+ timestruct.tm_min * 100
+ timestruct.tm_sec ;
return(result) ;
}
void time2seq(uint32_t timestamp, char *timestr)
{
struct tm timestruct ;
ts2tm(timestamp, ×truct) ;
sprintf(timestr, "%d%02d%02d%02d%02d%02d",
timestruct.tm_year,
timestruct.tm_mon + 1,
timestruct.tm_mday,
timestruct.tm_hour,
timestruct.tm_min,
timestruct.tm_sec
) ;
}
void time2date(struct tm *tm, char *datestr)
{
sprintf(datestr, "%d/%d/%d %02d:%02d:%02d (%s)",
tm->tm_year,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec,
nameOfDay[tm->tm_wday]
) ;
}
La Suno