Add rotation to M4_Eyes

This commit is contained in:
Phillip Burgess 2019-09-17 13:09:38 -07:00
parent fac20effdb
commit ba6d53509a
4 changed files with 13 additions and 4 deletions

View file

@ -201,7 +201,6 @@ void setup() {
// Initialize DMAs // Initialize DMAs
for(e=0; e<NUM_EYES; e++) { for(e=0; e<NUM_EYES; e++) {
eye[e].display->setRotation(3);
eye[e].display->fillScreen(0); eye[e].display->fillScreen(0);
eye[e].dma.allocate(); eye[e].dma.allocate();
eye[e].dma.setTrigger(eye[e].spi->getDMAC_ID_TX()); eye[e].dma.setTrigger(eye[e].spi->getDMAC_ID_TX());
@ -247,6 +246,7 @@ void setup() {
eye[e].sclera.mirror = 0; eye[e].sclera.mirror = 0;
eye[e].sclera.spin = 0.0; eye[e].sclera.spin = 0.0;
eye[e].sclera.iSpin = 0; eye[e].sclera.iSpin = 0;
eye[e].rotation = 3;
// Uncanny eyes carryover stuff for now, all messy: // Uncanny eyes carryover stuff for now, all messy:
eye[e].blink.state = NOBLINK; eye[e].blink.state = NOBLINK;
@ -400,7 +400,9 @@ void setup() {
randomSeed(SysTick->VAL + analogRead(A2)); randomSeed(SysTick->VAL + analogRead(A2));
eyeOldX = eyeNewX = eyeOldY = eyeNewY = mapRadius; // Start in center eyeOldX = eyeNewX = eyeOldY = eyeNewY = mapRadius; // Start in center
for(e=0; e<NUM_EYES; e++) { // For each eye... for(e=0; e<NUM_EYES; e++) { // For each eye...
eye[e].eyeX = eyeOldX; // Set up screen rotation (MUST be done after config load!)
eye[e].display->setRotation(eye[e].rotation);
eye[e].eyeX = eyeOldX; // Set up initial position
eye[e].eyeY = eyeOldY; eye[e].eyeY = eyeOldY;
} }
lastLightReadTime = micros() + 2000000; // Delay initial light reading lastLightReadTime = micros() + 2000000; // Delay initial light reading

View file

@ -185,6 +185,7 @@ static void getFilename(JsonVariant v, char **ptr) {
void loadConfig(char *filename) { void loadConfig(char *filename) {
File file; File file;
uint8_t rotation = 3;
if(file = filesys.open(filename, FILE_READ)) { if(file = filesys.open(filename, FILE_READ)) {
StaticJsonDocument<2048> doc; StaticJsonDocument<2048> doc;
@ -266,6 +267,9 @@ void loadConfig(char *filename) {
JsonVariant iristv = doc["irisTexture"], JsonVariant iristv = doc["irisTexture"],
scleratv = doc["scleraTexture"]; scleratv = doc["scleraTexture"];
rotation = doc["rotate"] | rotation; // Screen rotation (GFX lib)
rotation &= 3;
v = doc["tracking"]; v = doc["tracking"];
if(v.is<bool>()) tracking = v.as<bool>(); if(v.is<bool>()) tracking = v.as<bool>();
v = doc["squint"]; v = doc["squint"];
@ -361,6 +365,8 @@ void loadConfig(char *filename) {
if(eye[e].sclera.filename) free(eye[e].sclera.filename); if(eye[e].sclera.filename) free(eye[e].sclera.filename);
eye[e].sclera.filename = strdup(v); eye[e].sclera.filename = strdup(v);
} }
eye[e].rotation = doc[eye[e].name]["rotate"] | rotation;
eye[e].rotation &= 3;
} }
#endif #endif
} }

View file

@ -162,6 +162,7 @@ typedef struct {
uint16_t backColor; // 16-bit 565 RGB, big-endian uint16_t backColor; // 16-bit 565 RGB, big-endian
texture iris; // iris texture map texture iris; // iris texture map
texture sclera; // sclera texture map texture sclera; // sclera texture map
uint8_t rotation; // Screen rotation (GFX lib)
// Stuff carried over from Uncanny Eyes code. It now needs to be // Stuff carried over from Uncanny Eyes code. It now needs to be
// independent per-eye because we interleave between drawing the // independent per-eye because we interleave between drawing the

View file

@ -30,7 +30,7 @@ static void fatal(const char *message, uint16_t blinkDelay) {
void setup() { void setup() {
pinMode(SPEAKER_ENABLE_PIN, OUTPUT); pinMode(SPEAKER_ENABLE_PIN, OUTPUT);
digitalWrite(SPEAKER_ENABLE_PIN, HIGH); // Speaker OFF digitalWrite(SPEAKER_ENABLE_PIN, LOW); // Speaker OFF
Serial.begin(115200); Serial.begin(115200);
//while(!Serial); //while(!Serial);