/** * Display a line with text and let the user confirm * * text - text on line, within rectangle max 18 characters) * */ int screenTextOk(unsigned char text[] ) { int dataX; int dataY; int i = 0; screenClear (); //write text screenOutputText(4, 1, Blue, text); screenOutputText(6, 5, Red, "Please confirm"); //draw rectangle xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Blue); GLCD_drawRect(Line2, 5, 120,310); xSemaphoreGive(lcdLock); //wait for the user to confirm while(i == 0) { //select alternative screenTouched(&dataX, &dataY); //find out which alternative selected if (dataY > Line2 && dataY < Line6) i = 1; } return i; }
/** * Display one line of text plus a grid with characters (qwerty...) * asking for example to "Enter Text" * * textCol - text color, see file GLCD.h (not all colors work) * text - a number of characters forming a text string * numberOfChars - maximum number of characters in response * (maximum characters in one line is 20) * * returns entered characters, which can be ' ', ended by a \0 */ void screenQueryChars(unsigned short textCol, unsigned char text[], int numberOfChars, unsigned char textEntered[]) { int dataX; int dataY; int charInt = 0; int pos = 0; int caps = 1; //let capsOld be different from caps, //so grid with characters will be drawn first time int capsOld = 1 - caps; screenClear (); xSemaphoreTake(lcdLock, portMAX_DELAY); //clear display GLCD_clear(White); //set color GLCD_setTextColor(textCol); //write text on bottom line GLCD_displayStringLn(Line9, text); xSemaphoreGive(lcdLock); //loop over touched numbers while (pos < numberOfChars && charInt < 201) { //if caps changed, redraw grid with characters if (caps != capsOld) { screenDisplayGrid(0,caps); capsOld = caps; } //find out where screen touched screenTouched(&dataX, &dataY); //and which character this means charInt = screenGridTouchedChar(dataX, dataY); if (charInt == 32 || (charInt > 64 && charInt < 91)) { //spece or regular printable character //eventually change to lower case if (!caps && charInt != 32) charInt = charInt + 32; textEntered[pos] = charInt; //if lower case change character (except for spaces) screenDisplayChar(0, pos, textCol, charInt); pos++; } else if (charInt == 199) { //change between caps and lower case caps = 1 - caps; } else if (charInt == 200) { //Delete one character if (pos > 0) pos--; //write a space (clear next position) screenDisplayChar(0, pos, textCol, 32); } else if (charInt == 201 ) { //Cancel pressed pos = 0; //add a char 0 to end of string textEntered[pos] = 0; } else if (charInt == 202) { //Enter pressed textEntered[pos] = 0; } } }
void cBuilder::mapRoomsDraw( size_t pArrowRoom ) { map< int, cRoom *>::iterator roomIT; map< int, cRoom *> *rooms = mCastle->roomsGet(); screenClear(); // Loop through the data for each room, marking it as visible for( roomIT = rooms->begin(); roomIT != rooms->end(); ++roomIT ) { // Skip Final Room if( roomIT->second->mNumber == 0xFF ) continue; roomPtrSet( roomIT->second->mNumber ); mMemory[ mRoomPtr ] |= MAP_ROOM_VISIBLE; // Draw the room mapRoomDraw(); if( roomIT->second->mNumber == pArrowRoom ) { roomPtrSet( roomIT->second->mNumber ); mapArrowDraw( 0 ); } } // Set the sprite color to white mScreen->spriteGet( 0 )->_color = 1; }
void cBuilder::roomChange( int pNumber ) { if( mCurrentObject && mCurrentObject->partGet(0)->mPlaced == false ) { mCurrentRoom->objectDelete( mCurrentObject ); delete mCurrentObject; mCurrentObject = 0; } if( mLinkMode ) { mOriginalRoom = mCurrentRoom; mOriginalObject = mCurrentObject; } mCurrentRoom = mCastle->roomCreate( this, pNumber ); save( false ); // Set the room number in the window title mScreen->roomNumberSet( pNumber ); if( pNumber == -1) { screenClear(); mObjectPtr = readLEWord( &mMemory[ 0x785F ] ); roomPrepare(); } else { mMemory[ 0x7809 ] = pNumber; mMemory[ 0x780A ] = pNumber; roomLoad(); } playerDraw(); }
/** * Display a menu and select menu item number * With 3 menu items * * text1 - text on line 1 (max 18 characters) * text2 - text on line 2 (max 18 characters) * text3 - text on line 3 (max 18 characters) * * returns selected menue alternative, 1, 2 or 3 */ int screenMenu3(unsigned char text1[], unsigned char text2[], unsigned char text3[]) { int dataX; int dataY; int i = 0; screenClear (); //write text screenOutputText(2, 1, Blue, text1); screenOutputText(4, 1, Blue, text2); screenOutputText(6, 1, Blue, text3); //draw rectangles xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Blue); GLCD_drawRect(Line2 - 12, 5, 48, 310); GLCD_drawRect(Line4 - 12, 5, 48, 310); GLCD_drawRect(Line6 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); //wait for user to select alternative while(i == 0) { //select alternative screenTouched(&dataX, &dataY); //find out which alternative selected if (dataY > Line2 - 12 && dataY < Line4 - 12) i = 1; if (dataY > Line4 - 12 && dataY < Line6 - 12) i = 2; if (dataY > Line6 - 12 && dataY < Line8 - 12) i = 3; } xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setTextColor(Green); GLCD_setBackColor (Green); if ( i == 1) { GLCD_fillRect(Line2 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); screenOutputText(2, 1, Blue, text1); } else if (i == 2) { GLCD_fillRect(Line4 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); screenOutputText(4, 1, Blue, text2); } else { GLCD_fillRect(Line6 - 12, 5, 48, 310); xSemaphoreGive(lcdLock); screenOutputText(6, 1, Blue, text2); } xSemaphoreTake(lcdLock, portMAX_DELAY); GLCD_setBackColor (White); xSemaphoreGive(lcdLock); vTaskDelay(900 / portTICK_RATE_MS); return i; }
/** * Display one line of text plus a grid with numbers * from 0 to 9. Asking for example to "Enter Code * * textCol - text color, see file GLCD.h (not all colors work) * text - a number of characters forming a text string * numberOfDigits - maximum number of digits in response * * returns entered number, which can be 0 */ int screenQueryNumber(unsigned short textCol, unsigned char text[], int numberOfDigits) { int dataX; int dataY; int digit = 0; char cDigit; int pos = 0; int totalInput = 0; screenClear (); xSemaphoreTake(lcdLock, portMAX_DELAY); //clear display GLCD_clear(White); //set color GLCD_setTextColor(textCol); //write text on bottom line GLCD_displayStringLn(Line9, text); xSemaphoreGive(lcdLock); //show grid with numbers screenDisplayGrid(1, 0); //loop over touched numbers while (pos < numberOfDigits && digit < 201) { //find out where screen touched screenTouched(&dataX, &dataY); //find out the meaning of where screen touched digit = screenGridTouchedDigit(dataX, dataY); if(digit >= 0 && digit <= 9) { //regular input of digit pos++; cDigit = digit + 48; totalInput = totalInput*10 + digit; screenDisplayChar(0, pos, textCol, cDigit); } else if (digit == 200 && pos > 0 ) { //delete previous character cDigit = ' '; totalInput = totalInput/10; screenDisplayChar(0, pos, textCol, cDigit); pos--; } } if(digit == 201) { //cancel pressed totalInput = 0; } return totalInput; }
void cBuilder::castlePrepare( ) { save( false ); // Final Room? if( (char) mCurrentRoom->mNumber == -1) { screenClear(); mObjectPtr = readLEWord( &mMemory[ 0x785F ] ); roomPrepare(); } else { mMemory[ 0x7809 ] = mCurrentRoom->mNumber; mMemory[ 0x780A ] = mCurrentRoom->mNumber; roomLoad(); } // Print any strings objectStringsPrint(); // Force draw of sprites Sprite_Execute(); object_Execute(); playerDraw(); }
/** * Check queue for alarm status */ static void alarmTask(void *params) { int queueData = 0; int i; u8 alarms = 0; u8 maxAlarms = 8; for (;;) { xQueueReceive(alarmEventQueue, &queueData, portMAX_DELAY); //screenOutputTextLine(0, 192, "Alarm message"); if (alarmActive == 0 ) { //activate alarm? if (queueData == ACTIVATE_ALARM ) alarmActive = 1; } else { switch(queueData) { case DOOR_ALARM1: //alarm from a door alarm screenOutputText(8, 13, Red, "Alarm1\0"); alarms |= 1; if (alarmActive == 1) alarmActive = 2; break; case DOOR_ALARM2: //alarm from a door alarm screenOutputText(8, 13, Red, "Alarm2\0"); alarms |= 2; if (alarmActive == 1) alarmActive = 2; break; case TEMPERATURE_LOW_ALARM: //alarm regarding low temperature if (alarmActive == 1) alarmActive = 2; break; case TEMPERATURE_HIGH_ALARM: //alarm regarding high temperature if (alarmActive == 1) alarmActive = 2; break; //case RESET_ALARM: //reset the alarm // alarmActive = 1; //screenOutputTextLine(0, 216, "Alarm Reset "); // break; case DEACTIVATE_ALARM: //deactivate the alarm screenClear (); for (i = 0; i < maxAlarms; i++ ) { if(alarms & 1<<i) screenTextOk("Alarm!!!"); } alarms = 0; screenOutputTextLine(0, 0, "Alarm Deactivated"); vTaskDelay(500 / portTICK_RATE_MS); alarmActive = 0; break; default: break; } //switch statment ends here } //else statement ends here } //forever loop ends here }
void main(struct mbs_s *mbs, unsigned ebx, unsigned esp){ screenClear(); setTextColor(TEXTC_LGREEN); printk("\n%C%s :-)%C V. %C%s%C, Release %d (%s)\n", TEXTC_LRED, KERNEL_NAME, TEXTC_DEFAULT, TEXTC_WHITE, KERNEL_VERSION, TEXTC_DEFAULT, KERNEL_RELEASE, KERNEL_BUILD_DATE); printk(KERNEL_COPYRIGHT "\n"); printk("Licensed under " KERNEL_LICENSE ".\n\n"); printk("Init physical memory manager\n"); pmmInit(mbs, &kernelBase, &kernelEnd); //printk("%Cdone%C\n", TEXTC_GREEN, TEXTC_DEFAULT); printk("Init GDT ... "); gdtInit(); printk("%Cdone%C\n", TEXTC_GREEN, TEXTC_DEFAULT); /* unsigned int kdataseg, kcodeseg; asm("mov %%ds, %0" : "=g"(kdataseg)); asm("mov %%cs, %0" : "=g"(kcodeseg)); printk("\tKernel codesegment ... "); kcodeseg == GDT_KERNEL_CODESEG ? printk("%C*k", TEXTC_GREEN) : printk("%Cfailed", TEXTC_RED); printk("%C\n", TEXTC_DEFAULT); printk("\tKernel datasegment ... "); kdataseg == GDT_KERNEL_DATASEG ? printk("%C*k", TEXTC_GREEN) : printk("%Cfailed", TEXTC_RED); printk("%C\n", TEXTC_DEFAULT); */ /**/ printk("Init IDT ... "); idtInit(); printk("%Cdone%C\n", TEXTC_GREEN, TEXTC_DEFAULT); printk("Test interrupts\n"); asm volatile("push %eax; xor %eax, %eax; int $0x87; pop %eax;"); char *b = (char *)pmmAllocNext(4096); printk("b = %x\n", b); //systemPanic("STOP\n"); printk("Init Multitasking...\n"); initMultitasking(); printk("Init Multitasking done\n"); asm volatile("sti"); //pmmGetFreeMem(); /* asm volatile( "push %eax;" "xor %eax, %eax;" "mov $0x13, %al;" "int $0x10;" "pop %eax;" ); unsigned char *VGA = (unsigned char *)0xA0000; unsigned int x; for(x = 0; x < 320 * 200; x++) VGA[x] = (unsigned char)128; */ // should never be reached printk("Kernel infinite loop."); while(1); }