Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG mbed
Fork of DISCO-F746NG_TSL3301 by
Revision 2:6d7063605e3a, committed 2018-03-20
- Comitter:
- oZGi
- Date:
- Tue Mar 20 12:06:47 2018 +0000
- Parent:
- 1:979d4820e32a
- Child:
- 3:cb16c3af98de
- Commit message:
- 1;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F746NG.lib Tue Mar 20 12:06:47 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#df2ea349c37a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F746NG.lib Tue Mar 20 12:06:47 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F746NG.lib Tue Mar 20 12:06:47 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- a/main.cpp Tue Mar 06 13:04:48 2018 +0000 +++ b/main.cpp Tue Mar 20 12:06:47 2018 +0000 @@ -1,10 +1,16 @@ #include "mbed.h" +#include "TS_DISCO_F746NG.h" +#include "LCD_DISCO_F746NG.h" + +LCD_DISCO_F746NG lcd; +int line = 1; DigitalIn miso(D8); DigitalOut mosi(D7); DigitalOut clk(D6); unsigned char lcam_buffer[102]; +unsigned char max_area; void lcam_pulse(void) { clk = 1; @@ -133,9 +139,53 @@ } } +unsigned char lcam_getpic(void) +{ + unsigned char i, value, highest = 0, max_region = 0; + unsigned int average = 0; + for(i = 0; i < 25; i++) + { + // take 4-byte average and divide by 4 (shift to right by 2) + value = ((lcam_buffer[i*4] + lcam_buffer[i*4+1] + lcam_buffer[i*4+2] + lcam_buffer[i*4+3]) >> 2); + if(value > highest) + { + highest = value; + max_region = i; + } + average += value; + } + + average /= 25; + + if(highest > average + 30) + { + return max_region; + } + else + { + return 0; + } +} + int main() { lcam_setup(); while(1) { - + if (line == 10){ + line = 1; + } + + lcd.Clear(LCD_COLOR_WHITE); + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.SetTextColor(LCD_COLOR_RED); + + lcam_integrate(10); + + lcam_read(); + + max_area = lcam_getpic(); + + lcd.DisplayStringAt(0, LINE(line), (uint8_t *)max_area, CENTER_MODE); + line +=1; + wait_ms(200); } }