// Draw a little stick figure void drawStickFigure(int offset) { nxtEraseRect(0, 0, 99, 50); nxtDrawCircle(offset + 43, 40, 15); nxtDrawLine(offset + 50,25,offset + 50,10); nxtDrawLine(offset + 43, 22, offset + 58, 22); nxtDrawLine(offset + 43, 0, offset + 50, 10); nxtDrawLine(offset + 50, 10, offset + 58, 0); }
task main () { int _color = 0; string _tmp; int red = 0; int green = 0; int blue = 0; nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "COLOUR"); nxtDisplayCenteredTextLine(3, "SMUX Test"); nxtDisplayCenteredTextLine(5, "Connect SMUX to"); nxtDisplayCenteredTextLine(6, "S1 and CS to"); nxtDisplayCenteredTextLine(7, "SMUX Port 1"); wait1Msec(2000); eraseDisplay(); while (true) { // Read the currently detected colour from the sensor _color = HTCSreadColor(HTCOLOR); // If colour == -1, it implies an error has occurred if (_color < 0) { nxtDisplayTextLine(4, "ERROR!!"); nxtDisplayTextLine(5, "HTCSreadColor"); wait1Msec(2000); StopAllTasks(); } // Read the RGB values of the currently colour from the sensor // A return value of false implies an error has occurred if (!HTCSreadRGB(HTCOLOR, red, green, blue)) { nxtDisplayTextLine(4, "ERROR!!"); nxtDisplayTextLine(5, "HTCSreadRGB"); wait1Msec(2000); StopAllTasks(); } // Read the RGB values of the currently colour from the sensor // A return value of false implies an error has occurred nxtDisplayCenteredTextLine(0, "Color: %d", _color); nxtDisplayCenteredBigTextLine(1, "R G B"); nxtEraseRect(0,10, 99, 41); nxtFillRect( 0, 10, 30, 10 + (red+1)/8); nxtFillRect(35, 10, 65, 10 + (green+1)/8); nxtFillRect(70, 10, 99, 10 + (blue+1)/8); StringFormat(_tmp, " %3d %3d", red, green); nxtDisplayTextLine(7, "%s %3d", _tmp, blue); wait1Msec(100); } }
task updateHUD () { int x = 0; int y = 0; while (true) { nxtEraseRect(4,50, 44,10); nxtDisplayTextLine(2, " H: %3d", angleI/100); nxtDisplayTextLine(3, " X: %3d", x_accel/100); nxtDisplayTextLine(4, " Y: %3d", y_accel/100); nxtDisplayTextLine(5, " Z: %3d", z_accel/100); nxtDrawCircle(84, 50, 4); nxtDrawCircle(4, 50, 40); x = (cosDegrees(-1 * (angleI/100 - 90)) * 20) + 24; y = (sinDegrees(-1 * (angleI/100 - 90)) * 20) + 30; nxtDrawLine(24, 30, x, y); nxtEraseRect(0,0, 99, 8); nxtDrawRect(0,0, 99, 8); nxtFillRect(50,0, (float)(rotI / 150)/100.0 *50 + 50, 8); wait1Msec(100); } }
void doDrawPoint(int top, int x_pos, int y_pos) { nxtEraseRect(x_pos, 63, x_pos+5, 0); if (displayUnit == showcurrent) nxtDisplayCenteredTextLine(7, "Max: %d mA", top); else if (displayUnit == showvoltage) nxtDisplayCenteredTextLine(7, "Max: %d mV", top); nxtDisplayStringAt(0, 12, "0"); nxtDrawLine(10, 10, 10, 60); nxtDrawLine(10, 10, 15, 10); nxtDrawLine(10, 35, 15, 35); nxtDrawLine(10, 60, 15, 60); nxtSetPixel(x_pos, y_pos); }
//Retrieve data from the sound sensor void i2c_read_registers_text(ubyte register_2_read, int message_size, int return_size) { memset(I2Creply, 0, sizeof(I2Creply)); message_size = message_size+3; I2Cmessage[0] = message_size; // Messsage Size I2Cmessage[1] = ARDUINO_ADDRESS; I2Cmessage[2] = register_2_read; // Register sendI2CMsg(S1, &I2Cmessage[0], return_size); wait1Msec(20); readI2CReply(ARDUINO_PORT, &I2Creply[0], return_size); int i = 0,top=0; //Pitch if(cmd==1) writeDebugStreamLine("%d", (int)I2Creply[0]+(int)I2Creply[1]*256); //Sound Power Level else if(cmd==2) //For detecting clap //if((int)I2Creply>85) writeDebugStreamLine("%i", (int)I2Creply[0]); //FFT else if(cmd==3) { for(int x = 0; x <return_size; x++) { writeDebugStream("%i", I2Creply[x]); writeDebugStream(" "); } writeDebugStreamLine(" "); //Graphic Equalizer nxtEraseRect(6,62,99,6); nxtDrawLine(5,2,5,61); nxtDrawLine(2,5,95,5); for(int j=0;j<return_size;j++) { top=I2Creply[j]+5; if(top>61) top=61; nxtDrawRect(5+6*j,top,5+6*(j+1),5); } } }
void debug(char* text, tDHandler count) { if(count.resetAfterOverflow && (count.count >= count.__maxCount)) { nxtEraseRect(0, 0, 99, 63); nxtDisplayTextLine(0, "FTC5818 DBG v0.5-"); count.count = 1; } if(count.big) { nxtDisplayBigTextLine(count.count, text); count.count += 1; } else { nxtDisplayTextLine(count.count, text); count.count += 1; } }
/* Main task */ task main () { blob_array _blobs; memset(_blobs, 0, sizeof(blob_array)); // combine all colliding blobs into one bool _condensed = true; //blob_array _blobs; int _l, _t, _r, _b; int _x, _y; int _nblobs; eraseDisplay(); // Initialise the camera NXTCAMinit(cam); while(true) { eraseDisplay(); // Fetch all the blobs, have the driver combine all // the colliding blobs. _nblobs = NXTCAMgetBlobs(cam, _blobs, _condensed); for (int i = 0; i < _nblobs; i++) { // Draw the scaled blobs _l = xscale(_blobs[i].x1); _t = yscale(_blobs[i].y1); _r = xscale(_blobs[i].x2); _b = yscale(_blobs[i].y2); nxtDrawRect(_l, _t, _r, _b); } NXTCAMgetAverageCenter(_blobs, 3, 0, _x, _y); _x = xscale(_x); _y = yscale(_y); nxtEraseRect(_x-4, _y-4, _x+4, _y+4); nxtDrawLine(_x, _y+2, _x, _y-2); nxtDrawLine(_x+2, _y, _x-2, _y); nxtDisplayTextLine(1, "%d", _nblobs); wait1Msec(100); } }
task main () { nNxtButtonTask = -2; int strength_1; int strength_2; int strength_3; int strength_4; int strength_5; nxtDisplayCenteredTextLine(0, "Tris10"); nxtDisplayCenteredBigTextLine(1, "FindBall"); nxtDisplayCenteredTextLine(3, "Test 1"); nxtDisplayCenteredTextLine(5, "Connect sensor"); nxtDisplayCenteredTextLine(6, "to S1"); wait1Msec(2000); eraseDisplay(); nxtDisplayCenteredTextLine(0, "Tris10 FindBall"); while (true) { nxtEraseRect(0, 0, 99, 50); T10FBreadAllStrength(TR10FB, &strength_1, &strength_2, &strength_3, &strength_4, &strength_5); // Read the current data from the sensor nxtFillRect( 5, strength_1/4, 10, 0); nxtFillRect(15, strength_2/4, 20, 0); nxtFillRect(25, strength_3/4, 30, 0); nxtFillRect(35, strength_4/4, 40, 0); nxtFillRect(45, strength_5/4, 50, 0); nxtDisplayStringAt(52, 40," 1: %3d", strength_1); nxtDisplayStringAt(52, 32," 2: %3d", strength_2); nxtDisplayStringAt(52, 24," 3: %3d", strength_3); nxtDisplayStringAt(52, 16," 4: %3d", strength_4); nxtDisplayStringAt(52, 8," 5: %3d", strength_5); wait1Msec(100); } }
task main () { bool selected_50hz = true; nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "Color V2"); nxtDisplayCenteredTextLine(4, "Config operating"); nxtDisplayCenteredTextLine(5, "frequency to"); nxtDisplayCenteredTextLine(6, "50 or 60 Hz"); wait1Msec(2000); eraseDisplay(); nxtDisplayCenteredTextLine(0, "Use arrow keys"); nxtDisplayCenteredTextLine(1, "to select a"); nxtDisplayCenteredTextLine(2, "frequency"); nxtDisplayCenteredBigTextLine(4, "50 60"); nxtDisplayCenteredTextLine(6, "[enter] to set"); nxtDisplayCenteredTextLine(7, "[exit] to cancel"); nxtDrawRect(19, 34, 44, 16); while (true) { // Do nothing while no buttons are pressed while (nNxtButtonPressed == kNoButton) { wait1Msec(1); } switch (nNxtButtonPressed) { // if the left button is pressed, set the sensor for 50Hz case kLeftButton: if (selected_50hz) { PlaySound(soundBlip); while(bSoundActive) {wait1Msec(1);} } else { selected_50hz = true; nxtEraseRect(55, 34, 80, 16); nxtDisplayCenteredBigTextLine(4, "50 60"); nxtDrawRect(19, 34, 44, 16); } break; // if the right button is pressed, set the sensor for 60Hz case kRightButton: if (!selected_50hz) { PlaySound(soundBlip); while(bSoundActive) {wait1Msec(1);} } else { selected_50hz = false; nxtEraseRect(19, 34, 44, 16); nxtDisplayCenteredBigTextLine(4, "50 60"); nxtDrawRect(55, 34, 80, 16); } break; // Make the setting permanent by saving it to the sensor case kEnterButton: eraseDisplay(); nxtDisplayCenteredTextLine(2, "The Sensor is"); nxtDisplayCenteredTextLine(3, "configured for"); if (selected_50hz) { _HTCSsendCommand(HTCS2, 0x35); nxtDisplayCenteredTextLine(4, "50 Hz operating"); } else { _HTCSsendCommand(HTCS2, 0x36); nxtDisplayCenteredTextLine(4, "60 Hz operating"); } nxtDisplayCenteredTextLine(5, "frequency"); for (int i = 5; i > 0; i--) { nxtDisplayCenteredTextLine(7, "Exiting in %d sec", i); wait1Msec(1000); } StopAllTasks(); break; } // Debounce the button while (nNxtButtonPressed != kNoButton) { wait1Msec(1); } } }
/* Main task */ task main () { blob_array _blobs; memset(_blobs, 0, sizeof(blob_array)); //blob_array _blobs; int _x, _y, _x1, _y1; int _nblobs; eraseDisplay(); // pid variables float pwr_x = 0.0; float err_x = 0.0; float perr_x = 0.0; float aerr_x = 0.0; float sp_x = 0.0; float p_x = 0.0; float i_x = 0.0; float d_x = 0.0; float pwr_y = 0.0; float err_y = 0.0; float perr_y = 0.0; float aerr_y = 0.0; float sp_y = 0.0; float p_y = 0.0; float i_y = 0.0; float d_y = 0.0; sp_y = sp_x = 87; p_y = p_x = 0.5; d_y = d_x = 1.8; i_y = i_x = 0.05; nMotorEncoder[motorA] = 0; nMotorEncoder[motorB] = 0; // Initialise the camera NXTCAMinit(cam); while(true) { eraseDisplay(); // Fetch all the blobs, have the driver combine all // the colliding blobs. _nblobs = NXTCAMgetBlobs(cam, _blobs); nxtDisplayTextLine(1, "%d, %f", _nblobs, perr_x); if (_nblobs == 0) { if ((perr_x > 0) && (nMotorEncoder[motorB] > 660)) { motor[motorA] = 0; motor[motorB] = 0; } else if ((perr_x < 0) && (nMotorEncoder[motorB] < -660)) { motor[motorA] = 0; motor[motorB] = 0; } } else { _x = (_blobs[0].x2 + _blobs[0].x1)/2; _y = (_blobs[0].y2 + _blobs[0].y1)/2; err_x = _x - sp_x; aerr_x += err_x; pwr_x = (err_x * p_x) + ((err_x - perr_x) * d_x) + (aerr_x * i_x); err_y = _y - sp_y; aerr_y += err_y; pwr_y = (err_y * p_y) + ((err_y - perr_y) * d_y) + (aerr_y * i_y); motor[motorA] = round(pwr_y); motor[motorB] = round(pwr_x); _x1 = xscale(_x); _y1 = yscale(_y); nxtEraseRect(_x1-6, _y1-6, _x1+6, _y1+6); nxtDrawLine(_x1, _y1+3, _x1, _y1-3); nxtDrawLine(_x1+3, _y1, _x1-3, _y1); perr_y = err_y; perr_x = err_x; } wait1Msec(50); } }
void measureTime(const TInstructions nInstructionType) { TSensorTypes nSensorType = testSensorType; int i; int j; int k; #if defined(useLongs) long l1; long l2; #endif #if defined(useFloats) float idleLoopTime; float loopTime; float elapsed; #else int idleLoopTime; int loopTime; int elapsed; #endif float fTemp; short iArray[10]; long lArray[10]; float fArray[10]; const int kInitialValues = 511; // an arbitrary value testType = nInstructionType; wait1Msec(200); // Some variable initialization. //i = random(10); i = 0; j = kInitialValues; k = kInitialValues; #if defined(useLongs) l1 = kInitialValues * 256; l2 = kInitialValues; #endif #if defined(useFloats) fTemp = 0.999999999; #endif idleLoopTime = nElapsedTime[typeIdleLoop]; clearTimer(executionTimer); for (index = 1; index <= kNumberOfLoops; ++index) { // // to measure a different instruction type, simply change the // definition of the following constant. // // // Since 'nInstructionType' is a constant, code optimizer will eliminate // the 'switch' instruction and the 'dead code' for the unreachable // cases. // int nTemp; switch (nInstructionType) { case typeIdleLoop: { nTemp = typeIdleLoop; // So that branch does not get optimized out break; } case typeAlive: { alive(); alive(); alive(); alive(); alive(); alive(); alive(); alive(); alive(); alive(); nTemp = typeAlive; break; } case typeIntegerAssignConstant: { iArray[00] = 250; iArray[01] = 250; iArray[02] = 250; iArray[03] = 250; iArray[04] = 250; iArray[05] = 250; iArray[06] = 250; iArray[07] = 250; iArray[08] = 250; iArray[09] = 250; nTemp = typeIntegerAssignConstant; break; } case typeIntegerAssignVariable: { iArray[00] = i; iArray[01] = i; iArray[02] = i; iArray[03] = i; iArray[04] = i; iArray[05] = i; iArray[06] = i; iArray[07] = i; iArray[08] = i; iArray[09] = i; nTemp = typeIntegerAssignVariable; break; } case typeIntegerAssignSensor: { iArray[00] = SensorValue[in1]; iArray[01] = SensorValue[in1]; iArray[02] = SensorValue[in1]; iArray[03] = SensorValue[in1]; iArray[04] = SensorValue[in1]; iArray[05] = SensorValue[in1]; iArray[06] = SensorValue[in1]; iArray[07] = SensorValue[in1]; iArray[08] = SensorValue[in1]; iArray[09] = SensorValue[in1]; nTemp = typeIntegerAssignSensor; break; } case typeIntegerAssignIndexed: { iArray[i + 00] = 50; iArray[i + 01] = 50; iArray[i + 02] = 50; iArray[i + 03] = 50; iArray[i + 04] = 50; iArray[i + 05] = 50; iArray[i + 06] = 50; iArray[i + 07] = 50; iArray[i + 08] = 50; iArray[i + 09] = 50; nTemp = typeIntegerAssignIndexed; break; } case typeIntegerAddVariable: { // Have to use alternating assignments to 'i' and 'j'; otherwise // code optimizer will simplify into single 'i += 20*333' iArray[00] += i; iArray[01] += i; iArray[02] += i; iArray[03] += i; iArray[04] += i; iArray[05] += i; iArray[06] += i; iArray[07] += i; iArray[08] += i; iArray[09] += i; nTemp = typeIntegerAddVariable; break; } case typeIntegerAddConstant: { // Have to use alternating assignments to 'i' and 'j'; otherwise // code optimizer will simplify into single 'i ++= 20*333' iArray[00] += 250; iArray[01] += 250; iArray[02] += 250; iArray[03] += 250; iArray[04] += 250; iArray[05] += 250; iArray[06] += 250; iArray[07] += 250; iArray[08] += 250; iArray[09] += 250; nTemp = typeIntegerAddConstant; break; } #if defined(useLongs) case typeLongAssignConstant: { lArray[00] = 175; lArray[01] = 175; lArray[02] = 175; lArray[03] = 175; lArray[04] = 175; lArray[05] = 175; lArray[06] = 175; lArray[07] = 175; lArray[08] = 175; lArray[09] = 175; nTemp = typeLongAssignConstant; break; } case typeLongAssignVariable: { lArray[00] = lArray[9]; lArray[01] = lArray[9]; lArray[02] = lArray[9]; lArray[03] = lArray[9]; lArray[04] = lArray[9]; lArray[05] = lArray[9]; lArray[06] = lArray[9]; lArray[07] = lArray[9]; lArray[08] = lArray[9]; lArray[09] = lArray[9]; nTemp = typeLongAssignVariable; break; } case typeLongAssignIndexed: { lArray[i + 00] = 50; lArray[i + 01] = 50; lArray[i + 02] = 50; lArray[i + 03] = 50; lArray[i + 04] = 50; lArray[i + 05] = 50; lArray[i + 06] = 50; lArray[i + 07] = 50; lArray[i + 08] = 50; lArray[i + 09] = 50; nTemp = typeLongAssignIndexed; break; } #endif #if defined(useLongs) case typeLongAddConstant: { lArray[00] += 120; lArray[01] += 120; lArray[02] += 120; lArray[03] += 120; lArray[04] += 120; lArray[05] += 120; lArray[06] += 120; lArray[07] += 120; lArray[08] += 120; lArray[09] += 120; nTemp = typeLongAddConstant; break; } case typeLongAddVariable: { lArray[00] += iArray[09]; lArray[01] += iArray[09]; lArray[02] += iArray[09]; lArray[03] += iArray[09]; lArray[04] += iArray[09]; lArray[05] += iArray[09]; lArray[06] += iArray[09]; lArray[07] += iArray[09]; lArray[08] += iArray[09]; lArray[09] += iArray[09]; nTemp = typeLongAddVariable; break; } case typeLongTimes: { lArray[00] *= 3; lArray[01] *= 3; lArray[02] *= 3; lArray[03] *= 3; lArray[04] *= 3; lArray[05] *= 3; lArray[06] *= 3; lArray[07] *= 3; lArray[08] *= 3; lArray[09] *= 3; nTemp = typeLongTimes; break; } #endif #if defined(useFloats) case typeFloatAssignConstant: { fArray[00] = 3.357; fArray[01] = 3.357; fArray[02] = 3.357; fArray[03] = 3.357; fArray[04] = 3.357; fArray[05] = 3.357; fArray[06] = 3.357; fArray[07] = 3.357; fArray[08] = 3.357; fArray[09] = 3.357; nTemp = typeFloatAssignConstant; break; } case typeFloatAssignVariable: { fArray[00] = fTemp; fArray[01] = fTemp; fArray[02] = fTemp; fArray[03] = fTemp; fArray[04] = fTemp; fArray[05] = fTemp; fArray[06] = fTemp; fArray[07] = fTemp; fArray[08] = fTemp; fArray[09] = fTemp; nTemp = typeFloatAssignVariable; break; } case typeFloatAddVariable: { fArray[00] += fTemp; fArray[01] += fTemp; fArray[02] += fTemp; fArray[03] += fTemp; fArray[04] += fTemp; fArray[05] += fTemp; fArray[06] += fTemp; fArray[07] += fTemp; fArray[08] += fTemp; fArray[09] += fTemp; nTemp = typeFloatAddVariable; break; } case typeFloatAddConstant: { fArray[00] += 102.3; fArray[01] += 102.3; fArray[02] += 102.3; fArray[03] += 102.3; fArray[04] += 102.3; fArray[05] += 102.3; fArray[06] += 102.3; fArray[07] += 102.3; fArray[08] += 102.3; fArray[09] += 102.3; nTemp = typeFloatAddConstant; break; } case typeFloatTimes: { fArray[00] *= fTemp; fArray[01] *= fTemp; fArray[02] *= fTemp; fArray[03] *= fTemp; fArray[04] *= fTemp; fArray[05] *= fTemp; fArray[06] *= fTemp; fArray[07] *= fTemp; fArray[08] *= fTemp; fArray[09] *= fTemp; nTemp = typeFloatTimes; break; } #endif #if defined(NXT) || defined(TETRIX) case typeClearScreen: { eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); eraseDisplay(); nTemp = typeClearScreen; break; } case typeClearPixel: { nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nxtClearPixel(22, 22); nTemp = typeClearPixel ; break; } case typeRectangleErase: { nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nxtEraseRect(22, 22, 52, 52); nTemp = typeRectangleErase; break; } case typeRectangleFill: { nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nxtFillRect(22, 22, 52, 52); nTemp = typeRectangleFill; break; } case typeRectangleDraw: { nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nxtDrawRect(22, 22, 52, 52); nTemp = typeRectangleDraw; break; } #if (0) case typeIOMapRead: { const int kOffset = 0; const int kNumberOfBytes = 1; byte nBuffer[10]; const string pzModule1 = "UI.mod"; const string pzModule2 = "Display.mod"; #if (0) nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); nxtReadIOMap(pzModule1, ioResult, nBuffer[0], kOffset, kNumberOfBytes); #else nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 1; nUiOMap.OBPPointer += 20; #endif nTemp = typeIOMapRead; break; } #endif #endif #if defined(hasTranscendentalSupport) case typeSine: { fTemp *= 1.05; fArray[00] = sin(fTemp); fArray[01] = sin(fTemp); fArray[02] = sin(fTemp); fArray[03] = sin(fTemp); fArray[04] = sin(fTemp); fArray[05] = sin(fTemp); fArray[06] = sin(fTemp); fArray[07] = sin(fTemp); fArray[08] = sin(fTemp); fArray[09] = sin(fTemp); nTemp = typeSine; break; } case typeCosine: { fTemp *= 1.05; fArray[00] = cos(fTemp); fArray[01] = cos(fTemp); fArray[02] = cos(fTemp); fArray[03] = cos(fTemp); fArray[04] = cos(fTemp); fArray[05] = cos(fTemp); fArray[06] = cos(fTemp); fArray[07] = cos(fTemp); fArray[08] = cos(fTemp); fArray[09] = cos(fTemp); nTemp = typeCosine; break; } #endif case typeLogical: { #if defined(useLongs) iArray[00] = (l1 < l2); iArray[01] = (l1 < l2); iArray[02] = (l1 < l2); iArray[03] = (l1 < l2); iArray[04] = (l1 < l2); iArray[07] = (l1 < l2); iArray[06] = (l1 < l2); iArray[07] = (l1 < l2); iArray[08] = (l1 < l2); iArray[09] = (l1 < l2); #endif nTemp = typeLogical; break; } case typeTrinaryAdd: { iArray[00] = i + k; iArray[01] = i + k; iArray[02] = k + i; iArray[03] = i + k; iArray[04] = i + k; iArray[05] = k + i; iArray[06] = i + k; iArray[07] = i + k; iArray[08] = k + i; iArray[09] = i + k; nTemp = typeTrinaryAdd; break; } case typeTrinaryAddConstant1: { iArray[00] = i + 333; iArray[01] = i + 333; iArray[02] = 333 + i; iArray[03] = i + 333; iArray[04] = i + 333; iArray[05] = 333 + i; iArray[06] = i + 333; iArray[07] = i + 333; iArray[08] = 333 + i; iArray[09] = i + 333; nTemp = typeTrinaryAddConstant1; break; } case typeTrinaryAddConstant2: { iArray[00] = i + 127; iArray[01] = i + 127; iArray[02] = 127 + i; iArray[03] = i + 127; iArray[04] = i + 127; iArray[05] = 127 + i; iArray[06] = i + 127; iArray[07] = i + 127; iArray[08] = 127 + i; iArray[09] = i + 127; nTemp = typeTrinaryAddConstant2; break; } } } loopTime = time1[executionTimer]; #if defined(useFloats) loopTime /= 100.0; #endif if (nInstructionType == typeIdleLoop) elapsed = loopTime; else elapsed = loopTime - idleLoopTime; nElapsedTime[nInstructionType] = elapsed; // 'elapsed' contains the number of 10 msec 'ticks' to execute 100,000 (5,000 loops // each with 20) statements. Thus if 'elapsed' is 146, a single statement took // 14.6 microseconds: // - 1,460 millisecons total 'adjusted' time in loop (146 ticks x 10 milliseconds) // - 1,460 milliseconds is same as 1,460,000 microseconds // - divide by 100,000 to get 14.6 microseconds playSound(soundBlip); return; }
void erasePowerstacker(int x, int y){ nxtEraseEllipse(x+23, y+56, x+37, y+45); // Head nxtEraseRect (x+22, y+44, x+38, y+31); // Upper torso nxtEraseRect (x+20, y+30, x+40, y+26); // Middle torso nxtEraseRect (x+16, y+26, x+44, y+21); // Hips nxtEraseRect (x+16, y+20, x+23, y); // Left leg nxtEraseRect (x+8, y+5, x+15, y); // Left foot nxtEraseRect (x+37, y+20, x+44, y); // Right leg nxtEraseRect (x+45, y+5, x+52, y); // Right foot nxtEraseRect (x+8, y+44, x+21, y+40); // Left arm nxtEraseRect (x, y+48, x+13, y+45); // Left hand nxtEraseRect (x+39, y+44, x+52, y+40); // Right arm nxtEraseRect (x+47, y+48, x+60, y+45); // Right hand }