show_animation_common.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein is
  5. * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
  6. * the prior written permission of MediaTek inc. and/or its licensors, any
  7. * reproduction, modification, use or disclosure of MediaTek Software, and
  8. * information contained herein, in whole or in part, shall be strictly
  9. * prohibited.
  10. *
  11. * MediaTek Inc. (C) 2010. All rights reserved.
  12. *
  13. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  14. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  15. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
  16. * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
  17. * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
  19. * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
  20. * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
  21. * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
  22. * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
  23. * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
  24. * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
  25. * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
  26. * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  27. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
  28. * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
  29. * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
  30. * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
  31. * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  32. *
  33. * The following software/firmware and/or related documentation ("MediaTek
  34. * Software") have been modified by MediaTek Inc. All revisions are subject to
  35. * any receiver's applicable license agreements with MediaTek Inc.
  36. */
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include "show_animation_common.h"
  41. #include "show_logo_log.h"
  42. static int charging_low_index = 0;
  43. static int charging_animation_index = 0;
  44. static int version0_charging_index = 0;
  45. static int bits = 0;
  46. static int is_logo = 1;
  47. static int logo_offset = -1;
  48. static void *g_dec_logo_addr = NULL;
  49. #define CHECK_LOGO_BIN_OK 0
  50. #define CHECK_LOGO_BIN_ERROR -1
  51. static unsigned short number_pic_addr[(NUMBER_RIGHT - NUMBER_LEFT)*(NUMBER_BOTTOM - NUMBER_TOP)*4] = {0x0}; //addr
  52. static unsigned short line_pic_addr[(TOP_ANIMATION_RIGHT - TOP_ANIMATION_LEFT)*4] = {0x0};
  53. static unsigned short percent_pic_addr[(PERCENT_RIGHT - PERCENT_LEFT)*(PERCENT_BOTTOM - PERCENT_TOP)*4] = {0x0};
  54. static unsigned short top_animation_addr[(TOP_ANIMATION_RIGHT - TOP_ANIMATION_LEFT)*(TOP_ANIMATION_BOTTOM - TOP_ANIMATION_TOP)*4] = {0x0};
  55. /*
  56. * Check whether logo.bin is loaded or not. Avoid error in META mode
  57. * enable : logo.bin needs to be loaded or not
  58. */
  59. void enable_logo(bool enable)
  60. {
  61. is_logo = enable;
  62. }
  63. /*
  64. * Check logo.bin address if valid, and get logo related info
  65. *
  66. */
  67. int check_logo_index_valid(unsigned int index, void * logo_addr, LOGO_PARA_T * logo_info)
  68. {
  69. if (!is_logo) {
  70. return CHECK_LOGO_BIN_ERROR;
  71. }
  72. unsigned int *pinfo = (unsigned int*)logo_addr;
  73. logo_info->logonum = pinfo[0];
  74. LOG_ANIM("[show_animation_common: %s %d]logonum =%d, index =%d\n", __FUNCTION__,__LINE__,logo_info->logonum, index);
  75. if (index >= logo_info->logonum)
  76. {
  77. LOG_ANIM("[show_animation_common: %s %d]unsupported logo, index =%d\n", __FUNCTION__,__LINE__, index);
  78. return CHECK_LOGO_BIN_ERROR;
  79. }
  80. // LOG_ANIM("show_animation_common, pinfo[1]=%d, pinfo[2+index]=%d, pinfo[3+index]=%d, pinfo[3+index] - pinfo[2+index]= %d, pinfo[1] - pinfo[2+index] =%d \n",
  81. // pinfo[1],pinfo[2+index],pinfo[3+index], pinfo[3+index] - pinfo[2+index],pinfo[1] - pinfo[2+index]);
  82. if(index < logo_info->logonum - 1)
  83. logo_info->logolen = pinfo[3+index] - pinfo[2+index];
  84. else
  85. logo_info->logolen = pinfo[1] - pinfo[2+index];
  86. logo_info->inaddr = (unsigned int)logo_addr + pinfo[2+index];
  87. LOG_ANIM("show_animation_common, in_addr=0x%08x, logolen=%d\n",
  88. logo_info->inaddr, logo_info->logolen);
  89. return CHECK_LOGO_BIN_OK;
  90. }
  91. int get_total_logo_images_entries(void)
  92. {
  93. int total_logo_entries = 0;
  94. total_logo_entries = LOGOS_COUNT_NORMAL;
  95. #if defined(MTK_PUMP_EXPRESS_SUPPORT) || defined(MTK_PUMP_EXPRESS_PLUS_SUPPORT)
  96. total_logo_entries += LOGOS_COUNT_FAST_CHARGING;
  97. #endif
  98. #if defined(MTK_WIRELESS_CHARGER_SUPPORT)
  99. total_logo_entries += LOGOS_COUNT_WIRELESS;
  100. #endif
  101. return total_logo_entries;
  102. }
  103. int calculate_logo_offset(unsigned int index, void * dec_logo_addr,
  104. void * logo_addr, LCM_SCREEN_T phical_screen)
  105. {
  106. LOGO_PARA_T logo_info;
  107. int logo_width = phical_screen.width;
  108. int logo_height = phical_screen.height;
  109. int raw_data_size;
  110. unsigned int *pinfo;
  111. unsigned int logo_index = index;
  112. unsigned int total_logo_entries = 0;
  113. if(logo_offset != -1)
  114. return logo_offset;
  115. pinfo = (unsigned int*)logo_addr;
  116. logo_offset = 0;
  117. total_logo_entries = get_total_logo_images_entries();
  118. LOG_ANIM("[calculate_logo_offset: %s %d]pinfo[0] = %d\n",__FUNCTION__,__LINE__, pinfo[0]);
  119. LOG_ANIM("[calculate_logo_offset: %s %d]TOTAL_LOG0_COUNT = %d\n",__FUNCTION__,__LINE__,
  120. total_logo_entries);
  121. if(total_logo_entries == pinfo[0]){
  122. return logo_offset;
  123. }
  124. while(logo_index <= pinfo[0]){
  125. if(check_logo_index_valid(logo_index, logo_addr, &logo_info) != CHECK_LOGO_BIN_OK){
  126. LOG_ANIM("[calculate_logo_offset: %s %d][Error]Logo resolution not correct",
  127. __FUNCTION__,__LINE__);
  128. logo_offset = -1;
  129. return -1;
  130. }
  131. raw_data_size = decompress_logo((void*)logo_info.inaddr, dec_logo_addr, logo_info.logolen,
  132. phical_screen.fb_size);
  133. LOG_ANIM("[calculate_logo_offset: %s %d]Width = %d\n Height = %d\n raw_data_size = %d\n",
  134. __FUNCTION__,__LINE__, logo_width, logo_height, raw_data_size);
  135. if (raw_data_size == logo_width*logo_height*4) {
  136. bits = 32;
  137. break;
  138. } else if (raw_data_size == logo_width*logo_height*2) {
  139. bits = 16;
  140. break;
  141. } else {
  142. logo_offset += total_logo_entries;// Add number of logos entries
  143. logo_index += total_logo_entries;
  144. }
  145. LOG_ANIM("[calculate_logo_offset: %s %d]bits = %d\n",__FUNCTION__,__LINE__, bits);
  146. }
  147. LOG_ANIM("[calculate_logo_offset: %s %d]logo_offset = %d\n",__FUNCTION__,__LINE__, logo_offset);
  148. return logo_offset;
  149. }
  150. /*
  151. * Fill a screen size buffer with logo content
  152. *
  153. */
  154. void fill_animation_logo(unsigned int index, void *fill_addr, void * dec_logo_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
  155. {
  156. LOGO_PARA_T logo_info;
  157. int logo_width;
  158. int logo_height;
  159. int raw_data_size;
  160. int logo_index = index;
  161. int logo_offset = -1;
  162. g_dec_logo_addr = dec_logo_addr;
  163. logo_offset = calculate_logo_offset(index, dec_logo_addr, logo_addr, phical_screen);
  164. if(logo_offset == -1){
  165. return;
  166. }
  167. logo_index = logo_index + logo_offset;
  168. if(check_logo_index_valid(logo_index, logo_addr, &logo_info) != CHECK_LOGO_BIN_OK)
  169. return;
  170. raw_data_size = decompress_logo((void*)logo_info.inaddr, dec_logo_addr, logo_info.logolen, phical_screen.fb_size);
  171. //RECT_REGION_T rect = {0, 0, phical_screen.width, phical_screen.height};
  172. logo_width =phical_screen.width;
  173. logo_height = phical_screen.height;
  174. if (phical_screen.rotation == 270 || phical_screen.rotation == 90) {
  175. logo_width =phical_screen.height;
  176. logo_height = phical_screen.width;
  177. }
  178. LOG_ANIM("[show_animation_common: %s %d]Width = %d\n Height = %d\n raw_data_size = %d\n",__FUNCTION__,__LINE__, logo_width, logo_height, raw_data_size);
  179. if (0 == bits) {
  180. if (raw_data_size == logo_width*logo_height*4) {
  181. bits = 32;
  182. } else if (raw_data_size == logo_width*logo_height*2) {
  183. bits = 16;
  184. } else {
  185. LOG_ANIM("[show_animation_common: %s %d]Logo data error\n",__FUNCTION__,__LINE__);
  186. return;
  187. }
  188. LOG_ANIM("[show_animation_common: %s %d]bits = %d\n",__FUNCTION__,__LINE__, bits);
  189. }
  190. RECT_REGION_T rect = {0, 0, logo_width, logo_height};
  191. fill_rect_with_content(fill_addr, rect, dec_logo_addr, phical_screen, bits);
  192. }
  193. /*
  194. * Fill a rectangle size address with special color
  195. *
  196. */
  197. void fill_animation_prog_bar(RECT_REGION_T rect_bar,
  198. unsigned int fgColor,
  199. unsigned int start_div, unsigned int occupied_div,
  200. void *fill_addr, LCM_SCREEN_T phical_screen)
  201. {
  202. unsigned int div_size = (rect_bar.bottom - rect_bar.top) / (ANIM_V0_REGIONS);
  203. unsigned int draw_size = div_size - (ANIM_V0_SPACE_AFTER_REGION);
  204. unsigned int i;
  205. for (i = start_div; i < start_div + occupied_div; ++ i)
  206. {
  207. unsigned int draw_bottom = rect_bar.bottom - div_size * i - (ANIM_V0_SPACE_AFTER_REGION);
  208. unsigned int draw_top = draw_bottom - draw_size;
  209. RECT_REGION_T rect = {rect_bar.left, draw_top, rect_bar.right, draw_bottom};
  210. fill_rect_with_color(fill_addr, rect, fgColor, phical_screen);
  211. }
  212. }
  213. /*
  214. * Fill a rectangle with logo content
  215. *
  216. */
  217. void fill_animation_dynamic(unsigned int index, RECT_REGION_T rect, void *fill_addr, void * dec_logo_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
  218. {
  219. LOGO_PARA_T logo_info;
  220. int raw_data_size;
  221. int logo_index = index;
  222. int logo_offset = 0;
  223. g_dec_logo_addr = dec_logo_addr;
  224. logo_offset = calculate_logo_offset(index, dec_logo_addr, logo_addr, phical_screen);
  225. if(logo_offset == -1){
  226. return;
  227. }
  228. logo_index = logo_index + logo_offset;
  229. if(check_logo_index_valid(logo_index, logo_addr, &logo_info) != CHECK_LOGO_BIN_OK)
  230. return;
  231. raw_data_size = decompress_logo((void*)logo_info.inaddr, (void*)dec_logo_addr, logo_info.logolen, (rect.right-rect.left)*(rect.bottom-rect.top)*4);
  232. if (0 == bits) {
  233. if (raw_data_size == (rect.right-rect.left)*(rect.bottom-rect.top)*4) {
  234. bits = 32;
  235. } else if (raw_data_size == (rect.right-rect.left)*(rect.bottom-rect.top)*2) {
  236. bits = 16;
  237. } else {
  238. LOG_ANIM("[show_animation_common: %s %d]Logo data error\n",__FUNCTION__,__LINE__);
  239. return;
  240. }
  241. LOG_ANIM("[show_animation_common: %s %d]bits = %d\n",__FUNCTION__,__LINE__, bits);
  242. }
  243. fill_rect_with_content(fill_addr, rect, dec_logo_addr, phical_screen, bits);
  244. }
  245. /*
  246. * Fill a rectangle with number logo content
  247. *
  248. * number_position: 0~1st number, 1~2nd number
  249. */
  250. void fill_animation_number(unsigned int index, unsigned int number_position, void *fill_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
  251. {
  252. LOG_ANIM("[show_animation_common: %s %d]index= %d, number_position = %d\n",__FUNCTION__,__LINE__, index, number_position);
  253. LOGO_PARA_T logo_info;
  254. int raw_data_size;
  255. int logo_index = index;
  256. int logo_offset = 0;
  257. logo_offset = calculate_logo_offset(index, g_dec_logo_addr, logo_addr, phical_screen);
  258. if(logo_offset == -1){
  259. return;
  260. }
  261. logo_index = logo_index + logo_offset;
  262. if(check_logo_index_valid(logo_index, logo_addr, &logo_info) != CHECK_LOGO_BIN_OK)
  263. return;
  264. // draw default number rect,
  265. raw_data_size = decompress_logo((void*)logo_info.inaddr, (void*)number_pic_addr, logo_info.logolen, number_pic_size);
  266. //static RECT_REGION_T number_location_rect = {NUMBER_LEFT,NUMBER_TOP,NUMBER_RIGHT,NUMBER_BOTTOM};
  267. RECT_REGION_T battery_number_rect = {NUMBER_LEFT + (NUMBER_RIGHT - NUMBER_LEFT)*number_position,
  268. NUMBER_TOP,
  269. NUMBER_RIGHT + (NUMBER_RIGHT - NUMBER_LEFT)*number_position,
  270. NUMBER_BOTTOM};
  271. if (0 == bits) {
  272. if (raw_data_size == (NUMBER_RIGHT - NUMBER_LEFT)*(NUMBER_BOTTOM - NUMBER_TOP)*4) {
  273. bits = 32;
  274. } else if (raw_data_size == (NUMBER_RIGHT - NUMBER_LEFT)*(NUMBER_BOTTOM - NUMBER_TOP)*2) {
  275. bits = 16;
  276. } else {
  277. LOG_ANIM("[show_animation_common: %s %d]Logo data error\n",__FUNCTION__,__LINE__);
  278. return;
  279. }
  280. LOG_ANIM("[show_animation_common: %s %d]bits = %d\n",__FUNCTION__,__LINE__, bits);
  281. }
  282. fill_rect_with_content(fill_addr, battery_number_rect, number_pic_addr,phical_screen, bits);
  283. }
  284. /*
  285. * Fill a line with special color
  286. *
  287. */
  288. void fill_animation_line(unsigned int index, unsigned int capacity_grids, void *fill_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
  289. {
  290. LOGO_PARA_T logo_info;
  291. int raw_data_size;
  292. int logo_index = index;
  293. int logo_offset = 0;
  294. logo_offset = calculate_logo_offset(index, g_dec_logo_addr, logo_addr, phical_screen);
  295. if(logo_offset == -1){
  296. return;
  297. }
  298. logo_index = logo_index + logo_offset;
  299. if(check_logo_index_valid(logo_index, logo_addr, &logo_info) != CHECK_LOGO_BIN_OK)
  300. return;
  301. raw_data_size = decompress_logo((void*)logo_info.inaddr, (void*)line_pic_addr, logo_info.logolen, line_pic_size);
  302. if (0 == bits) {
  303. if (raw_data_size == (TOP_ANIMATION_RIGHT - TOP_ANIMATION_LEFT)*4) {
  304. bits = 32;
  305. } else if (raw_data_size == (TOP_ANIMATION_RIGHT - TOP_ANIMATION_LEFT)*2) {
  306. bits = 16;
  307. } else {
  308. LOG_ANIM("[show_animation_common: %s %d]Logo data error\n",__FUNCTION__,__LINE__);
  309. return;
  310. }
  311. LOG_ANIM("[show_animation_common: %s %d]bits = %d\n",__FUNCTION__,__LINE__, bits);
  312. }
  313. RECT_REGION_T rect = {CAPACITY_LEFT, CAPACITY_TOP, CAPACITY_RIGHT, CAPACITY_BOTTOM};
  314. int i = capacity_grids;
  315. for(; i < CAPACITY_BOTTOM; i++)
  316. {
  317. rect.top = i;
  318. rect.bottom = i+1;
  319. fill_rect_with_content(fill_addr, rect, line_pic_addr, phical_screen, bits);
  320. }
  321. }
  322. /*
  323. * Show old charging animation
  324. *
  325. */
  326. void fill_animation_battery_old(unsigned int capacity, void *fill_addr, void * dec_logo_addr, void * logo_addr,
  327. LCM_SCREEN_T phical_screen)
  328. {
  329. int capacity_grids = 0;
  330. if (capacity > 100) capacity = 100;
  331. capacity_grids = (capacity * (ANIM_V0_REGIONS)) / 100;
  332. if (version0_charging_index < capacity_grids * 2)
  333. version0_charging_index = capacity_grids * 2;
  334. if (capacity < 100){
  335. version0_charging_index > 7? version0_charging_index = capacity_grids * 2 : version0_charging_index++;
  336. } else {
  337. version0_charging_index = ANIM_V0_REGIONS * 2;
  338. }
  339. fill_animation_logo(ANIM_V0_BACKGROUND_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  340. RECT_REGION_T rect_bar = {bar_rect.left + 1, bar_rect.top + 1, bar_rect.right, bar_rect.bottom};
  341. fill_animation_prog_bar(rect_bar,
  342. (unsigned int)(BAR_OCCUPIED_COLOR),
  343. 0, version0_charging_index/2,
  344. fill_addr, phical_screen);
  345. fill_animation_prog_bar(rect_bar,
  346. (unsigned int)(BAR_EMPTY_COLOR),
  347. version0_charging_index/2, ANIM_V0_REGIONS - version0_charging_index/2,
  348. fill_addr, phical_screen);
  349. }
  350. /*
  351. * Show new charging animation
  352. *
  353. */
  354. void fill_animation_battery_new(unsigned int capacity, void *fill_addr, void * dec_logo_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
  355. {
  356. LOG_ANIM("[show_animation_common: %s %d]capacity : %d\n",__FUNCTION__,__LINE__, capacity);
  357. if (capacity >= 100) {
  358. //show_logo(37); // battery 100
  359. fill_animation_logo(FULL_BATTERY_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  360. } else if (capacity < 10) {
  361. LOG_ANIM("[show_animation_common: %s %d]charging_low_index = %d\n",__FUNCTION__,__LINE__, charging_low_index);
  362. charging_low_index ++ ;
  363. fill_animation_logo(LOW_BAT_ANIM_START_0 + charging_low_index, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  364. fill_animation_number(NUMBER_PIC_START_0 + capacity, 1, fill_addr, logo_addr, phical_screen);
  365. fill_animation_dynamic(NUMBER_PIC_PERCENT, percent_location_rect, fill_addr, percent_pic_addr, logo_addr, phical_screen);
  366. if (charging_low_index >= 9) charging_low_index = 0;
  367. } else {
  368. unsigned int capacity_grids = 0;
  369. //static RECT_REGION_T battery_rect = {CAPACITY_LEFT,CAPACITY_TOP,CAPACITY_RIGHT,CAPACITY_BOTTOM};
  370. capacity_grids = CAPACITY_BOTTOM - (CAPACITY_BOTTOM - CAPACITY_TOP) * (capacity - 10) / 90;
  371. LOG_ANIM("[show_animation_common: %s %d]capacity_grids : %d,charging_animation_index = %d\n",__FUNCTION__,__LINE__, capacity_grids,charging_animation_index);
  372. //background
  373. fill_animation_logo(ANIM_V1_BACKGROUND_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  374. fill_animation_line(ANIM_LINE_INDEX, capacity_grids, fill_addr, logo_addr, phical_screen);
  375. fill_animation_number(NUMBER_PIC_START_0 + (capacity/10), 0, fill_addr, logo_addr, phical_screen);
  376. fill_animation_number(NUMBER_PIC_START_0 + (capacity%10), 1, fill_addr, logo_addr, phical_screen);
  377. fill_animation_dynamic(NUMBER_PIC_PERCENT, percent_location_rect, fill_addr, percent_pic_addr, logo_addr, phical_screen);
  378. if (capacity <= 90)
  379. {
  380. RECT_REGION_T top_animation_rect = {TOP_ANIMATION_LEFT, capacity_grids - (TOP_ANIMATION_BOTTOM - TOP_ANIMATION_TOP), TOP_ANIMATION_RIGHT, capacity_grids};
  381. //top_animation_rect.bottom = capacity_grids;
  382. //top_animation_rect.top = capacity_grids - top_animation_height;
  383. charging_animation_index++;
  384. //show_animation_dynamic(15 + charging_animation_index, top_animation_rect, top_animation_addr);
  385. fill_animation_dynamic(BAT_ANIM_START_0 + charging_animation_index, top_animation_rect, fill_addr, top_animation_addr, logo_addr, phical_screen);
  386. if (charging_animation_index >= 9) charging_animation_index = 0;
  387. }
  388. }
  389. }
  390. /*
  391. * Show wireless charging animation
  392. * total 29 logo:from 39 ~ 68
  393. * less(0<10): 50-53 , low(<30):54-57 ,middle(<60):58-61 , high():62-75 , o:66, full:67,num (0-9):39-48, %:49
  394. *
  395. */
  396. void fill_animation_battery_wireless_charging(unsigned int capacity, void *fill_addr, void * dec_logo_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
  397. {
  398. LOG_ANIM("[show_animation_common: %s %d]capacity : %d\n",__FUNCTION__,__LINE__, capacity);
  399. // RECT_REGION_T wireless_bgd_rect = {0, 0, phical_screen.width, phical_screen.height};
  400. charging_low_index >= 3? charging_low_index = 0:charging_low_index++;
  401. LOG_ANIM("[show_animation_common: %s %d]charging_low_index = %d\n",__FUNCTION__,__LINE__, charging_low_index);
  402. if (capacity >= 100) {
  403. // battery 100
  404. fill_animation_logo(V2_BAT_100_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  405. } else if (capacity <= 0) {
  406. fill_animation_logo(V2_BAT_0_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  407. } else {
  408. int bg_index = V2_BAT_0_10_START_INDEX; //capacity > 0 && capacity < 10
  409. if (capacity >= 10 && capacity < 40) {
  410. bg_index = V2_BAT_10_40_START_INDEX;
  411. } else if (capacity >= 40 && capacity < 80) {
  412. bg_index = V2_BAT_40_80_START_INDEX;
  413. } else if (capacity >= 80 && capacity < 100) {
  414. bg_index = V2_BAT_80_100_START_NDEX;
  415. }
  416. fill_animation_logo(bg_index + charging_low_index, fill_addr, dec_logo_addr, logo_addr,phical_screen);
  417. RECT_REGION_T tmp_rect = {(int)phical_screen.width * 4/10,
  418. (int) phical_screen.height * 1/6,
  419. (int)phical_screen.width* 5/10,
  420. (int)phical_screen.height*16/60};
  421. unsigned short tmp_num_addr[(int)phical_screen.width * phical_screen.height/100]; //addr
  422. if (capacity >= 10) {
  423. LOG_ANIM("[show_animation_common: %s %d]tmp_rect left = %d, right = %d,top = %d,bottom = %d,\n",__FUNCTION__,__LINE__,
  424. tmp_rect.left,tmp_rect.right,tmp_rect.top,tmp_rect.bottom);
  425. fill_animation_dynamic(V2_NUM_START_0_INDEX + (capacity/10), tmp_rect, fill_addr, tmp_num_addr, logo_addr, phical_screen);
  426. tmp_rect.left += (int)phical_screen.width /10;
  427. tmp_rect.right += (int)phical_screen.width /10;
  428. }
  429. LOG_ANIM("[show_animation_common: %s %d]tmp_rect left = %d, right = %d,top = %d,bottom = %d,\n",__FUNCTION__,__LINE__,
  430. tmp_rect.left,tmp_rect.right,tmp_rect.top,tmp_rect.bottom);
  431. fill_animation_dynamic(V2_NUM_START_0_INDEX + (capacity%10), tmp_rect, fill_addr, tmp_num_addr, logo_addr, phical_screen);
  432. tmp_rect.left += (int)phical_screen.width /10;
  433. tmp_rect.right += (int)phical_screen.width /10;
  434. LOG_ANIM("[show_animation_common: %s %d]tmp_rect left = %d, right = %d,top = %d,bottom = %d,\n",__FUNCTION__,__LINE__,
  435. tmp_rect.left,tmp_rect.right,tmp_rect.top,tmp_rect.bottom);
  436. fill_animation_dynamic(V2_NUM_PERCENT_INDEX, tmp_rect, fill_addr, tmp_num_addr, logo_addr, phical_screen);
  437. }
  438. }
  439. /*
  440. * Show charging animation by version
  441. *
  442. */
  443. void fill_animation_battery_by_ver(unsigned int capacity,void *fill_addr, void * dec_logo_addr, void * logo_addr,
  444. LCM_SCREEN_T phical_screen, int version)
  445. {
  446. LOG_ANIM("[show_animation_common: %s %d]version : %d\n",__FUNCTION__,__LINE__, version);
  447. switch (version)
  448. {
  449. case VERION_OLD_ANIMATION:
  450. fill_animation_battery_old(capacity, fill_addr, dec_logo_addr, logo_addr, phical_screen);
  451. break;
  452. case VERION_NEW_ANIMATION:
  453. fill_animation_battery_new(capacity, fill_addr, dec_logo_addr, logo_addr, phical_screen);
  454. break;
  455. case VERION_WIRELESS_CHARGING_ANIMATION:
  456. fill_animation_battery_wireless_charging(capacity, fill_addr, dec_logo_addr, logo_addr, phical_screen);
  457. break;
  458. default:
  459. fill_animation_battery_old(capacity, fill_addr, dec_logo_addr, logo_addr, phical_screen);
  460. break;
  461. }
  462. }