badger icon indicating copy to clipboard operation
badger copied to clipboard

Why not ESP32?

Open bob-u opened this issue 3 years ago • 4 comments

Since you're using GPIO extenders, why not use ESP32 for the MCU?

EDIT: after watching you video on making the keyboard controller I realized that only recently Espressif has made USB OTG work on ESP32-S2. Still, it would be nice if in the future you could show how portable the badger code is and make it run on ESP32.

bob-u avatar Jul 02 '21 00:07 bob-u

Why would I use the ESP32? AFAIK it doesn't support Bluetooth HID so I can't use it to make the keyboard Bluetooth capable. And I'm not entirely sure what I'd do with WiFi without a screen (although adding a small screen could make the keyboard into a standalone SSH client).

The real reason why I'm not running it on an ESP32 is because when I first started the project I was new to custom keyboards and the Teensy 2.0 was recommended. My focus while writing the firmware has been on use-ability and small firmware size, with the firmware basically running well now I'm considering porting it to an ATTiny85 to really showcase how small this firmware really is.

PMunch avatar Jul 02 '21 12:07 PMunch

ESP32 is $3, has lots of ram, it does support Bluetooth HID, some versions now support USB OTG as well.

https://gist.github.com/manuelbl/66f059effc8a7be148adb1f104666467

If you want the project to reach more people and grow beyond keyboard controller than ESP32 would probably be one of the better options.

bob-u avatar Jul 02 '21 22:07 bob-u

Hmm interesting, I've got a couple of ESP32s lying around so I could definitely give it a go. I've run Nim on the ESP8266 before, so it shouldn't be that hard to get Badger running on the ESP32.

PMunch avatar Jul 03 '21 12:07 PMunch

@PMunch Hello, I really enjoyed your NimConf 2021 talk! I agree with @bob-u it would be great to use this with ESP32 devices. ESP32 uses a version of FreeRTOS so it's not as bare-metal as Arduino, etc. and has it's own development framework called ESP-IDF (there is also ESP32 Arduino core but in my opinion that's not the best route to go). There already is a library called Nesper by @elcritch which can be used. It is essentially a Nim wrapper around ESP-IDF. We can use both Nesper and Badger to achieve this.

There are a few ESP32 SoCs:

  • ESP32 (WiFi + Bluetooth 4.2, no native USB),
  • ESP32-S2 (WiFI + native USB, no Bluetooth),
  • ESP32-C3 (WiFi + Bluetooth 5, no native USB)
  • and upcoming ESP32-S3 (it should have everything included: WiFi, Bluetooth 5 and native USB also).

We should be able to use Bluetooth as Bluetooth HID & native USB as USB HID. However to support every SoC Nesper has to be updated to support the next version of ESP-IDF (v4.4) which should come out in around next 1-2 months. The now latest ESP-IDF v4.3 doesn't support ESP32-S3 as a compilation target (well, it's only available as samples right now, not officially launched so that's why). Right now Nesper officially supports only ESP-IDF v4.0.

All of this shouldn't be a concern to Badger however, once it's ported to ESP32 it should work on every SoC because ESP-IDF unifies the API. With current Nesper version we could get it running on basic ESP32 at least.

Also sorry for this wall of text ~~~

adokitkat avatar Jul 19 '21 14:07 adokitkat