Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Rop
    3. Posts
    • Continue chat with Rop
    • Start new chat with Rop
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Rop

    • ESP-IDF and ESP-ADF on M5Core2

      Hi all,

      I've created some components that might be useful for those that like programming M5Core2 using Espressif's Integrated Development Framework (ESP-IDF). It's a bit more complex to wrap your head around than Arduino, but then compiling is blazingly fast and you end up with more powerful tools at your disposal. And with the components I built at least some of the pain out of getting something working on the M5Core2.

      • m5core2_esp-idf_demo is a demo program that uses the lvgl display/touch interface library and also showcases both my i2c_manager thread-safe library as well as the m5core2_axp192 library to set up and control the power management in the M5Core2.

      • m5core2_adf is a component that will let you use the M5Core2 as an audio board for Espressif's Audio Development Framework (ESP-ADF). Anything from playing and recording sound to streaming MP3s and even voice recognition.

      posted in PROJECTS
      Rop
    • RE: Light / Deep sleep example

      Hi Felix!

      Strange... With me that code, using Arduino IDE, just says "Going to light sleep for 50 seconds." and then it never wakes up again. I measure 19.7 mA at the USB input when it does that.

      Have to powercycle and then start uploading code before it goes to sleep again to get out of it...

      posted in Core 2
      Rop
    • RE: Light / Deep sleep example

      Hi @felmue ,

      Question: do you know how many mA the system uses in it's most power-saving sleep state where it is still able to wake up on a timer as well as when the touch screen is pressed? Is there code somewhere to accomplish this?

      posted in Core 2
      Rop
    • RE: Windowing environment

      (Everything works with the stock M5Core2 library, or the current master branch. Just don't have M5.update() in the loop.)

      posted in Core 2
      Rop
    • RE: Windowing environment

      If yes..... :

      Check out https://github.com/M5ez/Core2ez

      recursively nested display windows, widgets, the works...

      Soon input boxes, scrolling subwindows, modal dialogs, etc

      A few of the demos are ported, tons of work to be done, but this is a good first alpha.

      happy playing...

      posted in Core 2
      Rop
    • Windowing environment

      Hey...

      Wouldn't it be cool to have something like Qt for the Core2? A real windowing environment with widgets, etc etc?

      posted in Core 2
      Rop
    • RE: Simple Touch Keyboard

      Tried my hand at a keyboard too... (Can't type on non-qwerty...)

      Found that the horizontal precision is actually nice on this touch sensor, it's the vertical registration where I go wrong the most. So I made a keyboard with only three rows of keys, and I can actually type on it. Trick for me is to briefly but consciously look at a key before hitting it: as soon as I start relying on muscle memory my error rate goes way up. Also find that if correcting mistakes is easy enough and doesn't lead to additional mistakes, it's OK to have some misses. Try the experimental branch on my repo, the Touch / Keyboard example for a taste.

      The help screen (which now just says "HELP"), will eventually explain that space is swipe right, backspace is swipe left and to get upper case, just drag a letter upwards. If you move across the typed text you move the caret unless text is wider than window, then you (smoothly..) drag the text. In that case drag down to bottom key row and then sideways to move caret. You can grab the text anywhere above the keys, even in the help/prompt bar.

      Note that I used sprites both for the text entry field and also (briefly) for the keyboard change so that I prevent flicker. Also, there's now M5.Buttons.pushState() and M5.Buttons.popState() to save and restore buttons, gestures and eventhandlers so that one can switch context (such as into and out of keyboard mode) without setting up one's entire environment again.

      Lots of emerging thoughts on how to structurally build out from here, but also just happily playing around building cool stuff and seeing how I would most like things to work for people to program with ease.

      posted in Core 2
      Rop
    • RE: Big Font

      It's just a web frontend to the adafruit font converter thing. Might have a look once I'm done with a bunch of other Core2-related goodness. Feel free figure out WTF...

      posted in Core 2
      Rop
    • RE: I can't access forum.m5stack.com from my location

      The forum software is funky somehow, sometimes I get timeouts as well here in Berlin. And the javascript hangs on to messages when you've left the page. Some of it is not very intuitive somehow...

      Oh well...

      posted in General
      Rop
    • RE: Big Font

      That font is "Run Length Encoded", which I think is not supported by the display library. Maybe try my font conversion tool to make your own font files.

      posted in Core 2
      Rop
    • RE: M5Sound 😎

      @vkichline Yes I have been making a few changes, just what I needed for M5Sound. Which did include pianoMode, which by necessity changes a bit of a voodoo state-machine. My examples all still work I think, no?

      posted in Core 2
      Rop
    • RE: M5Sound 😎

      Just checked in the new improvements. There is now a polyphonic piano demo. Only two notes can be sustained – if you touch at different screen heights – because of the touch-sensor limitation, but keys that were hit before keep sounding for a bit. Shows M5Sound has no problem with 14 concurrent Synth instances.

      To make this satisfying, I needed to be able to move my finger from key to key (glissando), which M5Button didn't let me do. Enter M5.Buttons.pianoMode = true. Now you can slip off one button and onto the next. The price to pay is that gesture recognition is switched off in pianoMode.

      (The DTMF dialer is also cooler in pianoMode, so changed that too.)

      Also there's now 1000_hzand C_major examples, just so that not all examples are somewhat advanced bits of code. But Piano, like the DTMF_dialer, is still pretty small and quite readable for a stylish polyphonic piano:

      /*
      
      Polyphonic synthesizer. Lingering notes will continue to sound as new notes
      are played. If you place one finger high on the screen and another low, you
      can even play two notes at the same time. As you can see you can have many
      synths going at the same time.
      
      */
      
      #include <M5Core2.h>
      
      #define WKW         40
      #define WKH        240
      #define BKW         30
      #define BKH        160
      #define WHITE_KEY  {WHITE, NODRAW, BLACK}
      #define BLACK_KEY  {BLACK, NODRAW, NODRAW}
      #define NUM_KEYS    14
      
      float notes[NUM_KEYS] = { NOTE_F4 , NOTE_G4 , NOTE_A4 , NOTE_B4 , NOTE_C5,
                                NOTE_D5 , NOTE_E5 , NOTE_F5 , NOTE_Gb4, NOTE_Ab4,
                                NOTE_Bb4, NOTE_Db5, NOTE_Eb5, NOTE_Gb5 };
      
      // (waveform, freq, attack, decay, sustain, release)
      Synth synth[NUM_KEYS] = Synth(TRIANGLE, 0, 50, 300, 0.7, 1000);
      
      Button f_(   0, 0, WKW, WKH, false, "f" , WHITE_KEY);
      Button g_(  40, 0, WKW, WKH, false, "g" , WHITE_KEY);
      Button A_(  80, 0, WKW, WKH, false, "A" , WHITE_KEY);
      Button B_( 120, 0, WKW, WKH, false, "B" , WHITE_KEY);
      Button C_( 160, 0, WKW, WKH, false, "C" , WHITE_KEY);
      Button D_( 200, 0, WKW, WKH, false, "D" , WHITE_KEY);
      Button E_( 240, 0, WKW, WKH, false, "E" , WHITE_KEY);
      Button F_( 280, 0, WKW, WKH, false, "F" , WHITE_KEY);
      Button gb(  25, 0, BKW, BKH, false, "gb", BLACK_KEY);
      Button Ab(  65, 0, BKW, BKH, false, "Ab", BLACK_KEY);
      Button Bb( 105, 0, BKW, BKH, false, "Bb", BLACK_KEY);
      Button Db( 185, 0, BKW, BKH, false, "Db", BLACK_KEY);
      Button Eb( 225, 0, BKW, BKH, false, "Eb", BLACK_KEY);
      Button Gb( 305, 0,  15, BKH, false, "Gb", BLACK_KEY);
      
      void setup() {
        M5.begin();
        M5.Buttons.draw();
      
        // Prettier with top of keys as straight line
        M5.Lcd.fillRect(0, 0, 320, 5, BLACK);
      
        // Trick to make sure buttons do not draw over eachother anymore
        M5.Buttons.drawFn = nullptr;
      
        // So that you can swipe from one button to another
        M5.Buttons.pianoMode = true;
      
        // Set up syths with their notes
        for (uint8_t n = 0; n < 14; n++) {
          synth[n].freq = notes[n];
        }
      
        M5.Buttons.addHandler(pressKey  , E_TOUCH);
        M5.Buttons.addHandler(releaseKey, E_RELEASE);
      }
      
      void loop() {
        M5.update();
      }
      
      void pressKey(Event& e) {
        // instanceIndex() -4 because of background, BtnA, BtnB and BtnC.
        uint8_t key = e.button->instanceIndex() - 4;
        synth[key].start();
      }
      
      
      void releaseKey(Event& e) {
        uint8_t key = e.button->instanceIndex() - 4;
        synth[key].stop();
      }
      
      posted in Core 2
      Rop
    • RE: M5Sound 😎

      @vkichline Made checkRotation more generic:

      bool checkRotation(uint16_t msec) {
        if (millis() - rotationLastChecked < msec) return false;
        rotationLastChecked = millis();
        const float threshold = 0.85;
        float ax, ay, az;
        M5.IMU.getAccelData(&ax, &ay, &az);
        uint8_t newRotation;
        if      (ay >  threshold) newRotation = 1;
        else if (ay < -threshold) newRotation = 3;
        else if (ax >  threshold) newRotation = 2;
        else if (ax < -threshold) newRotation = 0;
        else return false;
        if (M5.Lcd.rotation == newRotation) return false;
        columns = newRotation % 2 ? 4 : 3;
        M5.Lcd.clearDisplay();
        M5.Lcd.setRotation(newRotation);
        return true;
      }
      

      All it needs is a global uint32_t rotationLastChecked and for you to have ran M5.IMU.Init() (which seems to set power things on the MPU, so there's probably a reason it's not in M5.begin(), haven't read the datasheet.)

      checkRotation returns a bool and takes the number of milliseconds between checks. It returns true if it has already rotated and cleared the display for you and needs you to set things up again. So my loop() now does if (checkRotation(1000)) doButtons()

      posted in Core 2
      Rop
    • RE: M5Sound 😎

      I'm pretty sure it can do other tones as well. I chose blue for a reason... :)

      posted in Core 2
      Rop
    • RE: M5Sound 😎

      @felmue

      ☑ Valid DTMF. (Didn't have an easy means of testing...)

      posted in Core 2
      Rop
    • M5Sound 😎

      I just wrote a simple polyphonic background synthesizer library for the Core2:

      #include <M5Core2.h>
      
      Synth a;
      
      void setup() {
        M5.begin();
        a.freq = 1000;
        a.gain = 0.4;
      }
      
      void loop() {
        M5.update();
        if (M5.Buttons.event == E_TOUCH) a.start();
        if (M5.Buttons.event == E_RELEASE) a.stop();
      }
      

      You can have multiple Synth instances, their output is mixed. Every synth has attack, decay, sustain release envelope, and the waveform member can be set to SINE, SQUARE, SAWTOOTH, TRIANGLE or NOISE. Sound will continue as long as M5.update() is called. Default attack and release at 5 ms, so no ugly clicks.

      Under 200 lines in the cpp file...

      A few more convenience features coming, buffering to improve a bit still, but this is the core.

      Do play with the DTMF_dialer example, and try holding it sideways...

      It's all on the M5Sound branch of my fork.

      posted in Core 2
      Rop
    • RE: Core2

      @sparkinman

      Check that:

      • You have added the M5Core2 library and are doing #include <M5Core2.h> and not using M5Stack.h. Until they merge it my Pull Request and release a new version, my version is more like it will be, better documented and has graphical buttons. (Simply clone it or get the zip file and unpack so that M5Core2 is a subdir of your Arduino libraries dir.)

      • In Arduino Preferences, you have added https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json as an "Additional Board Manager URL"

      • Make sure you then select M5Stack-core2 from the "Tools / Board / M5Stack-Arduino" menu.

      If this is all good, then you should be able to run one of the examples from the "File / Examples / M5Core2" menu.

      posted in Cores
      Rop
    • RE: M5Button & M5Touch: progress update

      @m5stack ^_^

      posted in Core 2
      Rop
    • M5Button & M5Touch: progress update

      I just issued a Pull Request to pull the advances in M5Button and M5Touch into the M5Core2 library. As everything seems stable and nothing breaks anything existing, I hope m5Stack not only takes them on board but also releases a new version of the Arduino library so more people get to use the new features.

      I have also filed a PR on the M5Stack library for the 3-button 'Core-ESP32' and 'Fire' devices. It (naturally) does not have M5Touch but offers all of M5Button's button-drawing goodness and events as well as the same neat tweaks on the M5Display object. All the files are identical, with any changes behind #ifdef statements, so there's no need to have multiple versions of anything. i also hope M5Stack takes these on as soon as possible and also releases a new version.

      posted in Core 2
      Rop
    • RE: M5Core2 library fork that supports multi-touch and provides Arduino-style virtual buttons [update: and gestures and events] [update2: MERGED !]

      I think it's a wrap...

      That is: on something this size there will always be more work to do and corners that could be even cleaner. But i think it works, does the job, is well-documented and at the very least doesn't break anything else.

      So please give it a good test and tell me what y'all think, and then I'll make the PRs for M5Core2 (with M5Touch) and M5Stack (just m5Button).

      @vkichline By all means wrap up TouchGoal so it can be included.

      Everyone: please give the documentation a read and maybe write a tiny thing yourself to see if it works like you would expect... I'd love some more really basic simple examples if you can find the time...

      posted in Core 2
      Rop