Skip to content

Commit

Permalink
for raspberrypi 19296 movie play
Browse files Browse the repository at this point in the history
  • Loading branch information
WHJWNAVY committed Dec 7, 2019
1 parent a236d48 commit fb46f91
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 123 deletions.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,42 @@

![JLX19296G-382-PN_03](doc/JLX19296G-382-PN_03.jpg)

![JLX19296G-382-PN_04](doc/JLX19296G-382-PN_04.jpg)
![JLX19296G-382-PN_04](doc/JLX19296G-382-PN_04.jpg)

> USAGE
```bash
Usage: ./main <file-path>...
Options:
-h,--help -- Show this help message.
-f FILE_PATH,--file=FILE_PATH -- Lcd Movie Player File.
-l LOOP_TIMES,--loop=LOOP_TIMES -- Loop Number Of Times.
```

> Example
```bash
# time ./main -f nokia_lumia_925.mp4_170x96_25fps_875frame_2bit.bin -l 2
DEBUG: [main:98] MSG:Play Movie [nokia_lumia_925.mp4_170x96_25fps_875frame_2bit.bin] Loop Times [2].
DEBUG: [bmp_debug:42] MSG:video_width[1920]
DEBUG: [bmp_debug:43] MSG:video_height[1080]
DEBUG: [bmp_debug:44] MSG:lcd_width[170]
DEBUG: [bmp_debug:45] MSG:lcd_height[96]
DEBUG: [bmp_debug:46] MSG:video_fps[25]
DEBUG: [bmp_debug:47] MSG:video_frame[875]
DEBUG: [bmp_debug:48] MSG:pixel_bit[2]
DEBUG: [bmp_debug:49] MSG:video_fps[25]
DEBUG: [bmp_debug:51] MSG:IMG_FRAME_WIDTH[24]
DEBUG: [bmp_debug:52] MSG:IMG_FRAME_LEN[4080]
DEBUG: [bmp_debug:53] MSG:IMG_FILE_LEN[3570000]
DEBUG: [bmp_debug:54] MSG:IMG_FRAME_WIDTH[24]
DEBUG: [bmp_show:209] MSG:Waiting [40]ms ...
DEBUG: [bmp_show:209] MSG:Waiting [48]ms ...
DEBUG: [bmp_show:209] MSG:Waiting [48]ms ...
......
DEBUG: [main:115] MSG:Play Movie [nokia_lumia_925.mp4_170x96_25fps_875frame_2bit.bin] End.

real 1m10.859s
user 0m28.837s
sys 0m0.110s
```
15 changes: 6 additions & 9 deletions src/bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef struct lcd_img_hdr_s
int32_t pixel_bit; //每个像素点所占的bit
} lcd_img_hdr_t;

#define IMG_FRAME_DELAY (10) //16.75ms
#define IMG_FRAME_DELAY (24)

#define IMG_HDR_FLAG (0x4649564c) //"LVIF"

Expand Down Expand Up @@ -189,24 +189,21 @@ int32_t bmp_show(int32_t x0, int32_t y0, int32_t colour)
}

bmp_buff = (BMP_FILE_BUFF + (frame * IMG_FRAME_LEN));
#if 1
#if 1 // Center
x0 = ((LCD_MAX_X - IMG_HDR.lcd_width) / 2) - 1;
y0 = ((LCD_MAX_Y - IMG_HDR.lcd_height) / 2) - 1;
// y0 = ((LCD_MAX_Y - IMG_HDR.lcd_height) / 2) - 1;
#endif
if (lcd_putbmpspeed(x0, y0, IMG_HDR.lcd_width, IMG_HDR.lcd_height, bmp_buff, colour) != OK)
{
return LCD_CTRL_STOP;
}

#if 0 //DEBUG
sprintf(frame_string, "%04d", frame);
led_puts(0, 10, frame_string, colour, !colour);
#endif
lcd_update();
frame_fps1 = GetTickCount();
if ((frame_fps1 - frame_fps0) < (1000 / IMG_HDR.video_fps))
video_fps_delay = (1000 / IMG_HDR.video_fps);
if ((frame_fps1 - frame_fps0) < video_fps_delay)
{
video_fps_delay = ((1000 / IMG_HDR.video_fps) - (frame_fps1 - frame_fps0) + IMG_FRAME_DELAY);
video_fps_delay = (video_fps_delay - (frame_fps1 - frame_fps0) + IMG_FRAME_DELAY);
if(video_fps_delay > 0)
{
DEBUG_LOG("Waiting [%d]ms ...", video_fps_delay);
Expand Down
3 changes: 1 addition & 2 deletions src/bmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ typedef enum lcd_control_e
LCD_CTRL_STOP = 0,
LCD_CTRL_START,
LCD_CTRL_RUN,

} lcd_control_t;

extern int32_t bmp_init(int8_t* filename);
extern int32_t bmp_init(int8_t *filename);
extern int32_t bmp_dinit(void);
extern int32_t bmp_start(void);
extern int32_t bmp_show(int32_t x0, int32_t y0, int32_t colour);
Expand Down
23 changes: 7 additions & 16 deletions src/lcd192x96.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,37 +388,28 @@ int32_t lcd_drv_get_point(int32_t x, int32_t y)
void lcd_drv_bmp_speed(int32_t x0, int32_t y0, int32_t width, int32_t height, uint8_t *bmp, int32_t colour)
{
int32_t x = 0, y = 0;
int32_t width_t = width;
int32_t i = 0;
uint8 dat = 0;

x0 = ((x0 >= LCD_DRV_MAX_X) ? (LCD_DRV_MAX_X - 1) : ((x0 < 0) ? 0 : x0));
y0 = ((y0 >= LCD_DRV_MAX_Y) ? (LCD_DRV_MAX_Y - 1) : ((y0 < 0) ? 0 : y0));

#if 0
if ((y0 % LCD_DRV_PAGE_ROW) != 0)
{
y0 = ((y0 / LCD_DRV_PAGE_ROW) + 1) * LCD_DRV_PAGE_ROW;
}
#endif

height = ((height + y0) >= LCD_DRV_MAX_Y) ? LCD_DRV_MAX_Y - y0 : height;
y0 = ((y0 % LCD_DRV_PAGE_ROW == 0) ? (y0 / LCD_DRV_PAGE_ROW) : (y0 / LCD_DRV_PAGE_ROW + 1));
width = ((width + x0) >= LCD_DRV_MAX_X) ? LCD_DRV_MAX_X - x0 : width;
height = ((height % LCD_DRV_PAGE_ROW == 0) ? (height / LCD_DRV_PAGE_ROW) : (height / LCD_DRV_PAGE_ROW + 1));

//lcd_drv_set_mode();
#if 0
for (y = y0; y < height; y++)
#if 1
for (y = y0; y < y0 + height; y++)
{
lcd_drv_set_pos(x0, y);
lcd_drv_send_data(0x5C, LCD_SEND_MODE_CMD); // write data to lcd
for (x = x0; x < width; x++)
for (x = x0; x < x0 + width; x++)
{
if ((x >= LCD_DRV_MAX_X) || (y >= LCD_DRV_PAGE_MAX))
{
break;
}
// if ((x >= LCD_DRV_MAX_X) || (y >= LCD_DRV_PAGE_MAX))
// {
// break;
// }
dat = *bmp++;
lcd_drv_send_data(((colour != 0) ? dat : ~dat), LCD_DISP_MODE_DAT);
}
Expand Down
95 changes: 0 additions & 95 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,101 +7,6 @@
#include "lcd.h"
#include "bmp.h"

#if 0
int main(void)
{
uint8_t x = 0, y = 0;
uint8_t colour = 0;
printf("oled init ...\n");
lcd_init();
printf("oled init ok!\n");
int i = 0;
while (1)
{
printf("oled run...!\n");
lcd_set_mirror(i++);
if (i > 3) i = 0;
lcd_scroll_puts_s(10, 180, 10, LCD_SIMULATOR_NAME, LCD_COL_FALSE, LCD_COL_TRUE, 100*1000);
printf("oled on!\n");
colour = 0;
for (y = 0; y < 64; y++)
{
for (x = 0; x < 128; x++)
{
lcd_set_point(x, y, colour);
colour++;
if (colour >= LCD_COL_MAX)
{
colour = 0;
}
//lcd_update();
}
}
lcd_update();
delay(1000);

printf("oled off!\n");
colour = 0;
for (x = 0; x < 128; x++)
{
for (y = 0; y < 64; y++)
{
lcd_set_point(x, y, colour++);
colour++;
if (colour >= LCD_COL_MAX)
{
colour = 0;
}
//lcd_update();
}
}
lcd_update();
delay(1000);

lcd_clear(0);
lcd_line(0, 0, 127, 63, LCD_COL_BLACK);
lcd_update();
printf("line ok!\n");
delay(1500);

lcd_clear(0);
lcd_rectangle(0, 0, 47, 47, LCD_COL_WHITE, 1);
lcd_rectangle(48, 0, 95, 47, LCD_COL_LIGHT_GRAY, 1);
lcd_rectangle(96, 0, 143, 47, LCD_COL_DARK_GRAY, 1);
lcd_rectangle(144, 0, 191, 47, LCD_COL_BLACK, 1);

lcd_rectangle(0, 48, 47, 95, LCD_COL_BLACK, 1);
lcd_rectangle(48, 48, 95, 95, LCD_COL_WHITE, 1);
lcd_rectangle(96, 48, 143, 95, LCD_COL_LIGHT_GRAY, 1);
lcd_rectangle(144, 48, 191, 95, LCD_COL_DARK_GRAY, 1);
lcd_update();
printf("rectangle ok!\n");
delay(5000);

lcd_clear(0);
lcd_circle(63, 31, 30, LCD_COL_BLACK, 1);
lcd_update();
printf("circle ok!\n");
delay(1500);

lcd_clear(0);
lcd_ellipse(63, 31, 40, 20, LCD_COL_BLACK, 1);
lcd_update();
printf("ellipse ok!\n");
delay(1500);

lcd_clear(0);
lcd_text_s(10, 180, 0, "Hello,\nWorld!\r\nWHJWNAVY\r\nQQ:805400349", LCD_COL_FALSE, LCD_COL_TRUE);
lcd_update();
printf("puts ok!\n");
delay(1500);

lcd_clear(0);
}
printf("exit!\n");
}
#endif

#define LCD_MOVIE_NAME_LEN (1024)

#define HELP_PRINT_FORMATS " %-10s -- %s\r\n"
Expand Down

0 comments on commit fb46f91

Please sign in to comment.