Changes between Version 7 and Version 8 of KanjiROM


Ignore:
Timestamp:
Oct 7, 2015 6:30:15 PM (9 years ago)
Author:
kishida
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • KanjiROM

    v7 v8  
    9696ROMから読みだしてシリアルモニタに返すプログラムです。
    9797半角カナには対応していません。
    98 {{{
    99 /* GT20L16J1Y用サンプルプログラム
     98{{{/* GT20L16J1Y用サンプルプログラム
    10099 * Arduinoのシリアルモニタから送信されたSJISの文字を
    101100 * ROMから読みだしてシリアルモニタに返す
    102101 * 半角カナまわりはデータにはあるがROM内の順とJISX規格での順が
    103102 * 一致しないため未実装
    104  *
    105  * update:9/30 0:00
     103 *
     104 * memo:9/30 00:00
     105 * memo:10/7 18:30
    106106 */
    107107
     
    126126void loop (void)
    127127{
    128  
     128
    129129  if (Serial.available() > 0)
    130130  {
    131131    /*Arduinoのシリアルモニタから送られてくる日本語がSJISであることに注意*/
    132132    delayMicroseconds(200);//最低でも2文字受信したい
    133     uint16_t msbdata = Serial.read();//1バイト目
     133    uint8_t msbdata = Serial.read();//1バイト目 //10/07
    134134    /*SJISの1バイトコードか否か*/
    135135    if ( (msbdata < 0x80) || ((0xA0 < msbdata) && (msbdata <= 0xdF)) )
     
    138138    } else
    139139    {
    140       uint16_t lsbdata = Serial.read();//2バイト目
     140      uint8_t lsbdata = Serial.read();//2バイト目 //10/07
    141141      uint16_t data =  ((msbdata << 8) + lsbdata); //2
    142142      showSJIS2byte(data);
     
    160160  uint8_t c1 = ((code & 0xff00) >> 8);
    161161  uint8_t c2 = (code & 0xFF);
    162   if (c1 >= 0xe0) {
     162  if (c1 >= 0xe0)
     163  {
    163164    c1 = c1 - 0x40;
    164165  }
    165   if (c2 >= 0x80) {
     166  if (c2 >= 0x80)
     167  {
    166168    c2 = c2 - 1;
    167169  }
    168   if (c2 >= 0x9e) {
     170  if (c2 >= 0x9e)
     171  {
    169172    c1 = (c1 - 0x70) * 2;
    170173    c2 = c2 - 0x7d;
    171   } else {
     174  } else
     175  {
    172176    c1 = ((c1 - 0x70) * 2) - 1;
    173177    c2 = c2 - 0x1f;
     
    239243void readFontASCII(uint8_t ASCIICODE)
    240244{
    241   Serial.print(ASCIICODE, HEX);
     245  Serial.print("ASCII,0x");Serial.print(ASCIICODE, HEX); //10/07
    242246  uint32_t Address = 0;
    243247  /*ASCII文字*/
     
    248252  /*漢字ROMにデータを送信*/
    249253  digitalWrite(SS, HIGH);
    250   Serial.print("Address = "); Serial.println(Address, HEX);
     254  Serial.print("  Address = "); Serial.println(Address, HEX);
    251255  digitalWrite(SS, LOW);  //通信開始
    252256  SPI.transfer(0x03);
     
    272276    {
    273277      char byteDigit = (1 << i);
    274       if (matrixdata32[b] & byteDigit) {
     278      if (matrixdata32[b] & byteDigit)
     279      {
    275280        Serial.write("XX");
    276       } else {
     281      } else
     282      {
    277283        Serial.write("--");
    278284      }
     
    286292    {
    287293      char byteDigit = (1 << i);
    288       if (matrixdata32[b] & byteDigit) {
     294      if (matrixdata32[b] & byteDigit)
     295      {
    289296        Serial.write("XX");
    290       } else {
     297      } else
     298      {
    291299        Serial.write("--");
    292300      }
     
    307315    {
    308316      char byteDigit = (1 << i);
    309       if (matrixdata16[b] & byteDigit) {
     317      if (matrixdata16[b] & byteDigit)
     318      {
    310319        Serial.write("XX");
    311       } else {
     320      } else
     321      {
    312322        Serial.write("--");
    313323      }
     
    321331    {
    322332      char byteDigit = (1 << i);
    323       if (matrixdata16[b] & byteDigit) {
     333      if (matrixdata16[b] & byteDigit)
     334      {
    324335        Serial.write("XX");
    325       } else {
     336      } else
     337      {
    326338        Serial.write("--");
    327339      }
     
    332344}//sendDataToSerial32
    333345}}}
     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)]]