-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwidget_ActivityRing.cpp
66 lines (57 loc) · 2.01 KB
/
widget_ActivityRing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "tw_widgets/widget_ActivityRing.h"
#include "peripherals/imu.h"
#include "peripherals/rtc.h"
#include "fonts/RobotoMono_Light_All.h"
#include "bitmaps/bitmaps_general.h"
#include "settings/settings.h"
#include "tinywatch.h"
#include "activity.h"
void WidgetActivityRing::draw(uint canvasid)
{
if (settings.config.imu_process_steps)
{
uint16_t day, month, year;
rtc.get_step_date(day, month, year);
uint32_t steps = imu.get_steps(day, month, year);
uint8_t movement = imu.get_movement_activity_id();
if (!activity.loaded || day == 0)
{
canvas[canvasid].drawSmoothArc(pos_x, pos_y+radius, radius, radius-thickness, 0, 360, col_rings[0], 0);
canvas[canvasid].drawSmoothArc(pos_x, pos_y+radius, radius, radius-thickness, arc_pos, arc_pos+60, col_rings[1], 0);
canvas[canvasid].setTextColor(RGB(0x88, 0x88, 0x88));
canvas[canvasid].setFreeFont(RobotoMono_Light[6]);
canvas[canvasid].drawString("STEPS", pos_x, pos_y+radius);
arc_pos +=60;
return;
}
canvas[canvasid].setFreeFont(RobotoMono_Light[(steps < 100) ? 8 : 6]);
uint32_t ring_color = col_rings[movement];
canvas[canvasid].drawSmoothArc(pos_x, pos_y+radius, radius, radius-thickness, 0, 360, col_rings[movement], 0);
canvas[canvasid].setTextColor(RGB(0xff, 0xff, 0xff));
canvas[canvasid].drawNumber(steps, pos_x+1, pos_y+radius-1);
}
else
{
canvas[canvasid].drawSmoothArc(pos_x, pos_y+radius, radius, radius-thickness, 0, 360, col_rings[0], 0);
canvas[canvasid].setFreeFont(RobotoMono_Light[8]);
canvas[canvasid].setTextColor(RGB(0x99, 0x99, 0x99));
canvas[canvasid].drawString("-", pos_x, pos_y+radius);
}
}
bool WidgetActivityRing::click(uint16_t click_pos_x, uint16_t click_pos_y)
{
if (bounds_check(click_pos_x, click_pos_y))
{
info_println("Show activity face");
return true;
}
return false;
}
bool WidgetActivityRing::click_double(uint16_t click_pos_x, uint16_t click_pos_y)
{
return false;
}
bool WidgetActivityRing::click_long(uint16_t click_pos_x, uint16_t click_pos_y)
{
return false;
}