エレキジャックweb mbed入門 mbed CWデコーダ課題10です。欧文から和文を”ホレ”、和文から欧文を”ラタ”で自動切り替えします。デコーダ基板が必要です。

Dependencies:   mbed

Committer:
takeuchi
Date:
Mon Jul 16 04:52:32 2012 +0000
Revision:
0:79eff04722b2
???????web mbed?? mbed CW??????9????????????????????????????????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeuchi 0:79eff04722b2 1 // CW10
takeuchi 0:79eff04722b2 2 // BT AR taiou
takeuchi 0:79eff04722b2 3 // Wabun
takeuchi 0:79eff04722b2 4 // SW tuika
takeuchi 0:79eff04722b2 5 // hore rata kirikae
takeuchi 0:79eff04722b2 6
takeuchi 0:79eff04722b2 7 #include "mbed.h"
takeuchi 0:79eff04722b2 8 #include "TextLCD0420.h"
takeuchi 0:79eff04722b2 9
takeuchi 0:79eff04722b2 10 #define ON 1
takeuchi 0:79eff04722b2 11 #define OFF 0
takeuchi 0:79eff04722b2 12 #define XON 0
takeuchi 0:79eff04722b2 13 #define XOFF 1
takeuchi 0:79eff04722b2 14 #define XHI 0
takeuchi 0:79eff04722b2 15 #define XLOW 1
takeuchi 0:79eff04722b2 16 #define HI 1
takeuchi 0:79eff04722b2 17 #define LOW 0
takeuchi 0:79eff04722b2 18 #define OUBUN 1
takeuchi 0:79eff04722b2 19 #define WABUN 0
takeuchi 0:79eff04722b2 20 #define AUTO 1
takeuchi 0:79eff04722b2 21 #define MANUAL 0
takeuchi 0:79eff04722b2 22 #define KN 44
takeuchi 0:79eff04722b2 23 #define AS 33
takeuchi 0:79eff04722b2 24 #define CT 52
takeuchi 0:79eff04722b2 25 #define BT 48
takeuchi 0:79eff04722b2 26 #define AR 41
takeuchi 0:79eff04722b2 27 #define HH 255
takeuchi 0:79eff04722b2 28 #define VA 103
takeuchi 0:79eff04722b2 29 #define HORE 120
takeuchi 0:79eff04722b2 30
takeuchi 0:79eff04722b2 31 DigitalOut mled1(LED1);
takeuchi 0:79eff04722b2 32 DigitalOut mled2(LED2);
takeuchi 0:79eff04722b2 33 DigitalOut mled3(LED3);
takeuchi 0:79eff04722b2 34 DigitalOut mled4(LED4);
takeuchi 0:79eff04722b2 35 DigitalIn CW(p5);
takeuchi 0:79eff04722b2 36 DigitalIn SP_SELECT(p6);
takeuchi 0:79eff04722b2 37 DigitalIn GENGO_MODE(p7);
takeuchi 0:79eff04722b2 38 DigitalIn GENGO_SELECT(p8);
takeuchi 0:79eff04722b2 39
takeuchi 0:79eff04722b2 40 TextLCD lcd(p24, p25, p26, p27, p28, p29, p30,20,4); // rs, rw, e, d0, d1, d2, d3
takeuchi 0:79eff04722b2 41
takeuchi 0:79eff04722b2 42 int retu,gyou;
takeuchi 0:79eff04722b2 43 char g2[20],g3[20];
takeuchi 0:79eff04722b2 44 int init_flag=ON;
takeuchi 0:79eff04722b2 45 int min_ms,max_ms;
takeuchi 0:79eff04722b2 46
takeuchi 0:79eff04722b2 47 void lcd_scprintf(char pdata){
takeuchi 0:79eff04722b2 48 int i;
takeuchi 0:79eff04722b2 49
takeuchi 0:79eff04722b2 50 if(init_flag==ON){
takeuchi 0:79eff04722b2 51 if(gyou==1){
takeuchi 0:79eff04722b2 52 lcd.locate(retu,1);
takeuchi 0:79eff04722b2 53 lcd.printf("%c",pdata);
takeuchi 0:79eff04722b2 54 retu++;
takeuchi 0:79eff04722b2 55 if(retu==20){
takeuchi 0:79eff04722b2 56 gyou=2;
takeuchi 0:79eff04722b2 57 retu=0;
takeuchi 0:79eff04722b2 58 }
takeuchi 0:79eff04722b2 59 }
takeuchi 0:79eff04722b2 60 else if(gyou==2){
takeuchi 0:79eff04722b2 61 lcd.locate(retu,2);
takeuchi 0:79eff04722b2 62 lcd.printf("%c",pdata);
takeuchi 0:79eff04722b2 63 g2[retu]=pdata;
takeuchi 0:79eff04722b2 64 retu++;
takeuchi 0:79eff04722b2 65 if(retu==20){
takeuchi 0:79eff04722b2 66 retu=0;
takeuchi 0:79eff04722b2 67 gyou=3;
takeuchi 0:79eff04722b2 68 }
takeuchi 0:79eff04722b2 69 }
takeuchi 0:79eff04722b2 70 else if(gyou==3){
takeuchi 0:79eff04722b2 71 lcd.locate(retu,3);
takeuchi 0:79eff04722b2 72 lcd.printf("%c",pdata);
takeuchi 0:79eff04722b2 73 g3[retu]=pdata;
takeuchi 0:79eff04722b2 74 retu++;
takeuchi 0:79eff04722b2 75 if(retu==20){
takeuchi 0:79eff04722b2 76 retu=0;
takeuchi 0:79eff04722b2 77 gyou=1;
takeuchi 0:79eff04722b2 78 for(i=0;i<20;i++){
takeuchi 0:79eff04722b2 79 lcd.locate(i,1);
takeuchi 0:79eff04722b2 80 lcd.printf("%c",g2[i]);
takeuchi 0:79eff04722b2 81 }
takeuchi 0:79eff04722b2 82 for(i=0;i<20;i++){
takeuchi 0:79eff04722b2 83 lcd.locate(i,2);
takeuchi 0:79eff04722b2 84 lcd.printf("%c",g3[i]);
takeuchi 0:79eff04722b2 85 g2[i]=g3[i];
takeuchi 0:79eff04722b2 86 }
takeuchi 0:79eff04722b2 87 lcd.locate(0,3);
takeuchi 0:79eff04722b2 88 lcd.printf(" ");
takeuchi 0:79eff04722b2 89 init_flag=OFF;
takeuchi 0:79eff04722b2 90 }
takeuchi 0:79eff04722b2 91 }
takeuchi 0:79eff04722b2 92 }
takeuchi 0:79eff04722b2 93 if(init_flag==OFF){
takeuchi 0:79eff04722b2 94 gyou=3;
takeuchi 0:79eff04722b2 95 lcd.locate(retu,3);
takeuchi 0:79eff04722b2 96 lcd.printf("%c",pdata);
takeuchi 0:79eff04722b2 97 g3[retu]=pdata;
takeuchi 0:79eff04722b2 98 retu++;
takeuchi 0:79eff04722b2 99 if(retu==20){
takeuchi 0:79eff04722b2 100 for(i=0;i<20;i++){
takeuchi 0:79eff04722b2 101 lcd.locate(i,1);
takeuchi 0:79eff04722b2 102 lcd.printf("%c",g2[i]);
takeuchi 0:79eff04722b2 103 lcd.locate(i,2);
takeuchi 0:79eff04722b2 104 lcd.printf("%c",g3[i]);
takeuchi 0:79eff04722b2 105 g2[i]=g3[i];
takeuchi 0:79eff04722b2 106 }
takeuchi 0:79eff04722b2 107 lcd.locate(0,3);
takeuchi 0:79eff04722b2 108 lcd.printf(" ");
takeuchi 0:79eff04722b2 109 retu=0;
takeuchi 0:79eff04722b2 110 }
takeuchi 0:79eff04722b2 111 }
takeuchi 0:79eff04722b2 112 }
takeuchi 0:79eff04722b2 113
takeuchi 0:79eff04722b2 114 void set_speed(){
takeuchi 0:79eff04722b2 115 if(SP_SELECT==HI){
takeuchi 0:79eff04722b2 116 min_ms=30;
takeuchi 0:79eff04722b2 117 max_ms=90;
takeuchi 0:79eff04722b2 118 lcd.locate(5,0);
takeuchi 0:79eff04722b2 119 lcd.printf("H");
takeuchi 0:79eff04722b2 120 }
takeuchi 0:79eff04722b2 121 else if(SP_SELECT==LOW){
takeuchi 0:79eff04722b2 122 min_ms=70;
takeuchi 0:79eff04722b2 123 max_ms=210;
takeuchi 0:79eff04722b2 124 lcd.locate(5,0);
takeuchi 0:79eff04722b2 125 lcd.printf("L");
takeuchi 0:79eff04722b2 126 }
takeuchi 0:79eff04722b2 127 }
takeuchi 0:79eff04722b2 128
takeuchi 0:79eff04722b2 129 void lcd_manual(){
takeuchi 0:79eff04722b2 130 lcd.locate(6,0);
takeuchi 0:79eff04722b2 131 lcd.printf("M");
takeuchi 0:79eff04722b2 132 }
takeuchi 0:79eff04722b2 133
takeuchi 0:79eff04722b2 134 void lcd_auto(){
takeuchi 0:79eff04722b2 135 lcd.locate(6,0);
takeuchi 0:79eff04722b2 136 lcd.printf("A");
takeuchi 0:79eff04722b2 137 }
takeuchi 0:79eff04722b2 138
takeuchi 0:79eff04722b2 139 void lcd_alpha(){
takeuchi 0:79eff04722b2 140 lcd.locate(7,0);
takeuchi 0:79eff04722b2 141 lcd.printf("A");
takeuchi 0:79eff04722b2 142 }
takeuchi 0:79eff04722b2 143 void lcd_kana(){
takeuchi 0:79eff04722b2 144 lcd.locate(7,0);
takeuchi 0:79eff04722b2 145 lcd.printf("%c",0xb6);
takeuchi 0:79eff04722b2 146 }
takeuchi 0:79eff04722b2 147
takeuchi 0:79eff04722b2 148 int main() {
takeuchi 0:79eff04722b2 149
takeuchi 0:79eff04722b2 150 int i,j,k;
takeuchi 0:79eff04722b2 151 int code[8];
takeuchi 0:79eff04722b2 152 int scount;
takeuchi 0:79eff04722b2 153 char mj[115],mjj[121],c1,c2;
takeuchi 0:79eff04722b2 154 int cw_sum,tan_sum,tanten,cpm;
takeuchi 0:79eff04722b2 155 int gengo,wabun_temp;
takeuchi 0:79eff04722b2 156 char cw_class;
takeuchi 0:79eff04722b2 157
takeuchi 0:79eff04722b2 158 for(i=0;i<115;i++){
takeuchi 0:79eff04722b2 159 mj[i]=' ';
takeuchi 0:79eff04722b2 160 }
takeuchi 0:79eff04722b2 161 mj[5]='A';mj[16]='B';mj[20]='C';mj[8]='D';mj[1]='E';
takeuchi 0:79eff04722b2 162 mj[19]='F';mj[10]='G';mj[15]='H';mj[3]='I';mj[29]='J';
takeuchi 0:79eff04722b2 163 mj[12]='K';mj[17]='L';mj[6]='M';mj[4]='N';mj[14]='O';
takeuchi 0:79eff04722b2 164 mj[21]='P';mj[26]='Q';mj[9]='R';mj[7]='S';mj[2]='T';
takeuchi 0:79eff04722b2 165 mj[11]='U';mj[23]='V';mj[13]='W';mj[24]='X';mj[28]='Y';
takeuchi 0:79eff04722b2 166 mj[18]='Z';
takeuchi 0:79eff04722b2 167 mj[61]='1';mj[59]='2';mj[55]='3';mj[47]='4';mj[31]='5';
takeuchi 0:79eff04722b2 168 mj[32]='6';mj[34]='7';mj[38]='8';mj[46]='9';mj[62]='0';
takeuchi 0:79eff04722b2 169 mj[105]='.';mj[114]=',';mj[75]='?';mj[48]='=';mj[96]='-';
takeuchi 0:79eff04722b2 170 mj[70]=':';mj[93]='\'';mj[44]='(';mj[108]=')';mj[40]='/';
takeuchi 0:79eff04722b2 171 mj[85]='@';
takeuchi 0:79eff04722b2 172 //mj[41]='+';
takeuchi 0:79eff04722b2 173
takeuchi 0:79eff04722b2 174 for(i=0;i<121;i++){
takeuchi 0:79eff04722b2 175 mjj[i]=' ';
takeuchi 0:79eff04722b2 176 }
takeuchi 0:79eff04722b2 177 mjj[58]=0xb1;mjj[5]=0xb2;mjj[11]=0xb3;mjj[60]=0xb4;mjj[33]=0xb5;//a
takeuchi 0:79eff04722b2 178 mjj[17]=0xb6;mjj[36]=0xb7;mjj[23]=0xb8;mjj[28]=0xb9;mjj[30]=0xba;//ka
takeuchi 0:79eff04722b2 179 mjj[52]=0xbb;mjj[42]=0xbc;mjj[54]=0xbd;mjj[45]=0xbe;mjj[22]=0xbf;//sa
takeuchi 0:79eff04722b2 180 mjj[4]=0xc0;mjj[19]=0xc1;mjj[21]=0xc2;mjj[57]=0xc3;mjj[35]=0xc4;//ta
takeuchi 0:79eff04722b2 181 mjj[9]=0xc5;mjj[20]=0xc6;mjj[15]=0xc7;mjj[26]=0xc8;mjj[27]=0xc9;//na
takeuchi 0:79eff04722b2 182 mjj[16]=0xca;mjj[50]=0xcb;mjj[18]=0xcc;mjj[1]=0xcd;mjj[8]=0xce;//ha
takeuchi 0:79eff04722b2 183 mjj[24]=0xcf;mjj[51]=0xd0;mjj[2]=0xd1;mjj[48]=0xd2;mjj[40]=0xd3;//ma
takeuchi 0:79eff04722b2 184 mjj[13]=0xd4;mjj[56]=0xd5;mjj[6]=0xd6;//ya
takeuchi 0:79eff04722b2 185 mjj[7]=0xd7;mjj[10]=0xd8;mjj[44]=0xd9;mjj[14]=0xda;mjj[25]=0xdb;//ra
takeuchi 0:79eff04722b2 186 mjj[12]=0xdc;mjj[49]=0xb2;mjj[37]=0xb4;mjj[29]=0xa6;mjj[41]=0xdd;//wa
takeuchi 0:79eff04722b2 187 mjj[53]=0xb0;mjj[43]=0xdf;mjj[105]=',';
takeuchi 0:79eff04722b2 188 mjj[3]=0xde;mjj[73]=0xa3;
takeuchi 0:79eff04722b2 189 mjj[108]='(';mjj[81]=')';
takeuchi 0:79eff04722b2 190 mjj[61]='1';mjj[59]='2';mjj[55]='3';mjj[47]='4';mjj[31]='5';
takeuchi 0:79eff04722b2 191 mjj[32]='6';mjj[34]='7';mjj[38]='8';mjj[46]='9';mjj[62]='0';
takeuchi 0:79eff04722b2 192
takeuchi 0:79eff04722b2 193
takeuchi 0:79eff04722b2 194 lcd.cls();
takeuchi 0:79eff04722b2 195 lcd.printf("*CW10 ");
takeuchi 0:79eff04722b2 196
takeuchi 0:79eff04722b2 197 for(i=0;i<8;i++){
takeuchi 0:79eff04722b2 198 code[i]=0;
takeuchi 0:79eff04722b2 199 }
takeuchi 0:79eff04722b2 200
takeuchi 0:79eff04722b2 201 i=0;
takeuchi 0:79eff04722b2 202 tan_sum=0;
takeuchi 0:79eff04722b2 203 set_speed();
takeuchi 0:79eff04722b2 204 c1=' ',c2=' ';
takeuchi 0:79eff04722b2 205
takeuchi 0:79eff04722b2 206 while( i<5 ){//initialize
takeuchi 0:79eff04722b2 207 lcd.locate(8,0);
takeuchi 0:79eff04722b2 208 lcd.printf("%2d",5-i);
takeuchi 0:79eff04722b2 209 scount=0;
takeuchi 0:79eff04722b2 210 while(CW==XLOW){
takeuchi 0:79eff04722b2 211 }
takeuchi 0:79eff04722b2 212 mled1=ON;
takeuchi 0:79eff04722b2 213 while(CW==XHI){
takeuchi 0:79eff04722b2 214 scount++;
takeuchi 0:79eff04722b2 215 wait_ms(1);
takeuchi 0:79eff04722b2 216 }
takeuchi 0:79eff04722b2 217 mled1=OFF;
takeuchi 0:79eff04722b2 218 if(min_ms < scount && scount < max_ms){
takeuchi 0:79eff04722b2 219 tan_sum=tan_sum+scount;
takeuchi 0:79eff04722b2 220 i++;
takeuchi 0:79eff04722b2 221 }
takeuchi 0:79eff04722b2 222
takeuchi 0:79eff04722b2 223 }//while i
takeuchi 0:79eff04722b2 224
takeuchi 0:79eff04722b2 225 tanten=tan_sum/5;
takeuchi 0:79eff04722b2 226
takeuchi 0:79eff04722b2 227 j=0;
takeuchi 0:79eff04722b2 228 k=0;
takeuchi 0:79eff04722b2 229 tan_sum=0;
takeuchi 0:79eff04722b2 230 gyou=1,retu=0;
takeuchi 0:79eff04722b2 231 gengo=OUBUN;
takeuchi 0:79eff04722b2 232 while(1){
takeuchi 0:79eff04722b2 233 set_speed();
takeuchi 0:79eff04722b2 234
takeuchi 0:79eff04722b2 235 if(GENGO_MODE==MANUAL){// Manual mode
takeuchi 0:79eff04722b2 236 lcd_manual();
takeuchi 0:79eff04722b2 237 if(GENGO_SELECT==OUBUN){
takeuchi 0:79eff04722b2 238 gengo=OUBUN;
takeuchi 0:79eff04722b2 239 }
takeuchi 0:79eff04722b2 240 else if(GENGO_SELECT==WABUN){
takeuchi 0:79eff04722b2 241 gengo=WABUN;
takeuchi 0:79eff04722b2 242 wabun_temp=WABUN;
takeuchi 0:79eff04722b2 243
takeuchi 0:79eff04722b2 244 }
takeuchi 0:79eff04722b2 245 }
takeuchi 0:79eff04722b2 246 else if(GENGO_MODE==AUTO){// Auto mode
takeuchi 0:79eff04722b2 247 lcd_auto();
takeuchi 0:79eff04722b2 248 }
takeuchi 0:79eff04722b2 249
takeuchi 0:79eff04722b2 250 while(CW==XLOW){
takeuchi 0:79eff04722b2 251 }
takeuchi 0:79eff04722b2 252
takeuchi 0:79eff04722b2 253 scount=0;
takeuchi 0:79eff04722b2 254 mled1=ON;
takeuchi 0:79eff04722b2 255 while(CW==XHI){
takeuchi 0:79eff04722b2 256 wait_ms(1);
takeuchi 0:79eff04722b2 257 scount++;
takeuchi 0:79eff04722b2 258 }
takeuchi 0:79eff04722b2 259 mled1=OFF;
takeuchi 0:79eff04722b2 260
takeuchi 0:79eff04722b2 261 if(min_ms < scount && scount < max_ms){
takeuchi 0:79eff04722b2 262 //lcd.printf(".");
takeuchi 0:79eff04722b2 263 code[k]=1;
takeuchi 0:79eff04722b2 264 k++;
takeuchi 0:79eff04722b2 265 tan_sum=tan_sum+scount;
takeuchi 0:79eff04722b2 266 j++;
takeuchi 0:79eff04722b2 267 }
takeuchi 0:79eff04722b2 268
takeuchi 0:79eff04722b2 269 else if ( scount > tanten*2.0){
takeuchi 0:79eff04722b2 270 //lcd.printf("_");
takeuchi 0:79eff04722b2 271 code[k]=2;
takeuchi 0:79eff04722b2 272 k++;
takeuchi 0:79eff04722b2 273 tan_sum=tan_sum+scount/3;
takeuchi 0:79eff04722b2 274 j++;
takeuchi 0:79eff04722b2 275 }
takeuchi 0:79eff04722b2 276
takeuchi 0:79eff04722b2 277 lcd.locate(8,0);
takeuchi 0:79eff04722b2 278 lcd.printf("%2d",k);
takeuchi 0:79eff04722b2 279
takeuchi 0:79eff04722b2 280 scount=0;
takeuchi 0:79eff04722b2 281 while(CW==XLOW){
takeuchi 0:79eff04722b2 282 wait_ms(1);
takeuchi 0:79eff04722b2 283 scount++;
takeuchi 0:79eff04722b2 284 if(scount > tanten*10){
takeuchi 0:79eff04722b2 285 break;
takeuchi 0:79eff04722b2 286 }
takeuchi 0:79eff04722b2 287 }
takeuchi 0:79eff04722b2 288
takeuchi 0:79eff04722b2 289 if(k>8){
takeuchi 0:79eff04722b2 290 k=0;
takeuchi 0:79eff04722b2 291 lcd_scprintf('*');
takeuchi 0:79eff04722b2 292 for(i=0;i<=7;i++){
takeuchi 0:79eff04722b2 293 code[i]=0;
takeuchi 0:79eff04722b2 294 }
takeuchi 0:79eff04722b2 295 }
takeuchi 0:79eff04722b2 296
takeuchi 0:79eff04722b2 297 if(gengo==OUBUN && scount > tanten*2.0){
takeuchi 0:79eff04722b2 298 lcd_alpha();
takeuchi 0:79eff04722b2 299 cw_sum=0;
takeuchi 0:79eff04722b2 300 for(i=0;i<=7;i++){
takeuchi 0:79eff04722b2 301 cw_sum=cw_sum+code[i]*int(pow(2.0,i));
takeuchi 0:79eff04722b2 302 }
takeuchi 0:79eff04722b2 303
takeuchi 0:79eff04722b2 304 if(GENGO_MODE==AUTO && cw_sum==HORE ){// hore a e o ki ko ro
takeuchi 0:79eff04722b2 305 lcd_scprintf('[');lcd_scprintf(0xce);lcd_scprintf( 0xda);lcd_scprintf(']');//ho re
takeuchi 0:79eff04722b2 306 gengo=WABUN;
takeuchi 0:79eff04722b2 307 cw_sum=0;
takeuchi 0:79eff04722b2 308 }
takeuchi 0:79eff04722b2 309 else if(cw_sum==BT){
takeuchi 0:79eff04722b2 310 lcd_scprintf('[');lcd_scprintf('B');lcd_scprintf('T');lcd_scprintf(']');
takeuchi 0:79eff04722b2 311 }
takeuchi 0:79eff04722b2 312 else if(cw_sum==KN){
takeuchi 0:79eff04722b2 313 lcd_scprintf('[');lcd_scprintf('K');lcd_scprintf('N');lcd_scprintf(']');
takeuchi 0:79eff04722b2 314 }
takeuchi 0:79eff04722b2 315 else if(cw_sum==AR){
takeuchi 0:79eff04722b2 316 lcd_scprintf('[');lcd_scprintf('A');lcd_scprintf('R');lcd_scprintf(']');
takeuchi 0:79eff04722b2 317 }
takeuchi 0:79eff04722b2 318 else if(cw_sum==HH){
takeuchi 0:79eff04722b2 319 lcd_scprintf('[');lcd_scprintf('H');lcd_scprintf('H');lcd_scprintf(']');
takeuchi 0:79eff04722b2 320 }
takeuchi 0:79eff04722b2 321 else if(cw_sum==AS){
takeuchi 0:79eff04722b2 322 lcd_scprintf('[');lcd_scprintf('A');lcd_scprintf('S');lcd_scprintf(']');
takeuchi 0:79eff04722b2 323 }
takeuchi 0:79eff04722b2 324 else if(cw_sum==CT){
takeuchi 0:79eff04722b2 325 lcd_scprintf('[');lcd_scprintf('C');lcd_scprintf('T');lcd_scprintf(']');
takeuchi 0:79eff04722b2 326 }
takeuchi 0:79eff04722b2 327 else if(cw_sum==VA){
takeuchi 0:79eff04722b2 328 lcd_scprintf('[');lcd_scprintf('V');lcd_scprintf('A');lcd_scprintf(']');
takeuchi 0:79eff04722b2 329 }
takeuchi 0:79eff04722b2 330 else if(cw_sum > 115){
takeuchi 0:79eff04722b2 331 lcd_scprintf('*');
takeuchi 0:79eff04722b2 332 cw_sum=0;
takeuchi 0:79eff04722b2 333 }
takeuchi 0:79eff04722b2 334 else {
takeuchi 0:79eff04722b2 335 lcd_scprintf(mj[cw_sum]);
takeuchi 0:79eff04722b2 336 c1=c2;
takeuchi 0:79eff04722b2 337 c2=mj[cw_sum];
takeuchi 0:79eff04722b2 338 }
takeuchi 0:79eff04722b2 339 k=0;
takeuchi 0:79eff04722b2 340 for(i=0;i<=7;i++){
takeuchi 0:79eff04722b2 341 code[i]=0;
takeuchi 0:79eff04722b2 342 }
takeuchi 0:79eff04722b2 343 }//if oubun
takeuchi 0:79eff04722b2 344
takeuchi 0:79eff04722b2 345 else if(gengo==WABUN && scount > tanten*2.0){
takeuchi 0:79eff04722b2 346 lcd_kana();
takeuchi 0:79eff04722b2 347 cw_sum=0;
takeuchi 0:79eff04722b2 348 for(i=0;i<=7;i++){
takeuchi 0:79eff04722b2 349 cw_sum=cw_sum+code[i]*int(pow(2.0,i));
takeuchi 0:79eff04722b2 350 }
takeuchi 0:79eff04722b2 351
takeuchi 0:79eff04722b2 352 if(GENGO_MODE==AUTO && cw_sum==39){// ra ta
takeuchi 0:79eff04722b2 353 lcd_scprintf('[');lcd_scprintf(0xd7);lcd_scprintf(0xc0);lcd_scprintf(']');//ra ta
takeuchi 0:79eff04722b2 354 gengo=OUBUN;
takeuchi 0:79eff04722b2 355 wabun_temp=OUBUN;
takeuchi 0:79eff04722b2 356 }
takeuchi 0:79eff04722b2 357 if(cw_sum > 121){
takeuchi 0:79eff04722b2 358 cw_sum=0;
takeuchi 0:79eff04722b2 359 lcd_scprintf(' ');
takeuchi 0:79eff04722b2 360 }
takeuchi 0:79eff04722b2 361
takeuchi 0:79eff04722b2 362 lcd_scprintf(mjj[cw_sum]);
takeuchi 0:79eff04722b2 363
takeuchi 0:79eff04722b2 364 k=0;
takeuchi 0:79eff04722b2 365 for(i=0;i<=7;i++){
takeuchi 0:79eff04722b2 366 code[i]=0;
takeuchi 0:79eff04722b2 367 }
takeuchi 0:79eff04722b2 368 }//if wabun
takeuchi 0:79eff04722b2 369
takeuchi 0:79eff04722b2 370 if(scount > tanten*7){
takeuchi 0:79eff04722b2 371 lcd_scprintf(' ');
takeuchi 0:79eff04722b2 372 }
takeuchi 0:79eff04722b2 373
takeuchi 0:79eff04722b2 374 if(j==10){
takeuchi 0:79eff04722b2 375 tanten=tan_sum/10;
takeuchi 0:79eff04722b2 376 cpm=60000/(tanten*57)*5;
takeuchi 0:79eff04722b2 377 tan_sum=0;
takeuchi 0:79eff04722b2 378 j=0;
takeuchi 0:79eff04722b2 379 if(cpm > 100){
takeuchi 0:79eff04722b2 380 cw_class='P';
takeuchi 0:79eff04722b2 381 }
takeuchi 0:79eff04722b2 382 else if(cpm > 90){
takeuchi 0:79eff04722b2 383 cw_class='S';
takeuchi 0:79eff04722b2 384 }
takeuchi 0:79eff04722b2 385 else if(cpm > 65){
takeuchi 0:79eff04722b2 386 cw_class='1';
takeuchi 0:79eff04722b2 387 }
takeuchi 0:79eff04722b2 388 else if(cpm > 40){
takeuchi 0:79eff04722b2 389 cw_class='2';
takeuchi 0:79eff04722b2 390 }
takeuchi 0:79eff04722b2 391 else if(cpm > 30){
takeuchi 0:79eff04722b2 392 cw_class='3';
takeuchi 0:79eff04722b2 393 }
takeuchi 0:79eff04722b2 394 lcd.locate(11,0);
takeuchi 0:79eff04722b2 395 lcd.printf("%3dc(%c)",cpm,cw_class);
takeuchi 0:79eff04722b2 396 //lcd.printf("%3dc,%3dm",cpm,tanten);
takeuchi 0:79eff04722b2 397 }
takeuchi 0:79eff04722b2 398 }//while 1
takeuchi 0:79eff04722b2 399 }//main