LoginSignup
1
1

More than 3 years have passed since last update.

Windows版ZOOM専用リモコンをM5StickC(無印)でさらに作りこんでみた。

Last updated at Posted at 2020-11-20

前回よりも、より良いZOOMリモコンを求めて

前回はこちらを作ってみたが、自分はZOOMユーザーでWebEXを使わないし、マイクのミュート&ミュート解除とビデオのオン/オフが使いたかったので、コードをさらに書き換えてみた。

改善したい点

・ビデオのオン/オフ
・バッテリー寿命の延命
・バッテリーが切れそうになったら表示する
以上の自分の要望に応えるために以下のコードに改良した。改良点はコード内のコメントを参照ください。

#include <M5StickC.h>
#include <BleKeyboard.h>


BleKeyboard bleKeyboard;

enum ConfSystem {
  mic = 0,
  video,
  vaps
} conf;
int n_conf = 2;
bool on_air;

void setup() {
  M5.begin();
  bleKeyboard.begin();

  M5.Lcd.setRotation(3); // BtnA is left side to LCD

  //Make display daker
  M5.Axp.ScreenBreath( 8 );
  setCpuFrequencyMhz(80);

  // default
  conf = mic;
  on_air = true;
  update_display();
}

void loop() {
  M5.update();

  if(M5.BtnA.wasPressed()){
    if(bleKeyboard.isConnected()){
      on_air = !on_air;
      if(conf==mic){
        send_mute_mic();
      }
      else if(conf==video){
          send_off_video();
      }
    }
    else {
      Serial.println("BLE is not connected");
    }
    update_display();
  }

  if(M5.BtnB.wasPressed()){
    conf = ConfSystem((conf+1) % n_conf);
    update_display();
  }

  if(M5.Axp.GetWarningLeve() == 1){
    M5.Lcd.drawString("LowBattery",0,0);
    delay(10);
  }else{
  //Get Voltage of internal battery
    String vaps = String(M5.Axp.GetAPSVoltage())+ "V";
    M5.Lcd.drawString(vaps,0,0);
    delay(100);
  }
}

void update_display(){
  if(on_air){
    show_onair();
  }
  else {
    show_inmute();
  }
}

void show_onair(){
  M5.Lcd.fillScreen(TFT_RED);
  M5.Lcd.setTextColor(TFT_WHITE, TFT_RED);
  M5.Lcd.setTextSize(3);
  M5.Lcd.setTextDatum(MC_DATUM);
  M5.Lcd.drawString("ON AIR",80,40);

  M5.Lcd.setTextSize(2);
  M5.Lcd.setTextDatum(BR_DATUM);
  if(conf==mic){
    M5.Lcd.drawString("Mic",158,78);
  }
  else if (conf==video){
    M5.Lcd.drawString("Video", 158,78);  
  }
}

void show_inmute(){
  M5.Lcd.fillScreen(TFT_DARKGREY);
  M5.Lcd.setTextColor(TFT_WHITE, TFT_DARKGREY);
  M5.Lcd.setTextSize(3);
  M5.Lcd.setTextDatum(MC_DATUM);
  M5.Lcd.drawString("Muted...",80,40);

  M5.Lcd.setTextSize(2);
  M5.Lcd.setTextDatum(BR_DATUM);
  if(conf==mic){
    M5.Lcd.drawString("Mic",158,78);
  }
  else if (conf==video){
    M5.Lcd.drawString("Video", 158,78);  
  }
}

void send_mute_mic(){
  // https://support.zoom.us/hc/en-us/articles/205683899-Hot-Keys-and-Keyboard-Shortcuts-for-Zoom
  bleKeyboard.press(KEY_LEFT_ALT);
  bleKeyboard.press('a');
  delay(100);
  bleKeyboard.releaseAll();
}

void send_off_video(){
  // https://www.cisco.com/c/en/us/td/docs/collaboration/CWMS/2_5/b_manage_meetings/b_manage_meetings_chapter_0100.html
  M5.Lcd.drawString("Muted...",80,40);
  bleKeyboard.press(KEY_LEFT_ALT);
  bleKeyboard.press('v');
  delay(100);
  bleKeyboard.releaseAll();
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1