1+ // SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+ //
3+ // SPDX-License-Identifier: MIT
4+
5+ #include < Arduino.h>
6+ #include < Arduino_GFX.h>
7+ #include " databus/Arduino_XCA9554SWSPI.h"
8+ #include " databus/Arduino_ESP32RGBPanel.h"
9+ #include " display/Arduino_RGB_Display.h"
10+
11+ #define IMG_WIDTH 146
12+ #define IMG_HEIGHT 135
13+
14+ // uncomment for 240x960 bar display
15+ // #define long_display
16+
17+ // otherwise comment out for 320x820 bar display
18+
19+ Arduino_XCA9554SWSPI *expander = new Arduino_XCA9554SWSPI(
20+ PCA_TFT_RESET, PCA_TFT_CS, PCA_TFT_SCK, PCA_TFT_MOSI,
21+ &Wire, 0x3F );
22+
23+ #ifdef long_display
24+ #include " sushi_960x240.h"
25+ Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
26+ TFT_DE, TFT_VSYNC, TFT_HSYNC, TFT_PCLK,
27+ TFT_R1, TFT_R2, TFT_R3, TFT_R4, TFT_R5,
28+ TFT_G0, TFT_G1, TFT_G2, TFT_G3, TFT_G4, TFT_G5,
29+ TFT_B1, TFT_B2, TFT_B3, TFT_B4, TFT_B5,
30+ 1 /* hync_polarity */ , 20 /* hsync_front_porch */ , 8 /* hsync_pulse_width */ , 20 /* hsync_back_porch */ ,
31+ 1 /* vsync_polarity */ , 20 /* vsync_front_porch */ , 8 /* vsync_pulse_width */ , 20 /* vsync_back_porch, */ ,
32+ 0 /* pclk_active_neg */ , GFX_NOT_DEFINED /* prefer_speed */ , false /* useBigEndian */ , 0 /* de_idle_high */ ,
33+ 0 /* pclk_idle_high */ );
34+
35+ Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
36+ // 3.2" 320x820 rectangle bar display
37+ 240 /* width */ , 960 /* height */ , rgbpanel, 0 /* rotation */ , true /* auto_flush */ ,
38+ expander, GFX_NOT_DEFINED /* RST */ , HD371001C40_init_operations, sizeof (HD371001C40_init_operations), 120 /* col_offset1 */ );
39+
40+ const int numberOfBitmaps = 8 ;
41+ int display_w = 240 ;
42+ int display_h = 960 ;
43+ int sushi_h = 15 ;
44+ int sushi_offset = 62 ;
45+
46+ #else
47+ #include " sushi_320x820.h"
48+ Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
49+ TFT_DE, TFT_VSYNC, TFT_HSYNC, TFT_PCLK,
50+ TFT_R1, TFT_R2, TFT_R3, TFT_R4, TFT_R5,
51+ TFT_G0, TFT_G1, TFT_G2, TFT_G3, TFT_G4, TFT_G5,
52+ TFT_B1, TFT_B2, TFT_B3, TFT_B4, TFT_B5,
53+ 1 /* hsync_polarity */ , 50 /* hsync_front_porch */ , 2 /* hsync_pulse_width */ , 44 /* hsync_back_porch */ ,
54+ 1 /* vsync_polarity */ , 16 /* vsync_front_porch */ , 2 /* vsync_pulse_width */ , 18 /* vsync_back_porch */
55+ );
56+
57+ Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
58+ // 3.2" 320x820 rectangle bar display
59+ 320 /* width */ , 820 /* height */ , rgbpanel, 0 /* rotation */ , true /* auto_flush */ ,
60+ expander, GFX_NOT_DEFINED /* RST */ , tl032fwv01_init_operations, sizeof (tl032fwv01_init_operations));
61+
62+ const int numberOfBitmaps = 7 ;
63+ int display_w = 320 ;
64+ int display_h = 820 ;
65+ int sushi_h = 29 ;
66+ int sushi_offset = 55 ;
67+
68+ #endif
69+
70+ struct BitmapInfo {
71+ int yPosition;
72+ int bitmapIndex;
73+ };
74+
75+ BitmapInfo bitmaps[numberOfBitmaps];
76+
77+ void setup (void )
78+ {
79+ Serial.begin (115200 );
80+ // while (!Serial) delay(100);
81+
82+ #ifdef GFX_EXTRA_PRE_INIT
83+ GFX_EXTRA_PRE_INIT ();
84+ #endif
85+
86+ Serial.println (" Beginning" );
87+
88+ Wire.setClock (400000 );
89+ if (!gfx->begin ()) {
90+ Serial.println (" gfx->begin() failed!" );
91+ }
92+
93+ Serial.println (" Initialized!" );
94+
95+ gfx->fillScreen (BLACK);
96+
97+ expander->pinMode (PCA_TFT_BACKLIGHT, OUTPUT);
98+ expander->digitalWrite (PCA_TFT_BACKLIGHT, HIGH);
99+
100+ Serial.println (" Adafruit Sushi Conveyer Belt!" );
101+
102+ #ifdef GFX_EXTRA_PRE_INIT
103+ GFX_EXTRA_PRE_INIT ();
104+ #endif
105+
106+ #ifdef GFX_BL
107+ pinMode (GFX_BL, OUTPUT);
108+ digitalWrite (GFX_BL, HIGH);
109+ #endif
110+
111+ for (int i = 0 ; i < numberOfBitmaps; i++) {
112+ bitmaps[i].yPosition = (-IMG_WIDTH) * i;
113+ bitmaps[i].bitmapIndex = random (0 , myBitmapallArray_LEN - 1 );
114+ }
115+
116+ gfx->draw16bitRGBBitmap (0 , 0 , (uint16_t *)myBitmapallArray[6 ], display_w, display_h);
117+
118+ }
119+
120+ void loop ()
121+ {
122+
123+ for (int i = 0 ; i < numberOfBitmaps; i++) {
124+ bitmaps[i].yPosition ++;
125+ if (bitmaps[i].yPosition > gfx->height ()) {
126+
127+ bitmaps[i].yPosition = -IMG_WIDTH - sushi_offset;
128+ bitmaps[i].bitmapIndex = random (0 , myBitmapallArray_LEN - 1 );
129+ }
130+ gfx->draw16bitRGBBitmap (sushi_h, bitmaps[i].yPosition , (uint16_t *)myBitmapallArray[bitmaps[i].bitmapIndex ], IMG_HEIGHT, IMG_WIDTH);
131+ }
132+ delay (1 );
133+
134+ }
0 commit comments