oboo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. #include <stdlib.h>
  2. #include "oboo.h"
  3. #include "lv_theme_oboo.h"
  4. #include "oboo_notification.h"
  5. #include "lv_drivers/display/fbdev.h"
  6. #include "lv_drivers/display/monitor.h"
  7. #include "lv_omega_fs.h"
  8. #include "lvgl/lvgl.h"
  9. LV_FONT_DECLARE(dejavu_60);
  10. LV_FONT_DECLARE(dejavu_80);
  11. LV_FONT_DECLARE(Futura_15);
  12. LV_FONT_DECLARE(Futura_23);
  13. LV_FONT_DECLARE(Futura_50);
  14. LV_FONT_DECLARE(Futura_82);
  15. /* api functions */
  16. void oboo_graphics_init() {
  17. /*LittlevGL init*/
  18. lv_init();
  19. /*Linux frame buffer device init*/
  20. _lv_fb_init();
  21. /*filesystem init*/
  22. _lv_omega_fs_init();
  23. /*Apply Oboo Theme*/
  24. lv_theme_t *th = lv_theme_oboo_init(200, NULL); //200 is the color in hue formate
  25. lv_theme_set_current(th);
  26. /*Create the screen*/
  27. scr = lv_obj_create(NULL, NULL); /*Create a parent object on the current screen*/
  28. lv_scr_load(scr); /*Load the screen*/
  29. /* Initialize the Oboo GUI */
  30. _lv_init_oboo_gui();
  31. printf("DPI: %d, Anti-aliasing: %d\n", LV_DPI, LV_ANTIALIAS);
  32. }
  33. void oboo_graphics_handle() {
  34. lv_tick_inc(5);
  35. lv_task_handler();
  36. }
  37. /* init functions */
  38. void _lv_fb_init () {
  39. #if OB_PC_SIMULATOR
  40. monitor_init();
  41. #else
  42. fbdev_init();
  43. #endif
  44. /*Enable the frame buffer driver with LittlevGL*/
  45. lv_disp_drv_t disp_drv;
  46. lv_disp_drv_init(&disp_drv);
  47. #if OB_PC_SIMULATOR
  48. disp_drv.disp_flush = monitor_flush; /*flush the internal graphic buffer to the frame buffer*/
  49. #else
  50. disp_drv.disp_flush = fbdev_flush;
  51. #endif
  52. lv_disp_drv_register(&disp_drv);
  53. }
  54. void _lv_omega_fs_init () {
  55. /* Add a simple drive to open images from PC*/
  56. lv_fs_drv_t pcfs_drv; /*A driver descriptor*/
  57. memset(&pcfs_drv, 0, sizeof(lv_fs_drv_t)); /*Initialization*/
  58. pcfs_drv.file_size = sizeof(pc_file_t); /*Set up fields...*/
  59. pcfs_drv.letter = LV_OMEGA_FS_LETTER;
  60. pcfs_drv.open = pcfs_open;
  61. pcfs_drv.close = pcfs_close;
  62. pcfs_drv.read = pcfs_read;
  63. pcfs_drv.seek = pcfs_seek;
  64. pcfs_drv.tell = pcfs_tell;
  65. lv_fs_add_drv(&pcfs_drv);
  66. }
  67. void _lv_init_oboo_gui () {
  68. /* note: ensure this ordering is preserved:
  69. cardview added first
  70. and status bar added last
  71. the lv_oboo_obj_get_card_manager and lv_oboo_obj_get_status_bar functions
  72. depend on this creation order
  73. */
  74. /* 1 - create tabs */
  75. lv_obj_t *tv = ob_cardview_create(lv_scr_act(), NULL);
  76. lv_obj_set_size(tv, LV_HOR_RES, LV_VER_RES - OB_TOP_BAR_RES);
  77. lv_obj_set_pos(tv, 0, OB_TOP_BAR_RES);
  78. lv_obj_set_free_num(tv, OB_CARD_VIEW_OBJ_ID);
  79. /* 2 - create oboo logo splash screen */
  80. _lv_init_splash_screen();
  81. /* 3 - create status bar */
  82. // setup style first
  83. static lv_style_t sb_style;
  84. lv_style_copy(&sb_style, &lv_style_plain);
  85. sb_style.body.main_color = LV_COLOR_BLACK;
  86. sb_style.body.grad_color = LV_COLOR_BLACK;
  87. // create the statusbar
  88. lv_obj_t *sb = ob_statusbar_create(lv_scr_act(), NULL);
  89. lv_obj_set_style(sb, &sb_style);
  90. lv_obj_set_size(sb, LV_HOR_RES, OB_TOP_BAR_RES);
  91. lv_obj_set_pos(sb, 0, 0);
  92. lv_obj_set_free_num(sb, OB_STATUS_BAR_OBJ_ID);
  93. // populate status bar
  94. static lv_style_t sb_text_style;
  95. lv_style_copy(&sb_text_style, &lv_style_plain);
  96. sb_text_style.text.font = &lv_font_dejavu_20;
  97. sb_text_style.text.color = LV_COLOR_WHITE;
  98. lv_obj_t *statusLeft = lv_label_create(sb, NULL);
  99. lv_label_set_style(statusLeft, &sb_text_style);
  100. lv_obj_t *statusRight = lv_label_create(sb, NULL);
  101. lv_label_set_style(statusRight, &sb_text_style);
  102. lv_ob_statusbar_update();
  103. /*Initialize the notification*/
  104. oboo_notification_init();
  105. }
  106. void _lv_init_splash_screen () {
  107. #if OB_SPLASH_SCREEN_ENABLED == 1
  108. printf("Setting oboo logo background...");
  109. LV_IMG_DECLARE(img_oboo_logo);
  110. lv_obj_t *img_src = lv_img_create(lv_scr_act(), NULL); /*Create an image object*/
  111. lv_obj_set_free_num(img_src, OB_SPLASH_SCREEN_OBJ_ID);
  112. lv_img_set_src(img_src, &img_oboo_logo); /*Set the created file as image */
  113. lv_obj_align(img_src, NULL, LV_ALIGN_CENTER, 0, 0); /*Set the alignment*/
  114. printf(" done\n");
  115. #endif // OB_SPLASH_SCREEN_ENABLED
  116. }
  117. /* getter functions */
  118. // DEPRECATED: using lv_obj_get_child_by_fn_index instead
  119. // get an object's child by index that is based on order of addition to parent
  120. lv_obj_t* lv_obj_get_child_by_index(lv_obj_t *parent, int idx) {
  121. int count = 0;
  122. lv_obj_t* itr = NULL;
  123. while (1) {
  124. itr = lv_obj_get_child_back (parent, itr);
  125. // printf("count is %d, itr is Null: %s\n", count, itr == NULL ? "yes" : "no"); // debug print statements
  126. // leave the loop if reached the specified index (or if looped thru all children)
  127. if (count == idx || itr == NULL) {
  128. printf("leaving loop\n");
  129. break;
  130. }
  131. count++; // iterate the count
  132. }
  133. return (itr);
  134. }
  135. // get an object's child by a given free_num index
  136. // generally used to retrieve elements in a card
  137. lv_obj_t* lv_obj_get_child_by_fn_index(lv_obj_t *parent, int idx) {
  138. int childId = 0;
  139. lv_obj_t* itr = NULL;
  140. while (1) {
  141. itr = lv_obj_get_child_back (parent, itr);
  142. if (itr != NULL) {
  143. childId = lv_obj_get_free_num(itr);
  144. if (childId == idx) {
  145. // found the child we were looking for
  146. break;
  147. }
  148. } else {
  149. // leave the loop - we've looped through all the children - will return NULL
  150. break;
  151. }
  152. }
  153. return (itr);
  154. }
  155. lv_obj_t* lv_obj_get_card_element(int cardIdx, int elementIdx) {
  156. // printf("looking for card %d element %d\n", cardIdx, elementIdx);
  157. // get the specified card
  158. lv_obj_t *card = ob_cardview_get_card(lv_oboo_obj_get_card_manager(), cardIdx);
  159. // return the specified element
  160. if (card != NULL) {
  161. return (lv_obj_get_child_by_fn_index(lv_page_get_scrl(card), elementIdx));
  162. }
  163. return NULL;
  164. }
  165. lv_obj_t* lv_oboo_obj_get_card_manager() {
  166. lv_obj_t *cm = lv_obj_get_child_back (lv_scr_act(), NULL);
  167. if (cm != NULL && lv_obj_get_free_num(cm) == OB_CARD_VIEW_OBJ_ID) {
  168. return cm;
  169. }
  170. return NULL;
  171. }
  172. lv_obj_t* lv_oboo_obj_get_status_bar() {
  173. lv_obj_t *sb = lv_obj_get_child (lv_scr_act(), NULL);
  174. if (sb != NULL && lv_obj_get_free_num(sb) == OB_STATUS_BAR_OBJ_ID) {
  175. return sb;
  176. }
  177. return NULL;
  178. }
  179. int lv_oboo_get_card_id_by_fp(char* uid) {
  180. int cardIdx = -1;
  181. lv_obj_t *card = ob_cardview_get_card_by_fp_string(lv_oboo_obj_get_card_manager(), uid);
  182. if (card != NULL) {
  183. cardIdx = lv_obj_get_free_num(card);
  184. }
  185. return cardIdx;
  186. }
  187. /* add functions */
  188. // add a card to the card manager
  189. // returns: index of the card
  190. int lv_add_card (int bgColor) {
  191. return (lv_add_card_idx (bgColor, -1));
  192. }
  193. // add a card to the card manager with a specified index
  194. // returns: index of the card
  195. int lv_add_card_idx (int bgColor, int pos) {
  196. int idx;
  197. lv_obj_t *tab;
  198. _lv_remove_splash_screen();
  199. // get the card manager object
  200. lv_obj_t *cm = lv_oboo_obj_get_card_manager();
  201. int card_cnt = ob_cardview_get_card_count(cm);
  202. if(pos > card_cnt) pos = card_cnt;
  203. // add a card
  204. if (pos >=0) {
  205. printf("lv_add_card_idx:: adding card to pos %d\n", pos);
  206. tab = ob_cardview_add_card(cm, pos);
  207. }
  208. else {
  209. printf("lv_add_card_idx:: appending card to end\n");
  210. tab = ob_cardview_append_card(cm);
  211. // update pos to reflect that card was appended to cardview
  212. // note: now searching through all cards to find highest free_num
  213. pos = (int)ob_cardview_get_max_free_num(cm) + 1;
  214. }
  215. // set the background color - if greater than 0
  216. // onion.io: TODO: DEBUG: setting the background doesn't work...
  217. // kisvegabor@gmail.com: fixed
  218. // onion.io: TODO: DEBUG: setting the background for one card, sets the same background for all cards
  219. if (bgColor >= 0) {
  220. static lv_style_t newStyle;
  221. lv_style_copy(&newStyle, &lv_style_plain);
  222. newStyle.body.main_color = LV_COLOR_HEX(bgColor);
  223. newStyle.body.grad_color = LV_COLOR_HEX(bgColor);
  224. newStyle.body.padding.hor = 0;
  225. newStyle.body.padding.ver = 0;
  226. lv_page_set_style(tab, LV_PAGE_STYLE_BG, &newStyle);
  227. }
  228. // first element on a card cannot be properly position on the y-axis for some reason
  229. // WORKAROUND: add a dummy element that is empty
  230. lv_obj_t * element = element = lv_label_create(lv_page_get_scrl(tab), NULL);
  231. lv_label_set_text(element, " ");
  232. lv_obj_set_free_num(element, 999);
  233. // get card index
  234. idx = pos;
  235. // write the card index to the object
  236. lv_obj_set_free_num(tab, idx);
  237. printf("lv_add_card_idx:: returning index %d\n", idx);
  238. // return the index of the card (based on it's position as a child of card-manager)
  239. return (idx);
  240. }
  241. int lv_set_card_uid (int cardId, char* uid) {
  242. lv_obj_t *card = ob_cardview_get_card(lv_oboo_obj_get_card_manager(), cardId);
  243. char* mem;
  244. // write the uid to the element
  245. if (card != NULL) {
  246. mem = malloc(sizeof(char) * (strlen(uid) + 1));
  247. strcpy(mem, uid);
  248. lv_obj_set_free_ptr(card, mem);
  249. return 0;
  250. }
  251. return -1;
  252. }
  253. void lv_delete_card(int cardId)
  254. {
  255. lv_obj_t *card = ob_cardview_get_card(lv_oboo_obj_get_card_manager(), cardId);
  256. if(card != NULL){
  257. //printf("not Null");
  258. lv_obj_t *child = lv_obj_get_child_back(card, NULL);
  259. while(child != NULL){
  260. struct oboo_card_element_data *freePtr = lv_obj_get_free_ptr(child);
  261. if(freePtr != NULL){
  262. free(freePtr);
  263. }
  264. child = lv_obj_get_child_back(card, child);
  265. }
  266. ob_cardview_delete_card(lv_oboo_obj_get_card_manager(), card);
  267. }else{
  268. printf("there was no card with id: %d", cardId);
  269. }
  270. }
  271. int lv_add_card_element(int cardId, int elementId, char* elementType, int posX, int posY, int size, char* alignment, char* value) {
  272. lv_obj_t * element = NULL;
  273. // get the card
  274. lv_obj_t *card = ob_cardview_get_card(lv_oboo_obj_get_card_manager(), cardId);
  275. if (card == NULL) {
  276. return 1;
  277. }
  278. // printf("> C: Adding element to card %d: type '%s' at (%d, %d) of size %d with default value '%s'\n", cardId, elementType, posX, posY, size, value );
  279. // allocate element data structure
  280. // struct oboo_card_element_data *elementData = malloc(sizeof *elementData);
  281. struct oboo_card_element_data *elementData = malloc(sizeof (struct oboo_card_element_data));
  282. if (elementData != NULL) {
  283. /* populate the element data structure */
  284. // element type
  285. if (strcmp(elementType, "text") == 0) {
  286. elementData->type = OB_TEXT_ELEMENT;
  287. } else if (strcmp(elementType, "image") == 0) {
  288. elementData->type = OB_IMAGE_ELEMENT;
  289. }
  290. // alignment
  291. if (strcmp(alignment, "right") == 0) {
  292. elementData->alignment = LV_ALIGN_IN_TOP_RIGHT;
  293. }
  294. else if (strcmp(alignment, "center") == 0) {
  295. elementData->alignment = LV_ALIGN_IN_TOP_MID;
  296. }
  297. else {
  298. // if it's 'left' or other
  299. elementData->alignment = LV_ALIGN_IN_TOP_LEFT;
  300. }
  301. // position data
  302. elementData->posX = posX;
  303. elementData->posY = posY;
  304. // create the element based on its type
  305. if (elementData->type == OB_TEXT_ELEMENT) {
  306. // create a text element
  307. element = lv_label_create(lv_page_get_scrl(card), NULL);
  308. // set the font size
  309. lv_style_t *style1 = (lv_style_t*)malloc(sizeof(lv_style_t));
  310. lv_style_copy(style1, &lv_style_plain);
  311. style1->text.color = LV_COLOR_WHITE;
  312. switch (size) {
  313. case 10:
  314. style1->text.font = &lv_font_dejavu_10;
  315. break;
  316. case 20:
  317. style1->text.font = &lv_font_dejavu_20;
  318. break;
  319. case 30:
  320. style1->text.font = &lv_font_dejavu_30;
  321. break;
  322. case 40:
  323. style1->text.font = &lv_font_dejavu_40;
  324. break;
  325. case 60:
  326. style1->text.font = &dejavu_60;
  327. break;
  328. case 80:
  329. style1->text.font = &dejavu_80;
  330. break;
  331. case 15:
  332. style1->text.font = &Futura_15;
  333. break;
  334. case 23:
  335. style1->text.font = &Futura_23;
  336. break;
  337. case 50:
  338. style1->text.font = &Futura_50;
  339. break;
  340. case 82:
  341. style1->text.font = &Futura_82;
  342. break;
  343. default:
  344. // style1->text.font = &lv_font_dejavu_40;
  345. style1->text.font = &Futura_50;
  346. break;
  347. }
  348. printf("> setting text element to size '%d'\n", size);
  349. lv_label_set_style(element, style1);
  350. lv_label_set_recolor(element, true); // allow recoloring of the text based on input
  351. } else if (elementData->type == OB_IMAGE_ELEMENT) {
  352. // create an image element
  353. element = lv_img_create(lv_page_get_scrl(card), NULL);
  354. }
  355. // set the element ID
  356. lv_obj_set_free_num(element, elementId);
  357. // attach the elementData to the element
  358. lv_obj_set_free_ptr(element, (void*)elementData);
  359. // populate the element
  360. lv_update_card_element(cardId, elementId, value);
  361. // printf("> added element! card now has %d elements\n", (int)lv_obj_count_children(lv_page_get_scrl(card)) );
  362. return 0;
  363. }
  364. return 1;
  365. }
  366. /* setter functions */
  367. void lv_update_card_element(int cardId, int elementId, char* value) {
  368. char buf[256];
  369. struct oboo_card_element_data *elementData = NULL;
  370. // retrieve the element in question
  371. lv_obj_t *element = lv_obj_get_card_element(cardId, elementId);
  372. // grab the element data
  373. if (element != NULL) {
  374. elementData = lv_obj_get_free_ptr(element);
  375. if (elementData != NULL) {
  376. // update the element value based on its type
  377. if (elementData->type == OB_TEXT_ELEMENT) {
  378. // printf("> C: updating text element!\n");
  379. lv_label_set_text(element, value);
  380. } else if (elementData->type == OB_IMAGE_ELEMENT) {
  381. sprintf(buf, "%c:/%s", LV_OMEGA_FS_LETTER, value);
  382. // printf("> C: updating image element to '%s'\n", buf);
  383. lv_img_set_src(element, buf);
  384. }
  385. // update the position of the element
  386. if (elementData->alignment == LV_ALIGN_IN_TOP_RIGHT) {
  387. lv_obj_align(element, NULL, LV_ALIGN_IN_TOP_RIGHT, elementData->posX, elementData->posY-1);
  388. }
  389. else if (elementData->alignment == LV_ALIGN_IN_TOP_MID) {
  390. lv_obj_align(element, NULL, LV_ALIGN_IN_TOP_MID, elementData->posX, elementData->posY-1);
  391. }
  392. else {
  393. lv_obj_set_pos(element, elementData->posX, elementData->posY);
  394. }
  395. }
  396. }
  397. }
  398. int lv_ob_select_card(char* direction) {
  399. int status;
  400. int targetIdx = -1;
  401. lv_obj_t *cm = lv_oboo_obj_get_card_manager();
  402. int currentCard = (int)ob_cardview_get_card_act(cm);
  403. int highestIdx = (int)ob_cardview_get_card_count(cm) - 1;
  404. // configure which card is going to be active (if move is valid)
  405. if (strcmp(direction, "left") == 0) {
  406. if (currentCard != 0) {
  407. targetIdx = currentCard - 1;
  408. } else {
  409. // loop around - go to last card
  410. targetIdx = highestIdx;
  411. }
  412. }
  413. else if (strcmp(direction, "right") == 0) {
  414. if (currentCard != highestIdx) {
  415. targetIdx = currentCard + 1;
  416. } else {
  417. // loop around - go to first card
  418. targetIdx = 0;
  419. }
  420. }
  421. else if (strcmp(direction, "first") == 0) {
  422. targetIdx = 0;
  423. }
  424. else if (strcmp(direction, "last") == 0) {
  425. targetIdx = highestIdx;
  426. }
  427. // change the active card
  428. lv_ob_set_active_card(targetIdx);
  429. // grab the free_num of the active card
  430. targetIdx = ob_cardview_get_card_act_fn(cm);
  431. return targetIdx;
  432. }
  433. void lv_ob_set_status(char* statusIdx, int statusValue) {
  434. // get the statusbar
  435. lv_obj_t *sb = lv_oboo_obj_get_status_bar();
  436. if (sb != NULL) {
  437. ob_statusbar_ext_t *ext = lv_obj_get_ext_attr(sb);
  438. if (ext != NULL) {
  439. if (strcmp(statusIdx, "alarm") == 0) {
  440. ext->bAlarm = statusValue;
  441. }
  442. else if (strcmp(statusIdx, "bluetooth") == 0) {
  443. ext->bBluetooth = statusValue;
  444. }
  445. else if (strcmp(statusIdx, "wifi") == 0) {
  446. ext->bWifi = statusValue;
  447. }
  448. else if (strcmp(statusIdx, "battery") == 0) {
  449. ext->batteryLevel = statusValue;
  450. }
  451. }
  452. }
  453. lv_ob_statusbar_update();
  454. }
  455. /* update functions */
  456. void lv_ob_statusbar_update () {
  457. char buf[64];
  458. // get the statusbar
  459. lv_obj_t *sb = lv_oboo_obj_get_status_bar();
  460. lv_obj_t *sbLabel = NULL;
  461. if (sb != NULL) {
  462. ob_statusbar_ext_t *ext = lv_obj_get_ext_attr(sb);
  463. if (ext != NULL) {
  464. // build the left side status
  465. strcpy(buf, "");
  466. if (ext->bAlarm > 0) {
  467. strcat(buf, SYMBOL_BELL);
  468. // TODO: add alarm text here as well
  469. }
  470. // set the left status
  471. sbLabel = lv_obj_get_child_back(sb, NULL);
  472. lv_label_set_text(sbLabel, buf);
  473. lv_obj_align(sbLabel, NULL, LV_ALIGN_IN_LEFT_MID, 2, 0);
  474. // build the right side status
  475. strcpy(buf, "");
  476. if (ext->bBluetooth > 0) {
  477. strcat(buf, SYMBOL_BLUETOOTH);
  478. }
  479. if (ext->bWifi > 0) {
  480. strcat(buf, " ");
  481. strcat(buf, SYMBOL_WIFI);
  482. }
  483. if (ext->batteryLevel >= 0) {
  484. strcat(buf, " ");
  485. switch (ext->batteryLevel) {
  486. case 0:
  487. strcat(buf, SYMBOL_BATTERY_EMPTY);
  488. break;
  489. case 1:
  490. strcat(buf, SYMBOL_BATTERY_1);
  491. break;
  492. case 2:
  493. strcat(buf, SYMBOL_BATTERY_2);
  494. break;
  495. case 3:
  496. strcat(buf, SYMBOL_BATTERY_3);
  497. break;
  498. default:
  499. strcat(buf, SYMBOL_BATTERY_FULL);
  500. break;
  501. }
  502. }
  503. // set the right status
  504. sbLabel = lv_obj_get_child_back(sb, sbLabel);
  505. lv_label_set_text(sbLabel, buf);
  506. lv_obj_align(sbLabel, NULL, LV_ALIGN_IN_RIGHT_MID, -5, 0);
  507. }
  508. }
  509. }
  510. int lv_ob_set_active_card(int targetIdx) {
  511. lv_obj_t *cm;
  512. // only change the active card if the move is valid
  513. if (targetIdx >= 0) {
  514. cm = lv_oboo_obj_get_card_manager();
  515. printf("> new active card is index %d\n", targetIdx);
  516. ob_cardview_set_card_act(cm, targetIdx, true);
  517. return targetIdx;
  518. }
  519. return -1;
  520. }
  521. // returns 1 if card exists
  522. int lv_ob_check_card_exists(int cardId) {
  523. // get the card
  524. lv_obj_t *card = ob_cardview_get_card(lv_oboo_obj_get_card_manager(), cardId);
  525. if (card != NULL) {
  526. return 1;
  527. }
  528. return 0;
  529. }
  530. /* removal functions */
  531. void _lv_remove_splash_screen () {
  532. #if OB_SPLASH_SCREEN_ENABLED == 1
  533. lv_obj_t* itr = NULL;
  534. // loop through objects in screen, check for splash screen ID, remove it if found
  535. while(1) {
  536. itr = lv_obj_get_child_back (lv_scr_act(), itr);
  537. if (itr != NULL) {
  538. if (lv_obj_get_free_num(itr) == OB_SPLASH_SCREEN_OBJ_ID) {
  539. lv_obj_del(itr);
  540. }
  541. } else {
  542. break;
  543. }
  544. }
  545. #endif // OB_SPLASH_SCREEN_ENABLED
  546. }