#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED FeatherWing buttons map to different pins depending on board.
// The I2C (Wire) bus may also be different.
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
#define C_X 63
#define C_Y 31
static const unsigned char PROGMEM logo_bmp[]= {
0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf8, 0x38, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x1f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x07, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x20, 0x07, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x70, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xe0, 0x01, 0xfc, 0x00, 0x7f, 0xff,
0xff, 0xff, 0xe0, 0x03, 0xfe, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0x80, 0x7f, 0xff,
0xff, 0xff, 0xf0, 0x07, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xf0, 0x03, 0xff, 0xfe, 0x7f, 0xff,
0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xc0, 0x7e, 0x00, 0x7f, 0xf8, 0x07, 0xff, 0xff, 0x00, 0x1f, 0x00, 0x3f, 0xe0, 0x01, 0xff,
0xfc, 0x00, 0x07, 0x80, 0x3f, 0xc0, 0x00, 0x7f, 0xf8, 0x00, 0x03, 0xe0, 0x3f, 0x00, 0x00, 0x3f,
0xf0, 0x1f, 0x01, 0xf0, 0x3e, 0x01, 0xf0, 0x1f, 0xe0, 0x7f, 0xc0, 0xf0, 0x3e, 0x07, 0xfc, 0x0f,
0xc0, 0xff, 0xe0, 0x78, 0x3c, 0x1f, 0xfe, 0x0f, 0xc1, 0xff, 0xf0, 0x78, 0x3c, 0x1f, 0xff, 0x07,
0xc3, 0xff, 0xf8, 0x38, 0x38, 0x3f, 0xff, 0x87, 0x83, 0xff, 0xfc, 0x38, 0x38, 0x7f, 0xff, 0x83,
0x87, 0xff, 0xfc, 0x38, 0x38, 0x7f, 0xff, 0xc3, 0x87, 0xff, 0xfc, 0x38, 0x30, 0x7f, 0xff, 0xc3,
0x87, 0xff, 0xfe, 0x38, 0x30, 0xff, 0xff, 0xc3, 0x87, 0xff, 0xfe, 0x38, 0x30, 0xff, 0xff, 0xc3,
0x87, 0xff, 0xfc, 0x38, 0x30, 0x7f, 0xff, 0xc3, 0x87, 0xff, 0xfc, 0x38, 0x38, 0x7f, 0xff, 0xc3,
0x83, 0xff, 0xfc, 0x38, 0x38, 0x7f, 0xff, 0x83, 0xc3, 0xff, 0xf8, 0x38, 0x38, 0x3f, 0xff, 0x87,
0xc1, 0xff, 0xf0, 0x7f, 0xfc, 0x3f, 0xff, 0x07, 0xc0, 0xff, 0xf0, 0x7f, 0xfc, 0x1f, 0xfe, 0x0f,
0xe0, 0x7f, 0xc0, 0xff, 0xfe, 0x07, 0xfc, 0x0f};
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3c); // Address 0x3C for 128x32
display.display();
delay(1000);
display.clearDisplay();
//display.drawCircle(C_X,C_Y,31,SSD1306_WHITE);
//display.drawLine(0,0,100,100,SSD1306_WHITE);
//display.setTextSize(1);
//display.setTextColor(SSD1306_WHITE);
//display.setCursor(0,30);
//display.print("This is my 1306");
display.drawBitmap(0, 0, logo_bmp,64, 47,SSD1306_WHITE);
display.display();
}
float a=45;
float theta_r,x,y;
int i=360;
int h=0,m=0,t;
void loop(){
}
void test(){
//display.clearDisplay();
display.drawCircle(C_X,C_Y,31,SSD1306_WHITE);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,30);
display.print(h);
display.print(":");
display.print(m);
//t=(15-h)*30+(15-h)*m/60.0;
t=90-h*30-m*5/60.0;
//draw_hours
//算出度數
theta_r=t*(PI/180.0);
x=C_X+15*cos(theta_r);
y=C_Y-15*sin(theta_r);
display.drawLine(C_X,C_Y,x,y,SSD1306_WHITE);
t=90-m*6;
theta_r=t*(PI/180.0);
x=C_X+25*cos(theta_r);
y=C_Y-25*sin(theta_r);
display.drawLine(C_X,C_Y,x,y,SSD1306_WHITE);
display.display();
if (m<59){
m++;
}else{
m=0;
if (h<12)
h++;
else
h=0;
}
display.clearDisplay();
}