A "Hello" program for MARMEX_VB library. This application may work 40pin type mbed platforms ;) This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1)
Dependencies: MARMEX_VB NokiaLCD mbed
Sample code for MARMEX-VB (MARY-VB) camera module.
This is a very simple program just copies the data from camera to OELD.
main.cpp@2:7294334432d4, 2014-06-20 (annotated)
- Committer:
- nxpfan
- Date:
- Fri Jun 20 09:19:00 2014 +0000
- Revision:
- 2:7294334432d4
- Parent:
- 0:139f0c46d0fd
sample code with latest libraries (SPI-FIFO optimize option version)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nxpfan | 0:139f0c46d0fd | 1 | /** Hello program for MARMEX_VB Camera control library |
nxpfan | 0:139f0c46d0fd | 2 | * |
nxpfan | 0:139f0c46d0fd | 3 | * @version 0.1 |
nxpfan | 0:139f0c46d0fd | 4 | * @date 10-Jun-2014 |
nxpfan | 0:139f0c46d0fd | 5 | * |
nxpfan | 0:139f0c46d0fd | 6 | * Released under the Apache License, Version 2.0 : http://mbed.org/handbook/Apache-Licence |
nxpfan | 0:139f0c46d0fd | 7 | * |
nxpfan | 0:139f0c46d0fd | 8 | * ** This program may run on 40pin type mbed platfoms ;) ** |
nxpfan | 0:139f0c46d0fd | 9 | */ |
nxpfan | 0:139f0c46d0fd | 10 | |
nxpfan | 0:139f0c46d0fd | 11 | #include "mbed.h" |
nxpfan | 0:139f0c46d0fd | 12 | #include "MARMEX_OB_oled.h" |
nxpfan | 0:139f0c46d0fd | 13 | #include "MARMEX_VB.h" |
nxpfan | 0:139f0c46d0fd | 14 | |
nxpfan | 2:7294334432d4 | 15 | // Baseboard type selection |
nxpfan | 2:7294334432d4 | 16 | #define BASEBOARD_MAPLE_MINI_TYPE_B |
nxpfan | 2:7294334432d4 | 17 | //#define BASEBOARD_MAPLE_ORIGINAL |
nxpfan | 2:7294334432d4 | 18 | |
nxpfan | 2:7294334432d4 | 19 | #ifdef BASEBOARD_MAPLE_MINI_TYPE_B |
nxpfan | 2:7294334432d4 | 20 | MARMEX_OB_oled oled1( p5, p7, p20, p16, p15 ); |
nxpfan | 2:7294334432d4 | 21 | // mosi, sclk, cs, rst, power_control -- maple-mini-type-b-board-slot1 |
nxpfan | 2:7294334432d4 | 22 | MARMEX_VB camera( p5, p6, p7, p22, p26, p28, p27 ); |
nxpfan | 2:7294334432d4 | 23 | // mosi, miso, sclk, cs, reset, sda, scl -- maple-mini-type-b-board-slot2 |
nxpfan | 2:7294334432d4 | 24 | #endif |
nxpfan | 2:7294334432d4 | 25 | |
nxpfan | 2:7294334432d4 | 26 | #ifdef BASEBOARD_MAPLE_ORIGINAL |
nxpfan | 2:7294334432d4 | 27 | MARMEX_OB_oled oled1( p5, p7, p8, p30, p11 ); |
nxpfan | 2:7294334432d4 | 28 | // mosi, sclk, cs, rst, power_control -- maple-board-slot1 |
nxpfan | 2:7294334432d4 | 29 | MARMEX_VB camera( p5, p6, p7, p26, p17, p28, p27 ); |
nxpfan | 2:7294334432d4 | 30 | // mosi, miso, sclk, cs, reset, sda, scl -- maple-board-slot2 |
nxpfan | 2:7294334432d4 | 31 | #endif |
nxpfan | 2:7294334432d4 | 32 | //BusOut led( LED3, LED4 ); |
nxpfan | 0:139f0c46d0fd | 33 | |
nxpfan | 0:139f0c46d0fd | 34 | // image size (default image size) |
nxpfan | 0:139f0c46d0fd | 35 | #define CAMERA_WIDTH MARMEX_VB::QCIF_PIXEL_PER_LINE // 176 pixels(default size) |
nxpfan | 0:139f0c46d0fd | 36 | #define CAMERA_HEIGHT MARMEX_VB::QCIF_LINE_PER_FRAME // 144 lines (default size) |
nxpfan | 0:139f0c46d0fd | 37 | |
nxpfan | 0:139f0c46d0fd | 38 | // screen size |
nxpfan | 0:139f0c46d0fd | 39 | #define OLED_WIDTH MARMEX_OB_oled::WIDTH // 128 pixels |
nxpfan | 0:139f0c46d0fd | 40 | #define OLED_HEIGHT MARMEX_OB_oled::HEIGHT // 128 lines |
nxpfan | 0:139f0c46d0fd | 41 | |
nxpfan | 0:139f0c46d0fd | 42 | // x/y offset to draw center image of the camera |
nxpfan | 0:139f0c46d0fd | 43 | #define X_OFFSET ((CAMERA_WIDTH - OLED_WIDTH ) / 2) |
nxpfan | 0:139f0c46d0fd | 44 | #define Y_OFFSET ((CAMERA_HEIGHT - OLED_HEIGHT) / 2) |
nxpfan | 0:139f0c46d0fd | 45 | |
nxpfan | 0:139f0c46d0fd | 46 | int main() |
nxpfan | 0:139f0c46d0fd | 47 | { |
nxpfan | 0:139f0c46d0fd | 48 | short buf[ OLED_WIDTH ]; |
nxpfan | 0:139f0c46d0fd | 49 | |
nxpfan | 0:139f0c46d0fd | 50 | oled1.cls(); // clear OLED screen |
nxpfan | 0:139f0c46d0fd | 51 | |
nxpfan | 0:139f0c46d0fd | 52 | while ( 1 ) { |
nxpfan | 0:139f0c46d0fd | 53 | |
nxpfan | 0:139f0c46d0fd | 54 | camera.open_transfer(); // pause updating the camera buffer |
nxpfan | 0:139f0c46d0fd | 55 | |
nxpfan | 0:139f0c46d0fd | 56 | // data transfer from camera to OLED (line by line copy) |
nxpfan | 0:139f0c46d0fd | 57 | // |
nxpfan | 0:139f0c46d0fd | 58 | for ( int line = 0; line < OLED_HEIGHT; line++ ) { |
nxpfan | 0:139f0c46d0fd | 59 | |
nxpfan | 0:139f0c46d0fd | 60 | // 1 line (128 pixels) data read from camera |
nxpfan | 0:139f0c46d0fd | 61 | camera.read_a_line( buf, line + Y_OFFSET, X_OFFSET, OLED_WIDTH ); |
nxpfan | 0:139f0c46d0fd | 62 | |
nxpfan | 0:139f0c46d0fd | 63 | // 1 line (128 pixels) data write into OLED |
nxpfan | 0:139f0c46d0fd | 64 | oled1.blit565( 0, line, OLED_WIDTH, 1, buf ); |
nxpfan | 0:139f0c46d0fd | 65 | } |
nxpfan | 0:139f0c46d0fd | 66 | |
nxpfan | 0:139f0c46d0fd | 67 | camera.close_transfer(); // resume updating the camera buffer |
nxpfan | 0:139f0c46d0fd | 68 | } |
nxpfan | 0:139f0c46d0fd | 69 | } |