mirror of
https://github.com/aprochazka/ProfilometerProbe.git
synced 2025-06-30 01:27:23 +02:00
Camera progress
This commit is contained in:
@ -135,6 +135,7 @@ target_link_options(${EXECUTABLE} PRIVATE
|
||||
-Wl,--start-group
|
||||
-lc
|
||||
-lm
|
||||
-lnosys
|
||||
-lstdc++
|
||||
-Wl,--end-group
|
||||
-Wl,--print-memory-usage)
|
||||
|
@ -207,11 +207,11 @@ void Cam_Start_Burst_Read(SPI_HandleTypeDef *hspi)
|
||||
|
||||
void Cam_Capture(SPI_HandleTypeDef *hspi)
|
||||
{
|
||||
LED_On();
|
||||
//LED_On();
|
||||
|
||||
Cam_Start_Capture(hspi);
|
||||
|
||||
Cam_Wait_Capture_Done(hspi);
|
||||
|
||||
LED_Off();
|
||||
//LED_Off();
|
||||
}
|
@ -68,6 +68,7 @@ static void MX_USB_PCD_Init(void);
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
/*
|
||||
static unsigned frame_num = 0;
|
||||
static unsigned tx_busy = 0;
|
||||
static unsigned interval_ms = 1000 / FRAME_RATE;
|
||||
@ -86,7 +87,7 @@ static struct {
|
||||
{color_bar_7_jpg_len, color_bar_7_jpg},
|
||||
};
|
||||
|
||||
|
||||
*/
|
||||
/*
|
||||
void cdc_task(void)
|
||||
{
|
||||
@ -159,6 +160,7 @@ uint8_t sendT[600] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
/*
|
||||
|
||||
int currentIdx = 0;
|
||||
int currentImg = 0;
|
||||
@ -203,7 +205,7 @@ int send_CDC_Bulk(){
|
||||
currentIdx = currentIdx + 10;
|
||||
return 1;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
@ -247,14 +249,35 @@ int main(void)
|
||||
tud_init(BOARD_DEVICE_RHPORT_NUM);
|
||||
|
||||
|
||||
//HAL_Delay(10);
|
||||
//SPI_Init(&hspi1);
|
||||
HAL_Delay(10);
|
||||
SPI_Init(&hspi1);
|
||||
|
||||
// Wait for power stabilization
|
||||
//HAL_Delay(1000);
|
||||
|
||||
//Cam_Init(&hi2c1, &hspi1);
|
||||
Cam_Init(&hi2c1, &hspi1);
|
||||
|
||||
int currentSendingIndex = 0;
|
||||
|
||||
|
||||
Cam_Capture(&hspi1);
|
||||
|
||||
uint16_t image_size = Cam_FIFO_length(&hspi1);
|
||||
|
||||
//uint8_t *image_data = malloc((image_size + (image_size%10)) * sizeof(uint8_t));
|
||||
uint8_t image_data[10000];
|
||||
memset(image_data, 0x00, image_size + (image_size%10));
|
||||
|
||||
Cam_Start_Burst_Read(&hspi1);
|
||||
|
||||
HAL_SPI_Receive_DMA(&hspi1, image_data, image_size);
|
||||
|
||||
while (SPI_Rx_Done_Flag == 0)
|
||||
{
|
||||
// Wait for SPI transfer to finish
|
||||
}
|
||||
CS_Off();
|
||||
SPI_Rx_Done_Flag = 0;
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@ -262,42 +285,44 @@ int main(void)
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1)
|
||||
{
|
||||
|
||||
tud_task();
|
||||
//tud_cdc_write("1\r", 3);
|
||||
|
||||
//tud_cdc_write_flush();
|
||||
//video_task();
|
||||
//HAL_Delay(10);
|
||||
send_CDC_Bulk();
|
||||
HAL_Delay(5);
|
||||
if(currentSendingIndex >= 590){
|
||||
currentSendingIndex = 0;
|
||||
|
||||
//free(image_data);
|
||||
Cam_Capture(&hspi1);
|
||||
|
||||
/*
|
||||
Cam_Capture(&hspi1);
|
||||
image_size = Cam_FIFO_length(&hspi1);
|
||||
|
||||
uint16_t image_size = Cam_FIFO_length(&hspi1);
|
||||
//image_data = malloc((image_size + (image_size%10)) * sizeof(uint8_t));
|
||||
//memset(image_data, 0x00, image_size + (image_size%10));
|
||||
|
||||
uint8_t *image_data = malloc(image_size * sizeof(uint8_t));
|
||||
memset(image_data, 0x00, image_size);
|
||||
Cam_Start_Burst_Read(&hspi1);
|
||||
|
||||
Cam_Start_Burst_Read(&hspi1);
|
||||
HAL_SPI_Receive_DMA(&hspi1, &(image_data[0]), image_size);
|
||||
Debug_LED_On();
|
||||
|
||||
HAL_SPI_Receive_DMA(&hspi1, image_data, image_size);
|
||||
Debug_LED_On();
|
||||
|
||||
while (SPI_Rx_Done_Flag == 0)
|
||||
{
|
||||
// Wait for SPI transfer to finish
|
||||
while (SPI_Rx_Done_Flag == 0)
|
||||
{
|
||||
// Wait for SPI transfer to finish
|
||||
}
|
||||
CS_Off();
|
||||
SPI_Rx_Done_Flag = 0;
|
||||
if(image_size < 1){
|
||||
currentSendingIndex = 10000;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
LED_On();
|
||||
tud_cdc_write(&sendT[currentSendingIndex], 10);
|
||||
tud_cdc_write_flush();
|
||||
currentSendingIndex = currentSendingIndex + 10;
|
||||
HAL_Delay(5);
|
||||
}
|
||||
Debug_LED_Off();
|
||||
CS_Off();
|
||||
|
||||
SPI_Rx_Done_Flag = 0;
|
||||
|
||||
HAL_UART_Transmit(&huart2, image_data, image_size, HAL_MAX_DELAY);
|
||||
Debug_LED_Off();
|
||||
free(image_data);
|
||||
*/
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
1
HW/fp-info-cache
Normal file
1
HW/fp-info-cache
Normal file
@ -0,0 +1 @@
|
||||
0
|
BIN
Receiver/Displayer.o
Normal file
BIN
Receiver/Displayer.o
Normal file
Binary file not shown.
BIN
Receiver/ImageView.o
Normal file
BIN
Receiver/ImageView.o
Normal file
Binary file not shown.
@ -11,7 +11,7 @@ void Receiver::printHex(unsigned char value) {
|
||||
void Receiver::openStream(){
|
||||
while(1){
|
||||
// Open the CDC device file for reading
|
||||
cdcFile = open("/dev/ttyACM2", O_RDWR | O_NOCTTY);
|
||||
cdcFile = open("/dev/ttyACM1", O_RDWR | O_NOCTTY);
|
||||
if (cdcFile == -1) {
|
||||
std::cerr << "Failed to open CDC device file" << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
BIN
Receiver/Receiver.o
Normal file
BIN
Receiver/Receiver.o
Normal file
Binary file not shown.
BIN
Receiver/Transfer.o
Normal file
BIN
Receiver/Transfer.o
Normal file
Binary file not shown.
BIN
Receiver/main
Executable file
BIN
Receiver/main
Executable file
Binary file not shown.
@ -9,13 +9,22 @@
|
||||
|
||||
int cdcFile;
|
||||
struct termios tty;
|
||||
void readLoop(){
|
||||
openStream(&cdcFile);
|
||||
initSerial(&tty, &cdcFile);
|
||||
|
||||
void readLoop(Receiver ** receiverPtr){
|
||||
(*receiverPtr)->openStream();
|
||||
(*receiverPtr)->initSerial();
|
||||
|
||||
while (true) {
|
||||
readCdcData(&cdcFile);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
unsigned char character[10];
|
||||
(*receiverPtr)->readCdcData(&character);
|
||||
if((*receiverPtr)->findStart(&character) != -1)
|
||||
{std::cout << "start" << std::endl;}
|
||||
else if((*receiverPtr)->findEnd(&character) != -1)
|
||||
{std::cout << "stop" << std::endl;}
|
||||
else{
|
||||
std::cout << "-";
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
|
||||
close(cdcFile);
|
||||
@ -36,12 +45,13 @@ void receiverLoop(Receiver ** receiverPtr){
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
Displayer dis;
|
||||
Receiver *rec = new Receiver(&dis);
|
||||
|
||||
/*
|
||||
dis.createWindow();
|
||||
dis.renderWindow();
|
||||
|
||||
Receiver *rec = new Receiver(&dis);
|
||||
rec->openStream();
|
||||
rec->initSerial();
|
||||
rec->fillBuffer();
|
||||
@ -52,8 +62,8 @@ int main()
|
||||
dis.windowLoop();
|
||||
|
||||
t1.join();
|
||||
*/
|
||||
|
||||
|
||||
//readLoop();
|
||||
readLoop(&rec);
|
||||
return 0;
|
||||
}
|
||||
|
BIN
Receiver/main.o
Normal file
BIN
Receiver/main.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user