Giter VIP home page Giter VIP logo

m5stack-avatar's Introduction

M5Stack-Avatar

Powered By PlatformIO Build Status

M5Stack-Avatar

Video: https://www.youtube.com/watch?v=C1Hj9kfY5qc

日本語

Features

  • 😐 Draw avatar face
  • 😄 Expression(Happy, Angry, Sad etc.)
  • 😺 Customize face
  • 💋 Lip sync
  • 🎨 Color Palette
  • 🔃 Move, Zoom and Rotation
  • 2️⃣ Compatible with M5Stack Core2

Installation

Prerequisites

Using Arduino IDE

  • On Arduino IDE, Select "Sketch > Include Library > Manage Libraries..."
  • Search "m5stack avatar"
  • Select "M5Stack_Avatar" from the results then click "Install"
  • The library gets installed

Using Platform IO

  • Initialize your Platform IO project
mkdir my-avatar
cd my-avatar
platformio init -d . -b m5stack-core-esp32
  • Install the library and its dependency
platformio lib install M5Unified
platformio lib install M5Stack-Avatar
  • The library gets downloaded from repository to .piolibdeps directory

Usage

#include <M5Unified.h>
#include <Avatar.h>

using namespace m5avatar;

Avatar avatar;

void setup()
{
  M5.begin();
  avatar.init(); // start drawing
}

void loop()
{
  // avatar's face updates in another thread
  // so no need to loop-by-loop rendering
}

Using LipSync

  • setup AquesTalk-ESP32 (http://blog-yama.a-quest.com/?eid=970195).

    • (For parsing Kainji statement) Copy the dictionary file from above link to the microSD card.
    • You don't need to copy AquesTalkTTS files. They are included in this library.
  • Write below to open avatar mouth according to the audio output.

#include <AquesTalkTTS.h>
#include <M5Unified.h>
#include <Avatar.h>
#include <tasks/LipSync.h>

using namespace m5avatar;

// AquesTalk License Key
// NULL or wrong value is just ignored
const char* AQUESTALK_KEY = "XXXX-XXXX-XXXX-XXXX";
Avatar avatar;

void setup() {
  int iret;
  M5.begin();
  // For Kanji-to-speech mode (requires dictionary file saved on microSD)
  // iret = TTS.createK(AQUESTALK_KEY);
  iret = TTS.create(AQUESTALK_KEY);
  avatar.init();
  avatar.addTask(lipSync, "lipSync");
}

void loop() {
  M5.update();
  if (M5.BtnA.wasPressed()) {
    // For Kanji-to-speech mode
    // TTS.play("こんにちは。", 80);
    TTS.play("konnichiwa", 80);
  }
}

Further usage

see examples directory.

Migration from 0.7.x to 0.8.x

M5Stack-Avatar now depends on M5Unified, the integrated library for all devices of M5Stack series. Since 0.8.0, Sketches with avatar should include M5Unified.h instead of M5Stack.h or M5Core2.h

m5stack-avatar's People

Contributors

botamochi6277 avatar harajune avatar hollyhockberry avatar mcbeeringi avatar meganetaaan avatar mongonta0716 avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

m5stack-avatar's Issues

Make balloon better

  • auto resize text to fit balloon
  • large balloon for large text
  • use color palette
  • make border

Handle auto-updating tasks

Another issue caused of #7.
Need an API for handling auto-avatar-updating tasks such as blink, saccade and breath.

Bitmap parts

not a bunch of drawing function like fillRect or drawTriangle but just a bitmap pattern for face parts would be lovely.

change avatar size and offset

This function is necessary especially for coexisting with sprite rendering.Current implementation of draw() with sprite updates the whole area of face (= whole display for now).But users should want to other elements as well.

Avatar's loop functions never vTaskDelay()

In Avatar.cpp avatar's loop functions use delay() instead of vTaskDelay(). This means these tasks never release their resources untill interruption by other tasks that have higher priority.
It should use vTaskDelay() and follow the FreeRTOS way.

Select voice engine

Not only AquesTalkTTS but also Playing buzzer or audio file should be used as avatar voice

The compiler doesn't recognize AquesTalkTTS sources

Describe the bug
The compiler doesn't recognize AquesTalkTTS sources in this library then fails to compile

To Reproduce
Steps to reproduce the behavior:

  1. setup aquestalk_esp32 library except copying AquesTalkTTS sources
  2. compile

Expected behavior
You don't need to copy AquesTalkTTS files. They are included in this library.

Logs
Compile error appears.

Environment (please complete the following information):

  • OS: Linuxsources
  • IDE: VSCode with PlatformIO
  • Versions
  • This library(M5Stack-Avatar)
  • M5Stack

Install guide

  • Install as Arduino IDE library
  • Install from PlatformIO

DrawLoop and StateUpdate on background

We should contain drawLoop and stateUpdate such as succade and breath in the library.
For now we write them on our sketch like below. But It's slight annoying.

void saccade(void *args)
{
  for(;;)
  {
    float vertical = (float)rand()/(float)(RAND_MAX / 2) - 1;
    float horizontal = (float)rand()/(float)(RAND_MAX / 2) - 1;
    avator->setGaze(vertical, horizontal);
    delay(500 + 100 * random(20));
  }
}

void setup()
{
  xTaskCreatePinnedToCore(
                    saccade,     /* Function to implement the task */
                    "saccade",   /* Name of the task */
                    4096,      /* Stack size in words */
                    NULL,      /* Task input parameter */
                    3,         /* Priority of the task */
                    NULL,      /* Task handle. */
                    1);        /* Core where the task should run */
}

Destroy all the warnings

The main cause of #34 is that I ignored all the compile warnings without -Werror flag.
If this flag enabled, thus tihs library cannot be compiled.

So I've decided to destroy all the warnings using -Werror=all.

Avatar library don't work with WiFi On

Describe the bug
Code crash in setup() when Avatar library and WiFi is used together. There is no compilation error.

To Reproduce
Compile the following source code, in platform IO, upload to M5Stack-fire. View the serial monitor.

#include <Arduino.h>
#include <M5Stack.h>
#include <WiFi.h>
#include <Avatar.h>

using namespace m5avatar;

const char* ssid = "ssid";
const char* password = "passwd";
Avatar avatar;

void setup_wifi(){
  delay(10);
  WiFi.begin(ssid, password);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  while(WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void setup() {
  M5.begin();
  Serial.begin(115200);
  Serial.println("Init wifi");
  setup_wifi();
  Serial.println("Init avatar");
  avatar.init();
  Serial.println("Done");
}

void loop() {
  // put your main code here, to run repeatedly:
}

Platformio config is here

[env:m5stack-fire]
platform = espressif32
board = m5stack-fire
framework = arduino
monitor_speed = 115200

lib_deps = meganetaaan/M5Stack-Avatar@^0.7.3

Expected behavior
Code should work run on m5stack-fire. It should not cause the device to rebook.

Logs
If any compile error occurs, add a full compile log.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows
  • IDE: VSCode with PlatformIO plugin
  • Versions
  • This library(M5Stack-Avatar): M5Stack-Avatar@^0.7.3
  • M5Stack: 0.3.4

Additional context

This is run on M5Stack-fire

Output from serial monitor when running the code

Init wifi

Connecting to ssid
.....
WiFi connected
IP address:
192.168.0.149
Init avatar
Guru Meditation Error: Core  0 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (drawLoop)

ELF file SHA256: 0000000000000000

Backtrace: 0x4008bc54:0x3ffcc910 0x4008d212:0x3ffcc920 0x4008d391:0x3ffcc9f0 0x4008d675:0x3ffcca10 0x40089422:0x3ffcca30 0x4008d1d1:0x3ffccaf0 0x4008d44d:0x3ffccb10 0x4008918d:0x3ffccb30 0x400892b9:0x3ffccb60 0x400f5bef:0x3ffccb80 0x400f1efd:0x3ffcce40 0x400f1e98:0x3ffcce90 0x4008f475:0x3ffccec0 0x40091483:0x3ffccef0 0x40091abd:0x3ffccf10 0x40081f59:0x3ffccf30 0x40082130:0x3ffccf50 0x400815d7:0x3ffccf70 0x40142979:0x3ffccf90 0x401429fe:0x3ffccfb0 0x400d5eec:0x3ffccfd0 0x400d5243:0x3ffcd010 0x400d526f:0x3ffcd060 0x4008e452:0x3ffcd080

Rebooting...
```

Move avatar?

It seems simple to resize the avatar, but is there a way to move it on the display? If not, could this be addressed? Thanks!

Arduino-esp32 2.0.0 or later will repeatedly reboot.

Describe the bug
After the face appears, it will reboot.

To Reproduce
If you build with Arduino-esp32 2.0.0 or later, Avatar repeatedly reboots, and if you change the version back to 1.0.6 in the ArduinoIDE board manager, it works fine.

I have confirmed the phenomenon with M5Core2.

Animation

First we need an animation library like Tween...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.