Bonjour,
alors je suis un debutant en systeme embarque ... j´ai commence avec le code de demonstration que je n´arrive pas a bien saisir
enfaite je dois normalement dans ce programme , inserer un cube et un triangle grace a la librarie ugfx et faire la rotation autour d´un cercle ... mais jn´arrive pas bien comprendre comment utiliser les fonctions de Gdisp : http://api.ugfx.org/master/group___g...8eba8cd565e04fCode:#include "includes.h" // start and stop bytes for the UART protocol #define ESPL_StartByte 0xAA #define ESPL_StopByte 0x55 QueueHandle_t ESPL_RxQueue; // Already defined in ESPL_Functions.h SemaphoreHandle_t ESPL_DisplayReady; // Structs defined in Demo.h // struct line // { // char x_1; // char y_1; // char x_2; // char y_2; //char x_3; // char x_3; // }; // // struct coord // { // char x; // char y; // }; // Stores lines to be drawn QueueHandle_t DrawQueue; /** * Entry function to the example program. * Initializes hardware and software. * Starts scheduler. */ int main() { // Initialize Board functions ESPL_SystemInit(); // Initializes Draw Queue with 100 lines buffer DrawQueue = xQueueCreate(100, 4 * sizeof(char)); // Initializes Tasks with their respective priority xTaskCreate(drawTask, "drawTask", 1000, NULL, 4, NULL); xTaskCreate(checkJoystick, "checkJoystick", 1000, NULL, 3, NULL); xTaskCreate(uartReceive, "queueReceive", 1000, NULL, 2, NULL); // Start FreeRTOS Scheduler vTaskStartScheduler(); } /** * Example task which draws to the display. */ static void drawTask() { char str[100]; // Init buffer for message struct line line; // Init buffer for line font_t font1; // Load font for ugfx font1 = gdispOpenFont("DejaVuSans24*"); gdispClear(White); for (int i = 0; i < 255; i++) { gdispDrawLine(10 + i, 170, 10 + i, 200, ((i >> 3) << 11)); } for (int i = 0; i < 255; i++) { gdispDrawLine(10 + i, 140, 10 + i, 170, ((i >> 3) << 6)); } for (int i = 0; i < 255; i++) { gdispDrawLine(10 + i, 110, 10 + i, 140, (i >> 3)); } for (int i = 0; i < 255; i++) { gdispDrawLine(10 + i, 200, 10 + i, 230, (i >> 3) | ((i >> 3) << 6) | ((i >> 3) << 11)); } // Start endless loop while (TRUE) { // wait for buffer swap while (xQueueReceive(DrawQueue, &line, 0) == pdTRUE) { } // draw to display gdispClear(White); if (current_layer == LCD_BACKGROUND_LAYER) { gdispFillArea(0, 210, 320, 20, Blue); } else { gdispFillArea(0, 220, 320, 20, Red); } gdispDrawLine(0, 0, 10, 10, Yellow ); // Generate string with current joystick values sprintf(str, "Axis 1: %5d|Axis 2: %5d|VBat: %5d", ADC_GetConversionValue(ESPL_ADC_Joystick_1), ADC_GetConversionValue(ESPL_ADC_Joystick_2),ADC_GetConversionValue(ESPL_ADC_VBat)); // Print string of joystick values gdispDrawString(0, 0, str, font1, Black); // Generate string with current joystick values sprintf(str, "A: %d|B: %d|C %d|D: %d|E: %d|J: %d", GPIO_ReadInputDataBit(ESPL_Register_Button_A, ESPL_Pin_Button_A), GPIO_ReadInputDataBit(ESPL_Register_Button_B, ESPL_Pin_Button_B), GPIO_ReadInputDataBit(ESPL_Register_Button_C, ESPL_Pin_Button_C), GPIO_ReadInputDataBit(ESPL_Register_Button_D, ESPL_Pin_Button_D), GPIO_ReadInputDataBit(ESPL_Register_Button_E, ESPL_Pin_Button_E), GPIO_ReadInputDataBit(ESPL_Register_Button_K, ESPL_Pin_Button_K)); // Print string of joystick values gdispDrawString(0, 11, str, font1, Black); gdispFillCircle(20+ line.x_2, 10 + line.y_2, 10, Green); gdispDrawBox(40+line.x_2,10+line.y_2 ,10, 10, Red); // Wait for display to stop writing xSemaphoreTake(ESPL_DisplayReady, 0); // Wait for display to stop writing xSemaphoreTake(ESPL_DisplayReady, portMAX_DELAY); // swap buffers ESPL_DrawLayer(); } } /** * This task polls the joystick value every 20 ticks */ static void checkJoystick() { TickType_t xLastWakeTime; xLastWakeTime = xTaskGetTickCount(); struct coord joystick_now = { 0, 0 }, joystick_last = { 0, 0 }; while (TRUE) { // Remember last joystick values joystick_last = joystick_now; joystick_now.x = (uint8_t) (ADC_GetConversionValue(ESPL_ADC_Joystick_2) >> 4); joystick_now.y = (uint8_t) 255 - (ADC_GetConversionValue(ESPL_ADC_Joystick_1) >> 4); // Send over UART sendLine(joystick_last, joystick_now); // Execute every 20 Ticks vTaskDelayUntil(&xLastWakeTime, 20); } } /** * Example function to send data over UART */ void sendLine(struct coord coord_1, struct coord coord_2) { char checksum; // Generate simple error detection checksum checksum = coord_1.x ^ coord_1.y ^ coord_2.x ^ coord_2.y; // Structure of one packet: // Start byte // 4 * line byte // checksum (all xor) // End byte UART_SendData((uint8_t) ESPL_StartByte); UART_SendData((uint8_t) coord_1.x); UART_SendData((uint8_t) coord_1.y); UART_SendData((uint8_t) coord_2.x); UART_SendData((uint8_t) coord_2.y); UART_SendData((uint8_t) checksum); UART_SendData((uint8_t) ESPL_StopByte); } /** * Task which receives data via UART and decodes it. */ static void uartReceive() { char input; uint8_t pos = 0; char checksum; char buffer[7]; // Start byte,4* line byte, checksum (all xor), End byte struct line line; while (TRUE) { // wait for data in queue xQueueReceive(ESPL_RxQueue, &input, portMAX_DELAY); // decode package by buffer position switch (pos) { // start byte case 0: if (input == ESPL_StartByte) { buffer[0] = input; pos = 1; } break; // line bytes case 1: case 2: case 3: case 4: // Check sum case 5: buffer[pos] = input; pos++; break; // Last byte should be stop byte case 6: if (input == ESPL_StopByte) { // Check if checksum is accurate checksum = buffer[1] ^ buffer[2] ^ buffer[3] ^ buffer[4]; // Decode packet to line struct if (buffer[5] == checksum) { line.x_1 = buffer[1] / 2; line.y_1 = buffer[2] / 2; line.x_2 = buffer[3] / 2; line.y_2 = buffer[4] / 2; // Send line to be drawn xQueueSend(DrawQueue, &line, 100); pos = 0; } else { // Reset buffer pos = 0; } } else { pos = 0; } } } } /** * Idle hook, definition is needed for FreeRTOS to function. */ void VApplicationIdleHook() { while (TRUE) { }; }
en plus je ne comprend pas ce que c´est line.x_2 et line.y_2
Si quelqu´un pourrait aider j´en serai tres reconaissant
Merci !
-----