Skip to content

Commit ba6d535

Browse files
Add rotation to M4_Eyes
1 parent fac20ef commit ba6d535

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

M4_Eyes/M4_Eyes.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ void setup() {
201201

202202
// Initialize DMAs
203203
for(e=0; e<NUM_EYES; e++) {
204-
eye[e].display->setRotation(3);
205204
eye[e].display->fillScreen(0);
206205
eye[e].dma.allocate();
207206
eye[e].dma.setTrigger(eye[e].spi->getDMAC_ID_TX());
@@ -247,6 +246,7 @@ void setup() {
247246
eye[e].sclera.mirror = 0;
248247
eye[e].sclera.spin = 0.0;
249248
eye[e].sclera.iSpin = 0;
249+
eye[e].rotation = 3;
250250

251251
// Uncanny eyes carryover stuff for now, all messy:
252252
eye[e].blink.state = NOBLINK;
@@ -400,7 +400,9 @@ void setup() {
400400
randomSeed(SysTick->VAL + analogRead(A2));
401401
eyeOldX = eyeNewX = eyeOldY = eyeNewY = mapRadius; // Start in center
402402
for(e=0; e<NUM_EYES; e++) { // For each eye...
403-
eye[e].eyeX = eyeOldX;
403+
// Set up screen rotation (MUST be done after config load!)
404+
eye[e].display->setRotation(eye[e].rotation);
405+
eye[e].eyeX = eyeOldX; // Set up initial position
404406
eye[e].eyeY = eyeOldY;
405407
}
406408
lastLightReadTime = micros() + 2000000; // Delay initial light reading

M4_Eyes/file.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static void getFilename(JsonVariant v, char **ptr) {
184184
}
185185

186186
void loadConfig(char *filename) {
187-
File file;
187+
File file;
188+
uint8_t rotation = 3;
188189

189190
if(file = filesys.open(filename, FILE_READ)) {
190191
StaticJsonDocument<2048> doc;
@@ -266,6 +267,9 @@ void loadConfig(char *filename) {
266267
JsonVariant iristv = doc["irisTexture"],
267268
scleratv = doc["scleraTexture"];
268269

270+
rotation = doc["rotate"] | rotation; // Screen rotation (GFX lib)
271+
rotation &= 3;
272+
269273
v = doc["tracking"];
270274
if(v.is<bool>()) tracking = v.as<bool>();
271275
v = doc["squint"];
@@ -361,6 +365,8 @@ void loadConfig(char *filename) {
361365
if(eye[e].sclera.filename) free(eye[e].sclera.filename);
362366
eye[e].sclera.filename = strdup(v);
363367
}
368+
eye[e].rotation = doc[eye[e].name]["rotate"] | rotation;
369+
eye[e].rotation &= 3;
364370
}
365371
#endif
366372
}

M4_Eyes/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ typedef struct {
162162
uint16_t backColor; // 16-bit 565 RGB, big-endian
163163
texture iris; // iris texture map
164164
texture sclera; // sclera texture map
165+
uint8_t rotation; // Screen rotation (GFX lib)
165166

166167
// Stuff carried over from Uncanny Eyes code. It now needs to be
167168
// independent per-eye because we interleave between drawing the

MonsterMaskVoiceChanger/MonsterMaskVoiceChanger.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void fatal(const char *message, uint16_t blinkDelay) {
3030

3131
void setup() {
3232
pinMode(SPEAKER_ENABLE_PIN, OUTPUT);
33-
digitalWrite(SPEAKER_ENABLE_PIN, HIGH); // Speaker OFF
33+
digitalWrite(SPEAKER_ENABLE_PIN, LOW); // Speaker OFF
3434

3535
Serial.begin(115200);
3636
//while(!Serial);

0 commit comments

Comments
 (0)