diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/calendar.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/calendar.cpp b/src/calendar.cpp index 04325b0..a9b3d00 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -3,6 +3,7 @@ #include <ctime> #define CELL_SPACING 8 +#define FONTSIZE 10 extern GxEPD2_GFX_BASE_CLASS &get_display(); extern U8G2_FOR_ADAFRUIT_GFX u8g2Fonts; @@ -67,7 +68,7 @@ static int days_in_month(int month, int year) { */ static void draw_cell_content(int16_t x0, int16_t y0, uint16_t w0, uint16_t h0, uint8_t xoff, uint8_t yoff, String &text, bool highlight = false) { uint16_t w = u8g2Fonts.getUTF8Width(text.c_str()); - uint16_t h = 10; /* assume 10px high font */ + uint16_t h = FONTSIZE; int16_t w_diff = w0 - w; int x2 = x0 + xoff * w0 + w_diff/2; @@ -98,21 +99,21 @@ void draw_calendar(int16_t x0, int16_t y0) { u8g2Fonts.setFont(u8g2_font_helvB10_tf); uint16_t cell_width, cell_height; int w = u8g2Fonts.getUTF8Width(week_days[0]); - int h = 10; /* assume 10px high font */ + int h = FONTSIZE; cell_width = w + CELL_SPACING; cell_height = h + CELL_SPACING + 5; /* draw title with month and year */ u8g2Fonts.setFont(u8g2_font_helvB14_tf); String title_text = String(months[now.tm_mon]) + " " + String(1900 + now.tm_year); - draw_cell_content(x0, y0, cell_width * 7, h, 0, 0, title_text); - y0 += h + 2 * CELL_SPACING; + draw_cell_content(x0, y0 + 14, cell_width * 7, h, 0, 0, title_text); + y0 += 14 + 2 * CELL_SPACING; /* draw table header with week days */ u8g2Fonts.setFont(u8g2_font_helvB10_tf); for (int i=0; i<7; i++) { String week_day = String(week_days[i]); - draw_cell_content(x0, y0, cell_width, cell_height, i, 0, week_day); + draw_cell_content(x0, y0 + FONTSIZE, cell_width, cell_height, i, 0, week_day); } /* draw days */ @@ -121,7 +122,7 @@ void draw_calendar(int16_t x0, int16_t y0) { uint8_t row = 1; for (uint8_t day = 1; day <= n_days; day++) { String day_str = String(day); - draw_cell_content(x0, y0, cell_width, cell_height, wday, row, day_str, day == now.tm_mday); + draw_cell_content(x0, y0 + FONTSIZE, cell_width, cell_height, wday, row, day_str, day == now.tm_mday); wday++; if (wday > 6) { |
