5 Replies Latest reply on Feb 5, 2020 3:58 PM by BoTa_264741

    8x8 LED Sample for CY8CKIT-149 (Wingless)

    MoTa_728816

      Hi,

       

      This time I tried to create a simple(?) sample for 8x8 LED using CY8CKIT-149.

      Note: I have detached the wings of CY8CKIT-149 to use more pins.

       

      今回は CY8CKIT-149 (PSoC 4100S Plus) を使用して 8x8 マトリクス LED を動かすサンプルを作ってみました。

      ※ 私の CY8CKIT-149 は羽 (CapSense) の部分は取り外して、ピンソケットが付けてあります。

      IMG_4102_S.JPG

       

      I purchased the Matrix LED (8x8) from Akizuki

      マトリクス LED は秋月から購入した下記のものを使用しています。

      赤色ドットマトリクスLED 8×8ドット OSL641501−ARA: LED(発光ダイオード) 秋月電子通商-電子部品・ネット通販

       

      The COLS and ROWS connection are

      LED のピン配置は下記の様に COL と ROW になっています。

      SEG_LED_PIN.JPG

       

      The schematic / 回路図

      schematic.JPG

      PINS / ピン配置

      DWR_PINS.JPG

       

      The program has a frame buffer wannabe

      プログラムはなんちゃってフレームバッファとして下記の配列を使います。

      uint8_t led[NUM_LED_ROW][NUM_LED_COL] ;

       

       

      If USE_TICK in the beginning of the program is 1 then CySysTick (1ms) is used for the periodical interrupt

      or Timer (100/1MHz = 0.1ms) interval is used. Although with SysTick we can save a Timer, but the flicker was bad...

       

      プログラムの先頭で USE_TICK を 1 と定義すると、定期割込みに CySysTick (1ms) を使用します、

      もしくは Timer を使用して 0.1ms の定期割込みを行わせています。 CySysTick を使用すると

      Timer を一つ節約できるのですが、8x8 マトリクスでは、チラツキが多くてあまりお勧めではありませんでした。

       

      Also if USE_UART is defined as 1, then UART (serial out) is used to show current output pattern

      また、プログラムの先頭で USE_UART を 1 と定義するとシリアル出力に現在のパターンが出力されます。

      TeraTerm-log.JPG

       

      main.c

      ==========================

      #include "project.h"

      #include "stdio.h"

       

      #define USE_TICK 0

      #define USE_UART 1

       

      #define NUM_LED_COL 8

      #define NUM_LED_ROW 8

      volatile int led_row = 0 ;

      volatile int led_col = 0 ;

      uint8_t led[NUM_LED_ROW][NUM_LED_COL] = { 0u } ;

       

      CY_ISR(seg_led_isr)

      {

      #if !USE_TICK

          Timer_ClearInterrupt(Timer_INTR_MASK_TC) ;

      #endif

         

          int R, C ;

          C = (led[led_row][led_col]) ? 1 : 0 ;

          R = (C) ? 0 : 1 ;

          switch(led_row) {

          case 0:  ROW_1_Write(R);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

          case 1:  ROW_1_Write(1);ROW_2_Write(R);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

          case 2:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(R);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

          case 3:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(R);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

          case 4:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(R);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

          case 5:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(R);ROW_7_Write(1);ROW_8_Write(1);break;

          case 6:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(R);ROW_8_Write(1);break;

          case 7:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(R);break;

          default: ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

          }

          switch(led_col) {

          case 0:  COL_1_Write(C);COL_2_Write(0);COL_3_Write(0);COL_4_Write(0);COL_5_Write(0);COL_6_Write(0);COL_7_Write(0);COL_8_Write(0);break ;

          case 1:  COL_1_Write(0);COL_2_Write(C);COL_3_Write(0);COL_4_Write(0);COL_5_Write(0);COL_6_Write(0);COL_7_Write(0);COL_8_Write(0);break ;

          case 2:  COL_1_Write(0);COL_2_Write(0);COL_3_Write(C);COL_4_Write(0);COL_5_Write(0);COL_6_Write(0);COL_7_Write(0);COL_8_Write(0);break ;

          case 3:  COL_1_Write(0);COL_2_Write(0);COL_3_Write(0);COL_4_Write(C);COL_5_Write(0);COL_6_Write(0);COL_7_Write(0);COL_8_Write(0);break ;

          case 4:  COL_1_Write(0);COL_2_Write(0);COL_3_Write(0);COL_4_Write(0);COL_5_Write(C);COL_6_Write(0);COL_7_Write(0);COL_8_Write(0);break ;

          case 5:  COL_1_Write(0);COL_2_Write(0);COL_3_Write(0);COL_4_Write(0);COL_5_Write(0);COL_6_Write(C);COL_7_Write(0);COL_8_Write(0);break ;

          case 6:  COL_1_Write(0);COL_2_Write(0);COL_3_Write(0);COL_4_Write(0);COL_5_Write(0);COL_6_Write(0);COL_7_Write(C);COL_8_Write(0);break ;

          case 7:  COL_1_Write(0);COL_2_Write(0);COL_3_Write(0);COL_4_Write(0);COL_5_Write(0);COL_6_Write(0);COL_7_Write(0);COL_8_Write(C);break ;

          default: COL_1_Write(0);COL_2_Write(0);COL_3_Write(0);COL_4_Write(0);COL_5_Write(0);COL_6_Write(0);COL_7_Write(0);COL_8_Write(0);break ;

          }

          led_col++ ;

          if (led_col >= NUM_LED_COL) {

              led_col = 0 ;

              led_row = (led_row + 1) % NUM_LED_ROW ;

          }

      }

       

      #if USE_UART

      #define STR_LEN 64

      char str[STR_LEN+1] ;

      void print(char *str)

      {

          UART_UartPutString(str) ;

      }

       

      void cls(void)

      {

          print("\033c") ; /* reset */

          CyDelay(20) ;

          print("\033[2J") ; /* clear screen */

          CyDelay(20) ;

      }

       

      void splash(void)

      {

          cls() ;

          print("SEG LED Test") ;

          snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;

          print(str) ;

      }

       

      void dump_value(void)

      {

          int c, r ;

         

          cls() ;

         

          for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

              for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                  if (led[r][c]) {

                      print("*") ;

                  } else {

                      print("-") ;

                  }

              }

              print("\n") ;

          }

      }

      #endif

       

      void init_hardware(void)

      {

          CyGlobalIntEnable; /* Enable global interrupts. */

      #if USE_UART

          UART_Start() ;

          splash() ;

      #endif

       

      #if USE_TICK

          CySysTickStart() ;

          CySysTickSetCallback(0, seg_led_isr) ;

      #else

          isr_1_ClearPending() ;

          isr_1_StartEx(seg_led_isr) ;

         

          Timer_Start() ;

      #endif

      }

       

      void all_clear(void)

      {

          int c, r ;

       

       

          for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

              for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                  led[r][c] = 0 ;

              }

          }

      }

       

      void draw_h_bar(int p)

      {

          int c, r ;

       

          for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

              for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                  if (r == p) {

                      led[r][c] = 1 ;

                  } else {

                      led[r][c] = 0 ;

                  }

              }

          }

      }

       

      void draw_v_bar(int p)

      {

          int c, r ;

       

       

          for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

              for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                  if (c == p) {

                      led[r][c] = 1 ;

                  } else {

                      led[r][c] = 0 ;

                  }

              }

          }   

      }

       

      int main(void)

      {

          int x, y ;

         

          init_hardware() ;

         

          for(;;)

          {

              all_clear() ;

      #if USE_UART

              dump_value() ;

      #endif

              for (x = 0 ; x < NUM_LED_COL ; x++ ) {

                  draw_v_bar(x) ;

      #if USE_UART

                  dump_value() ;

      #endif

                  CyDelay(1000) ;

              }

              for (y = 0 ; y < NUM_LED_ROW ; y++) {

                  draw_h_bar(y) ;

      #if USE_UART

                  dump_value() ;

      #endif

                  CyDelay(1000) ;

              }

          }

      }

      ==========================

       

      In this sample, only horizontal line and vertical line is displayed and moved each seconds,

      you can assign any pattern to led[][] in the loop of main() and the update of display will be taken care of

      by the interrupt service routine.

       

      サンプルでは水平か垂直の線を一秒毎に動かすようにしていますが、

      main() のループ内で led[][] のパターンを書き変えるだけで、

      そのパターンは自動的に割込み処理ルーチンにより マトリクスLEDに表示されます。

       

      moto

        • 1. Re: 8x8 LED Sample for CY8CKIT-149 (Wingless)
          BoTa_264741

          Moto,

          Is this an RGB panel? Can it change LEDs brightness?

          It can be useful for making a MIDI synth panel.

          /odissey1

          • 2. Re: 8x8 LED Sample for CY8CKIT-149 (Wingless)
            MoTa_728816

            Dear /odissey1-san,

             

            I love the calling "Motor" (lol)

             

            And that is a good question!

            Until this morning I did not know about color led segment and matrix driver for PSoC 3 and 5LP.

            https://www.cypress.com/documentation/component-datasheets/led-segment-and-matrix-driver

             

            The one I used was a $2.00 plain vanilla red-color LED.

            But as I searched there are 8x8 color ones, they seem to be about 10x more expensive though.

             

            I made this sample, as one of our customer was going to need it.

            To support color, basically making the matrix to 8x8x3 or use each item in the array as value instead of on/off.

             

            For the brightness, as I'm not using hardware component, if PSoC can catch up with much higher speed loop

            we should be able to make it. (I hope that we can)

             

            Anyway thank you for your idea(s) about more challenging theme ;-)

             

            Best Regards,

            22-Jan-2020

            Motoo Tanaka

            • 3. Re: 8x8 LED Sample for CY8CKIT-149 (Wingless)
              BoTa_264741

              Motoo,

              I apologise for misspelling. It is now corrected. The autocorrection function sometimes leads to embarrassing results.

              /odissey1

              • 4. Re: 8x8 LED Sample for CY8CKIT-149 (Wingless)
                MoTa_728816

                Dear odissey1-san,

                 

                So yesterday, one of my colleague had a chance to make a round trip to Akihabara,

                I asked him to grab one of these color matrix LEDs for me.

                 

                昨日、同僚が秋葉原へ行く用事があったので、ついでにカラーマトリクス LED をゲットしてもらいました。

                  RGBフルカラードットマトリクスLED 8×8ドット OSL642372−ARGB: LED(発光ダイオード) 秋月電子通商-電子部品・ネット通販

                 

                Although in their web the LED seems to be almost identical with the mono-color one,

                the size was different.

                 

                ウェブでみると単色のものと殆ど同じものにみえるのですが、

                実物は少し大きかったです・・・

                 

                By the way, the most challenging part of this project was

                finding usable pin(s) and connect them physically one by one

                I felt like I was weaving a basket >_<

                 

                ところで、本プロジェクトの最大難関は

                使えるピンを探して、一本一本結線するところでした、

                ほとんど籠(かご)を編んでいるような感じでした >_<

                IMG_4128.JPG

                 

                Anyway, I modified my project as below

                Note: I used only 1 timer, so the CPU needed to work harder.

                  If this was PSoC 42xx, I would have used UDB ...

                 

                Although I thought I was also working on gradation it's not quite working,

                may be, I must think more later...

                 

                とりま、プロジェクトを下記の様に変更しました

                ※ タイマーを一つしか使用していないので、ソフトウェア側の仕事が多くなっています。

                 PSoC 42xx シリーズを使っていたら、UDB で対応したい案件ですね・・・

                 

                諧調も付けたつもりだったのですが、殆ど機能していません、

                後でちゃんと考えなくてはいけない感じです・・・

                 

                schematic

                000-schematic.JPG

                pins

                001-schematic.JPG

                main.c

                ===================

                #include "project.h"

                #include "stdio.h"

                 

                #define USE_TICK 0

                #define USE_UART 0

                 

                #define NUM_LED_RES 16

                #define NUM_LED_COL 8

                #define NUM_LED_ROW 8

                volatile int     led_row  = NUM_LED_ROW-1 ;

                volatile int     led_col  = NUM_LED_COL-1 ;

                volatile uint8_t phase = NUM_LED_RES ;

                 

                uint8_t led[NUM_LED_ROW][NUM_LED_COL][3] = { 0u } ;

                 

                CY_ISR(seg_led_isr)

                {

                #if !USE_TICK

                    Timer_ClearInterrupt(Timer_INTR_MASK_TC) ;

                #endif

                    int R, G, B, C ;

                    if (phase >= NUM_LED_RES) {

                        phase = 0 ;

                        led_col++ ;

                        if (led_col >= NUM_LED_COL) {

                            led_col = 0 ;

                            led_row = (led_row + 1) % NUM_LED_ROW ;

                        }

                       

                        R = (phase < led[led_row][led_col][0]) ? 1 : 0 ;

                        G = (phase < led[led_row][led_col][1]) ? 1 : 0 ;

                        B = (phase < led[led_row][led_col][2]) ? 1 : 0 ;

                        C = (R || G || B) ? 0 : 1 ;

                       

                 

                    switch(led_row) {

                    case 0:  ROW_1_Write(C);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

                    case 1:  ROW_1_Write(1);ROW_2_Write(C);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

                    case 2:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(C);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

                    case 3:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(C);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

                    case 4:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(C);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

                    case 5:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(C);ROW_7_Write(1);ROW_8_Write(1);break;

                    case 6:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(C);ROW_8_Write(1);break;

                    case 7:  ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(C);break;

                    default: ROW_1_Write(1);ROW_2_Write(1);ROW_3_Write(1);ROW_4_Write(1);ROW_5_Write(1);ROW_6_Write(1);ROW_7_Write(1);ROW_8_Write(1);break;

                    }

                       

                    switch(led_col) {

                    case 0: COLR_1_Write(R);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(G);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(B);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(0);break ;

                           

                    case 1: COLR_1_Write(0);COLR_2_Write(R);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(G);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(B);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(0);break ;

                           

                    case 2: COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(R);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(G);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(B);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(0);break ;       

                 

                    case 3: COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(R);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(G);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(B);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(0);break ;

                           

                    case 4: COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(R);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(G);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(B);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(0);break ;             

                          

                    case 5: COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(R);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(G);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(B);COLB_7_Write(0);COLB_8_Write(0);break ;

                           

                    case 6: COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(R);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(G);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(B);COLB_8_Write(0);break ; 

                           

                    case 7: COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(R);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(G);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(B);break ;

                           

                    default:COLR_1_Write(0);COLR_2_Write(0);COLR_3_Write(0);COLR_4_Write(0);COLR_5_Write(0);COLR_6_Write(0);COLR_7_Write(0);COLR_8_Write(0);

                            COLG_1_Write(0);COLG_2_Write(0);COLG_3_Write(0);COLG_4_Write(0);COLG_5_Write(0);COLG_6_Write(0);COLG_7_Write(0);COLG_8_Write(0);

                            COLB_1_Write(0);COLB_2_Write(0);COLB_3_Write(0);COLB_4_Write(0);COLB_5_Write(0);COLB_6_Write(0);COLB_7_Write(0);COLB_8_Write(0);break ; 

                    }

                 

                 

                    }

                    phase++ ;

                }

                 

                 

                #if USE_UART

                #define STR_LEN 64

                char str[STR_LEN+1] ;

                void print(char *str)

                {

                    UART_UartPutString(str) ;

                }

                 

                void cls(void)

                {

                    print("\033c") ; /* reset */

                    CyDelay(20) ;

                    print("\033[2J") ; /* clear screen */

                    CyDelay(20) ;

                }

                 

                void splash(void)

                {

                    cls() ;

                    print("SEG LED Test") ;

                    snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;

                    print(str) ;

                }

                 

                void dump_value(void)

                {

                    int c, r, p ;

                   

                    cls() ;

                   

                    for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

                        for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                            for (p = 0 ; p < 3 ; p++ ) {

                                if (led[r][c][p]) {

                                    print("*") ;

                                } else {

                                    print("-") ;

                                }

                            }

                        }

                        print("\n") ;

                    }

                }

                #endif

                 

                 

                void init_hardware(void)

                {

                    CyGlobalIntEnable; /* Enable global interrupts. */

                #if USE_UART

                    UART_Start() ;

                    splash() ;

                #endif

                 

                 

                #if USE_TICK

                    CySysTickStart() ;

                    CySysTickSetCallback(0, seg_led_isr) ;

                #else

                    isr_1_ClearPending() ;

                    isr_1_StartEx(seg_led_isr) ;

                   

                    Timer_Start() ;

                #endif

                }

                 

                void all_clear(void)

                {

                    int c, r, color ;

                 

                    for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

                        for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                            for (color = 0 ; color < 3 ; color++ ) {

                                led[r][c][color] = 0 ;

                            }

                        }

                    }

                }

                 

                void draw_h_bar(int p)

                {

                    int c, r ;

                 

                    for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

                        for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                            if (r == p) {

                                led[r][c][0] = NUM_LED_RES/4 ;

                                led[r][c][1] = NUM_LED_RES/4 ;

                                led[r][c][2] = NUM_LED_RES/4 ;

                            } else {

                                led[r][c][0] = 0 ;

                                led[r][c][1] = 0 ;

                                led[r][c][2] = 0 ;

                            }

                        }

                    }

                }

                 

                void draw_v_bar(int p)

                {

                    int c, r ;

                 

                    for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

                        for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                            if (c == p) {

                                led[r][c][0] = NUM_LED_RES/4 ;

                                led[r][c][1] = NUM_LED_RES/4 ;

                                led[r][c][2] = NUM_LED_RES/4 ;

                            } else {

                                led[r][c][0] = 0 ;

                                led[r][c][1] = 0 ;

                                led[r][c][2] = 0 ;

                            }

                        }

                    }   

                }

                 

                void draw_color_bar(int offset_x, int offset_y)

                {

                    int x, y, i, j ;

                   

                    for (j = 0 ; j < NUM_LED_ROW ; j++ ) {

                        y = (j + offset_y) % NUM_LED_ROW ;

                        for (i = 0 ; i < NUM_LED_COL ; i++ ) {

                            x = (i + offset_x) % NUM_LED_COL ;

                            if (j & 0x01) {

                                led[y][x][0] = NUM_LED_RES * (i+1) / NUM_LED_COL ;              

                            }

                            if (j & 0x02) {

                                led[y][x][1] = NUM_LED_RES * (i+1) / NUM_LED_COL ;        

                            }

                            if (j & 0x04) {

                                led[y][x][2] = NUM_LED_RES * (i+1) / NUM_LED_COL ;       

                            }

                        }

                    }   

                }

                 

                void draw_pixel(int x, int y)

                {

                    int c, r ;

                 

                 

                    for (r = 0 ; r < NUM_LED_ROW ; r++ ) {

                        for (c = 0 ; c < NUM_LED_COL ; c++ ) {

                            if ((c == x)&&(r == y)) {

                                led[r][c][0] = NUM_LED_RES/4 ;

                                led[r][c][1] = NUM_LED_RES/4 ;

                                led[r][c][2] = NUM_LED_RES/4 ;

                            } else {

                                led[r][c][0] = 0 ;

                                led[r][c][1] = 0 ;

                                led[r][c][2] = 0 ;

                            }

                        }

                    }      

                }

                 

                int main(void)

                {

                    int x, y ;

                   

                    init_hardware() ;

                   

                    for(;;)

                    {

                        all_clear() ;

                #if USE_UART

                        dump_value() ;

                #endif

                        for (x = 0 ; x < NUM_LED_COL ; x++ ) {

                            draw_v_bar(x) ;

                #if USE_UART

                            dump_value() ;

                #endif

                            CyDelay(50) ;

                        }

                        for (y = 0 ; y < NUM_LED_ROW ; y++) {

                            draw_h_bar(y) ;

                #if USE_UART

                            dump_value() ;

                #endif

                            CyDelay(50) ;

                        }

                        for (y = 0 ; y < NUM_LED_ROW ; y++ ) {

                            for (x = 0 ; x < NUM_LED_COL ; x++ ) {

                                all_clear() ;

                                draw_color_bar(x, y) ;

                                CyDelay(10) ;

                            }

                        }

                        CyDelay(1000) ;

                    }

                }

                ===================

                 

                Attached is the project and an iPhone movie

                 

                添付はプロジェクトと iPhone のムービーです。

                 

                Best Regards,

                5-Feb-2020

                Motoo Tanaka

                 

                • 5. Re: 8x8 LED Sample for CY8CKIT-149 (Wingless)
                  BoTa_264741

                  Motoo,

                  Interesting video! I once programmed a matrix of RGB LEDs, driven by SPI. From that experience, the hardest part was to make it output something reasonable, like geometric patters or color splash, which would require using of external software for development of color sequences (like Jason, etc.). That's where my patience had exhausted.

                  /odissey1

                  PS. I like Akihabara, spent there endless hours browsing through the labirinth of small shops. Build my first PC there from parts (486x?), cost me almost $2k back then. And got Orange Pecoe hot tee from vending machine on way back to Ikebukoro. Sweet days!