This program plays QuickTime movies on GR-Peach
Dependencies: AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP TLV320_RBSP mbed-rtos mbed
Requirements
- GR-Peach
- GR-Peach Audio Camera Shield or I²S compatible audio DAC
- GR-Peach LCD Shield
- USB memory stick
How to play movie files
- Encode movie files
encode movies with ffmpeg
$ ffmpeg -i <input -ar 44100 -acodec pcm_s16le -s 480x270 -vcodec mjpeg -q:v 3 -movflags faststart -threads 4 -vf fps=30 <output>.mov
- Copy movies to the root directory of USB memory
- Build and upload this program
- Run it
Revision 1:3e638b9e91cd, committed 2017-03-12
- Comitter:
- mtkrtk
- Date:
- Sun Mar 12 02:01:46 2017 +0000
- Parent:
- 0:d0f130e27d32
- Commit message:
- fixed lcd contrast pin
Changed in this revision
LCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
LCD.hpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d0f130e27d32 -r 3e638b9e91cd LCD.cpp --- a/LCD.cpp Fri Mar 10 11:30:02 2017 +0000 +++ b/LCD.cpp Sun Mar 12 02:01:46 2017 +0000 @@ -1,126 +1,126 @@ -#include "LCD.hpp" -#include "rtos.h" - -#define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565) -#define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT) - -volatile int32_t LCD::vsync_count = 0; -uint8_t LCD::user_frame_buffer1[]; -uint8_t LCD::user_frame_buffer2[]; -frame_buffer_t LCD::frame_buffer_info; -LCD LCD::instance; - -void LCD::IntCallbackFunc_LoVsync(DisplayBase::int_type_t MBED_UNUSED int_type) { - /* Interrupt callback function for Vsync interruption */ - if (vsync_count > 0) { - vsync_count--; - } -} - -LCD::LCD() : lcd_pwon(P7_15), lcd_blon(P8_1), lcd_cntrst(P8_14), lcd_nctrst_dummy(P8_15) -{ -} - -void LCD::start() -{ - DisplayBase::graphics_error_t error; - DisplayBase::lcd_config_t lcd_config; - PinName lvds_pin[8] = { - /* data pin */ - P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0 - }; - - lcd_pwon = 0; - lcd_blon = 0; - rtos::Thread::wait(100); - lcd_pwon = 1; - lcd_blon = 1; - - Display.Graphics_Lvds_Port_Init(lvds_pin, 8); - - /* Graphics initialization process */ - lcd_config = LcdCfgTbl_LCD_shield; - error = Display.Graphics_init(&lcd_config); - if (error != DisplayBase::GRAPHICS_OK) { - printf("Line %d, error %d\n", __LINE__, error); - mbed_die(); - } - - /* Interrupt callback function setting (Vsync signal output from scaler 0) */ - error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, LCD::IntCallbackFunc_LoVsync); - if (error != DisplayBase::GRAPHICS_OK) { - printf("Line %d, error %d\n", __LINE__, error); - mbed_die(); - } - - memset(user_frame_buffer1, 0, sizeof(user_frame_buffer1)); - memset(user_frame_buffer2, 0, sizeof(user_frame_buffer2)); - frame_buffer_info.buffer_address[0] = user_frame_buffer1; - frame_buffer_info.buffer_address[1] = user_frame_buffer2; - frame_buffer_info.buffer_count = 2; - frame_buffer_info.show_buffer_index = 0; - frame_buffer_info.draw_buffer_index = 0; - frame_buffer_info.width = LCD_PIXEL_WIDTH; - frame_buffer_info.byte_per_pixel = FRAME_BUFFER_BYTE_PER_PIXEL; - frame_buffer_info.stride = LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL; - frame_buffer_info.height = LCD_PIXEL_HEIGHT; - frame_buffer_info.pixel_format = PIXEL_FORMAT_RGB565; - - DisplayBase::rect_t rect; - - rect.vs = 0; - rect.vw = LCD_PIXEL_HEIGHT; - rect.hs = 0; - rect.hw = LCD_PIXEL_WIDTH; - Display.Graphics_Read_Setting(DisplayBase::GRAPHICS_LAYER_0, (void *)frame_buffer_info.buffer_address[0], - FRAME_BUFFER_STRIDE, GRAPHICS_FORMAT, WR_RD_WRSWA, &rect); - Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); - - rtos::Thread::wait(200); - lcd_cntrst.period_us(491); - lcd_cntrst = 0.1; - - errnum_t err; - Canvas2D_ContextConfigClass config; - config.frame_buffer = &frame_buffer_info; - canvas2d = R_RGA_New_Canvas2D_ContextClass(config); - err = R_OSPL_GetErrNum(); - if (err != 0) { - printf("Line %d, error %d\n", __LINE__, err); - while (1); - } - - graphics = canvas2d.c_LanguageContext; -} - -void LCD::stop() -{ - lcd_pwon = 0; - lcd_blon = 0; -} - -void LCD::Wait_Vsync(const int32_t wait_count) -{ - /* Wait for the specified number of times Vsync occurs */ - vsync_count = wait_count; - while (vsync_count > 0) { - /* Do nothing */ - } -} - -void LCD::Swap_FrameBuffer() -{ - if (frame_buffer_info.draw_buffer_index == 1) { - frame_buffer_info.draw_buffer_index = 0; - } else { - frame_buffer_info.draw_buffer_index = 1; - } -} - -void LCD::Update_LCD_Display() -{ - Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, - (void *)frame_buffer_info.buffer_address[frame_buffer_info.draw_buffer_index]); - Wait_Vsync(1); -} +#include "LCD.hpp" +#include "rtos.h" + +#define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565) +#define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT) + +volatile int32_t LCD::vsync_count = 0; +uint8_t LCD::user_frame_buffer1[]; +uint8_t LCD::user_frame_buffer2[]; +frame_buffer_t LCD::frame_buffer_info; +LCD LCD::instance; + +void LCD::IntCallbackFunc_LoVsync(DisplayBase::int_type_t MBED_UNUSED int_type) { + /* Interrupt callback function for Vsync interruption */ + if (vsync_count > 0) { + vsync_count--; + } +} + +LCD::LCD() : lcd_pwon(P7_15), lcd_blon(P8_1), lcd_cntrst(P8_15) +{ +} +void LCD::start() +{ + DisplayBase::graphics_error_t error; + DisplayBase::lcd_config_t lcd_config; + PinName lvds_pin[8] = { + /* data pin */ + P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0 + }; + + lcd_pwon = 0; + lcd_blon = 0; + rtos::Thread::wait(100); + lcd_pwon = 1; + lcd_blon = 1; + + Display.Graphics_Lvds_Port_Init(lvds_pin, 8); + + /* Graphics initialization process */ + lcd_config = LcdCfgTbl_LCD_shield; + error = Display.Graphics_init(&lcd_config); + if (error != DisplayBase::GRAPHICS_OK) { + printf("Line %d, error %d\n", __LINE__, error); + mbed_die(); + } + + /* Interrupt callback function setting (Vsync signal output from scaler 0) */ + error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, LCD::IntCallbackFunc_LoVsync); + if (error != DisplayBase::GRAPHICS_OK) { + printf("Line %d, error %d\n", __LINE__, error); + mbed_die(); + } + + memset(user_frame_buffer1, 0, sizeof(user_frame_buffer1)); + memset(user_frame_buffer2, 0, sizeof(user_frame_buffer2)); + frame_buffer_info.buffer_address[0] = user_frame_buffer1; + frame_buffer_info.buffer_address[1] = user_frame_buffer2; + frame_buffer_info.buffer_count = 2; + frame_buffer_info.show_buffer_index = 0; + frame_buffer_info.draw_buffer_index = 0; + frame_buffer_info.width = LCD_PIXEL_WIDTH; + frame_buffer_info.byte_per_pixel = FRAME_BUFFER_BYTE_PER_PIXEL; + frame_buffer_info.stride = LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL; + frame_buffer_info.height = LCD_PIXEL_HEIGHT; + frame_buffer_info.pixel_format = PIXEL_FORMAT_RGB565; + + DisplayBase::rect_t rect; + + rect.vs = 0; + rect.vw = LCD_PIXEL_HEIGHT; + rect.hs = 0; + rect.hw = LCD_PIXEL_WIDTH; + Display.Graphics_Read_Setting(DisplayBase::GRAPHICS_LAYER_0, (void *)frame_buffer_info.buffer_address[0], + FRAME_BUFFER_STRIDE, GRAPHICS_FORMAT, WR_RD_WRSWA, &rect); + Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); + + rtos::Thread::wait(200); + lcd_cntrst.period_us(491); + lcd_cntrst = 0.1; + + errnum_t err; + Canvas2D_ContextConfigClass config; + config.frame_buffer = &frame_buffer_info; + canvas2d = R_RGA_New_Canvas2D_ContextClass(config); + err = R_OSPL_GetErrNum(); + if (err != 0) { + printf("Line %d, error %d\n", __LINE__, err); + while (1); + } + + graphics = canvas2d.c_LanguageContext; +} + +void LCD::stop() +{ + lcd_pwon = 0; + lcd_blon = 0; +} + +void LCD::Wait_Vsync(const int32_t wait_count) +{ + /* Wait for the specified number of times Vsync occurs */ + vsync_count = wait_count; + while (vsync_count > 0) { + /* Do nothing */ + } +} + +void LCD::Swap_FrameBuffer() +{ + if (frame_buffer_info.draw_buffer_index == 1) { + frame_buffer_info.draw_buffer_index = 0; + } else { + frame_buffer_info.draw_buffer_index = 1; + } +} + +void LCD::Update_LCD_Display() +{ + Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, + (void *)frame_buffer_info.buffer_address[frame_buffer_info.draw_buffer_index]); + Wait_Vsync(1); +} +
diff -r d0f130e27d32 -r 3e638b9e91cd LCD.hpp --- a/LCD.hpp Fri Mar 10 11:30:02 2017 +0000 +++ b/LCD.hpp Sun Mar 12 02:01:46 2017 +0000 @@ -1,52 +1,51 @@ -#ifndef __LCD__ -#define __LCD__ - -#include "mbed.h" -#include "DisplayBace.h" -#include "LCD_shield_config_4_3inch.h" -#include "RGA.h" -#include "CppStandardHelper.hpp" - -class LCD { - static constexpr int FRAME_BUFFER_BYTE_PER_PIXEL = 2; - static constexpr int FRAME_BUFFER_STRIDE = ((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u; - static volatile int32_t vsync_count; - static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type); - static frame_buffer_t frame_buffer_info; - static uint8_t MBED_ALIGN(32) user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; - static uint8_t MBED_ALIGN(32) user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; - mbed::DigitalOut lcd_pwon; - mbed::DigitalOut lcd_blon; - mbed::PwmOut lcd_cntrst; - mbed::DigitalIn lcd_nctrst_dummy; - DisplayBase Display; - Canvas2D_ContextClass canvas2d; - graphics_t *graphics; - LCD(); - static LCD instance; - void Wait_Vsync(const int32_t wait_count); - void Swap_FrameBuffer(); - void Update_LCD_Display(); - -public: - static LCD *singleton() { - return &instance; - } - void start(); - void stop(); - void drawImage(const graphics_image_t *image, int_t minX, int_t minY) { -// Swap_FrameBuffer(); - frame_buffer_info.draw_buffer_index ^= 1; - R_GRAPHICS_DrawImage(graphics, image, minX, minY); - R_GRAPHICS_Finish(graphics); - Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, - (void *)frame_buffer_info.buffer_address[frame_buffer_info.draw_buffer_index]); -// Update_LCD_Display(); - } - void drawImage(const graphics_image_t *image) { - drawImage(image, 0, 0); - } -}; - -#endif +#ifndef __LCD__ +#define __LCD__ + +#include "mbed.h" +#include "DisplayBace.h" +#include "LCD_shield_config_4_3inch.h" +#include "RGA.h" +#include "CppStandardHelper.hpp" +class LCD { + static constexpr int FRAME_BUFFER_BYTE_PER_PIXEL = 2; + static constexpr int FRAME_BUFFER_STRIDE = ((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u; + static volatile int32_t vsync_count; + static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type); + static frame_buffer_t frame_buffer_info; + static uint8_t MBED_ALIGN(32) user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; + static uint8_t MBED_ALIGN(32) user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; + mbed::DigitalOut lcd_pwon; + mbed::DigitalOut lcd_blon; + mbed::PwmOut lcd_cntrst; + DisplayBase Display; + Canvas2D_ContextClass canvas2d; + graphics_t *graphics; + LCD(); + static LCD instance; + void Wait_Vsync(const int32_t wait_count); + void Swap_FrameBuffer(); + void Update_LCD_Display(); + +public: + static LCD *singleton() { + return &instance; + } + void start(); + void stop(); + void drawImage(const graphics_image_t *image, int_t minX, int_t minY) { +// Swap_FrameBuffer(); + frame_buffer_info.draw_buffer_index ^= 1; + R_GRAPHICS_DrawImage(graphics, image, minX, minY); + R_GRAPHICS_Finish(graphics); + Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, + (void *)frame_buffer_info.buffer_address[frame_buffer_info.draw_buffer_index]); +// Update_LCD_Display(); + } + void drawImage(const graphics_image_t *image) { + drawImage(image, 0, 0); + } +}; + +#endif +