Skip to content

Commit 78cee83

Browse files
author
Adafruit Adabot
committed
backtrack
1 parent 7a143f2 commit 78cee83

2 files changed

Lines changed: 16 additions & 39 deletions

File tree

M4_Eyes/M4_Eyes.ino

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,16 @@ void setup() {
145145

146146

147147
Serial.begin(115200);
148-
//while(!Serial) delay(10);
148+
while(!Serial) delay(10);
149149

150150
Serial.printf("Available RAM at start: %d\n", availableRAM());
151151
Serial.printf("Available flash at start: %d\n", availableNVM());
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);
155+
arcada.setBacklight(0);
157156
#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);
157+
priorButtonState = 0b111000000000;
172158
#endif
173159

174160
yield();
@@ -186,27 +172,20 @@ void setup() {
186172
yield();
187173
if (arcada.drawBMP("/splash.bmp", 0, 0, (eye[0].display)) == IMAGE_SUCCESS) {
188174
Serial.println("Splashing");
189-
#if NUM_EYES > 1
190-
// other eye
191-
yield();
192-
arcada.drawBMP("/splash.bmp", 0, 0, (eye[1].display));
193-
#endif
175+
if (NUM_EYES > 1) { // other eye
176+
yield();
177+
arcada.drawBMP("/splash.bmp", 0, 0, (eye[1].display));
178+
}
194179
// backlight on for a bit
195-
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);
200-
delay(10);
180+
for (int bl=0; bl<=250; bl+=20) {
181+
arcada.setBacklight(bl);
182+
delay(20);
201183
}
202184
delay(2000);
203185
// backlight back off
204-
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);
209-
delay(10);
186+
for (int bl=250; bl>=0; bl-=20) {
187+
arcada.setBacklight(bl);
188+
delay(20);
210189
}
211190
}
212191

@@ -269,7 +248,7 @@ void setup() {
269248

270249
analogWrite(BACKLIGHT_PIN, 255);
271250
#if defined(SEESAW_BACKLIGHT_PIN)
272-
seesaw.analogWrite(SEESAW_BACKLIGHT_PIN, 255);
251+
arcada.ss.analogWrite(SEESAW_BACKLIGHT_PIN, 255);
273252
#endif
274253

275254
// LOAD CONFIGURATION FILE -----------------------------------------------
@@ -443,7 +422,7 @@ void setup() {
443422
static inline uint16_t readLightSensor(void) {
444423
#if NUM_EYES > 1
445424
if(lightSensorPin >= 100) {
446-
return seesaw.analogRead(lightSensorPin - 100);
425+
return arcada.ss.analogRead(lightSensorPin - 100);
447426
}
448427
#else
449428
return analogRead(lightSensorPin);
@@ -925,7 +904,7 @@ void loop() {
925904
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
926905
if(voiceOn) {
927906
// Read buttons, change pitch
928-
uint32_t buttonState = seesaw.digitalReadBulk(0b111000000000); // Bits CLEAR if currently pressed
907+
uint32_t buttonState = arcada.ss.digitalReadBulk(0b111000000000); // Bits CLEAR if currently pressed
929908
uint32_t changedState = ~(buttonState ^ priorButtonState); // Bits CLEAR if changed from before
930909
uint32_t newlyPressed = ~(buttonState | changedState); // Bits SET if newly pressed
931910
if( newlyPressed & 0b001000000000) { // Seesaw pin 9 (inner)

M4_Eyes/globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
1919
#define NUM_EYES 2
20-
#include <Adafruit_seesaw.h>
21-
GLOBAL_VAR Adafruit_seesaw seesaw; // Controls some left-eye signals
2220
#define SEESAW_TFT_RESET_PIN 8 // Left eye TFT reset
2321
#define SEESAW_BACKLIGHT_PIN 5 // Left eye TFT backlight
2422
#define BACKLIGHT_PIN 21 // Right eye TFT backlight

0 commit comments

Comments
 (0)