Image rotation Sample. This program uses GraphicsFramework library and L3GD20 sensor.
Dependencies: GR-PEACH_video GraphicsFramework L3GD20 R_BSP mbed-rtos mbed
Fork of RGA_HelloWorld by
About L3GD20
L3GD20 is a 3-axis gyroscope sensor and can be controlled by using theI2C.
- Datasheet of L3GD20
http://www.st.com/content/ccc/resource/technical/document/datasheet/43/37/e3/06/b0/bf/48/bd/DM00036465.pdf/files/DM00036465.pdf/jcr:content/translations/en.DM00036465.pdf
About wiring
Sensor | GR-PEACH |
VDD | 3.3V |
SCL | D15 |
SDA | D14 |
SA0 | 3.3V |
CS | 3.3V |
GND | GND |
rga_func.cpp@4:138b18a6ac7b, 2016-05-23 (annotated)
- Committer:
- 1050186
- Date:
- Mon May 23 10:03:17 2016 +0000
- Revision:
- 4:138b18a6ac7b
- Parent:
- 3:841987280a7f
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
1050186 | 0:84e4649e7707 | 1 | /* |
1050186 | 0:84e4649e7707 | 2 | Permission is hereby granted, free of charge, to any person obtaining a copy |
1050186 | 0:84e4649e7707 | 3 | of this software and associated documentation files (the "Software"), to deal |
1050186 | 0:84e4649e7707 | 4 | in the Software without restriction, including without limitation the rights |
1050186 | 0:84e4649e7707 | 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
1050186 | 0:84e4649e7707 | 6 | copies of the Software, and to permit persons to whom the Software is |
1050186 | 0:84e4649e7707 | 7 | furnished to do so, subject to the following conditions: |
1050186 | 0:84e4649e7707 | 8 | |
1050186 | 0:84e4649e7707 | 9 | The above copyright notice and this permission notice shall be included in |
1050186 | 0:84e4649e7707 | 10 | all copies or substantial portions of the Software. |
1050186 | 0:84e4649e7707 | 11 | |
1050186 | 0:84e4649e7707 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
1050186 | 0:84e4649e7707 | 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
1050186 | 0:84e4649e7707 | 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
1050186 | 0:84e4649e7707 | 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
1050186 | 0:84e4649e7707 | 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
1050186 | 0:84e4649e7707 | 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
1050186 | 0:84e4649e7707 | 18 | THE SOFTWARE. |
1050186 | 0:84e4649e7707 | 19 | */ |
1050186 | 0:84e4649e7707 | 20 | |
1050186 | 0:84e4649e7707 | 21 | #include "mbed.h" |
1050186 | 0:84e4649e7707 | 22 | #include "rga_func.h" |
1050186 | 0:84e4649e7707 | 23 | #include "Images/BinaryImage_RZ_A1H.h" |
1050186 | 0:84e4649e7707 | 24 | |
1050186 | 0:84e4649e7707 | 25 | Canvas2D_ContextClass canvas2d; |
1050186 | 0:84e4649e7707 | 26 | |
1050186 | 0:84e4649e7707 | 27 | void Set_RGAObject(frame_buffer_t* frmbuf_info) { |
1050186 | 0:84e4649e7707 | 28 | errnum_t err; |
1050186 | 0:84e4649e7707 | 29 | Canvas2D_ContextConfigClass config; |
1050186 | 0:84e4649e7707 | 30 | |
1050186 | 0:84e4649e7707 | 31 | config.frame_buffer = frmbuf_info; |
1050186 | 0:84e4649e7707 | 32 | canvas2d = R_RGA_New_Canvas2D_ContextClass(config); |
1050186 | 0:84e4649e7707 | 33 | err = R_OSPL_GetErrNum(); |
1050186 | 0:84e4649e7707 | 34 | if (err != 0) { |
1050186 | 0:84e4649e7707 | 35 | printf("Line %d, error %d\n", __LINE__, err); |
1050186 | 0:84e4649e7707 | 36 | while (1); |
1050186 | 0:84e4649e7707 | 37 | } |
1050186 | 0:84e4649e7707 | 38 | } |
1050186 | 0:84e4649e7707 | 39 | |
1050186 | 4:138b18a6ac7b | 40 | void RGA_Func_Rotation(frame_buffer_t* frmbuf_info, graphics_matrix_float_t image_angle) { |
1050186 | 4:138b18a6ac7b | 41 | /* Rotate the image */ |
1050186 | 0:84e4649e7707 | 42 | /* Clear */ |
1050186 | 0:84e4649e7707 | 43 | canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); |
dkato | 2:c7faef0ef374 | 44 | |
1050186 | 0:84e4649e7707 | 45 | /* Move to drawing position */ |
1050186 | 4:138b18a6ac7b | 46 | canvas2d.translate((155 + (IMG_DRAW_WIDTH / 2)), (73 + (IMG_DRAW_HEIGHT / 2))); |
dkato | 2:c7faef0ef374 | 47 | |
1050186 | 0:84e4649e7707 | 48 | /* Rotate */ |
1050186 | 0:84e4649e7707 | 49 | canvas2d.rotate(image_angle * (3.14159 / 180)); |
dkato | 2:c7faef0ef374 | 50 | |
1050186 | 0:84e4649e7707 | 51 | /* Move to center to rotate */ |
1050186 | 0:84e4649e7707 | 52 | canvas2d.translate((-IMG_DRAW_WIDTH / 2), (-IMG_DRAW_HEIGHT / 2)); |
1050186 | 0:84e4649e7707 | 53 | canvas2d.drawImage(Flower_jpg_File, 0, 0); |
1050186 | 0:84e4649e7707 | 54 | canvas2d.setTransform(1, 0, 0, 1, 0, 0); |
1050186 | 0:84e4649e7707 | 55 | |
1050186 | 0:84e4649e7707 | 56 | /* Complete drawing */ |
1050186 | 0:84e4649e7707 | 57 | R_GRAPHICS_Finish(canvas2d.c_LanguageContext); |
1050186 | 0:84e4649e7707 | 58 | } |