|
| 1 | +#include "arduino_4_lib.h" |
| 2 | + |
| 3 | +const int ArduinoTypeID = 4; |
| 4 | + |
| 5 | +Adafruit_BNO055 bno_0 = Adafruit_BNO055(55, BNO055_ADDRESS_A); |
| 6 | +Adafruit_BNO055 bno_1 = Adafruit_BNO055(56, BNO055_ADDRESS_B); |
| 7 | +//Adafruit_BNO055 bno = bno_0; |
| 8 | + |
| 9 | +struct measurementsStruct{ |
| 10 | + String current_time; |
| 11 | + float face_temparature_hottest; |
| 12 | +}; |
| 13 | + |
| 14 | +std::vector<String> columns = { |
| 15 | + "Timestamp", |
| 16 | + "FaceTemperatureHottest", |
| 17 | +}; |
| 18 | + |
| 19 | +int incr = 0; |
| 20 | +const int QUEUE_SIZE = 500; |
| 21 | +struct measurementsStruct dataArray[QUEUE_SIZE]; |
| 22 | +struct measurementsStruct *P_send = dataArray; |
| 23 | +struct measurementsStruct *P_receive = NULL; |
| 24 | +int pixelTable[64]; |
| 25 | + |
| 26 | +float testPixelValue = 0; |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +void grideyeInit(){ |
| 32 | + // Start your preferred I2C object |
| 33 | + Wire.begin(); |
| 34 | + // Library assumes "Wire" for I2C but you can pass something else with begin() if you like |
| 35 | + grideye.begin(); |
| 36 | +} |
| 37 | + |
| 38 | +void arduinoInit(){ |
| 39 | + grideyeInit(); |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +void Task_ReadingData(void *pvParameters){ |
| 44 | + while (true) { |
| 45 | + if (do_measurements) { |
| 46 | + // sensors_event_t event; |
| 47 | + // bno.getEvent(&event); |
| 48 | + struct measurementsStruct measurements; |
| 49 | + |
| 50 | + measurements.current_time = dateTime(TIME_FORMAT); |
| 51 | + |
| 52 | + float hotPixelValue = 0; |
| 53 | + int hotPixelIndex = 0; |
| 54 | + |
| 55 | + for(unsigned char i = 0; i < 64; i++){ |
| 56 | + testPixelValue = grideye.getPixelTemperature(i); |
| 57 | + if (testPixelValue > hotPixelValue){ |
| 58 | + hotPixelValue = testPixelValue; |
| 59 | + hotPixelIndex = i; |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + measurements.face_temparature_hottest = hotPixelValue; |
| 64 | + |
| 65 | + dataArray[incr] = measurements; |
| 66 | + |
| 67 | + P_send = dataArray+incr; |
| 68 | + |
| 69 | + incr = (incr + 1) % QUEUE_SIZE; |
| 70 | + |
| 71 | + xQueueSend(queue, &P_send, portMAX_DELAY); |
| 72 | +// delay(1); |
| 73 | + } else { |
| 74 | + delay(IDLE_DELAY); // THAT'S JUST IN CASE do_measurements == false |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +void Task_WritingData(void *pvParameters){ |
| 80 | + while (true) { |
| 81 | + xQueueReceive(queue, &P_receive, portMAX_DELAY); |
| 82 | + |
| 83 | + myFile.print(P_receive -> current_time); |
| 84 | + myFile.print(DELIMITER); |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + myFile.print('\n'); |
| 90 | + myFile.flush(); |
| 91 | + } |
| 92 | +} |
| 93 | + |
0 commit comments