Monster Mask Interface
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Dr_Bruce
- Posts: 4
- Joined: Sun Jul 25, 2021 1:20 pm
Monster Mask Interface
I'm interested in having someone code an interface to the Monster Mask so that I could send simple commands from a PC over the USB to the Mask to make the eyes look right, look left, look up, etc... I'm thinking something as simple as Python on the PC sending a 1 to look right, a 2 to look left, etc... I'm willing to discuss this with someone with the coding experience to do this - and I would be willing to discuss paying for your time....
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Monster Mask Interface
Here's at least a start. Send u, d, l, r, to look up, down, left, right. Send c to recenter the gaze, and f to return it to random movement.
You can test it (aka play around with it) from the serial monitor in Arduino. But anything that will send characters to the connected serial port (i.e. COM port or tty device) will do. It's easy to extend my changing the switch cases.
See https://learn.adafruit.com/adafruit-mon ... ource-code.
Save this as a user_xx.cpp file in the M4_Eyes directory. I called it user_serial_ command.cpp. Remember to change #if 1 at the start of user.cpp to #if 0.
Dave
You can test it (aka play around with it) from the serial monitor in Arduino. But anything that will send characters to the connected serial port (i.e. COM port or tty device) will do. It's easy to extend my changing the switch cases.
See https://learn.adafruit.com/adafruit-mon ... ource-code.
Save this as a user_xx.cpp file in the M4_Eyes directory. I called it user_serial_ command.cpp. Remember to change #if 1 at the start of user.cpp to #if 0.
Code: Select all
#if 1 // Change to 1 to enable this code (must enable ONE user*.cpp only!)
// CORRESPONDING LINE IN HeatSensor.cpp MUST ALSO BE ENABLED!
#include "globals.h"
float x_look = 0.0;
float y_look = 0.0;
// Called once near the end of the setup() function. If your code requires
// a lot of time to initialize, make periodic calls to yield() to keep the
// USB mass storage filesystem alive.
void user_setup(void) {
showSplashScreen = false;
moveEyesRandomly = true;
}
// Called periodically during eye animation. This is invoked in the
// interval before starting drawing on the last eye (left eye on MONSTER
// M4SK, sole eye on HalloWing M0) so it won't exacerbate visible tearing
// in eye rendering. This is also SPI "quiet time" on the MONSTER M4SK so
// it's OK to do I2C or other communication across the bridge.
void user_loop(void) {
// Set values for the new X and Y.
// X: 1 = right, -1 = left
// Y: -1 = up, 1 = down
if (Serial.available() > 0) {
char ch = Serial.read();
switch (ch) {
case 'u':
y_look = -1.0;
moveEyesRandomly = false;
break;
case 'd':
y_look = 1.0;
moveEyesRandomly = false;
break;
case 'l':
x_look = -1.0;
moveEyesRandomly = false;
break;
case 'r':
x_look = 1.0;
moveEyesRandomly = false;
break;
case 'c':
x_look = 0.0;
y_look = 0.0;
moveEyesRandomly = false;
break;
case 'f':
moveEyesRandomly = true;
}
}
if (!moveEyesRandomly) {
eyeTargetX = x_look;
eyeTargetY = y_look;
}
}
#endif // 0
- Dr_Bruce
- Posts: 4
- Joined: Sun Jul 25, 2021 1:20 pm
Re: Monster Mask Interface
Thank you so much for this! I've ordered another Monster Mask (arriving Friday) to try this out on - I'm always afraid to try completely new things on a device that I already have (mostly) working in case I do something wrong and brick it!
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Monster Mask Interface
You are most welcome. I understand ... as a rule I get 2 of things "just in case".
Dave
Dave
- Dr_Bruce
- Posts: 4
- Joined: Sun Jul 25, 2021 1:20 pm
Re: Monster Mask Interface
Okay. I'm trying to build the M4 Mask but I'm getting this compilation error:
Arduino: 1.8.5 (Windows 10), Board: "Adafruit MONSTER M4SK (SAMD51), Enabled, 180 MHz (overclock), Faster (-O3), 50 MHz (standard), TinyUSB, Off"
Build options changed, rebuilding all
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp: In function 'int serial1_printf(const char*, ...)':
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp:65:3: error: 'Serial1' was not declared in this scope; did you mean 'Serial'?
65 | Serial1.write(buf);
| ^~~~~~~
| Serial
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp: In function 'void TinyUSB_Port_InitDevice(uint8_t)':
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp:130:3: error: 'Serial1' was not declared in this scope; did you mean 'Serial'?
130 | Serial1.begin(115200);
| ^~~~~~~
| Serial
exit status 1
Error compiling for board Adafruit MONSTER M4SK (SAMD51).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Any ideas?
Arduino: 1.8.5 (Windows 10), Board: "Adafruit MONSTER M4SK (SAMD51), Enabled, 180 MHz (overclock), Faster (-O3), 50 MHz (standard), TinyUSB, Off"
Build options changed, rebuilding all
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp: In function 'int serial1_printf(const char*, ...)':
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp:65:3: error: 'Serial1' was not declared in this scope; did you mean 'Serial'?
65 | Serial1.write(buf);
| ^~~~~~~
| Serial
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp: In function 'void TinyUSB_Port_InitDevice(uint8_t)':
C:\Users\bjwei\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.3\libraries\Adafruit_TinyUSB_Arduino\src\arduino\ports\samd\Adafruit_TinyUSB_samd.cpp:130:3: error: 'Serial1' was not declared in this scope; did you mean 'Serial'?
130 | Serial1.begin(115200);
| ^~~~~~~
| Serial
exit status 1
Error compiling for board Adafruit MONSTER M4SK (SAMD51).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Any ideas?
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Monster Mask Interface
Did you install both the Arduino AND Adafruit SAMD board support packages?
Dave
Dave
- Dr_Bruce
- Posts: 4
- Joined: Sun Jul 25, 2021 1:20 pm
Re: Monster Mask Interface
Wow! I somehow made the mask stop working - but I followed all your online instructions and fixed it... great instructions by the way... Then I reinstalled the TinyURL library - and then it compiled. Finally I uploaded everything and it's all working now! So this is great and thank you so much for your help!
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Monster Mask Interface
Awesome! Have fun with it.
Dave
Dave
Please be positive and constructive with your questions and comments.