@@ -145,6 +145,10 @@ void setup() {
145
145
146
146
arcada.displayBegin ();
147
147
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
+
148
152
Serial.begin (115200 );
149
153
// while(!Serial) delay(10);
150
154
@@ -161,22 +165,24 @@ void setup() {
161
165
// of the nose booper when doing this...it self-calibrates on startup.
162
166
// DO THIS BEFORE THE SPLASH SO IT DOESN'T REQUIRE A LENGTHY HOLD.
163
167
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 " ) ) {
167
171
filename = " config1.eye" ;
168
- } else if (buttonState & ARCADA_BUTTONMASK_A) {
172
+ } else if (( buttonState & ARCADA_BUTTONMASK_A) && arcada. exists ( " config2.eye " ) ) {
169
173
filename = " config2.eye" ;
170
- } else if (buttonState & ARCADA_BUTTONMASK_DOWN) {
174
+ } else if (( buttonState & ARCADA_BUTTONMASK_DOWN) && arcada. exists ( " config3.eye " ) ) {
171
175
filename = " config3.eye" ;
172
176
}
173
177
174
178
yield ();
175
179
// Initialize displays
176
- eye[ 0 ]. display = arcada. _display ;
177
- if (NUM_EYES > 1 ) {
180
+ # if (NUM_EYES > 1)
181
+ eye[ 0 ]. display = arcada. _display ;
178
182
eye[1 ].display = arcada.display2 ;
179
- }
183
+ #else
184
+ eye[0 ].display = arcada.display ;
185
+ #endif
180
186
181
187
yield ();
182
188
if (arcada.drawBMP (" /splash.bmp" , 0 , 0 , (eye[0 ].display )) == IMAGE_SUCCESS) {
@@ -200,10 +206,11 @@ void setup() {
200
206
201
207
// Initialize DMAs
202
208
yield ();
203
- uint8_t e, rtna = 0x01 ; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
209
+ uint8_t e;
204
210
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
205
212
eye[e].spi ->setClockSource (DISPLAY_CLKSRC);
206
- eye[e]. display -> sendCommand ( 0xC6 , &rtna, 1 );
213
+ # endif
207
214
eye[e].display ->fillScreen (0 );
208
215
eye[e].dma .allocate ();
209
216
eye[e].dma .setTrigger (eye[e].spi ->getDMAC_ID_TX ());
@@ -836,7 +843,7 @@ void loop() {
836
843
// Initialize new SPI transaction & address window...
837
844
eye[eyeNum].spi ->beginTransaction (settings);
838
845
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);
840
847
delayMicroseconds (1 );
841
848
digitalWrite (eye[eyeNum].dc , HIGH); // Data mode
842
849
if (eyeNum == (NUM_EYES-1 )) {
@@ -888,6 +895,7 @@ void loop() {
888
895
irisValue = irisMin + (sum * irisRange); // 0.0-1.0 -> iris min/max
889
896
if ((++iris_frame) >= (1 << IRIS_LEVELS)) iris_frame = 0 ;
890
897
}
898
+ #if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
891
899
if (voiceOn) {
892
900
// Read buttons, change pitch
893
901
arcada.readButtons ();
@@ -906,6 +914,7 @@ void loop() {
906
914
Serial.println (currentPitch);
907
915
}
908
916
}
917
+ #endif
909
918
user_loop ();
910
919
}
911
920
} // end first-column check
0 commit comments