Post date: 2018/08/11 1:50:26
WiFiBoy32を Makere Faire Tokyo 2018 で購入.結構楽しい.
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 0void 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 0void 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);}