void GLCD_DrawO(int row, int col) { Point points[] = { {0,17}, {0,16}, {0,15}, {0,14}, {0,13}, {1,12}, {1,11}, {1,10}, {2,10}, {2, 9}, {2, 8}, {3, 8}, {3, 7}, {4, 6}, {5, 5}, {6, 4}, {7, 3}, {8, 3}, {8, 2}, {9, 2}, {10,2}, {10,1}, {11,1}, {12,1}, {13,0}, {14,0}, {15,0}, {16,0}, {17,0} }; int len_points = 29; int i; for (i = 0; i < len_points; i++) { // upper left quadrant GLCD_PutPixel(rows[row] + points[i].x, cols[col] + points[i].y); // upper right GLCD_PutPixel(rows[row] + LETTERDIM - points[i].x, cols[col] + points[i].y); // lower left GLCD_PutPixel(rows[row] + points[i].x, cols[col] + LETTERDIM - points[i].y); // lower right GLCD_PutPixel(rows[row] + LETTERDIM - points[i].x, cols[col] + LETTERDIM - points[i].y); } }
void KEN_draw_straightlineY( int x0, int y0, int y1){ // first obtain absolute distance int dy = y0<y1 ? (y1-y0) : (y0-y1); // basically dx=abs(y1-y0) int k = dy/2+1; // Get k value to get distance by 2. while(k>0) { GLCD_PutPixel(x0,y0); // Put pixels from one direction GLCD_PutPixel(x0,y1); // Put pixels from opposite direction y1--; // decrement in one direction y0++; // increment on other direction k--; } }
void Draw_straightlineX( int x0, int y0, int x1){ // first obtain absolute distance int dx = x0<x1 ? (x1-x0) : (x0-x1); // basically dx=abs(x1-x0) int k = dx/2+1; // Get k value to get distance by 2. while(k>0) { // call of GCLD function; GLCD_PutPixel(x0,y0); // Put pixels from one direction GLCD_PutPixel(x1,y0); // Put pixels from opposite direction x1--; // decrement in one direction x0++; // increment on other direction k--; } }
/******************************************************************************* * Draw a line at specified coordinates (x,y) with specified length (len) in * * given direction (dir). * * Parameter: x: x position * * y: y position * * len: length * * dir: direction * * Return: * *******************************************************************************/ void GLCD_DrawLine (unsigned int x, unsigned int y, unsigned int len, unsigned int dir) { uint32_t i; if (dir == 0) { /* Vertical line */ for (i = 0; i < len; i++) { GLCD_PutPixel (x, y + i); } } else { /* Horizontal line */ for (i = 0; i < len; i++) { GLCD_PutPixel (x + i, y); } } }
void GLCD_DrawBoard(void) { int w, h; for (w = 0 + W_OFFSET; w < BOARD_WIDTH + W_OFFSET; w++) { for (h = 0 + H_OFFSET; h < BOARD_HEIGHT + H_OFFSET; h++) { if (w == (SPACER * 2 + LETTERDIM + 1 + W_OFFSET) || w == ((SPACER * 2 + LETTERDIM) * 2 + 1 + W_OFFSET) ) GLCD_PutPixel(w, h); else if (h == (SPACER * 2 + LETTERDIM + 1 + H_OFFSET) || h == ((SPACER * 2 + LETTERDIM) * 2 + 1 + H_OFFSET) ) GLCD_PutPixel(w, h); else GLCD_ClearPixel(w, h); } } }
void GLCD_DrawX(int row, int col) { int w, h; for (w = 0; w < LETTERDIM; w++) { for (h = 0; h < LETTERDIM; h++) { if (w == h || w + h == LETTERDIM - 1) GLCD_PutPixel(w + cols[col], h + rows[row]); } } }
void Draw_lineXY( int x0, int y0,int x1,int y1, int t,int s){ int i,d; y1>y0 ? (d = 1) : (d = 2); while(x0<=x1 & y0!=y1) { i = 0; while(i < t){ GLCD_PutPixel(x0+i,y0); // Put pixels i++; } if(d == 1){ y0++; } else if(d == 2){ y0--; } x0 = x0 + s; } }
// This is the actual task that is run static portTASK_FUNCTION( vLCDUpdateTask, pvParameters ) { #if LCD_EXAMPLE_OP==0 unsigned short screenColor = 0; unsigned short tscr; unsigned char curLine; unsigned timerCount = 0; int xoffset = 0, yoffset = 0; unsigned int xmin=0, xmax=0, ymin=0, ymax=0; unsigned int x, y; int i, j; float hue=0, sat=0.2, light=0.2; #elif LCD_EXAMPLE_OP==1 unsigned char picIndex = 0; #else Bad definition #endif vtLCDMsg msgBuffer; vtLCDStruct *lcdPtr = (vtLCDStruct *) pvParameters; #ifdef INSPECT_STACK // This is meant as an example that you can re-use in your own tasks // Inspect to the stack remaining to see how much room is remaining // 1. I'll check it here before anything really gets started // 2. I'll check during the run to see if it drops below 10% // 3. You could use break points or logging to check on this, but // you really don't want to print it out because printf() can // result in significant stack usage. // 4. Note that this checking is not perfect -- in fact, it will not // be able to tell how much the stack grows on a printf() call and // that growth can be *large* if version 1 of printf() is used. unsigned portBASE_TYPE InitialStackLeft = uxTaskGetStackHighWaterMark(NULL); unsigned portBASE_TYPE CurrentStackLeft; float remainingStack = InitialStackLeft; remainingStack /= lcdSTACK_SIZE; if (remainingStack < 0.10) { // If the stack is really low, stop everything because we don't want it to run out // The 0.10 is just leaving a cushion, in theory, you could use exactly all of it VT_HANDLE_FATAL_ERROR(0); } #endif /* Initialize the LCD and set the initial colors */ GLCD_Init(); tscr = Red; // may be reset in the LCDMsgTypeTimer code below screenColor = White; // may be reset in the LCDMsgTypeTimer code below GLCD_SetTextColor(tscr); GLCD_SetBackColor(screenColor); GLCD_Clear(screenColor); // Added by Matthew Ibarra 2/2/2013 int xPos = 0; // Note that srand() & rand() require the use of malloc() and should not be used unless you are using // MALLOC_VERSION==1 #if MALLOC_VERSION==1 srand((unsigned) 55); // initialize the random number generator to the same seed for repeatability #endif curLine = 5; // This task should never exit for(;;) { #ifdef INSPECT_STACK CurrentStackLeft = uxTaskGetStackHighWaterMark(NULL); float remainingStack = CurrentStackLeft; remainingStack /= lcdSTACK_SIZE; if (remainingStack < 0.10) { // If the stack is really low, stop everything because we don't want it to run out VT_HANDLE_FATAL_ERROR(0); } #endif #if LCD_EXAMPLE_OP==0 // Wait for a message if (xQueueReceive(lcdPtr->inQ,(void *) &msgBuffer,portMAX_DELAY) != pdTRUE) { VT_HANDLE_FATAL_ERROR(0); } #if EXAMPLE_COLOR_CHANGE==1 //Log that we are processing a message -- more explanation of logging is given later on vtITMu8(vtITMPortLCDMsg,getMsgType(&msgBuffer)); vtITMu8(vtITMPortLCDMsg,getMsgLength(&msgBuffer)); // Take a different action depending on the type of the message that we received switch(getMsgType(&msgBuffer)) { case LCDMsgTypePrint: { // This will result in the text printing in the last five lines of the screen char lineBuffer[lcdCHAR_IN_LINE+1]; copyMsgString(lineBuffer,&msgBuffer,lcdCHAR_IN_LINE); // clear the line GLCD_ClearLn(curLine,1); // show the text GLCD_DisplayString(curLine,0,1,(unsigned char *)lineBuffer); curLine++; if (curLine == lcdNUM_LINES) { curLine = 5; } break; } case LCDMsgTypeTimer: { // Note: if I cared how long the timer update was I would call my routine // unpackTimerMsg() which would unpack the message and get that value // Each timer update will cause a circle to be drawn on the top half of the screen // as explained below if (timerCount == 0) { /* ************************************************** */ // Find a new color for the screen by randomly (within limits) selecting HSL values // This can be ignored unless you care about the color map #if MALLOC_VERSION==1 hue = rand() % 360; sat = (rand() % 1024) / 1023.0; sat = sat * 0.5; sat += 0.5; light = (rand() % 1024) / 1023.0; light = light * 0.8; light += 0.10; #else hue = (hue + 1); if (hue >= 360) hue = 0; sat+=0.01; if (sat > 1.0) sat = 0.20; light+=0.03; if (light > 1.0) light = 0.20; #endif screenColor = hsl2rgb(hue,sat,light); // Now choose a complementary value for the text color hue += 180; if (hue >= 360) hue -= 360; tscr = hsl2rgb(hue,sat,light); GLCD_SetTextColor(tscr); GLCD_SetBackColor(screenColor); // End of playing around with figuring out a random color /* ************************************************** */ // clear the top half of the screen GLCD_ClearWindow(0,0,320,120,screenColor); // Now we are going to draw a circle in the upper left corner of the screen int count = 200; float radius; float inc, val, offset = MAX_RADIUS; unsigned short circleColor; inc = 2*M_PI/count; xmax = 0; ymax = 0; xmin = 50000; ymin = 50000; val = 0.0; for (i=0;i<count;i++) { // Make the circle a little thicker // by actually drawing three circles w/ different radii float cv = cos(val), sv=sin(val); circleColor = (val*0xFFFF)/(2*M_PI); GLCD_SetTextColor(circleColor); for (radius=MAX_RADIUS-2.0;radius<=MAX_RADIUS;radius+=1.0) { x = round(cv*radius+offset); y = round(sv*radius+offset); if (x > xmax) xmax = x; if (y > ymax) ymax = y; if (x < xmin) xmin = x; if (y < ymin) ymin = y; GLCD_PutPixel(x,y); } val += inc; } // Now we are going to read the upper left square of the LCD's // memory (see its data sheet for details on that) and save // that into a buffer for fast re-drawing later if (((xmax+1-xmin)*(ymax+1-ymin)) > BUF_LEN) { // Make sure we have room for the data VT_HANDLE_FATAL_ERROR(0); } unsigned short int *tbuffer = buffer; unsigned int width = (xmax+1-xmin); for (j=ymin;j<=ymax;j++) { GLCD_GetPixelRow (xmin,j,width,tbuffer); tbuffer += width; } // end of reading in the buffer xoffset = xmin; yoffset = ymin; } else { // We are going to write out the data read into the buffer // back onto the screen at a new location // This is *very* fast // First, clear out where we were GLCD_ClearWindow(xoffset,yoffset,xmax+1-xmin,ymax+1-ymin,screenColor); // Pick the new location #if MALLOC_VERSION==1 xoffset = rand() % (320-(xmax+1-xmin)); yoffset = rand() % (120-(ymax+1-ymin)); #else xoffset = (xoffset + 10) % (320-(xmax+1-xmin)); yoffset = (yoffset + 10) % (120-(ymax+1-ymin)); #endif // Draw the bitmap GLCD_Bitmap(xoffset,yoffset,xmax+1-xmin,ymax-1-ymin,(unsigned char *)buffer); } timerCount++; if (timerCount >= 40) { // every so often, we reset timer count and start again // This isn't for any important reason, it is just to for this example code to do "stuff" timerCount = 0; } break; } default: { // In this configuration, we are only expecting to receive timer messages VT_HANDLE_FATAL_ERROR(getMsgType(&msgBuffer)); break; } } // end of switch() #endif #if MILESTONE_1==1 // Added by Matthew Ibarra 2/2/2013 if(timerCount==0) { GLCD_Clear(screenColor); // Draw the vertical gridlines onto the LCD int i; for(i = 320/6; i < 315; i = i + 320/6) { GLCD_ClearWindow(i, 0, 1, 240, Red); } // Draw the vertical gridlines onto the LCD for(i = 240/4; i < 235; i = i + 240/4) { GLCD_ClearWindow(0, i, 320, 1, Red); } //Output Scale on LCD GLCD_DisplayString(29, 0, 0, (unsigned char*) "V/div=2.5 s/div=3"); timerCount++; } int adcValue; getMsgValue(&adcValue, &msgBuffer); int displayValue; displayValue = 120 - (adcValue * 120)/(0x100); GLCD_ClearWindow(xPos, displayValue, 2, 2, Black); xPos += 2; if(xPos > 320) { timerCount = 0; xPos = 0; } #endif // Here is a way to do debugging output via the built-in hardware -- it requires the ULINK cable and the // debugger in the Keil tools to be connected. You can view PORT0 output in the "Debug(printf) Viewer" // under "View->Serial Windows". You have to enable "Trace" and "Port0" in the Debug setup options. This // should not be used if you are using Port0 for printf() // There are 31 other ports and their output (and port 0's) can be seen in the "View->Trace->Records" // windows. You have to enable the prots in the Debug setup options. Note that unlike ITM_SendChar() // this "raw" port write is not blocking. That means it can overrun the capability of the system to record // the trace events if you go too quickly; that won't hurt anything or change the program execution and // you can tell if it happens because the "View->Trace->Records" window will show there was an overrun. //vtITMu16(vtITMPortLCD,screenColor); #elif LCD_EXAMPLE_OP==1 // In this alternate version, we just keep redrawing a series of bitmaps as // we receive timer messages // Wait for a message if (xQueueReceive(lcdPtr->inQ,(void *) &msgBuffer,portMAX_DELAY) != pdTRUE) { VT_HANDLE_FATAL_ERROR(0); } if (getMsgType(&msgBuffer) != LCDMsgTypeTimer) { // In this configuration, we are only expecting to receive timer messages VT_HANDLE_FATAL_ERROR(getMsgType(&msgBuffer)); } /* go through a bitmap that is really a series of bitmaps */ picIndex = (picIndex + 1) % 9; GLCD_Bmp(99,99,120,45,(unsigned char *) &ARM_Ani_16bpp[picIndex*(120*45*2)]); #else Bad setting #endif } }
// This is the actual task that is run static portTASK_FUNCTION(vLCDUpdateTask, pvParameters) { #if LCD_EXAMPLE_OP == 0 unsigned short screenColor = 0; unsigned short tscr; unsigned char curLine; unsigned timerCount = 0; int xoffset = 0, yoffset = 0; unsigned int xmin = 0, xmax = 0, ymin = 0, ymax = 0; unsigned int x, y; int i; float hue = 0, sat = 0.2, light = 0.2; #else // if LCD_EXAMPLE_OP==1 unsigned char picIndex = 0; #endif vtLCDMsg msgBuffer; vtLCDStruct *lcdPtr = (vtLCDStruct *)pvParameters; #ifdef INSPECT_STACK // This is meant as an example that you can re-use in your own tasks // Inspect to the stack remaining to see how much room is remaining // 1. I'll check it here before anything really gets started // 2. I'll check during the run to see if it drops below 10% // 3. You could use break points or logging to check on this, but // you really don't want to print it out because printf() can // result in significant stack usage. // 4. Note that this checking is not perfect -- in fact, it will not // be able to tell how much the stack grows on a printf() call and // that growth can be *large* if version 1 of printf() is used. unsigned portBASE_TYPE InitialStackLeft = uxTaskGetStackHighWaterMark(NULL); unsigned portBASE_TYPE CurrentStackLeft; float remainingStack = InitialStackLeft; remainingStack /= lcdSTACK_SIZE; if (remainingStack < 0.10) { // If the stack is really low, stop everything because we don't want it to // run out // The 0.10 is just leaving a cushion, in theory, you could use exactly all // of it VT_HANDLE_FATAL_ERROR(0); } #endif // Graph initialization const unsigned graphXoff = 30; const unsigned graphYoff = 10; const unsigned graphWidth = 260; const unsigned graphHeight = 160; uint8_t graphVals[graphWidth]; for (i = 0; i < graphWidth; i++) { graphVals[i] = 0; } uint8_t graphStart = 0; /* Initialize the LCD and set the initial colors */ GLCD_Init(); tscr = White; // may be reset in the LCDMsgTypeTimer code below screenColor = Black; // may be reset in the LCDMsgTypeTimer code below GLCD_SetTextColor(tscr); GLCD_SetBackColor(screenColor); GLCD_Clear(screenColor); GLCD_ClearWindow(graphXoff - 1, graphYoff - 1, 1, graphHeight + 1, Blue); GLCD_ClearWindow( graphXoff - 1, graphYoff + graphHeight + 1, graphWidth + 1, 1, Blue); GLCD_DisplayString(22, 47, 0, (unsigned char *)"0min"); GLCD_DisplayString(22, 37, 0, (unsigned char *)"-1min"); GLCD_DisplayString(22, 27, 0, (unsigned char *)"-2min"); GLCD_DisplayString(22, 17, 0, (unsigned char *)"-3min"); GLCD_DisplayString(22, 7, 0, (unsigned char *)"-4min"); GLCD_DisplayString(22, 0, 0, (unsigned char *)"0.0m"); GLCD_DisplayString(14, 0, 0, (unsigned char *)"0.5m"); GLCD_DisplayString(8, 0, 0, (unsigned char *)"1.0m"); GLCD_DisplayString(2, 0, 0, (unsigned char *)"1.5m"); // Note that srand() & rand() require the use of malloc() and should not be used // unless you are using // MALLOC_VERSION==1 #if MALLOC_VERSION == 1 srand((unsigned)55); // initialize the random number generator to the same // seed for repeatability #endif curLine = lcdNUM_SMALL_LINES - 1; // This task should never exit for (;;) { #ifdef INSPECT_STACK CurrentStackLeft = uxTaskGetStackHighWaterMark(NULL); float remainingStack = CurrentStackLeft; remainingStack /= lcdSTACK_SIZE; if (remainingStack < 0.10) { // If the stack is really low, stop everything because we don't want it to // run out VT_HANDLE_FATAL_ERROR(0); } #endif #if LCD_EXAMPLE_OP == 0 // Wait for a message if (xQueueReceive(lcdPtr->inQ, (void *)&msgBuffer, portMAX_DELAY) != pdTRUE) { VT_HANDLE_FATAL_ERROR(0); } // Log that we are processing a message -- more explanation of logging is // given later on vtITMu8(vtITMPortLCDMsg, getMsgType(&msgBuffer)); vtITMu8(vtITMPortLCDMsg, getMsgLength(&msgBuffer)); // Take a different action depending on the type of the message that we // received switch (getMsgType(&msgBuffer)) { case LCDMsgTypePrint: { // This will result in the text printing in the last five lines of the // screen char lineBuffer[lcdCHAR_IN_LINE + 1]; copyMsgString(lineBuffer, &msgBuffer, lcdCHAR_IN_LINE); // clear the line GLCD_ClearLn(curLine, 1); // show the text GLCD_DisplayString(curLine, 0, 0, (unsigned char *)lineBuffer); curLine++; if (curLine == lcdNUM_SMALL_LINES) { curLine = lcdNUM_SMALL_LINES - 1; } break; } case LCDMsgTypePoint: { graphVals[graphStart] = getMsgPoint(&msgBuffer); break; } case LCDMsgTypeTimer: { // Note: if I cared how long the timer update was I would call my // routine // unpackTimerMsg() which would unpack the message and get that value // Each timer update will cause a circle to be drawn on the top half of // the screen // as explained below if (timerCount % 2 == 0) { /* ************************************************** */ // Find a new color for the screen by randomly (within limits) // selecting // HSL values // This can be ignored unless you care about the color map /* #if MALLOC_VERSION==1 hue = rand() % 360; sat = (rand() % 1024) / 1023.0; sat = sat * 0.5; sat += 0.5; light = (rand() % 1024) / 1023.0; light = light * 0.8; light += 0.10; #else hue = (hue + 1); if (hue >= 360) hue = 0; sat+=0.01; if (sat > 1.0) sat = 0.20; light+=0.03; if (light > 1.0) light = 0.20; #endif screenColor = hsl2rgb(hue,sat,light); // Now choose a complementary value for the text color hue += 180; if (hue >= 360) hue -= 360; tscr = hsl2rgb(hue,sat,light); GLCD_SetTextColor(tscr); GLCD_SetBackColor(screenColor); unsigned short int *tbuffer = buffer; //int i; for(i = BUF_LEN; i--;) { tbuffer[i] = screenColor; } */ // End of playing around with figuring out a random color /* ************************************************** */ // clear the top half of the screen // GLCD_ClearWindow(0,0,320,120,screenColor); /* // Now we are going to draw a circle in the buffer // count is how many pixels are in the circle int count = 50; float radius; float inc, val, offset = MAX_RADIUS; unsigned short circleColor; inc = 2*M_PI/count; xmax = 0; ymax = 0; xmin = 50000; ymin = 50000; val = 0.0; for (i=0;i<count;i++) { // Make the circle a little thicker // by actually drawing three circles w/ different radii float cv = cos(val), sv=sin(val); circleColor = (val*0xFFFF)/(2*M_PI); GLCD_SetTextColor(circleColor); for (radius=MAX_RADIUS-2.0;radius<=MAX_RADIUS;radius+=1.0) { x = round(cv*radius+offset); y = round(sv*radius+offset); if (x > xmax) xmax = x; if (y > ymax) ymax = y; if (x < xmin) xmin = x; if (y < ymin) ymin = y; //tbuffer[(y*((MAX_RADIUS*2)+1)) + x] = circleColor; } val += inc; } */ // GLCD_ClearWindow(graphXoff, graphYoff, graphWidth, graphHeight, // screenColor); graphStart = (graphStart + 1) % graphWidth; DEBUG_OUT(0xf); for (i = 0; i < graphWidth; i++) { unsigned index = (i + graphStart) % graphWidth; unsigned y = graphHeight - graphVals[index] + graphYoff; unsigned x = i + graphXoff; GLCD_ClearWindow(x, graphYoff, 1, graphHeight, screenColor); GLCD_PutPixel(x, y); } DEBUG_OUT(0x0); } // else { // We are going to write out the buffer // back onto the screen at a new location // This is *very* fast /* // First, clear out where we were GLCD_ClearWindow(xoffset,yoffset,xmax+1-xmin,ymax+1-ymin,screenColor); // Pick the new location #if MALLOC_VERSION==1 xoffset = rand() % (320-(xmax+1-xmin)); yoffset = rand() % (120-(ymax+1-ymin)); #else xoffset = (xoffset + 10) % (320-(xmax+1-xmin)); yoffset = (yoffset + 10) % (120-(ymax+1-ymin)); #endif // Draw the bitmap GLCD_Bitmap(xoffset,yoffset,xmax+1-xmin,ymax-1-ymin,(unsigned char*)buffer); */ //} timerCount++; if (timerCount >= 100) { // every so often, we reset timer count and start again // This isn't for any important reason, it is just to for this example // code to do "stuff" timerCount = 0; } break; } default: { // In this configuration, we are only expecting to receive timer // messages VT_HANDLE_FATAL_ERROR(getMsgType(&msgBuffer)); break; } } // end of switch() // Here is a way to do debugging output via the built-in hardware -- it requires // the ULINK cable and the debugger in the Keil tools to be connected. You can // view PORT0 output in the "Debug(printf) Viewer" under "View->Serial Windows". // You have to enable "Trace" and "Port0" in the Debug setup options. This // should not be used if you are using Port0 for printf(). There are 31 other // ports and their output (and port 0's) can be seen in the // "View->Trace->Records" windows. You have to enable the ports in the Debug // setup options. Note that unlike ITM_SendChar() this "raw" port write is not // blocking. That means it can overrun the capability of the system to record // the trace events if you go too quickly; that won't hurt anything or change // the program execution and you can tell if it happens because the // "View->Trace->Records" window will show there was an overrun. // vtITMu16(vtITMPortLCD,screenColor); #elif LCD_EXAMPLE_OP == 1 // In this alternate version, we just keep redrawing a series of bitmaps as // we receive timer messages // Wait for a message if (xQueueReceive(lcdPtr->inQ, (void *)&msgBuffer, portMAX_DELAY) != pdTRUE) { VT_HANDLE_FATAL_ERROR(0); } if (getMsgType(&msgBuffer) != LCDMsgTypeTimer) { // In this configuration, we are only expecting to receive timer messages VT_HANDLE_FATAL_ERROR(getMsgType(&msgBuffer)); } /* go through a bitmap that is really a series of bitmaps */ picIndex = (picIndex + 1) % 9; GLCD_Bmp(99, 99, 120, 45, (unsigned char *)&ARM_Ani_16bpp[picIndex * (120 * 45 * 2)]); #else Bad setting #endif } }
void Draw_CHICKEN2(int y0 ){ GLCD_SetTextColor(Red); GLCD_PutPixel(319-21,y0); GLCD_PutPixel(319-17,y0+1); GLCD_PutPixel(319-18,y0+1); Draw_lineX2( 319-20, y0+1, 319-22); Draw_lineX2(319-17, y0+2, 319-23); Draw_lineX2(319-16, y0+3, 319-23); Draw_lineX2(319-17, y0+4, 319-22); GLCD_PutPixel(319-18, y0+5); GLCD_SetTextColor(Orange); Draw_lineX2(319-25, y0+7, 319-28); Draw_lineX2(319-25, y0+8, 319-26); Draw_lineX2(319-25, y0+9, 319-28); Draw_lineX2(319-25, y0+10, 319-26); GLCD_SetTextColor(Black); GLCD_PutPixel(319-19, y0+9); GLCD_PutPixel(319-20, y0+9); GLCD_SetTextColor(Yellow); Draw_lineX2(319-19,y0+5,319-22); Draw_lineX2(319-17,y0+6,319-23); Draw_lineX2(319-17,y0+7,319-24); Draw_lineX2(319-16,y0+8,319-24); Draw_lineX2(319-15,y0+9,319-24); Draw_lineX2(319-14,y0+10,319-24); Draw_lineX2(319-14,y0+11,319-24); Draw_lineX2(319-13,y0+12,319-24); Draw_lineX2(319-12,y0+13,319-22); Draw_lineX2(319-11,y0+14,319-22); Draw_lineX2(319-10,y0+15,319-22); Draw_lineX2(319-2,y0+16,319-22); Draw_lineX2(319-0,y0+17,319-22); Draw_lineX2(319-0,y0+18,319-22); Draw_lineX2(319-0,y0+19,319-22); Draw_lineX2(319-2,y0+20,319-21); Draw_lineX2(319-4,y0+21,319-21); Draw_lineX2(319-2,y0+22,319-21); Draw_lineX2(319-0,y0+23,319-20); Draw_lineX2(319-1,y0+24,319-20); Draw_lineX2(319-1,y0+25,319-20); Draw_lineX2(319-2,y0+26,319-19); Draw_lineX2(319-3,y0+27,319-18); Draw_lineX2(319-3,y0+28,319-17); Draw_lineX2(319-4,y0+29,319-16); Draw_lineX2(319-5,y0+30,319-15); Draw_lineX2(319-6,y0+31,319-14); //Tail GLCD_PutPixel(319-0, y0+10); Draw_lineX2(319-0, y0+9, 319-1); Draw_lineX2(319-0, y0+10, 319-2); Draw_lineX2(319-0, y0+11, 319-3); Draw_lineX2(319-1, y0+12, 319-4); Draw_lineX2(319-1, y0+13, 319-5); Draw_lineX2(319-2, y0+14, 319-6); Draw_lineX2(319-3, y0+15, 319-7); GLCD_SetTextColor(Black); GLCD_PutPixel(319-20, y0+8); GLCD_PutPixel(319-21, y0+8); GLCD_PutPixel(319-19, y0+9); GLCD_PutPixel(319-20, y0+9); }
void Draw_CHICKEN1(int y0 ){ GLCD_SetTextColor(Red); GLCD_PutPixel(21,y0); GLCD_PutPixel(17,y0+1); GLCD_PutPixel(18,y0+1); Draw_lineX( 20, y0+1, 22); Draw_lineX(17, y0+2, 23); Draw_lineX(16, y0+3, 23); Draw_lineX(17, y0+4, 22); GLCD_PutPixel(18, y0+5); GLCD_SetTextColor(Orange); Draw_lineX(25, y0+7, 28); Draw_lineX(25, y0+8, 26); Draw_lineX(25, y0+9, 28); Draw_lineX(25, y0+10, 26); GLCD_SetTextColor(Black); GLCD_PutPixel(19, y0+9); GLCD_PutPixel(20, y0+9); GLCD_SetTextColor(Yellow); Draw_lineX(19,y0+5,22); Draw_lineX(17,y0+6,23); Draw_lineX(17,y0+7,24); Draw_lineX(16,y0+8,24); Draw_lineX(15,y0+9,24); Draw_lineX(14,y0+10,24); Draw_lineX(14,y0+11,24); Draw_lineX(13,y0+12,24); Draw_lineX(12,y0+13,22); Draw_lineX(11,y0+14,22); Draw_lineX(10,y0+15,22); Draw_lineX(2,y0+16,22); Draw_lineX(0,y0+17,22); Draw_lineX(0,y0+18,22); Draw_lineX(0,y0+19,22); Draw_lineX(2,y0+20,21); Draw_lineX(4,y0+21,21); Draw_lineX(2,y0+22,21); Draw_lineX(0,y0+23,20); Draw_lineX(1,y0+24,20); Draw_lineX(1,y0+25,20); Draw_lineX(2,y0+26,19); Draw_lineX(3,y0+27,18); Draw_lineX(3,y0+28,17); Draw_lineX(4,y0+29,16); Draw_lineX(5,y0+30,15); Draw_lineX(6,y0+31,14); //Tail GLCD_PutPixel(0, y0+10); Draw_lineX(0, y0+9, 1); Draw_lineX(0, y0+10, 2); Draw_lineX(0, y0+11, 3); Draw_lineX(1, y0+12, 4); Draw_lineX(1, y0+13, 5); Draw_lineX(2, y0+14, 6); Draw_lineX(3, y0+15, 7); GLCD_SetTextColor(Black); GLCD_PutPixel(20, y0+8); GLCD_PutPixel(21, y0+8); GLCD_PutPixel(19, y0+9); GLCD_PutPixel(20, y0+9); }
// This is the actual task that is run static portTASK_FUNCTION( vLCDUpdateTask, pvParameters ) { portTickType xUpdateRate, xLastUpdateTime; int pixel_buffer[80]; float max = 0; float min = 990; unsigned short screenColor; #if LCD_EXAMPLE_OP==0 unsigned short tscr; static char scrString[40]; unsigned char curLine = 0; float hue=0, sat=0.2, light=0.2; #elif LCD_EXAMPLE_OP==1 unsigned char picIndex = 0; #elif LCD_EXAMPLE_OP==2 vtLCDMsg msgBuffer; unsigned char curLine = 0; #endif vtLCDStruct *lcdPtr = (vtLCDStruct *) pvParameters; /* Initialize the LCD */ GLCD_Init(); GLCD_Clear(Yellow); // Scale the update rate to ensure it really is in ms xUpdateRate = lcdWRITE_RATE_BASE / portTICK_RATE_MS; /* We need to initialise xLastUpdateTime prior to the first call to vTaskDelayUntil(). */ xLastUpdateTime = xTaskGetTickCount(); // Note that srand() & rand() require the use of malloc() and should not be used unless you are using // MALLOC_VERSION==1 #if MALLOC_VERSION==1 srand((unsigned) 55); // initialize the random number generator to the same seed for repeatability #endif // Like all good tasks, this should never exit int i = 0; GLCD_SetTextColor(Black); GLCD_SetBackColor(Yellow); for(;;) { #if LCD_EXAMPLE_OP==0 /* Ask the RTOS to delay reschduling this task for the specified time */ vTaskDelayUntil( &xLastUpdateTime, xUpdateRate ); // Find a new color for the screen by randomly (within limits) selecting HSL values #if MALLOC_VERSION==1 hue = rand() % 360; sat = (rand() % 1024) / 1023.0; sat = sat * 0.5; sat += 0.5; light = (rand() % 1024) / 1023.0; light = light * 0.8; light += 0.10; #else hue = (hue + 1); if (hue >= 360) hue = 0; sat+=0.01; if (sat > 1.0) sat = 0.20; light+=0.03; if (light > 1.0) light = 0.20; #endif screenColor = hsl2rgb(hue,sat,light); // Now choose a complementary value for the text color hue += 180; if (hue >= 360) hue -= 360; tscr = hsl2rgb(hue,sat,light); GLCD_SetTextColor(tscr); GLCD_SetBackColor(screenColor); /* create a string for printing to the LCD */ sprintf(scrString,"LCD: %d %d %d",screenColor,(int)xUpdateRate,(int)xLastUpdateTime); GLCD_ClearLn(curLine,1); GLCD_DisplayString(curLine,0,1,(unsigned char *)scrString); curLine++; if (curLine == 10) { /* clear the LCD at the end of the screen */ GLCD_Clear(screenColor); curLine = 0; } printf("BackColor (RGB): %d %d %d - (HSL) %3.0f %3.2f %3.2f \n", (screenColor & 0xF800) >> 11,(screenColor & 0x07E0) >> 5,screenColor & 0x001F, hue,sat,light); printf("TextColor (RGB): %d %d %d\n", (tscr & 0xF800) >> 11,(tscr & 0x07E0) >> 5,tscr & 0x001F); // Here is a way to do debugging output via the built-in hardware -- it requires the ULINK cable and the // debugger in the Keil tools to be connected. You can view PORT0 output in the "Debug(printf) Viewer" // under "View->Serial Windows". You have to enable "Trace" and "Port0" in the Debug setup options. This // should not be used if you are using Port0 for printf() // There are 31 other ports and their output (and port 0's) can be seen in the "View->Trace->Records" // windows. You have to enable the prots in the Debug setup options. Note that unlike ITM_SendChar() // this "raw" port write is not blocking. That means it can overrun the capability of the system to record // the trace events if you go too quickly; that won't hurt anything or change the program execution and // you can tell if it happens because the "View->Trace->Records" window will show there was an overrun. vtITMu16(vtITMPortLCD,screenColor); #elif LCD_EXAMPLE_OP==1 /* Ask the RTOS to delay reschduling this task for the specified time */ vTaskDelayUntil( &xLastUpdateTime, xUpdateRate ); /* go through a bitmap that is really a series of bitmaps */ picIndex = (picIndex + 1) % 9; GLCD_Bmp(99,99,120,45,(unsigned char *) &ARM_Ani_16bpp[picIndex*(120*45*2)]); #elif LCD_EXAMPLE_OP==2 // wait for a message from another task telling us to send/recv over i2c if (xQueueReceive(lcdPtr->inQ,(void *) &msgBuffer,portMAX_DELAY) != pdTRUE) { VT_HANDLE_FATAL_ERROR(0); } //get the data from the message queue and reconvert it into a 10-bit value int pixel = msgBuffer.buf[1]<<8; pixel = pixel + msgBuffer.buf[0]; //set minimum and maximum values should they change across the 80 data points in buffer if (pixel > max) max = pixel; if (pixel < min) min = pixel; //trim pixel data value to fit it on screen pixel = pixel / 5; //add pixel to a data buffer so we can clear the screen and keep accurate data pixel_buffer[i] = pixel; //increment for next position in the buffer i++; //once we have a filled buffer of data points, print the screen if (i > 79) { GLCD_Clear(Yellow); //each data point is 4 pixels by 4 pixels for (i = 0; i < 80; i++) { GLCD_PutPixel(i*4, 240-pixel_buffer[i]); GLCD_PutPixel(i*4, 240-pixel_buffer[i]+1); GLCD_PutPixel(i*4, 240-pixel_buffer[i]+2); GLCD_PutPixel(i*4, 240-pixel_buffer[i]+3); GLCD_PutPixel(i*4+1, 240-pixel_buffer[i]); GLCD_PutPixel(i*4+1, 240-pixel_buffer[i]+1); GLCD_PutPixel(i*4+1, 240-pixel_buffer[i]+2); GLCD_PutPixel(i*4+1, 240-pixel_buffer[i]+3); GLCD_PutPixel(i*4+2, 240-pixel_buffer[i]); GLCD_PutPixel(i*4+2, 240-pixel_buffer[i]+1); GLCD_PutPixel(i*4+2, 240-pixel_buffer[i]+2); GLCD_PutPixel(i*4+2, 240-pixel_buffer[i]+3); GLCD_PutPixel(i*4+3, 240-pixel_buffer[i]); GLCD_PutPixel(i*4+3, 240-pixel_buffer[i]+1); GLCD_PutPixel(i*4+3, 240-pixel_buffer[i]+2); GLCD_PutPixel(i*4+3, 240-pixel_buffer[i]+3); } //convert max and mins to voltages max = max / 300; min = min / 300; //display the max and min voltages on the screen uint8_t toprint[4]; sprintf((char *)toprint, "%1.1fV", max); GLCD_DisplayString(0,9,1, (unsigned char*)&toprint); sprintf((char *)toprint, "%1.1fV", min); GLCD_DisplayString(9,9,1, (unsigned char*)&toprint); //display the scalar on the screen GLCD_DisplayString(9,0,1, (unsigned char *)"0V"); GLCD_DisplayString(7,0,1, (unsigned char *)"1V"); GLCD_DisplayString(5,0,1, (unsigned char *)"2V"); GLCD_DisplayString(3,0,1, (unsigned char *)"3V"); //reset values for the next buffer screen i = 0; max = 0; min = 990; } #else Bad setting #endif } }