@@ -145,6 +145,10 @@ void setup() {
145145
146146 arcada.displayBegin ();
147147
148+ DISPLAY_SIZE = min (ARCADA_TFT_WIDTH, ARCADA_TFT_HEIGHT);
149+ DISPLAY_X_OFFSET = (ARCADA_TFT_WIDTH - DISPLAY_SIZE) / 2 ;
150+ DISPLAY_Y_OFFSET = (ARCADA_TFT_HEIGHT - DISPLAY_SIZE) / 2 ;
151+
148152 Serial.begin (115200 );
149153// while(!Serial) delay(10);
150154
@@ -161,22 +165,24 @@ void setup() {
161165 // of the nose booper when doing this...it self-calibrates on startup.
162166 // DO THIS BEFORE THE SPLASH SO IT DOESN'T REQUIRE A LENGTHY HOLD.
163167 char *filename = " config.eye" ;
164- arcada. readButtons ();
165- uint32_t buttonState = arcada.justPressedButtons ();
166- if (buttonState & ARCADA_BUTTONMASK_UP) {
168+
169+ uint32_t buttonState = arcada.readButtons ();
170+ if (( buttonState & ARCADA_BUTTONMASK_UP) && arcada. exists ( " config1.eye " ) ) {
167171 filename = " config1.eye" ;
168- } else if (buttonState & ARCADA_BUTTONMASK_A) {
172+ } else if (( buttonState & ARCADA_BUTTONMASK_A) && arcada. exists ( " config2.eye " ) ) {
169173 filename = " config2.eye" ;
170- } else if (buttonState & ARCADA_BUTTONMASK_DOWN) {
174+ } else if (( buttonState & ARCADA_BUTTONMASK_DOWN) && arcada. exists ( " config3.eye " ) ) {
171175 filename = " config3.eye" ;
172176 }
173177
174178 yield ();
175179 // Initialize displays
176- eye[ 0 ]. display = arcada. _display ;
177- if (NUM_EYES > 1 ) {
180+ # if (NUM_EYES > 1)
181+ eye[ 0 ]. display = arcada. _display ;
178182 eye[1 ].display = arcada.display2 ;
179- }
183+ #else
184+ eye[0 ].display = arcada.display ;
185+ #endif
180186
181187 yield ();
182188 if (arcada.drawBMP (" /splash.bmp" , 0 , 0 , (eye[0 ].display )) == IMAGE_SUCCESS) {
@@ -200,10 +206,11 @@ void setup() {
200206
201207 // Initialize DMAs
202208 yield ();
203- uint8_t e, rtna = 0x01 ; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
209+ uint8_t e;
204210 for (e=0 ; e<NUM_EYES; e++) {
211+ #if (ARCADA_TFT_WIDTH != 160) && (ARCADA_TFT_HEIGHT != 128) // 160x128 is ST7735 which isn't able to deal
205212 eye[e].spi ->setClockSource (DISPLAY_CLKSRC);
206- eye[e]. display -> sendCommand ( 0xC6 , &rtna, 1 );
213+ # endif
207214 eye[e].display ->fillScreen (0 );
208215 eye[e].dma .allocate ();
209216 eye[e].dma .setTrigger (eye[e].spi ->getDMAC_ID_TX ());
@@ -836,7 +843,7 @@ void loop() {
836843 // Initialize new SPI transaction & address window...
837844 eye[eyeNum].spi ->beginTransaction (settings);
838845 digitalWrite (eye[eyeNum].cs , LOW); // Chip select
839- eye[eyeNum].display ->setAddrWindow (0 , 0 , DISPLAY_SIZE, DISPLAY_SIZE);
846+ eye[eyeNum].display ->setAddrWindow (DISPLAY_X_OFFSET, DISPLAY_Y_OFFSET , DISPLAY_SIZE, DISPLAY_SIZE);
840847 delayMicroseconds (1 );
841848 digitalWrite (eye[eyeNum].dc , HIGH); // Data mode
842849 if (eyeNum == (NUM_EYES-1 )) {
@@ -888,6 +895,7 @@ void loop() {
888895 irisValue = irisMin + (sum * irisRange); // 0.0-1.0 -> iris min/max
889896 if ((++iris_frame) >= (1 << IRIS_LEVELS)) iris_frame = 0 ;
890897 }
898+ #if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
891899 if (voiceOn) {
892900 // Read buttons, change pitch
893901 arcada.readButtons ();
@@ -906,6 +914,7 @@ void loop() {
906914 Serial.println (currentPitch);
907915 }
908916 }
917+ #endif
909918 user_loop ();
910919 }
911920 } // end first-column check
0 commit comments