エレキジャックweb mbed入門 mbed CWデコーダ課題9です。英数字に加えて、和文にスイッチで切り替えることで対応します。デコーダ基板が必要です

Dependencies:   mbed

Committer:
takeuchi
Date:
Mon Jul 16 02:33:03 2012 +0000
Revision:
0:4a234ad277bf
???????web mbed?? mbed CW??????8??????????????????BT?AR??????????????????????????

Who changed what in which revision?

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