librairie de fonctions de base du pixy : recuperation infos sur bloc detecte
Dependencies: mbed pixy_lib_base
main.cpp@0:0dde75f5e5a2, 2020-11-20 (annotated)
- Committer:
- michelmoulin
- Date:
- Fri Nov 20 15:38:37 2020 +0000
- Revision:
- 0:0dde75f5e5a2
Affiche les coordonnees x et y du bloc le plus gros vu par la camera pixy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
michelmoulin | 0:0dde75f5e5a2 | 1 | |
michelmoulin | 0:0dde75f5e5a2 | 2 | /* 17/11/20 : Ce pg affiche les coordonnées x et y du block détecté par la pixy */ |
michelmoulin | 0:0dde75f5e5a2 | 3 | #include "Pixy.h" |
michelmoulin | 0:0dde75f5e5a2 | 4 | |
michelmoulin | 0:0dde75f5e5a2 | 5 | Serial serial(USBTX, USBRX); |
michelmoulin | 0:0dde75f5e5a2 | 6 | SPI spi(PC_12, PC_11, PC_10); // mosi, miso, clk du SPI3 |
michelmoulin | 0:0dde75f5e5a2 | 7 | PixySPI pixy(&spi); |
michelmoulin | 0:0dde75f5e5a2 | 8 | |
michelmoulin | 0:0dde75f5e5a2 | 9 | int main() |
michelmoulin | 0:0dde75f5e5a2 | 10 | { |
michelmoulin | 0:0dde75f5e5a2 | 11 | uint16_t blocks; |
michelmoulin | 0:0dde75f5e5a2 | 12 | serial.printf("debut....\n\r"); |
michelmoulin | 0:0dde75f5e5a2 | 13 | spi.frequency(1000000); |
michelmoulin | 0:0dde75f5e5a2 | 14 | while(1) |
michelmoulin | 0:0dde75f5e5a2 | 15 | { |
michelmoulin | 0:0dde75f5e5a2 | 16 | serial.printf("nouvel essai : "); |
michelmoulin | 0:0dde75f5e5a2 | 17 | blocks = pixy.getBlocks(); |
michelmoulin | 0:0dde75f5e5a2 | 18 | if (blocks) |
michelmoulin | 0:0dde75f5e5a2 | 19 | { |
michelmoulin | 0:0dde75f5e5a2 | 20 | serial.printf("Detected %d : ", blocks); |
michelmoulin | 0:0dde75f5e5a2 | 21 | serial.printf("x=%d, y=%d \n\r",pixy.blocks[0].x,pixy.blocks[0].y); |
michelmoulin | 0:0dde75f5e5a2 | 22 | } |
michelmoulin | 0:0dde75f5e5a2 | 23 | wait(1); |
michelmoulin | 0:0dde75f5e5a2 | 24 | } |
michelmoulin | 0:0dde75f5e5a2 | 25 | } |