/** * @brief Displays recieved data * @param data: Keyboard data to be displayed * @retval None */ static void DumpReceivedData(void) { uint16_t size; uint8_t *ptr = CDC_RX_Buffer; size = USBH_CDC_GetLastReceivedDataSize(&hUSBHost); BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); while(size--) { if((*ptr != '\n') && (*ptr != '\r')) { if(*ptr == '\t') { BSP_LCD_DisplayChar(xPos, LINE(yLinePos), ' '); } else { BSP_LCD_DisplayChar(xPos, LINE(yLinePos), *ptr); } xPos += 7; } else if(*ptr == '\n') { yLinePos++; xPos = 0; } ptr++; if(xPos > (BSP_LCD_GetXSize() - 7)) { xPos = 0; yLinePos++; } if(yLinePos > 13) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"Use [User Key] to see more data"); /* Key Button in polling */ while(BSP_PB_GetState(BUTTON_KEY) != RESET) { /* Wait for User Input */ } LCD_ClearTextZone(); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAtLine(3, (uint8_t *)"Receiving data ..."); BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); xPos = 0; yLinePos = 4; } } }
void printNewRampID() { xSemaphoreTake(mutex_drawer, portMAX_DELAY); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); if (rampSelected == 128) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayChar(380, 210, 'N'); } else { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(380, 210, '0' + rampSelected); } xSemaphoreGive(mutex_drawer); }
void printNewCycleID() { xSemaphoreTake(mutex_drawer, portMAX_DELAY); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); if (cycleSelected == 128) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayChar(380, 240, 'N'); } else { BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); BSP_LCD_DisplayChar(380, 240, '0' + cycleSelected); } xSemaphoreGive(mutex_drawer); }
/** * @brief Displays received data * @param data: Keyboard data to be displayed * @retval None */ static void DumpReceivedData(void) { uint16_t size; uint8_t *ptr = CDC_RX_Buffer; size = USBH_CDC_GetLastReceivedDataSize(&hUSBHost); BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); while(size--) { if((*ptr != '\n') && (*ptr != '\r')) { if(*ptr == '\t') { BSP_LCD_DisplayChar(xPos, LINE(yLinePos), ' '); } else { BSP_LCD_DisplayChar(xPos, LINE(yLinePos), *ptr); } xPos += 7; } else if(*ptr == '\n') { yLinePos++; xPos = 0; } ptr++; if(xPos > (BSP_LCD_GetXSize() - 7)) { xPos = 0; yLinePos++; } if(yLinePos > 13) { xPos = 0; yLinePos = 5; } } }
/** * @brief Displays characters on the LCD. * @param Xpos: X position (in pixel) * @param Ypos: Y position (in pixel) * @param Text: Pointer to string to display on LCD * @param Mode: Display mode * This parameter can be one of the following values: * @arg CENTER_MODE * @arg RIGHT_MODE * @arg LEFT_MODE * @retval None */ void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) { uint16_t ref_column = 1, i = 0; uint32_t size = 0, xsize = 0; uint8_t *ptr = Text; /* Get the text size */ while (*ptr++) size ++ ; /* Characters number per line */ xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); switch (Mode) { case CENTER_MODE: { ref_column = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2; break; } case LEFT_MODE: { ref_column = Xpos; break; } case RIGHT_MODE: { ref_column = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); break; } default: { ref_column = Xpos; break; } } /* Check that the Start column is located in the screen */ if ((ref_column < 1) || (ref_column >= 0x8000)) { ref_column = 1; } /* Send the string character by character on LCD */ while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) { /* Display one character on LCD */ BSP_LCD_DisplayChar(ref_column, Ypos, *Text); /* Decrement the column position by 16 */ ref_column += DrawProp[ActiveLayer].pFont->Width; /* Point on the next character */ Text++; i++; } }
/** * @brief Displays the current Time on the LCD. * @param Line: the Line where to display the Current time . * This parameter can be one of the following values: * @arg Linex: where x can be 0..9 * @param Color_x: specifies the Background Color. * @param table: the Current time and sub second. * @retval None */ static void RTC_Time_display(uint8_t Line, uint32_t Color_x, Table_TypeDef table ) { uint8_t i = 0; /* Initialize table */ BSP_LCD_SetTextColor(Color_x); for(i=0; i<8; i++) { /* Display char on the LCD */ BSP_LCD_DisplayChar((150 + (20 *i)),LINE(Line), table.tab[i]); } }
/** * @brief Handles mouse scroll to update the mouse position on display window. * @param x: USB HID Mouse X co-ordinate * @param y: USB HID Mouse Y co-ordinate * @retval None */ static void HID_MOUSE_UpdatePosition(int8_t x, int8_t y) { static int16_t x_loc = 0, y_loc = 0; static int16_t prev_x = 5, prev_y = 1; if((x != 0) || (y != 0)) { x_loc += x/2; y_loc += y/10; if(y_loc > MOUSE_WINDOW_HEIGHT - 12) { y_loc = MOUSE_WINDOW_HEIGHT - 12; } if(x_loc > MOUSE_WINDOW_WIDTH - 10) { x_loc = MOUSE_WINDOW_WIDTH - 10; } if(y_loc < 2) { y_loc = 2; } if(x_loc < 2) { x_loc = 2; } BSP_LCD_SetBackColor(LCD_COLOR_BLACK); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DisplayChar(MOUSE_WINDOW_X + prev_x, MOUSE_WINDOW_Y + prev_y, 'x'); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayChar(MOUSE_WINDOW_X + x_loc, MOUSE_WINDOW_Y + y_loc, 'x'); prev_x = x_loc; prev_y = y_loc; } }
/** * @brief Displays characters on the LCD. * @param Xpos: X position (in pixel) * @param Ypos: Y position (in pixel) * @param pText: Pointer to string to display on LCD * @param Mode: Display mode * This parameter can be one of the following values: * @arg CENTER_MODE * @arg RIGHT_MODE * @arg LEFT_MODE * @retval None */ void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *pText, Line_ModeTypdef Mode) { uint16_t refcolumn = 1, counter = 0; uint32_t size = 0, xsize = 0; uint8_t *ptr = pText; /* Get the text size */ while (*ptr++) size ++ ; /* Characters number per line */ xsize = (BSP_LCD_GetXSize()/DrawProp.pFont->Width); switch (Mode) { case CENTER_MODE: { refcolumn = Xpos + ((xsize - size)* DrawProp.pFont->Width) / 2; break; } case LEFT_MODE: { refcolumn = Xpos; break; } case RIGHT_MODE: { refcolumn = - Xpos + ((xsize - size)*DrawProp.pFont->Width); break; } default: { refcolumn = Xpos; break; } } /* Send the string character by character on lCD */ while ((*pText != 0) & (((BSP_LCD_GetXSize() - (counter*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width)) { /* Display one character on LCD */ BSP_LCD_DisplayChar(refcolumn, Ypos, *pText); /* Decrement the column position by 16 */ refcolumn += DrawProp.pFont->Width; /* Point on the next character */ pText++; counter++; } }
void lcdPutChar(char_t c) { if(c == '\r') { lcdColumn = 0; } else if(c == '\n') { lcdColumn = 0; lcdLine++; } else if(lcdLine < 11 && lcdColumn < 30) { //Display current character BSP_LCD_DisplayChar(lcdColumn * 16, lcdLine * 24, c); //Advance the cursor position if(++lcdColumn >= 30) { lcdColumn = 0; lcdLine++; } } }
/** * @brief Processes Keyboard data. * @param data: Keyboard data to be displayed * @retval None */ void USR_KEYBRD_ProcessData(uint8_t data) { if(data == '\n') { KeybrdCharYpos = KYBRD_FIRST_COLUMN; /* Increment char X position */ KeybrdCharXpos += SMALL_FONT_LINE_WIDTH; if(KeybrdCharXpos > KYBRD_LAST_LINE) { LCD_LOG_ClearTextZone(); KeybrdCharXpos = KYBRD_FIRST_LINE; KeybrdCharYpos = KYBRD_FIRST_COLUMN; } } else if(data == '\r') { /* Manage deletion of character and upadte cursor location */ if(KeybrdCharYpos == KYBRD_FIRST_COLUMN) { /* First character of first line to be deleted */ if(KeybrdCharXpos == KYBRD_FIRST_LINE) { KeybrdCharYpos = KYBRD_FIRST_COLUMN; } else { KeybrdCharXpos += SMALL_FONT_LINE_WIDTH; KeybrdCharYpos = (KYBRD_LAST_COLUMN + SMALL_FONT_COLUMN_WIDTH); } } else { KeybrdCharYpos += SMALL_FONT_COLUMN_WIDTH; } BSP_LCD_DisplayChar(KeybrdCharYpos, KeybrdCharXpos, ' '); } else { /* Update the cursor position on LCD */ BSP_LCD_DisplayChar(KeybrdCharYpos, KeybrdCharXpos, data); /* Increment char Y position */ KeybrdCharYpos += SMALL_FONT_COLUMN_WIDTH; /* Check if the Y position has reached the last column */ if(KeybrdCharYpos == KYBRD_LAST_COLUMN) { KeybrdCharYpos = KYBRD_FIRST_COLUMN; /* Increment char X position */ KeybrdCharXpos += SMALL_FONT_LINE_WIDTH; } if(KeybrdCharXpos > KYBRD_LAST_LINE) { LCD_LOG_ClearTextZone(); KeybrdCharXpos = KYBRD_FIRST_LINE; /* Start New Display of the cursor position on LCD */ BSP_LCD_DisplayChar(KeybrdCharYpos,KeybrdCharXpos, data); } } }
/** * @brief Joystick cursor position * @param None * @retval None */ void Joystick_SetCursorPosition(void) { static uint16_t xPtr = 12; static uint16_t yPtr = 52; static uint16_t old_xPtr = 12; static uint16_t old_yPtr = 52; switch(JoyState) { case JOY_UP: if(yPtr > 52) { yPtr--; } break; case JOY_DOWN: if(yPtr < (BSP_LCD_GetYSize() - 12 - 11)) { yPtr++; } break; case JOY_LEFT: if(xPtr > 12) { xPtr--; } break; case JOY_RIGHT: if(xPtr < (BSP_LCD_GetXSize() - 8 - 11)) { xPtr++; } break; default: break; } BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); if(JoyState == JOY_SEL) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); } else if(JoyState == JOY_NONE) { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); } else { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayChar(old_xPtr, old_yPtr, 'X'); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); old_xPtr = xPtr; old_yPtr = yPtr; } }
void Draw_Menu(void) { BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_FillRect((uint16_t)0, (uint16_t)GRID_DIVISION_V, (uint16_t)BSP_LCD_GetXSize(), (uint16_t)(BSP_LCD_GetYSize() - GRID_DIVISION_V)); BSP_LCD_SetTextColor(LCD_COLOR_DARKGRAY); BSP_LCD_FillRect((uint16_t)(GRID_DIVISION_H * 3), (uint16_t)GRID_DIVISION_V, (uint16_t)(BSP_LCD_GetXSize() - GRID_DIVISION_H * 3), (uint16_t)(BSP_LCD_GetYSize() - GRID_DIVISION_V)); BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); BSP_LCD_FillRect((uint16_t)0, (uint16_t)0, (uint16_t)BSP_LCD_GetXSize(), (uint16_t)(24 * 3)); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_DARKBLUE); BSP_LCD_DisplayStringAt((uint16_t)0, (uint16_t)24, (uint8_t *)"calc_stm32f469i-disco", CENTER_MODE); BSP_LCD_SetBackColor(LCD_COLOR_BLACK); BSP_LCD_DisplayChar((uint16_t)(KEY_7_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_7_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'7'); BSP_LCD_DisplayChar((uint16_t)(KEY_7_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_4_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'4'); BSP_LCD_DisplayChar((uint16_t)(KEY_7_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_1_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'1'); BSP_LCD_DisplayChar((uint16_t)(KEY_7_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_0_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'0'); BSP_LCD_DisplayChar((uint16_t)(KEY_8_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_7_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'8'); BSP_LCD_DisplayChar((uint16_t)(KEY_8_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_4_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'5'); BSP_LCD_DisplayChar((uint16_t)(KEY_8_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_1_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'2'); BSP_LCD_DisplayChar((uint16_t)(KEY_8_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_0_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'.'); BSP_LCD_DisplayChar((uint16_t)(KEY_9_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_7_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'9'); BSP_LCD_DisplayChar((uint16_t)(KEY_9_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_4_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'6'); BSP_LCD_DisplayChar((uint16_t)(KEY_9_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_1_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'3'); BSP_LCD_DisplayChar((uint16_t)(KEY_9_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_0_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'='); BSP_LCD_SetBackColor(LCD_COLOR_DARKGRAY); BSP_LCD_DisplayChar((uint16_t)(KEY_C_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_C_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'C'); BSP_LCD_DisplayStringAt((uint16_t)(KEY_C_CENTER_X - 17), (uint16_t)(KEY_CE_CENTER_Y - TEXT_OFFSET_Y), (uint8_t *)"CE", LEFT_MODE); BSP_LCD_DisplayChar((uint16_t)(KEY_C_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_DIV_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'/'); BSP_LCD_DisplayChar((uint16_t)(KEY_C_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_MUL_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'*'); BSP_LCD_DisplayChar((uint16_t)(KEY_C_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_SUB_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'-'); BSP_LCD_DisplayChar((uint16_t)(KEY_C_CENTER_X - TEXT_OFFSET_X), (uint16_t)(KEY_ADD_CENTER_Y - TEXT_OFFSET_Y), (uint8_t)'+'); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); }
/** * @brief Joystick demo * @param None * @retval None */ void Joystick_demo(void) { static uint16_t xPtr = 12; static uint16_t yPtr = 92; static uint16_t old_xPtr = 12; static uint16_t old_yPtr = 92; uint8_t status = 0; Joystick_SetHint(); status = BSP_JOY_Init(JOY_MODE_GPIO); if (status != IO_OK) { BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 95, (uint8_t *)"ERROR", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 80, (uint8_t *)"Joystick cannot be initialized", CENTER_MODE); } while (1) { if (status == IO_OK) { /* Get the Joystick State */ JoyState = BSP_JOY_GetState(); switch(JoyState) { case JOY_UP: if(yPtr > 92) { yPtr--; } break; case JOY_DOWN: if(yPtr < (BSP_LCD_GetYSize() - 12 - 11)) { yPtr++; } break; case JOY_LEFT: if(xPtr > 12) { xPtr--; } break; case JOY_RIGHT: if(xPtr < (BSP_LCD_GetXSize() - 8 - 11)) { xPtr++; } break; default: break; } BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); if(JoyState == JOY_SEL) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); } else if(JoyState == JOY_NONE) { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); } else { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayChar(old_xPtr, old_yPtr, 'X'); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); old_xPtr = xPtr; old_yPtr = yPtr; } } if(CheckForUserInput() > 0) { return; } HAL_Delay(5); } }
// Note modifed by CMN to use X as a coordinate, not a character position void BSP_LCD_DisplayStringAt(uint16_t X, uint16_t Y, uint8_t *pText, Text_AlignModeTypdef mode) { uint32_t fgColor; uint32_t bgColor; fgColor = BSP_LCD_GetTextColor(); bgColor = BSP_LCD_GetBackColor(); uint16_t refcolumn = 1, i = 0; uint32_t size = 0, xsize = 0; uint8_t *ptr = pText; /* Get the text size */ while (*ptr++) size ++ ; /* Characters number per line */ xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); switch (mode) { case CENTER_MODE: { refcolumn = X - ((size)* DrawProp[ActiveLayer].pFont->Width) / 2; break; } case LEFT_MODE: { refcolumn = X; break; } case RIGHT_MODE: { refcolumn = X + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); break; } default: { refcolumn = X; break; } } /* Send the string character by character on LCD */ while ((*pText != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) { // inverse video if (*pText & 0x80) { BSP_LCD_SetTextColor(bgColor); BSP_LCD_SetBackColor(fgColor); } else { BSP_LCD_SetTextColor(fgColor); BSP_LCD_SetBackColor(bgColor); } /* Display one character on LCD */ BSP_LCD_DisplayChar(refcolumn, Y, 0x7f & (*pText)); /* Decrement the column position by 16 */ refcolumn += DrawProp[ActiveLayer].pFont->Width; /* Point on the next character */ pText++; i++; } }
void LCD_DISCO_F469NI::DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) { BSP_LCD_DisplayChar(Xpos, Ypos, Ascii); }