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@0:139f0c46d0fd, 2014-06-09 (annotated)
- Committer:
- nxpfan
- Date:
- Mon Jun 09 20:14:04 2014 +0000
- Revision:
- 0:139f0c46d0fd
- Child:
- 2:7294334432d4
1st release
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 | 0:139f0c46d0fd | 15 | MARMEX_OB_oled oled1( p5, p7, p20, p16, p15 ); // mosi, sclk, cs, rst, power_control -- maple-mini-type-b-board-slot1 |
nxpfan | 0:139f0c46d0fd | 16 | MARMEX_VB camera( p5, p6, p7, p22, p26, p28, p27 ); // mosi, miso, sclk, cs, reset, sda, scl -- maple-mini-type-b-board-slot2 |
nxpfan | 0:139f0c46d0fd | 17 | BusOut led( LED3, LED4 ); |
nxpfan | 0:139f0c46d0fd | 18 | |
nxpfan | 0:139f0c46d0fd | 19 | // image size (default image size) |
nxpfan | 0:139f0c46d0fd | 20 | #define CAMERA_WIDTH MARMEX_VB::QCIF_PIXEL_PER_LINE // 176 pixels(default size) |
nxpfan | 0:139f0c46d0fd | 21 | #define CAMERA_HEIGHT MARMEX_VB::QCIF_LINE_PER_FRAME // 144 lines (default size) |
nxpfan | 0:139f0c46d0fd | 22 | |
nxpfan | 0:139f0c46d0fd | 23 | // screen size |
nxpfan | 0:139f0c46d0fd | 24 | #define OLED_WIDTH MARMEX_OB_oled::WIDTH // 128 pixels |
nxpfan | 0:139f0c46d0fd | 25 | #define OLED_HEIGHT MARMEX_OB_oled::HEIGHT // 128 lines |
nxpfan | 0:139f0c46d0fd | 26 | |
nxpfan | 0:139f0c46d0fd | 27 | // x/y offset to draw center image of the camera |
nxpfan | 0:139f0c46d0fd | 28 | #define X_OFFSET ((CAMERA_WIDTH - OLED_WIDTH ) / 2) |
nxpfan | 0:139f0c46d0fd | 29 | #define Y_OFFSET ((CAMERA_HEIGHT - OLED_HEIGHT) / 2) |
nxpfan | 0:139f0c46d0fd | 30 | |
nxpfan | 0:139f0c46d0fd | 31 | int main() |
nxpfan | 0:139f0c46d0fd | 32 | { |
nxpfan | 0:139f0c46d0fd | 33 | short buf[ OLED_WIDTH ]; |
nxpfan | 0:139f0c46d0fd | 34 | |
nxpfan | 0:139f0c46d0fd | 35 | led = 0x3; |
nxpfan | 0:139f0c46d0fd | 36 | oled1.cls(); // clear OLED screen |
nxpfan | 0:139f0c46d0fd | 37 | |
nxpfan | 0:139f0c46d0fd | 38 | while ( 1 ) { |
nxpfan | 0:139f0c46d0fd | 39 | |
nxpfan | 0:139f0c46d0fd | 40 | led = 0x1; |
nxpfan | 0:139f0c46d0fd | 41 | camera.open_transfer(); // pause updating the camera buffer |
nxpfan | 0:139f0c46d0fd | 42 | |
nxpfan | 0:139f0c46d0fd | 43 | // data transfer from camera to OLED (line by line copy) |
nxpfan | 0:139f0c46d0fd | 44 | // |
nxpfan | 0:139f0c46d0fd | 45 | for ( int line = 0; line < OLED_HEIGHT; line++ ) { |
nxpfan | 0:139f0c46d0fd | 46 | |
nxpfan | 0:139f0c46d0fd | 47 | // 1 line (128 pixels) data read from camera |
nxpfan | 0:139f0c46d0fd | 48 | camera.read_a_line( buf, line + Y_OFFSET, X_OFFSET, OLED_WIDTH ); |
nxpfan | 0:139f0c46d0fd | 49 | |
nxpfan | 0:139f0c46d0fd | 50 | // 1 line (128 pixels) data write into OLED |
nxpfan | 0:139f0c46d0fd | 51 | oled1.blit565( 0, line, OLED_WIDTH, 1, buf ); |
nxpfan | 0:139f0c46d0fd | 52 | } |
nxpfan | 0:139f0c46d0fd | 53 | |
nxpfan | 0:139f0c46d0fd | 54 | led = 0x2; |
nxpfan | 0:139f0c46d0fd | 55 | camera.close_transfer(); // resume updating the camera buffer |
nxpfan | 0:139f0c46d0fd | 56 | } |
nxpfan | 0:139f0c46d0fd | 57 | } |