Skip to content

Commit e0add1c

Browse files
author
Adafruit Adabot
committed
more arcadifit=
1 parent acd5c65 commit e0add1c

2 files changed

Lines changed: 10 additions & 24 deletions

File tree

M4_Eyes/M4_Eyes.ino

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void setup() {
398398
voiceGain(gain);
399399
currentPitch = voicePitch(currentPitch);
400400
if(waveform) voiceMod(modulate, waveform);
401-
digitalWrite(20, HIGH); // Speaker on
401+
arcada.enableSpeaker(true);
402402
}
403403
}
404404
#endif
@@ -417,15 +417,7 @@ void setup() {
417417
lastLightReadTime = micros() + 2000000; // Delay initial light reading
418418
}
419419

420-
static inline uint16_t readLightSensor(void) {
421-
#if NUM_EYES > 1
422-
if(lightSensorPin >= 100) {
423-
return arcada.ss.analogRead(lightSensorPin - 100);
424-
}
425-
#else
426-
return analogRead(lightSensorPin);
427-
#endif
428-
}
420+
429421

430422
// LOOP FUNCTION - CALLED REPEATEDLY UNTIL POWER-OFF -----------------------
431423

@@ -860,7 +852,7 @@ void loop() {
860852
// pupils will react even if the opposite eye is stimulated.
861853
// Meaning we can get away with using a single light sensor for
862854
// both eyes. This comment has nothing to do with the code.
863-
uint16_t rawReading = readLightSensor();
855+
uint16_t rawReading = arcada.readLightSensor();
864856
if(rawReading <= 1023) {
865857
if(rawReading < lightSensorMin) rawReading = lightSensorMin; // Clamp light sensor range
866858
else if(rawReading > lightSensorMax) rawReading = lightSensorMax; // to within usable range
@@ -902,10 +894,10 @@ void loop() {
902894
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
903895
if(voiceOn) {
904896
// Read buttons, change pitch
905-
uint32_t buttonState = arcada.ss.digitalReadBulk(0b111000000000); // Bits CLEAR if currently pressed
906-
uint32_t changedState = ~(buttonState ^ priorButtonState); // Bits CLEAR if changed from before
907-
uint32_t newlyPressed = ~(buttonState | changedState); // Bits SET if newly pressed
908-
if( newlyPressed & 0b001000000000) { // Seesaw pin 9 (inner)
897+
uint32_t buttonState = arcada.readButtons(); // Bits SET if currently pressed
898+
uint32_t changedState = ~(buttonState ^ priorButtonState); // Bits SET if changed from before
899+
uint32_t newlyPressed = buttonState | changedState; // Bits SET if newly pressed
900+
if( newlyPressed & ARCADA_BUTTONMASK_UP) { // Seesaw pin 9 (inner)
909901
currentPitch *= 1.05;
910902
} else if(newlyPressed & ARCADA_BUTTONMASK_A) { // Seesaw pin 10 (middle)
911903
currentPitch = defaultPitch;

M4_Eyes/globals.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313

1414
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
1515
#define NUM_EYES 2
16-
#define SEESAW_TFT_RESET_PIN 8 // Left eye TFT reset
17-
#define SEESAW_BACKLIGHT_PIN 5 // Left eye TFT backlight
18-
#define BACKLIGHT_PIN 21 // Right eye TFT backlight
19-
#define LIGHTSENSOR_PIN 2
2016
// Light sensor is not active by default. Use "lightSensor : 102" in config
2117
#else
2218
#define NUM_EYES 1
@@ -181,12 +177,10 @@ typedef struct {
181177
eyeStruct eye[NUM_EYES] = {
182178
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
183179
// name spi cs dc rst wink
184-
{ "right", &SPI , 5, 6, 4, -1 },
185-
{ "left" , &SPI1, 9, 10, -1, -1 } };
186-
#elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
187-
{ NULL , &SPI1, 44, 45, 46, -1 } };
180+
{ "right", &ARCADA_TFT_SPI , ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST, -1 },
181+
{ "left" , &ARCADA_LEFTTFT_SPI, ARCADA_LEFTTFT_CS, ARCADA_LEFTTFT_DC, ARCADA_LEFTTFT_RST, -1 } };
188182
#else
189-
#error "This project supports Adafruit MONSTER M4SK and HALLOWING M4 only"
183+
{ NULL , &ARCADA_TFT_SPI, ARCADA_TFT_CS, ARCADA_TFT_DC, ARCADA_TFT_RST, -1 } };
190184
#endif
191185
#else
192186
extern eyeStruct eye[];

0 commit comments

Comments
 (0)