Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
PaperdinkUITodoListClass Class Reference

#include <todo_list.h>

Inheritance diagram for PaperdinkUITodoListClass:
PaperdinkUIBaseClass PaperdinkUITodoListTaigaClass PaperdinkUITodoListTodoistClass

Public Member Functions

void display_list_style1 (GxEPD2_GFX &display, int16_t x, int16_t y, int16_t rows=TODO_LIST_MAX_TASKS, int16_t columns=1, uint16_t max_line_width=400)
 

Public Attributes

char tasks [TODO_LIST_MAX_TASKS][TODO_LIST_MAX_TODO_STR_LENGTH+1]
 
uint8_t task_count
 
String token
 
- Public Attributes inherited from PaperdinkUIBaseClass
const GFXfont * font = &PAPERDINK_FONT_SML
 
const GFXfont * font_bold = &PAPERDINK_FONT_SML_BOLD
 
int primary_color = GxEPD_BLACK
 
int secondary_color = GxEPD_WHITE
 
int tertiary_color = GxEPD_BLACK
 

Detailed Description

Definition at line 11 of file todo_list.h.

Member Function Documentation

◆ display_list_style1()

void PaperdinkUITodoListClass::display_list_style1 ( GxEPD2_GFX & display,
int16_t x,
int16_t y,
int16_t rows = TODO_LIST_MAX_TASKS,
int16_t columns = 1,
uint16_t max_line_width = 400 )

Definition at line 207 of file todo_list.cpp.

208{
209 int16_t xt, yt;
210 uint16_t wt, ht, char_ht, prev_height = y, prev_width = x;
211 uint16_t i = 0, j = 0, start_height = 0;
212
213 display.setFont(font_bold);
214 display.setTextColor(primary_color);
215 display.setTextSize(1);
216
217 display.getTextBounds(F("To-Do List"), 0, 0, &xt, &yt, &wt, &ht);
218 display.setCursor(prev_width + 5, prev_height + ht);
219 prev_height += ht;
220 prev_width += 5;
221 display.println(F("To-Do List"));
222
223 display.setFont(font);
224 display.setTextColor(primary_color);
225 display.getTextBounds("W", 0, 0, &xt, &yt, &wt, &char_ht);
226
227 // Display tasks
228 start_height = prev_height + ht + 5;
229 for (j = 0; j < columns; j++) {
230 prev_height = start_height;
231 for (i = 0; i + (j * rows) < task_count && i < rows; i++) {
232 String task = tasks[i + (j * rows)];
233 uint16_t cnt = task.length();
234 do{
235 task = task.substring(0, cnt);
236 display.getTextBounds(task.c_str(), 0, 0, &xt, &yt, &wt, &ht);
237 }while (wt > max_line_width && cnt-- > 0);
238
239 DEBUG.printf("Task: %s\r\n", task.c_str());
240 display.setCursor(prev_width, prev_height);
241 display.printf("%s", task.c_str());
242 prev_height += char_ht + 7;
243 }
244 prev_width += max_line_width + 10;
245 }
246}
const GFXfont * font
Definition ui_base.h:9
const GFXfont * font_bold
Definition ui_base.h:10
char tasks[TODO_LIST_MAX_TASKS][TODO_LIST_MAX_TODO_STR_LENGTH+1]
Definition todo_list.h:14
#define DEBUG
Definition todo_list.h:6

Member Data Documentation

◆ task_count

uint8_t PaperdinkUITodoListClass::task_count

Definition at line 15 of file todo_list.h.

◆ tasks

char PaperdinkUITodoListClass::tasks[TODO_LIST_MAX_TASKS][TODO_LIST_MAX_TODO_STR_LENGTH+1]

Definition at line 14 of file todo_list.h.

◆ token

String PaperdinkUITodoListClass::token

Definition at line 16 of file todo_list.h.


The documentation for this class was generated from the following files: