#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int x=195;
int y=140; /*圆心 */
int data[100][2];/*取出的坐标*/
int r = 60; /*圆半径 */
int step_du = 6; /*步进角度,小时-30° , 分钟 - 6°*/
#define PI 3.1415926
int main(int argc, char *argv[]) {
int i=0,j=0;
int du=0; /*角度 */
for(i=0,j=0;i<360;i+=step_du,j++)
{
data[j][0] = x-r*sin(du*PI/180);
data[j][1] = y-r*cos(du*PI/180);
du+=step_du; /*一次加多少°*/
}
data[60][0] =x;
data[60][1] = y-r;
j-=1;
printf("j = %d\r\n",j);
for(;j>=0;j--)
{
printf("{%d,%d},",data[j][0],data[j][1]);
}
return 0;
}
//圆心195,140
//min_r = 60 step=6; hour_r = 45 ,step=30
const uint16_t Min_pointer_addr[][2]={
{195,80},{201,80},{207,81},{213,82},{219,85},{225,88},{230,91},{235,95},{239,99},{243,104},{246,110},{249,115},{252,121},{253,127},{254,133},{254,140},{254,146},{253,152},{252,158},{249,164},{246,170},{243,175},{239,180},{235,184},{230,188},{224,191},{219,194},{213,197},{207,198},{201,199},{194,199},{188,199},{182,198},{176,197},{170,194},{164,191},{159,188},{154,184},{150,180},{146,175},{143,169},{140,164},{137,158},{136,152},{135,146},{135,139},{135,133},{136,127},{137,121},{140,115},{143,109},{146,104},{150,99},{154,95},{159,91},{165,88},{170,85},{176,82},{182,81},{188,80},{195,80},
};
const uint16_t Hour_pointer_addr[][2]={
{195,97},{217,101},{233,117},{239,140},{233,162},{217,178},{194,184},{172,178},{156,162},{150,139},{156,117},{172,101},{195,95},
};
void LCD_Draw_Pointer(uint8_t hour,uint8_t min)
{
int i=0;
if(hour==0)
{
LCD_DrawLine_Color(195,140,Hour_pointer_addr[11][0],Hour_pointer_addr[11][1],BLACK);
LCD_DrawLine_Color(195,140,Hour_pointer_addr[0][0],Hour_pointer_addr[0][1],WHITE);
}
else
{
LCD_DrawLine_Color(195,140,Hour_pointer_addr[hour-1][0],Hour_pointer_addr[hour-1][1],BLACK);
LCD_DrawLine_Color(195,140,Hour_pointer_addr[hour][0],Hour_pointer_addr[hour][1],WHITE);
}
if(min == 0)
{
LCD_DrawLine_Color(195,140,Min_pointer_addr[59][0],Min_pointer_addr[59][1],BLACK);
LCD_DrawLine_Color(195,140,Min_pointer_addr[0][0],Min_pointer_addr[0][1],WHITE);
}
else
{
LCD_DrawLine_Color(195,140,Min_pointer_addr[min-1][0],Min_pointer_addr[min-1][1],BLACK);
LCD_DrawLine_Color(195,140,Min_pointer_addr[min][0],Min_pointer_addr[min][1],WHITE);
}
if((min) == ((hour*5)+1))
{
if(hour==0)
{
LCD_DrawLine_Color(195,140,Hour_pointer_addr[11][0],Hour_pointer_addr[11][1],BLACK);
LCD_DrawLine_Color(195,140,Hour_pointer_addr[0][0],Hour_pointer_addr[0][1],WHITE);
}
else
{
LCD_DrawLine_Color(195,140,Hour_pointer_addr[hour-1][0],Hour_pointer_addr[hour-1][1],BLACK);
LCD_DrawLine_Color(195,140,Hour_pointer_addr[hour][0],Hour_pointer_addr[hour][1],WHITE);
}
}
LCD_Draw_circle(195,140,4,WHITE,1);
}