Android 8.1 關(guān)機(jī)充電動(dòng)畫(二)Uboot模式

      網(wǎng)友投稿 1390 2025-04-03

      system:Android 8.1


      platform:RK3326/PX30

      uboot

      kernel

      Android 8.1 關(guān)機(jī)充電動(dòng)畫(一)模式選擇

      Android 8.1 關(guān)機(jī)充電動(dòng)畫(二)Uboot模式

      Android 8.1 關(guān)機(jī)充電動(dòng)畫(三)Android模式

      文章目錄

      前言

      相關(guān)文檔

      相關(guān)代碼

      總結(jié)

      附錄

      前言

      這部分要涉及到uboot下關(guān)機(jī)充電動(dòng)畫的定制,屬于比較low level的部分,所以代碼修改的部分不大,在uboot中主要是對(duì)多張圖片進(jìn)行輪播,所以這里的主要工作是定位到相應(yīng)的代碼以及如何定制自己的動(dòng)畫。

      相關(guān)文檔

      RK在uboot的開(kāi)發(fā)方面已經(jīng)給出了文檔,

      其中已經(jīng)包括了這部分動(dòng)畫如何打包到rom中,不可避免的是需要重新編譯uboot,但是圖片會(huì)被打包到resource.img中。

      相關(guān)代碼

      重新回到代碼中u-boot/drivers/power/charge_animation.c

      struct charge_image { const char *name; int soc; int period; /* ms */ }; /* * IF you want to use your own charge images, please: * * 1. Update the following 'image[]' to point to your own images; * 2. You must set the failed image as last one and soc = -1 !!! */ static const struct charge_image image[] = { { .name = "battery_0.bmp", .soc = 5, .period = 600 }, { .name = "battery_1.bmp", .soc = 20, .period = 600 }, { .name = "battery_2.bmp", .soc = 40, .period = 600 }, { .name = "battery_3.bmp", .soc = 60, .period = 600 }, { .name = "battery_4.bmp", .soc = 80, .period = 600 }, { .name = "battery_5.bmp", .soc = 100, .period = 600 }, { .name = "battery_fail.bmp", .soc = -1, .period = 1000 }, };

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      name :文件名

      soc:圖片對(duì)應(yīng)的電量百分比

      period:圖片顯示的時(shí)間(單位:ms)

      那么,這里問(wèn)題來(lái)了,圖片如何打包到固件里呢?

      先找到RK提供的打包用的腳本,u-boot/pack_resource.sh

      找到需要打包的圖片,然后需要修改的直接替換掉,圖片采用8bit或24bit bmp格式,圖片路徑:u-boot/tools/images/,如下圖所示:

      最終就是如何打包圖片了:

      cd u-boot && ./pack_resource.sh ../kernel/resource.img

      1

      執(zhí)行完以上命令后,終端會(huì)輸出以下信息,說(shuō)明打包成功;

      Pack ./tools/images/ & resource.img to resource.img ... Unpacking old image(resource.img): rk-kernel.dtb battery_1.bmp battery_2.bmp battery_3.bmp battery_4.bmp battery_5.bmp battery_fail.bmp logo.bmp logo_kernel.bmp battery_0.bmp Pack to resource.img successed! Packed resources: rk-kernel.dtb battery_1.bmp battery_2.bmp battery_3.bmp battery_4.bmp battery_5.bmp battery_fail.bmp logo.bmp logo_kernel.bmp battery_0.bmp resource.img is packed ready

      1

      2

      3

      4

      5

      6

      7

      并且會(huì)在當(dāng)前的路徑下重新生成resource.img,將這個(gè)文件重新燒寫到設(shè)備的對(duì)應(yīng)分區(qū),就可以把充電動(dòng)畫打包到設(shè)備的rom中了。

      總結(jié)

      簡(jiǎn)單介紹了RK平臺(tái)上進(jìn)行關(guān)機(jī)充電uboot模式下充電動(dòng)畫的定制和打包方法,篇幅較短,也可以參考RK官方的文檔,下一篇介紹一下,關(guān)機(jī)充電Android模式下如何進(jìn)行充電動(dòng)畫的修改。附錄是充電動(dòng)畫顯示的主要代碼。

      附錄

      下面的代碼是函數(shù)static int charge_animation_show(struct udevice *dev)中的while(1),這里會(huì)一直循環(huán)顯示充電圖片;

      /* Charging ! */ while (1) { /* * At the most time, fuel gauge is usually a i2c device, we * should avoid read/write all the time. We had better set * poll seconds to update fuel gauge info. */ if (!first_poll_fg && get_timer(delta) < FUEL_GAUGE_POLL_MS) goto show_images; delta = get_timer(0); debug("step1 (%d)... \n", screen_on); /* * Most fuel gauge is I2C interface, it shouldn't be interrupted * during tansfer. The power key event depends on interrupt, so * so we should disable local irq when update fuel gauge. */ local_irq_disable(); /* Step1: Is charging now ? */ charging = fuel_gauge_get_chrg_online(fg); if (charging <= 0) { printf("Not charging, online=%d. Shutdown...\n", charging); /* wait uart flush before shutdown */ mdelay(5); /* PMIC shutdown */ pmic_shutdown(pmic); printf("Cpu should never reach here, shutdown failed !\n"); continue; } debug("step2 (%d)... show_idx=%d\n", screen_on, show_idx); /* Step2: get soc and voltage */ soc = fuel_gauge_get_soc(fg); if (soc < 0 || soc > 100) { printf("get soc failed: %d\n", soc); continue; } voltage = fuel_gauge_get_voltage(fg); if (voltage < 0) { printf("get voltage failed: %d\n", voltage); continue; } current = fuel_gauge_get_current(fg); if (current == -ENOSYS) { printf("get current failed: %d\n", current); continue; } first_poll_fg = 0; local_irq_enable(); show_images: /* * Just for debug, otherwise there will be nothing output which * is not good to know what happen. */ if (!debug_start) debug_start = get_timer(0); if (get_timer(debug_start) > 20000) { debug_start = get_timer(0); printf("[%8ld]: soc=%d%%, vol=%dmv, c=%dma, online=%d, screen_on=%d\n", get_timer(0)/1000, soc, voltage, current, charging, screen_on); } /* * If ever lowpower screen off, force screen_on=false, which * means key event can't modify screen_on, only voltage higher * then threshold can update screen_on=true; */ if (ever_lowpower_screen_off) screen_on = false; /* * Auto turn on screen when voltage higher than Vol screen on. * 'ever_lowpower_screen_off' means enter while loop with * screen off. */ if ((ever_lowpower_screen_off) && (voltage > pdata->screen_on_voltage)) { ever_lowpower_screen_off = false; screen_on = true; show_idx = IMAGE_SHOW_RESET; } /* * IMAGE_SHOW_RESET means show_idx show be update by start_idx. * When short key pressed event trigged, we will set show_idx * as IMAGE_SHOW_RESET which updates images index from start_idx * that calculate by current soc. */ if (show_idx == IMAGE_SHOW_RESET) { for (i = 0; i < image_num - 2; i++) { /* Find out which image we start to show */ if ((soc >= image[i].soc) && (soc < image[i + 1].soc)) { start_idx = i; break; } if (soc >= 100) { start_idx = image_num - 2; break; } } debug("%s: show_idx=%d, screen_on=%d\n", __func__, show_idx, screen_on); /* Mark start index and start time */ show_idx = start_idx; show_start = get_timer(0); } debug("step3 (%d)... show_idx=%d\n", screen_on, show_idx); /* Step3: show images */ if (screen_on) { /* Don't call 'charge_show_bmp' unless image changed */ if (old_show_idx != show_idx) { old_show_idx = show_idx; debug("SHOW: %s\n", image[show_idx].name); charge_show_bmp(image[show_idx].name); } /* Re calculate timeout to off screen */ if (priv->auto_screen_off_timeout == 0) priv->auto_screen_off_timeout = get_timer(0); } else { priv->auto_screen_off_timeout = 0; system_suspend_enter(pdata); } mdelay(5); /* Every image shows period */ if (get_timer(show_start) > image[show_idx].period) { show_start = get_timer(0); /* Update to next image */ show_idx++; if (show_idx > (image_num - 2)) show_idx = IMAGE_SHOW_RESET; } debug("step4 (%d)... \n", screen_on); /* * Step4: check key event. * * Short key event: turn on/off screen; * Long key event: show logo and boot system or still charging. */ key_state = check_key_press(dev); if (key_state == KEY_PRESS_DOWN) { old_show_idx = IMAGE_SHOW_RESET; /* NULL means show nothing, ie. turn off screen */ if (screen_on) charge_show_bmp(NULL); /* * Clear current image index, and show image * from start_idx */ show_idx = IMAGE_SHOW_RESET; /* * We turn off screen by charge_show_bmp(NULL), so we * should tell while loop to stop show images any more. * * If screen_on=false, means this short key pressed * event turn on the screen and we need show images. * * If screen_on=true, means this short key pressed * event turn off the screen and we never show images. */ if (screen_on) screen_on = false; else screen_on = true; } else if (key_state == KEY_PRESS_LONG_DOWN) { /* Only long pressed while screen off needs screen_on true */ if (!screen_on) screen_on = true; /* Is able to boot now ? */ if (soc < pdata->exit_charge_level) { printf("soc=%d%%, threshold soc=%d%%\n", soc, pdata->exit_charge_level); printf("Low power, unable to boot, charging...\n"); show_idx = image_num - 1; continue; } if (voltage < pdata->exit_charge_voltage) { printf("voltage=%dmv, threshold voltage=%dmv\n", voltage, pdata->exit_charge_voltage); printf("Low power, unable to boot, charging...\n"); show_idx = image_num - 1; continue; } /* Success exit charging */ printf("Exit charge animation...\n"); charge_show_logo(); break; } else { /* Do nothing */ } debug("step5 (%d)... \n", screen_on); /* Step5: Exit by ctrl+c */ if (ctrlc()) { if (voltage >= pdata->screen_on_voltage) charge_show_logo(); printf("Exit charge, due to ctrl+c\n"); break; } }

      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

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      89

      90

      91

      92

      93

      94

      95

      96

      97

      98

      99

      100

      101

      102

      103

      104

      105

      106

      107

      108

      109

      110

      111

      112

      113

      114

      115

      116

      117

      Android 8.1 關(guān)機(jī)充電動(dòng)畫(二)Uboot模式

      118

      119

      120

      121

      122

      123

      124

      125

      126

      127

      128

      129

      130

      131

      132

      133

      134

      135

      136

      137

      138

      139

      140

      141

      142

      143

      144

      145

      146

      147

      148

      149

      150

      151

      152

      153

      154

      155

      156

      157

      158

      159

      160

      161

      162

      163

      164

      165

      166

      167

      168

      169

      170

      171

      172

      173

      174

      175

      176

      177

      178

      179

      180

      181

      182

      183

      184

      185

      186

      187

      188

      189

      190

      191

      192

      193

      194

      195

      196

      197

      198

      199

      200

      201

      202

      203

      204

      205

      206

      207

      208

      209

      210

      211

      212

      213

      214

      215

      216

      217

      218

      219

      220

      221

      222

      223

      224

      225

      226

      227

      228

      229

      230

      Android iPhone

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:HBase 2.0 中的 In-Memory Compaction
      下一篇:wps如何設(shè)置剪貼板
      相關(guān)文章
      亚洲va中文字幕无码久久不卡| 中文字幕第一页亚洲| 久久久亚洲精品无码| 国产成人麻豆亚洲综合无码精品| 美腿丝袜亚洲综合| 久久久无码精品亚洲日韩软件| 另类图片亚洲校园小说区| 久久亚洲精品无码av| 国产亚洲人成在线播放| 亚洲精品123区在线观看| 亚洲一区二区三区国产精品无码 | 国产91成人精品亚洲精品| 国产精品亚洲а∨无码播放不卡| 亚洲精品成a人在线观看夫| 亚洲专区一路线二| 亚洲国产最大av| 亚洲日本在线电影| 亚洲av无码偷拍在线观看| jjzz亚洲亚洲女人| 亚洲熟女乱综合一区二区| 国产日产亚洲系列| 亚洲AV日韩AV天堂久久| 亚洲AV无一区二区三区久久| 亚洲人成电影亚洲人成9999网| 亚洲AV本道一区二区三区四区| 色拍自拍亚洲综合图区| 337p日本欧洲亚洲大胆精品555588 | 亚洲国产精品lv| 亚洲性色高清完整版在线观看| 亚洲午夜在线一区| 亚洲色大成网站www久久九| 亚洲.国产.欧美一区二区三区| 亚洲成片观看四虎永久| 三上悠亚亚洲一区高清| 久久久久亚洲AV成人无码网站| 亚洲成人在线免费观看| 亚洲狠狠婷婷综合久久蜜芽| 亚洲国产成人精品91久久久 | 亚洲永久在线观看| 欧美亚洲国产SUV| 伊人婷婷综合缴情亚洲五月|