Skip to content

Commit 87015a9

Browse files
author
Adafruit Adabot
committed
remove more seesaw
1 parent 7a143f2 commit 87015a9

2 files changed

Lines changed: 18 additions & 59 deletions

File tree

M4_Eyes/M4_Eyes.ino

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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

443419
static 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) {

M4_Eyes/globals.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
//34567890123456789012345678901234567890123456789012345678901234567890123456
22

3-
#include <Adafruit_GFX.h> // Core graphics for Adafruit displays
4-
#include <Adafruit_ST7789.h> // TFT-specific display library
5-
#include <Adafruit_ZeroDMA.h> // SAMD-specific DMA library
6-
#include <Adafruit_ImageReader.h> // ImageReturnCode type
73
#include "Adafruit_Arcada.h"
84
#include "DMAbuddy.h" // DMA-bug-workaround class
95

@@ -17,16 +13,9 @@
1713

1814
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
1915
#define NUM_EYES 2
20-
#include <Adafruit_seesaw.h>
21-
GLOBAL_VAR Adafruit_seesaw seesaw; // Controls some left-eye signals
22-
#define SEESAW_TFT_RESET_PIN 8 // Left eye TFT reset
23-
#define SEESAW_BACKLIGHT_PIN 5 // Left eye TFT backlight
24-
#define BACKLIGHT_PIN 21 // Right eye TFT backlight
25-
#define LIGHTSENSOR_PIN 2
2616
// Light sensor is not active by default. Use "lightSensor : 102" in config
2717
#else
2818
#define NUM_EYES 1
29-
#define BACKLIGHT_PIN 47
3019
#endif
3120

3221
// GLOBAL VARIABLES --------------------------------------------------------

0 commit comments

Comments
 (0)