wb32_color_chart:顯示基本顏色與名稱


  • wbo


    WiFiBoy32 的 TFT LCD 可以顯示 18bit 顏色,也就是 RGB 各 6 個 bits,一共可以顯示出 262144 種顏色。

    但我們為了方便計算,以 2 個 bytes 來處理顏色,也就是有 65536 色。少了兩個 bits,RGB各為 5-6-5 bits。

    程式打包在此:wb32_color_chart.zip

    Source codes:

    /*
     *  Default Color Chart -- WiFiBoy32 Demo Code for Arduino/ESP32
     *
     *  Oct 13, 2017 Created. (derek@wifiboy.org)
     *
     */
    #include "wifiboy32.h"

    String colorName[]={
      "wbBLACK", "wbNAVY", "wbDARKGREEN", "wbDARKCYAN", "wbMAROON", "wbPURPLE",
      "wbOLIVE", "wbLIGHTGREY", "wbDARKGREY", "wbBLUE", "wbGREEN", "wbCYAN", "wbRED",
      "wbMAGENTA", "wbYELLOW", "wbWHITE", "wbORANGE", "wbGREENYELLOW", "wbPINK"
    };

    uint16_t _wbColor[]={
      wbBLACK, wbNAVY, wbDARKGREEN, wbDARKCYAN, wbMAROON, wbPURPLE, wbOLIVE,
      wbLIGHTGREY, wbDARKGREY, wbBLUE, wbGREEN, wbCYAN, wbRED, wbMAGENTA, wbYELLOW,
      wbWHITE, wbORANGE, wbGREENYELLOW, wbPINK
    };

    void setup()
    {
      char numStr[5];
     
      wb32_init();
      wb32_fillScreen(0);
     
      wb32_setTextColor(wbYELLOW, wbYELLOW);
      wb32_drawString("WiFiBoy Color Chart", 16, 5, 1, 3);
     
      wb32_drawRect(24, 32, 102, 19*15, wbWHITE);

      wb32_setTextColor(wbWHITE, wbWHITE);
      for(int i=0; i<19; i++) {
        sprintf(numStr, "%d", i);
        wb32_drawString(numStr, 130, i*15+35, 2, 1);
        wb32_fillRect(25, i*15+33, 100, 13, _wbColor[i]);
        wb32_drawString(colorName[i].c_str(), 145, i*15+35, 2, 1);
      }
    }

    void loop()
    {
    }




看起來你的連線到 WiFiBoy.Club 已經遺失,請稍等一下我們嘗試重新連線。