消えゆく世界と流れる未来に最後の灯を since 2006/4/3
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
// GPIO
P1DIR |= BIT0 | BIT1 | BIT2 | BIT3;
P2DIR |= BIT0 | BIT2;
P1OUT = 0;
P2OUT = 0;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
__delay_cycles(50000);
wp(0b0011); // init 1st
wp(0b0011); // init 2nd
wp(0b0011); // init 3rd
wp(0b0010); // 4bit transition-1
wp(0b0010); // 4bit transition-2
wp(0b1000); // 2lines
wp(0b0000); // Display On/Cursor On/Position Off
wp(0b1110);
wp(0b0000); // Clear Display
wp(0b0001);
wp(0b0000); // Return Home
wp(0b0010);
P2OUT |= BIT0; // Start writing to DDRAM
__delay_cycles(10000);
wp(0b1011); // ア
wp(0b0001);
wp(0b1011); // ス
wp(0b1101);
wp(0b1101); // ゛
wp(0b1110);
wp(0b1011); // キ
wp(0b0111);
P2OUT &= ~BIT0;
wp(0b1100); // Move to 2nd line 3rd char at DDRAM
wp(0b0010);
P2OUT |= BIT0; // Start writing to DDRAM
__delay_cycles(10000);
wp(0b1011); // ア
wp(0b0001);
wp(0b1011); // ス
wp(0b1101);
wp(0b1101); // ゛
wp(0b1110);
wp(0b1011); // キ
wp(0b0111);
P2OUT &= ~BIT0;
return 0;
}
// int to Parallel
int wp (int bits) {
P1OUT = (char)bits;
__delay_cycles(100);
P2OUT |= BIT2;
__delay_cycles(100);
P2OUT &= ~BIT2;
__delay_cycles(50000);
return 0;
}
// sending character to display
int sendChar (unsigned char bits) {
wp((char)(bits>>4));
wp((char)(bits));
return 0;
}
// ASCII
int sendAlphabets(unsigned char *str) {
int i=0;
for (; i<strlen(str); i++)
sendChar(str[i]);
}
// Japanese
int sendJapaneses(unsigned char *str) {
int i=0;
unsigned char c0=0xb1;
unsigned char c=c0;
unsigned char daku=0;
for (; i<strlen(str); i++) {
if (str[i]==str[i+1]) {
switch (str[i]) {
case 'a':
case 'i':
case 'u':
case 'e':
case 'o':
case 'n':
break;
default:
sendChar(0xaf);
c=c0;
continue;
}
}
switch (str[i]) {
// 特殊
case '/':
c++;
case ',':
c++;
case ')':
c++;
case '(':
c++;
case '.':
c-=16;
sendChar(c);
c=c0;
break;
case '=':
sendChar(0xaf);
break;
case '-':
sendChar(0xb0);
c=c0;
break;
case '\'':
sendChar(0xdf);
c=c0;
break;
case '\"':
sendChar(0xde);
c=c0;
break;
// 子音
case 'x':
case 'l':
c=0xa7;
break;
case 'w':
c+=5;
case 'r':
c+=3;
case 'y':
if (c==0xa7) {
c=0xac;
break;
}
c+=5;
case 'm':
c+=5;
case 'b':
case 'p':
case 'h':
c+=5;
case 'n':
if (str[i-1]=='n') {
sendChar(0xdd);
c=c0;
break;
}
c+=5;
case 'd':
case 't':
c+=5;
case 'z':
case 's':
c+=5;
case 'g':
case 'k':
c+=5;
break;
// 母音
case 'o':
if (str[i-1]=='w') {
sendChar(0xa6);
c=c0;
break;
}
c++;
case 'e':
c++;
case 'u':
c++;
case 'i':
c++;
default:
sendChar(c);
switch (str[i-1]){
case 'p':
sendChar(0xdf);
break;
case 'g':
case 'z':
case 'd':
case 'b':
sendChar(0xde);
break;
}
c=c0;
}
}
}