Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Board_GLCD.h"
- #include "Board_LED.h"
- #include "stm32f2xx_hal.h"
- #include "GLCD_Config.h"
- #include "JOY.h"
- #include "Serial.h"
- #include "string.h"
- extern GLCD_FONT GLCD_Font_16x24;
- uint32_t fw,fh,dx,dy;
- bool ready;
- const char ASCII[] = {' ','!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' , 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'};
- /**Initialize the peripherals: Already Done**/
- void setup(void){
- GLCD_Initialize();
- LED_Initialize();
- JOY_Init();
- SER_Init(115200);
- GLCD_SetFont(&GLCD_Font_16x24);
- GLCD_SetBackgroundColor(GLCD_COLOR_PURPLE);
- fw = GLCD_Font_16x24.width;// font width
- fh = GLCD_Font_16x24.height; //font height
- //minimum x position on the screen. Corresponds to column 0
- dx = (GLCD_WIDTH - 16*fw)>>1;
- //minimum y position on the screen. Corresponds to row 0
- dy = (GLCD_HEIGHT - 6*fh)>>1;
- //use to prevent Joy stick sampling when the joy stick has not be initialized
- ready = true;
- }
- /**Checks if the direction of the joy stick and move the cursor in the joy stick's direction. If the cursor is at the bounds, cursor will not be moved**/
- void sampleJoystick(void){
- if(!ready)return; //initialization has not completed, abort
- uint32_t key = JOY_GetKeys();
- // Put code here //
- }
- int32_t* convertChar(int32_t* array){
- int arraySize = (sizeof(ASCII)/sizeof(ASCII[0]));
- int arrayIndex = 0;
- for(arrayIndex = 0; arrayIndex < arraySize; arrayIndex++){
- memcpy(&array[arrayIndex], &ASCII[arrayIndex] + (arrayIndex * 4), sizeof(int32_t));
- }
- return array;
- }
- /**Convert row and column to actual x y position: p[0] = column p[1] = row **/
- uint32_t toPosition(int* p){
- char position[6][12];
- }
- /**Draw ascii characters on the screen**/
- void draw(void){
- int arraySize = (sizeof(ASCII)/sizeof(ASCII[0]));
- int32_t int32_tASCII[arraySize];
- int32_t* ASCIIArray = convertChar(int32_tASCII);
- int arrayIndex = 0;
- int* x;
- for(arrayIndex = 0; arrayIndex < arraySize; arrayIndex++){
- GLCD_DrawChar(toPosition(x), 0, ASCIIArray[arrayIndex]);
- }
- }
- int main(void){
- SystemCoreClockUpdate();
- HAL_Init();
- SysTick_Config(SystemCoreClock/1000);
- setup();
- GLCD_ClearScreen();
- draw();
- // Add Additional lines of code if required //
- while(1){}
- }
- /*SysTick ISR*/
- void SysTick_Handler(void){
- //increment HAL tick variable; this is required for LCD Display Config.
- HAL_IncTick();
- //check for joy stick movement to configure Joystick Sampling
- sampleJoystick();
- }
- /**Highlight the character c in the 16x6 grid **/
- void highlightText(uint32_t c){
- // Put code here //
- }
- /**Fill the array p with the row and column number of the character ch: p[0] column p[1] = row **/
- void getPos(uint32_t ch,int *p){
- // Put code here //
- }
- /**Toggle the LED based on the bits of the character c.
- 1 LED will be turned on
- 0 LED will be turned off **/
- void LED (uint32_t c){
- // Put code here //
- }
- /** Clear any previous highlight and highlight c **/
- void ClearHighlight(uint32_t c){
- // Put code here //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement