⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock.c

📁 编译后直接运行的MP3播放器全部C语言源代码 一个包含FAT文件系统、系统引导 Boot、FLASH Driver等内容的
💻 C
📖 第 1 页 / 共 2 页
字号:
                        case BUTTON_OFF:                            used = true;                            break;                        case SYS_USB_CONNECTED:                            return PLUGIN_USB_CONNECTED;                            rb->usb_screen();                            break;                    }                }                break;                /* options screen */            case BUTTON_F3:                while (!exit)                {                    if(settings.analog_clock)                    {                        rb->lcd_clear_display();                        rb->lcd_putsxy(7, 0,  "FF  > Show Time");                        rb->lcd_putsxy(7, 10, "DOWN> Show Frame");                        rb->lcd_putsxy(7, 20, "UP  > Show Date");                        rb->lcd_putsxy(7, 30, "REW > Show Digits");                        rb->lcd_putsxy(15, 46, "OFF > All OFF");                        rb->lcd_putsxy(17, 56, "ON  > All ON");                        rb->lcd_drawline(0, 41, 112, 41);                        /* draw checkmarks */                        if(settings.is_time_displayed)                        {                            rb->lcd_drawline(0, 4, 3, 7);                            rb->lcd_drawline(3, 7, 5, 0);                        }                        if(settings.is_rect_displayed)                        {                            rb->lcd_drawline(0, 14, 3, 17);                            rb->lcd_drawline(3, 17, 5, 10);                        }                        if(settings.is_date_displayed)                        {                            rb->lcd_drawline(0, 24, 3, 27);                            rb->lcd_drawline(3, 27, 5, 20);                        }                        if(settings.are_digits_displayed)                        {                            rb->lcd_drawline(0, 34, 3, 37);                            rb->lcd_drawline(3, 37, 5, 30);                        }                    	/* update the LCD after all this madness */                    	rb->lcd_update();                        /* ... and finally, setting options from screen: */                        switch (rb->button_get(true))                        {                    	    case BUTTON_F3 | BUTTON_REL:                    	        if (used)                    	            exit = true;                    	        used = true;                    	        break;                            case BUTTON_RIGHT:                                settings.is_time_displayed =                                    !settings.is_time_displayed;                                break;                            case BUTTON_DOWN:                                settings.is_rect_displayed =                                    !settings.is_rect_displayed;                                break;                            case BUTTON_UP:                                settings.is_date_displayed =                                    !settings.is_date_displayed;                                break;                            case BUTTON_LEFT:                                settings.are_digits_displayed =                                    !settings.are_digits_displayed;                                break;                            case BUTTON_ON:                                settings.is_time_displayed = true;                                settings.is_rect_displayed = true;                                settings.is_date_displayed = true;                                settings.are_digits_displayed = true;                                break;                            case BUTTON_OFF:                                settings.is_time_displayed = false;                                settings.is_rect_displayed = false;                                settings.is_date_displayed = false;                                settings.are_digits_displayed = false;                                break;                            case SYS_USB_CONNECTED:                                return PLUGIN_USB_CONNECTED;                                rb->usb_screen();                                break;                        }                    }                    else /* 7-Segment clock shown, less options */                    {                        rb->lcd_clear_display();                        rb->lcd_putsxy(7, 0,  "DOWN> Show Frame");                        rb->lcd_putsxy(7, 10, "UP  > Show Date");                        rb->lcd_putsxy(7, 20, "FF  > Seconds");                        rb->lcd_putsxy(15, 46, "OFF > All OFF");                        rb->lcd_putsxy(17, 56, "ON  > All ON");                        rb->lcd_drawline(0, 41, 112, 41);                        /* draw checkmarks */                        if(settings.is_rect_displayed)                        {                            rb->lcd_drawline(0, 4, 3, 7);                            rb->lcd_drawline(3, 7, 5, 0);                        }                        if(settings.is_date_displayed)                        {                            rb->lcd_drawline(0, 14, 3, 17);                            rb->lcd_drawline(3, 17, 5, 10);                        }                        if(settings.is_time_displayed)                        {                            rb->lcd_drawline(0, 24, 3, 27);                            rb->lcd_drawline(3, 27, 5, 20);                        }                        /* And finally, update the LCD */                        rb->lcd_update();                        switch (rb->button_get(true))                        {                    	    case BUTTON_F3 | BUTTON_REL:                    	        if (used)                    	            exit = true;                    	        used = true;                    	        break;                            case BUTTON_DOWN:                                settings.is_rect_displayed =                                    !settings.is_rect_displayed;                                break;                            case BUTTON_UP:                                settings.is_date_displayed =                                    !settings.is_date_displayed;                                break;                            case BUTTON_RIGHT:                                settings.is_time_displayed =                                    !settings.is_time_displayed;                                break;                            case BUTTON_ON:                                settings.is_time_displayed = true;                                settings.is_rect_displayed = true;                                settings.is_date_displayed = true;                                break;                            case BUTTON_OFF:                                settings.is_time_displayed = false;                                settings.is_rect_displayed = false;                                settings.is_date_displayed = false;                                break;                            case SYS_USB_CONNECTED:                                return PLUGIN_USB_CONNECTED;                                rb->usb_screen();                                break;                        }                    }                }                break;                /* Toggle analog/digital */            case BUTTON_PLAY:                settings.analog_clock = !settings.analog_clock;                break;                /* Show time */            case BUTTON_RIGHT:                settings.is_time_displayed = !settings.is_time_displayed;                break;                /* Show border */            case BUTTON_DOWN:                settings.is_rect_displayed = !settings.is_rect_displayed ;                break;                /* Show date */            case BUTTON_UP:                settings.is_date_displayed = !settings.is_date_displayed;                break;                /* Show digits */            case BUTTON_LEFT:                settings.are_digits_displayed = !settings.are_digits_displayed;                break;                /* USB plugged? */            case SYS_USB_CONNECTED:                rb->usb_screen();                return PLUGIN_USB_CONNECTED;                break;        }    }}/* 7 Segment LED imitation code by Linus Nielsen Feltzing *//*       a     0     b        #########       #         #       #         #      1#         #2       #         #       #    3    #      c ######### d       #         #       #         #      4#         #5       #         #       #    6    #      e ######### f*//* The coordinates of each end point (a-f) of the segment lines (0-6) */static unsigned int point_coords[6][2] ={    {0, 0}, /* a */    {1, 0}, /* b */    {0, 1}, /* c */    {1, 1}, /* d */    {0, 2}, /* e */    {1, 2}  /* f */};/* The end points (a-f) for each segment line */static unsigned int seg_points[7][2] ={    {0,1}, /* a to b */    {0,2}, /* a to c */    {1,3}, /* b to d */    {2,3}, /* c to d */    {2,4}, /* c to e */    {3,5}, /* d to f */    {4,5}  /* e to f */};/* Lists that tell which segments (0-6) to enable for each digit (0-9),   the list is terminated with -1 */static int digit_segs[10][8] ={    {0,1,2,4,5,6, -1},   /* 0 */    {2,5, -1},           /* 1 */    {0,2,3,4,6, -1},     /* 2 */    {0,2,3,5,6, -1},     /* 3 */    {1,2,3,5, -1},       /* 4 */    {0,1,3,5,6, -1},     /* 5 */    {0,1,3,4,5,6, -1},   /* 6 */    {0,2,5, -1},         /* 7 */    {0,1,2,3,4,5,6, -1}, /* 8 */    {0,1,2,3,5,6, -1}    /* 9 */};/* Draws one segment */void draw_seg(int seg, int x, int y, int width, int height){    int p1 = seg_points[seg][0];    int p2 = seg_points[seg][1];    int x1 = point_coords[p1][0];    int y1 = point_coords[p1][1];    int x2 = point_coords[p2][0];    int y2 = point_coords[p2][1];    /* It draws parallel lines of different lengths for thicker segments */    if(seg == 0 || seg == 3 || seg == 6)    {        rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2,                         x + x2 * width - 1 , y + y2 * height / 2);        rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 - 1,                         x + x2 * width - 2, y + y2 * height / 2 - 1);        rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 1,                         x + x2 * width - 2, y + y2 * height / 2 + 1);        rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 - 2,                         x + x2 * width - 3, y + y2 * height / 2 - 2);        rb->lcd_drawline(x + x1 * width + 3, y + y1 * height / 2 + 2,                         x + x2 * width - 3, y + y2 * height / 2 + 2);    }    else    {        rb->lcd_drawline(x + x1 * width, y + y1 * height / 2 + 1,                         x + x2 * width , y + y2 * height / 2 - 1);        rb->lcd_drawline(x + x1 * width - 1, y + y1 * height / 2 + 2,                         x + x2 * width - 1, y + y2 * height / 2 - 2);        rb->lcd_drawline(x + x1 * width + 1, y + y1 * height / 2 + 2,                         x + x2 * width + 1, y + y2 * height / 2 - 2);        rb->lcd_drawline(x + x1 * width - 2, y + y1 * height / 2 + 3,                         x + x2 * width - 2, y + y2 * height / 2 - 3);                rb->lcd_drawline(x + x1 * width + 2, y + y1 * height / 2 + 3,                         x + x2 * width + 2, y + y2 * height / 2 - 3);    }}/* Draws one digit */void draw_7seg_digit(int digit, int x, int y, int width, int height){    int i;    int c;    for(i = 0;digit_segs[digit][i] >= 0;i++)    {        c = digit_segs[digit][i];        draw_seg(c, x, y, width, height);    }}/* Draws the entire 7-segment hour-minute time display */void draw_7seg_time(int hour, int minute, int x, int y, int width, int height,bool colon){    int xpos = x;    draw_7seg_digit(hour / 10, xpos, y, width, height);    xpos += width + 6;    draw_7seg_digit(hour % 10, xpos, y, width, height);    xpos += width + 6;    if(colon)    {        rb->lcd_drawline(xpos, y + height/3 + 2,                         xpos, y + height/3 + 2);        rb->lcd_drawline(xpos+1, y + height/3 + 1,                         xpos+1, y + height/3 + 3);        rb->lcd_drawline(xpos+2, y + height/3,                         xpos+2, y + height/3 + 4);        rb->lcd_drawline(xpos+3, y + height/3 + 1,                         xpos+3, y + height/3 + 3);        rb->lcd_drawline(xpos+4, y + height/3 + 2,                         xpos+4, y + height/3 + 2);        rb->lcd_drawline(xpos, y + height-height/3 + 2,                         xpos, y + height-height/3 + 2);        rb->lcd_drawline(xpos+1, y + height-height/3 + 1,                         xpos+1, y + height-height/3 + 3);        rb->lcd_drawline(xpos+2, y + height-height/3,                         xpos+2, y + height-height/3 + 4);        rb->lcd_drawline(xpos+3, y + height-height/3 + 1,                         xpos+3, y + height-height/3 + 3);        rb->lcd_drawline(xpos+4, y + height-height/3 + 2,                         xpos+4, y + height-height/3 + 2);    }    xpos += 12;    draw_7seg_digit(minute / 10, xpos, y, width, height);    xpos += width + 6;    draw_7seg_digit(minute % 10, xpos, y, width, height);    xpos += width + 6;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -