@@ -137,12 +137,12 @@ void setup() {
137137 if (!arcada.arcadaBegin ()) {
138138 while (1 );
139139 }
140+ arcada.displayBegin ();
140141 // MUST set up flash filesystem before Serial.begin() or seesaw.begin()
141- arcada.filesysBeginMSD ();
142-
143- // if(i == 1) fatal("Flash init fail", 100);
144- // else if(i == 2) fatal("No filesys", 500);
145-
142+ if (!arcada.filesysBeginMSD ()) {
143+ arcada.setBacklight (255 );
144+ arcada.haltBox (" No filesystem found, please load CircuitPython on in order to create one!" );
145+ }
146146
147147 Serial.begin (115200 );
148148 // while(!Serial) delay(10);
@@ -152,24 +152,7 @@ void setup() {
152152 yield (); // Periodic yield() makes sure mass storage filesystem stays alive
153153
154154 // Backlight(s) off ASAP, they'll switch on after screen(s) init & clear
155- pinMode (BACKLIGHT_PIN, OUTPUT);
156- analogWrite (BACKLIGHT_PIN, 0 );
157- #if NUM_EYES > 1
158- if (!seesaw.begin ()) fatal (" Seesaw init fail" , 1000 );
159- seesaw.analogWrite (SEESAW_BACKLIGHT_PIN, 0 );
160- // Configure Seesaw pins 9,10,11 as inputs
161- seesaw.pinModeBulk (0b111000000000 , INPUT_PULLUP);
162- priorButtonState = seesaw.digitalReadBulk (0b111000000000 );
163- #endif
164-
165-
166- #if NUM_EYES > 1
167- seesaw.pinMode (SEESAW_TFT_RESET_PIN, OUTPUT);
168- seesaw.digitalWrite (SEESAW_TFT_RESET_PIN, LOW);
169- delay (10 );
170- seesaw.digitalWrite (SEESAW_TFT_RESET_PIN, HIGH);
171- delay (20 );
172- #endif
155+ arcada.setBacklight (0 );
173156
174157 yield ();
175158 uint8_t e, rtna = 0x01 ; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
@@ -193,19 +176,13 @@ void setup() {
193176 #endif
194177 // backlight on for a bit
195178 for (int bl=0 ; bl<=250 ; bl+=10 ) {
196- #if NUM_EYES > 1
197- seesaw.analogWrite (SEESAW_BACKLIGHT_PIN, bl);
198- #endif
199- analogWrite (BACKLIGHT_PIN, bl);
179+ arcada.setBacklight (bl);
200180 delay (10 );
201181 }
202182 delay (2000 );
203183 // backlight back off
204184 for (int bl=250 ; bl>=0 ; bl-=10 ) {
205- #if NUM_EYES > 1
206- seesaw.analogWrite (SEESAW_BACKLIGHT_PIN, bl);
207- #endif
208- analogWrite (BACKLIGHT_PIN, bl);
185+ arcada.setBacklight (bl);
209186 delay (10 );
210187 }
211188 }
@@ -267,10 +244,7 @@ void setup() {
267244 eye[e].blinkFactor = 0.0 ;
268245 }
269246
270- analogWrite (BACKLIGHT_PIN, 255 );
271- #if defined(SEESAW_BACKLIGHT_PIN)
272- seesaw.analogWrite (SEESAW_BACKLIGHT_PIN, 255 );
273- #endif
247+ arcada.setBacklight (255 );
274248
275249 // LOAD CONFIGURATION FILE -----------------------------------------------
276250
@@ -280,13 +254,15 @@ void setup() {
280254 // of the nose booper when doing this...it self-calibrates on startup.
281255 char *filename = " config.eye" ;
282256#if NUM_EYES > 1 // Only available on MONSTER M4SK
257+ /* MEMEFIX
283258 if(!(priorButtonState & 0b001000000000)) {
284259 filename = "config1.eye";
285260 } else if(!(priorButtonState & 0b010000000000)) {
286261 filename = "config2.eye";
287262 } else if(!(priorButtonState & 0b100000000000)) {
288263 filename = "config3.eye";
289264 }
265+ */
290266#endif
291267 loadConfig (filename);
292268
@@ -441,13 +417,7 @@ void setup() {
441417}
442418
443419static inline uint16_t readLightSensor (void ) {
444- #if NUM_EYES > 1
445- if (lightSensorPin >= 100 ) {
446- return seesaw.analogRead (lightSensorPin - 100 );
447- }
448- #else
449- return analogRead (lightSensorPin);
450- #endif
420+ return arcada.readLightSensor ();
451421}
452422
453423// LOOP FUNCTION - CALLED REPEATEDLY UNTIL POWER-OFF -----------------------
@@ -925,14 +895,14 @@ void loop() {
925895#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
926896 if (voiceOn) {
927897 // Read buttons, change pitch
928- uint32_t buttonState = seesaw. digitalReadBulk ( 0b111000000000 ); // Bits CLEAR if currently pressed
929- uint32_t changedState = ~( buttonState ^ priorButtonState) ; // Bits CLEAR if changed from before
930- uint32_t newlyPressed = ~( buttonState | changedState) ; // Bits SET if newly pressed
931- if ( newlyPressed & 0b001000000000 ) { // Seesaw pin 9 (inner)
898+ uint32_t buttonState = arcada. readButtons ();
899+ uint32_t changedState = buttonState ^ priorButtonState; // Bits CLEAR if changed from before
900+ uint32_t newlyPressed = buttonState | changedState; // Bits SET if newly pressed
901+ if ( newlyPressed & ARCADA_BUTTONMASK_UP ) { // Seesaw pin 9 (inner)
932902 currentPitch *= 1.05 ;
933- } else if (newlyPressed & 0b010000000000 ) { // Seesaw pin 10 (middle)
903+ } else if (newlyPressed & ARCADA_BUTTONMASK_A ) { // Seesaw pin 10 (middle)
934904 currentPitch = defaultPitch;
935- } else if (newlyPressed & 0b100000000000 ) { // Seesaw pin 11 (outer)
905+ } else if (newlyPressed & ARCADA_BUTTONMASK_DOWN ) { // Seesaw pin 11 (outer)
936906 currentPitch *= 0.95 ;
937907 }
938908 if (newlyPressed) {
0 commit comments