Sommaire
Basé sur un projet ProTIS / 2A
Objectifs
- Utiliser une matrice de capteurs infrarouges de type GridEye / I2C
- Visualiser cette matrice à l’aide d’un écran LCD TFT
Matériel
- Capteur GridEye : Panasonic AMG88 (utilisation d’un module MAXIM MAXREFDES131 (1-WIRE GRID-EYE SENSOR)
- Carte STMicroelectronics F746NG
Capteur GridEye / Mode I2C
A venir
Interface graphique sur Disco F746NG
A venir
Exemple d’application
Code complet
#include "mbed.h" #include "LCD_DISCO_F746NG.h" LCD_DISCO_F746NG lcd; /* Grid Eye on I2C */ I2C gridEye(I2C_SDA, I2C_SCL); #define AMG8833_ADR 0x68 #define AMG8833_PCTL 0x00 #define AMG8833_RST 0x01 #define AMG8833_FPSC 0x02 #define AMG8833_STAT 0x04 #define AMG8833_THERM 0x0E #define AMG8833_PIX1 0x80 #define AMG8833_NB_PIX 64 void initAMG8833(void){ char data[2] = {AMG8833_PCTL, 0}; // Normal Mode -> PCTL gridEye.write(AMG8833_ADR << 1, data, 2); } int getThermAMG8833(void){ char data[2] = {AMG8833_THERM, 0}; gridEye.write(AMG8833_ADR << 1, data, 1); gridEye.read(AMG8833_ADR << 1, data, 2); int k = data[0] + data[1]*256; return k; } void getMatriceTempAMG8833(int *t){ char data[AMG8833_NB_PIX*2] = {0}; data[0] = AMG8833_PIX1; gridEye.write(AMG8833_ADR << 1, data, 1); gridEye.read(AMG8833_ADR << 1, data, AMG8833_NB_PIX*2); for(int i = 0; i < AMG8833_NB_PIX; i++){ t[i] = data[2*i] + data[2*i+1]*256; } } int matriceGridEye[AMG8833_NB_PIX] = {0}; void DrawMatrice(LCD_DISCO_F746NG *lcd){ int x, y, x_max, y_max; int taille_pixel = 30; x_max = 8; y_max = 8; for(y = 0; y < y_max; y++){ for(x = 0; x < x_max; x++){ uint32_t col = matriceGridEye[x + y*x_max] * 0x00000100 + 0xFF000000; lcd->SetTextColor(col); lcd->FillRect(x*taille_pixel, y*taille_pixel, taille_pixel, taille_pixel); } } } /* MAIN FUNCTION */ int main() { gridEye.frequency(400000); pc.baud(115200); /* Initialisation Grid Eye */ initAMG8833(); wait_ms(100); /* Initialisation LCD */ lcd.Clear(LCD_COLOR_BLACK); lcd.SetBackColor(LCD_COLOR_BLACK); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Grid EYE Sensor / I2C", CENTER_MODE); wait(1); while(1) { getMatriceTempAMG8833(matriceGridEye); DrawMatrice(&lcd); wait(1); } }
Image thermique à l’aide d’un capteur GridEye