computer

profileAlkhawaa
code_snippets.txt

<code c> /* USER CODE BEGIN 3 */ if (stateChanged) printf("The current state is State%1d.\n\r", currentState); switch (currentState) { case State1: if (stateChanged) { printf("Press the Down key to go to State 2.\n\r"); stateChanged = false; BSP_LCD_GLASS_DisplayString(myStr1); } if (DOWN_KEY_IS_PRESSED) { currentState = State2; stateChanged = true; break; } break; case State2: if (stateChanged) { printf("Press the Up key to go to State 1.\n\r"); stateChanged = false; BSP_LCD_GLASS_DisplayString(myStr2); } //BSP_LCD_GLASS_ScrollSentence(myStr2, 1, SCROLL_SPEED_MEDIUM); if (UP_KEY_IS_PRESSED) { currentState = State1; stateChanged = true; break; } break; default: printf("Something is deadly wrong if you see this state.\n\r"); break; } } /* USER CODE END 3 */ </code> <code c> Point_Typedef myStr1Point[] = {POINT_OFF, POINT_OFF, POINT_OFF, POINT_ON, POINT_OFF, POINT_OFF}; </code> <code c> DoublePoint_Typedef myString1Colon[] = {DOUBLEPOINT_OFF, DOUBLEPOINT_OFF, DOUBLEPOINT_ON, DOUBLEPOINT_OFF, DOUBLEPOINT_OFF, DOUBLEPOINT_OFF,}; </code> <code c> BSP_LCD_GLASS_DisplayString_Pnt_Cln(myStr1, myStr1Point, myString1Colon); </code> <code c> /** * @brief Write a character string in the LCD RAM buffer with points/colons. * @param pstr: Pointer to string to display on the LCD Glass. * @param ppnt: Pointer to point to display on the LCD Glass. * @param pcol: Pointer to colon to display on the LCD Glass. * @retval None */ void BSP_LCD_GLASS_DisplayString_Pnt_Cln(uint8_t *pstr, Point_Typedef *ppnt, DoublePoint_Typedef *pcol) { DigitPosition_Typedef position = LCD_DIGIT_POSITION_1; int i = 0; /* Send the string character by character on lCD */ while ((*pstr != 0) & (position <= LCD_DIGIT_POSITION_6)) { /* Write one character on LCD */ WriteChar(pstr++, ppnt[i], pcol[i], position++); i++; } /* Update the LCD display */ HAL_LCD_UpdateDisplayRequest(&LCDHandle); } </code> <code c> void BSP_LCD_GLASS_DisplayString_Pnt_Cln(uint8_t *pstr, Point_Typedef *ppnt, DoublePoint_Typedef *pcol); </code> <code c> #ifndef __MY_NEW_SPECIAL_LCD_CODE_H #define __MY_NEW_SPECIAL_LCD_CODE_H #ifdef __cplusplus extern "C" { #endif // My own new LCD characters and codes #define MY_CODE1 ((uint8_t) 251) #define C_MY_CODE1 ((uint16_t) to be modified) #define MY_CODE2 ((uint8_t) 252) #define C_MY_CODE2 ((uint16_t) to be modified) #define MY_CODE3 ((uint8_t) 253) #define C_MY_CODE3 ((uint16_t) to be modified) #ifdef __cplusplus } #endif #endif /* __MY_NEW_SPECIAL_LCD_CODE_H */ </code> <code c> static void Convert(uint8_t *Char, Point_Typedef Point, DoublePoint_Typedef Colon) { uint16_t ch = 0 ; uint8_t loop = 0, index = 0; bool isDefault = false; switch (*Char) { case MY_CODE1: ch = C_MY_CODE1; break ; case MY_CODE2: ch = C_MY_CODE2; break ; case MY_CODE3: ch = C_MY_CODE3; break ; default: isDefault = true; Convert_bsp(Char, (Point_Typedef)Point, (DoublePoint_Typedef)Colon); break; } // Set the decimal point and the colon and prepare the data in Digit // See the comments in Convert_bsp for functions of the code below. if (!isDefault) { ... } </code> <code c> uint8_t myStr2[] = "LGOabc"; myStr2[3] = MY_CODE1; myStr2[4] = MY_CODE2; myStr2[5] = MY_CODE3; </code>