Changes between Version 7 and Version 8 of KanjiROM
- Timestamp:
- Oct 7, 2015 6:30:15 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
KanjiROM
v7 v8 96 96 ROMから読みだしてシリアルモニタに返すプログラムです。 97 97 半角カナには対応していません。 98 {{{ 99 /* GT20L16J1Y用サンプルプログラム 98 {{{/* GT20L16J1Y用サンプルプログラム 100 99 * Arduinoのシリアルモニタから送信されたSJISの文字を 101 100 * ROMから読みだしてシリアルモニタに返す 102 101 * 半角カナまわりはデータにはあるがROM内の順とJISX規格での順が 103 102 * 一致しないため未実装 104 * 105 * update:9/30 0:00 103 * 104 * memo:9/30 00:00 105 * memo:10/7 18:30 106 106 */ 107 107 … … 126 126 void loop (void) 127 127 { 128 128 129 129 if (Serial.available() > 0) 130 130 { 131 131 /*Arduinoのシリアルモニタから送られてくる日本語がSJISであることに注意*/ 132 132 delayMicroseconds(200);//最低でも2文字受信したい 133 uint 16_t msbdata = Serial.read();//1バイト目133 uint8_t msbdata = Serial.read();//1バイト目 //10/07 134 134 /*SJISの1バイトコードか否か*/ 135 135 if ( (msbdata < 0x80) || ((0xA0 < msbdata) && (msbdata <= 0xdF)) ) … … 138 138 } else 139 139 { 140 uint 16_t lsbdata = Serial.read();//2バイト目140 uint8_t lsbdata = Serial.read();//2バイト目 //10/07 141 141 uint16_t data = ((msbdata << 8) + lsbdata); //2 142 142 showSJIS2byte(data); … … 160 160 uint8_t c1 = ((code & 0xff00) >> 8); 161 161 uint8_t c2 = (code & 0xFF); 162 if (c1 >= 0xe0) { 162 if (c1 >= 0xe0) 163 { 163 164 c1 = c1 - 0x40; 164 165 } 165 if (c2 >= 0x80) { 166 if (c2 >= 0x80) 167 { 166 168 c2 = c2 - 1; 167 169 } 168 if (c2 >= 0x9e) { 170 if (c2 >= 0x9e) 171 { 169 172 c1 = (c1 - 0x70) * 2; 170 173 c2 = c2 - 0x7d; 171 } else { 174 } else 175 { 172 176 c1 = ((c1 - 0x70) * 2) - 1; 173 177 c2 = c2 - 0x1f; … … 239 243 void readFontASCII(uint8_t ASCIICODE) 240 244 { 241 Serial.print( ASCIICODE, HEX);245 Serial.print("ASCII,0x");Serial.print(ASCIICODE, HEX); //10/07 242 246 uint32_t Address = 0; 243 247 /*ASCII文字*/ … … 248 252 /*漢字ROMにデータを送信*/ 249 253 digitalWrite(SS, HIGH); 250 Serial.print(" Address = "); Serial.println(Address, HEX);254 Serial.print(" Address = "); Serial.println(Address, HEX); 251 255 digitalWrite(SS, LOW); //通信開始 252 256 SPI.transfer(0x03); … … 272 276 { 273 277 char byteDigit = (1 << i); 274 if (matrixdata32[b] & byteDigit) { 278 if (matrixdata32[b] & byteDigit) 279 { 275 280 Serial.write("XX"); 276 } else { 281 } else 282 { 277 283 Serial.write("--"); 278 284 } … … 286 292 { 287 293 char byteDigit = (1 << i); 288 if (matrixdata32[b] & byteDigit) { 294 if (matrixdata32[b] & byteDigit) 295 { 289 296 Serial.write("XX"); 290 } else { 297 } else 298 { 291 299 Serial.write("--"); 292 300 } … … 307 315 { 308 316 char byteDigit = (1 << i); 309 if (matrixdata16[b] & byteDigit) { 317 if (matrixdata16[b] & byteDigit) 318 { 310 319 Serial.write("XX"); 311 } else { 320 } else 321 { 312 322 Serial.write("--"); 313 323 } … … 321 331 { 322 332 char byteDigit = (1 << i); 323 if (matrixdata16[b] & byteDigit) { 333 if (matrixdata16[b] & byteDigit) 334 { 324 335 Serial.write("XX"); 325 } else { 336 } else 337 { 326 338 Serial.write("--"); 327 339 } … … 332 344 }//sendDataToSerial32 333 345 }}} 346 347 ---- 348 349 === 動作サンプル === 350 351 ==== Sample1 ==== 352 353 「科学」と入力してEnterを押した時の動作です。 354 [[Image(sample.png)]] 355 356 ==== Sample2 ==== 357 358 「Ss」と入力してEnterを押した時の動作です。 359 [[Image(sample2.png)]]