ช่วยแปล โค้ดแล้วคอมเม้นให้หน่อยครับ TT

// scrolltext demo for Adafruit RGBmatrixPanel library.
// Demonstrates double-buffered animation on our 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

#include "Adafruit_GFX.h"   // Core graphics library
#include "RGBmatrixPanel.h" // Hardware-specific library

// Similar to F(), but for PROGMEM string pointers rather than literals
#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr

#define CLK 11  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT 10
#define OE  9
#define A   A0
#define B   A1
#define C   A2
// Last parameter = 'true' enables double-buffering, for flicker-free,
// buttery smooth animation.  Note that NOTHING WILL SHOW ON THE DISPLAY
// until the first call to swapBuffers().  This is normal.
#define NUMDISPLAYS 7
#define DOUBLEBUFFER false
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, DOUBLEBUFFER, NUMDISPLAYS);
// Double-buffered mode consumes nearly all the RAM available on the
// Arduino Uno -- only a handful of free bytes remain.  Even the
// following string needs to go in PROGMEM:

#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

#define FS(x) (__FlashStringHelper*)(x)
const char str[] PROGMEM = "กขคงจ";

int    textX   = matrix.width(),
       textMin = sizeof(str) * 0,
       hue     = 7;
int8_t ball[3][4] = {
  {  3,  0,  1,  1 }, // Initial X,Y pos & velocity for 3 bouncy balls
  { 17, 15,  1, -1 },
  { 27,  4, -1,  1 }
};
static const uint16_t PROGMEM ballcolor[3] = {
  0x0080, // Green=1
  0x0002, // Blue=1
  0x1000  // Red=1
};
byte myByte;
char string;
char* s="AaBbกขคงจ๛";

void setup() {
  Serial.begin(9600);
//  Serial.println(str);
//  utf8ascii(s);
//  Serial.print("Extended ASCII-Version ");
//  Serial.println(s);

  matrix.begin();
  matrix.setTextWrap(false); // Allow text to run off right edge
  matrix.setTextSize(2);
  matrix.setRotation(0);
//  matrix.setTextColor(CYAN);
  matrix.setTextColor(BLUE);
  matrix.setCursor(1,1);
//  matrix.print(F2(str));
//  matrix.ThaiString("กำลังหัดพูดภาษาไทย",10,1,GREEN,YELLOW);
  matrix.ThaiString("  สวัสดีครับ ",1,1,GREEN,YELLOW);
//  matrix.ThaiString("กขคงจฉชซฌญฏฎฐ",10,-1,GREEN,YELLOW);
}

void loop() {

  byte i;
  // Clear background
  matrix.fillScreen(0);
  // Draw big scrolly text on top
  //matrix.setTextColor(matrix.ColorHSV(1000, 255, 255, true));
  matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
  matrix.setCursor(textX, 1);
  matrix.ThaiString("วิทยาลัยเทคโนโลยีดรุณาโปลีเทคนิค",1,1,RED,YELLOW);
  // Move text left (w/wrap), increase hue
  if((--textX) < textMin) textX = matrix.width();
  hue += 3;
  if(hue >= 1536) hue -= 1536;

  // Update display
  matrix.swapBuffers(true);
  delay(1);


  if (Serial.available() > 0) { // there are bytes in the serial buffer to read
    while (Serial.available() > 0) { // every time a byte is read it is expunged
      myByte = Serial.read(); // read in the next byte
     string = myByte;
    }
    Serial.println(myByte, DEC); // base 10, this is the default
    Serial.println(myByte, HEX); // base 16
    Serial.println(myByte, OCT); // base 8
    Serial.println(myByte, BIN); // base 2
    Serial.write(myByte); // ASCII character
    Serial.println(string); // carriage return
//    matrix.fillScreen(matrix.Color333(0, 0, 0));
//    matrix.setCursor(161, 1);
    matrix.setCursor(10, 1);
    matrix.setTextColor(CYAN);
    matrix.print(string);
    delay(100); // a short delay
  }

}
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่