WiFiBoy32

Post date: 2018/08/11 1:50:26

WiFiBoy32を Makere Faire Tokyo 2018 で購入.結構楽しい.

  • Setup (Windows10)
    1. Arduino
    2. git (bash)
    3. arduino-esp32 for windows
      1. Git GUI : Clone Existing Repository
        • target : https://github.com/espressif/arduino-esp32.git
        • source : C:/Users/_USERNAME_/Documents/Arduino/hardware/espressif/esp32
      2. Git Bash
        1. $ cd Documents/Arduino/hardware/espressif/esp32
        2. $ git submodule update --init --recursive
      3. Explorer から tools/get.exe を実行
    4. CP210x USB to UART Bridge VCP Drivers(入っていた)
    5. Arduino
      1. ツール>ボード : ESP32 Dev Module
      2. ツール>COM : COMXX
      3. WiFiBoy32Lib.zip をインストール
    6. Samples
      • BLINK : setup() の前に一行追加
        • int LED_BUILTIN=16; // WiFiBoy32
      • WiFiBoy32 Tutorials : tetris, brick, garaxian, L-game, tello controller, etc.

ref:

Sample: HellowWorldPush

/*
 * Hello World for WiFiBoy32 
 */
#include <wifiboy32.h>
#define PIN_L 17  // Button L (Green)
#define PIN_R 32  // Button R (Red)
#define PIN_U 33  // Button U (Blue)
#define PIN_D 27  // Button D (Yellow)
#define BUTTON_ON 0

void setup() {
  Serial.begin(115200);
  wb32_init();
  wb32_setTextColor(wbGREEN, wbGREEN);
  pinMode(PIN_L,INPUT); 
  pinMode(PIN_R,INPUT);
  pinMode(PIN_U,INPUT);
  pinMode(PIN_D,INPUT);
}

int last_key=0;
int str_x=0, str_y=0;
void loop() {
  if (digitalRead(PIN_L)==BUTTON_ON && last_key!=PIN_L){
    clear_display();
    wb32_setTextColor(wbGREEN, wbGREEN);
    str_x=20; str_y=150;
    wb32_drawString("Push L", 5, 23, 2, 2);
    last_key=PIN_L;
  }
  if (digitalRead(PIN_R)==BUTTON_ON && last_key!=PIN_R){
    clear_display();
    wb32_setTextColor(wbRED, wbRED);
    str_x=140; str_y=150;
    wb32_drawString("Push R", 5, 23, 2, 2);
    last_key=PIN_R;
  }
  if (digitalRead(PIN_U)==BUTTON_ON && last_key!=PIN_U){
    clear_display();
    wb32_setTextColor(wbBLUE, wbBLUE);
    str_x=80; str_y=20;
    wb32_drawString("Push U", 5, 23, 2, 2);
    last_key=PIN_U;
  }
  if (digitalRead(PIN_D)==BUTTON_ON && last_key!=PIN_D){
    clear_display();
    wb32_setTextColor(wbYELLOW, wbYELLOW);
    str_x=80; str_y=290;
    wb32_drawString("Push D", 5, 23, 2, 2); 
    last_key=PIN_D;
  }
  wb32_drawString("Hello World", str_x, str_y, 1, 2);
}

void clear_display(){
 wb32_fillRect(0,0,240,320,0);
}/*
 * Hello World for WiFiBoy32 
 */
#include <wifiboy32.h>
#define PIN_L 17  // Button L (Green)
#define PIN_R 32  // Button R (Red)
#define PIN_U 33  // Button U (Blue)
#define PIN_D 27  // Button D (Yellow)
#define BUTTON_ON 0

void setup() {
  Serial.begin(115200);
  wb32_init();
  wb32_setTextColor(wbGREEN, wbGREEN);
  pinMode(PIN_L,INPUT); 
  pinMode(PIN_R,INPUT);
  pinMode(PIN_U,INPUT);
  pinMode(PIN_D,INPUT);
}

int last_key=0;
int str_x=0, str_y=0;
void loop() {
  if (digitalRead(PIN_L)==BUTTON_ON && last_key!=PIN_L){
    clear_display();
    wb32_setTextColor(wbGREEN, wbGREEN);
    str_x=20; str_y=150;
    wb32_drawString("Push L", 5, 23, 2, 2);
    last_key=PIN_L;
  }
  if (digitalRead(PIN_R)==BUTTON_ON && last_key!=PIN_R){
    clear_display();
    wb32_setTextColor(wbRED, wbRED);
    str_x=140; str_y=150;
    wb32_drawString("Push R", 5, 23, 2, 2);
    last_key=PIN_R;
  }
  if (digitalRead(PIN_U)==BUTTON_ON && last_key!=PIN_U){
    clear_display();
    wb32_setTextColor(wbBLUE, wbBLUE);
    str_x=80; str_y=20;
    wb32_drawString("Push U", 5, 23, 2, 2);
    last_key=PIN_U;
  }
  if (digitalRead(PIN_D)==BUTTON_ON && last_key!=PIN_D){
    clear_display();
    wb32_setTextColor(wbYELLOW, wbYELLOW);
    str_x=80; str_y=290;
    wb32_drawString("Push D", 5, 23, 2, 2); 
    last_key=PIN_D;
  }
  wb32_drawString("Hello World", str_x, str_y, 1, 2);
}

void clear_display(){
 wb32_fillRect(0,0,240,320,0);
}