Ejemplo n.º 1
0
int main()
{
	int dia, mes, anio;
	long int fecha;

	writeLnString("ingrese la fecha en formato AAAAMMDD");
	readLong(fecha);

	anio = fecha/10000;

	fecha -= anio * 10000;

	mes = fecha/100;

	fecha -= mes * 100;

	dia = fecha;

	writeString("La Fecha es ");

	writeInteger(dia);
	writeString("/");
	writeInteger(mes);
	writeString("/");
	writeInteger(anio);

	return 0;
}
Ejemplo n.º 2
0
int Path::write(std::ofstream &out, std::string &msg)
{
	short record_size;

	record_size = 4;
	writeShort(out, record_size);
	writeByte(out, PATH);
	writeByte(out, NoData);

	record_size = 6;
	writeShort(out, record_size);
	writeByte(out, EFLAGS);
	writeByte(out, Integer_2);
	writeShort(out, Eflags);

	record_size = 6;
	writeShort(out, record_size);
	writeByte(out, LAYER);
	writeByte(out, Integer_2);
	writeShort(out, Layer);

	record_size = 6;
	writeShort(out, record_size);
	writeByte(out, DATATYPE);
	writeByte(out, Integer_2);
	writeShort(out, Data_type);

	record_size = 8;
	writeShort(out, record_size);
	writeByte(out, WIDTH);
	writeByte(out, Integer_4);
	writeInteger(out, Width);

	record_size = 6;
	writeShort(out, record_size);
	writeByte(out, PATHTYPE);
	writeByte(out, Integer_2);
	writeShort(out, Path_type);

    record_size = 4 + short(8 * Pts.size());
	writeShort(out, record_size);
	writeByte(out, XY);
	writeByte(out, Integer_4);
	for (auto p : Pts)
	{
		writeInteger(out, p.x);
		writeInteger(out, p.y);
	}

	record_size = 4;
	writeShort(out, record_size);
	writeByte(out, ENDEL);
	writeByte(out, NoData);

	return out.fail() ? FILE_ERROR : 0;
}
Ejemplo n.º 3
0
  void writeFloat(JsonFloat value, int digits = 2) {
    if (Polyfills::isNaN(value)) return writeRaw("NaN");

    if (value < 0.0) {
      writeRaw('-');
      value = -value;
    }

    if (Polyfills::isInfinity(value)) return writeRaw("Infinity");

    short powersOf10;
    if (value > 1000 || value < 0.001) {
      powersOf10 = Polyfills::normalize(value);
    } else {
      powersOf10 = 0;
    }

    // Round correctly so that print(1.999, 2) prints as "2.00"
    JsonFloat rounding = 0.5;
    for (uint8_t i = 0; i < digits; ++i) rounding /= 10.0;

    value += rounding;

    // Extract the integer part of the value and print it
    JsonUInt int_part = static_cast<JsonUInt>(value);
    JsonFloat remainder = value - static_cast<JsonFloat>(int_part);
    writeInteger(int_part);

    // Print the decimal point, but only if there are digits beyond
    if (digits > 0) {
      writeRaw('.');
    }

    // Extract digits from the remainder one at a time
    while (digits-- > 0) {
      remainder *= 10.0;
      JsonUInt toPrint = JsonUInt(remainder);
      writeInteger(JsonUInt(remainder));
      remainder -= static_cast<JsonFloat>(toPrint);
    }

    if (powersOf10 < 0) {
      writeRaw("e-");
      writeInteger(-powersOf10);
    }

    if (powersOf10 > 0) {
      writeRaw('e');
      writeInteger(powersOf10);
    }
  }
Ejemplo n.º 4
0
  void writeFloat(JsonFloat value, uint8_t digits = 2) {
    if (Polyfills::isNaN(value)) return writeRaw("NaN");

    if (value < 0.0) {
      writeRaw('-');
      value = -value;
    }

    if (Polyfills::isInfinity(value)) return writeRaw("Infinity");

    short powersOf10;
    if (value > 1000 || value < 0.001) {
      powersOf10 = Polyfills::normalize(value);
    } else {
      powersOf10 = 0;
    }

    // Round up last digit (so that print(1.999, 2) prints as "2.00")
    value += getRoundingBias(digits);

    // Extract the integer part of the value and print it
    JsonUInt int_part = static_cast<JsonUInt>(value);
    JsonFloat remainder = value - static_cast<JsonFloat>(int_part);
    writeInteger(int_part);

    // Print the decimal point, but only if there are digits beyond
    if (digits > 0) {
      writeRaw('.');
    }

    // Extract digits from the remainder one at a time
    while (digits-- > 0) {
      // Extract digit
      remainder *= 10.0;
      char currentDigit = char(remainder);
      remainder -= static_cast<JsonFloat>(currentDigit);

      // Print
      writeRaw(char('0' + currentDigit));
    }

    if (powersOf10 < 0) {
      writeRaw("e-");
      writeInteger(-powersOf10);
    }

    if (powersOf10 > 0) {
      writeRaw('e');
      writeInteger(powersOf10);
    }
  }
int main(void)
{
	initRobotBase();

	setLEDs(0b111111);
	mSleep(500);
	setLEDs(0b000000);

	writeString_P("\nJust a simple counter program\n\n");
	
	uint16_t counter = 0;

	while(true)
	{
		timer = 0; 
		if(counter < 100) 
		{
			writeString_P("Counter: ");
			writeInteger(counter, BIN);
			writeString_P("(BIN) | ");
			writeInteger(counter, OCT);
			writeString_P("(OCT) | ");
			writeInteger(counter, DEC);
			writeString_P("(DEC) | ");
			writeInteger(counter, HEX);
			writeString_P("(HEX) ");
		}
		else
		{
			writeString_P("Counter L: ");
			writeIntegerLength(counter, BIN, 16);  
			writeString_P("(BIN) | ");
			writeIntegerLength(counter, OCT, 6);
			writeString_P("(OCT) | ");
			writeIntegerLength(counter, DEC, 6);
			writeString_P("(DEC) | ");
			writeIntegerLength(counter, HEX, 4);
			writeString_P("(HEX) ");
		}
		
		writeChar(' ');
		writeInteger(timer,DEC); 
		writeString(" *100us");
		writeChar('\n');
		
		counter++;  
		mSleep(100);
	}
	return 0;
}
Ejemplo n.º 6
0
void test(uint8_t number)
{
	bars(2);
	writeString_P("#### TEST #");
	writeInteger(number, DEC);
	writeString_P(" ####\n");
}
Ejemplo n.º 7
0
void SendDataOverUART(int value)
{
	// These functions send data over the UART
	writeString_P("Counter: "); 

	writeInteger(value, DEC);
	writeString_P("(DEC) | ");

	writeInteger(value, HEX);
	writeString_P("(HEX) | ");
	
	writeInteger(value, BIN);
	writeString_P("(BIN) ");

	writeChar('\n'); // New Line
}
Ejemplo n.º 8
0
void BranchState::writeInteger( Token::Argument& argument )
{
	assert( argument.type() == Token::Argument::INTEGER_REGISTER );

	if( argument.content() == Token::Argument::REGISTER )
	{
		writeInteger( argument.regNumber() );
	}
	else if( argument.content() == Token::Argument::ALIAS )
	{
		std::map< std::string, State >::iterator i = m_integers.find( argument.alias() );

		if( i == m_integers.end() )
		{
			State newState;

			m_integers[ argument.alias() ] = newState;
			i = m_integers.find( argument.alias() ); // this could be retrieved directly, but I've had issues with inserting into maps and retrieving the iterator in the same operation

			assert( i != m_integers.end() );
		}

		i->second.setFields( 1 );
		i->second.clearAddress();

		updateDependency( argument, i->second, Alias::INTEGER, i->first, false );
	}
}
Ejemplo n.º 9
0
/**
 * This function gets called automatically if there was an I2C Error like
 * the slave sent a "not acknowledge" (NACK, error codes e.g. 0x20 or 0x30).
 */
void I2C_transmissionError(uint8_t errorState)
{
	writeString_P("\n############ I2C ERROR!!!!! - TWI STATE: 0x");
	writeInteger(errorState, HEX);
	writeChar('\n');
	errors++;
}
Ejemplo n.º 10
0
extern void FilterRequestData(REQUEST_STRUCT* request, char request_buffer[], size_t separatorindex, size_t startindex, size_t endindex)
{
	if((separatorindex - startindex) > 0 && (endindex - separatorindex) > 2 && request != NULL)
	{			
		char cmdbuffer[(separatorindex - startindex)+1];
		strncpy(cmdbuffer, request_buffer+startindex, ((separatorindex - startindex)+1));
		
		static char* proper_keys[2] = {"cmd", "val"};
		int index = -1;
		
		for(uint8_t i = 0; i < 2;i++)
		{
			if(strncmp(cmdbuffer, proper_keys[i], strlen(proper_keys[i])) == 0)
			{	 			
				index = i;
				break;
			}
		}
		
		switch(index)
		{
			case 0://CMD
			{
				uint16_t length = (endindex-separatorindex+1);
				
				if(length > 0)
				{
				//				
					char filtervalue [length];
					strncpy(filtervalue, request_buffer+(separatorindex+1), length);
				
						uint16_t value = strtol(filtervalue, NULL, 0);
						
						writeString("{cmd=0x");
						writeInteger(value, HEX);
						writeChar('}');
						
						(*request).cmd = value;
				}
				//
				break;
			}
			case 1: //VAL
			{
				//				
				char filtervalue [(endindex-separatorindex)+1];
				strncpy(filtervalue, request_buffer+(separatorindex+1), (endindex-separatorindex+1));
				
				if(strlen(filtervalue) > 0)
				{
					uint16_t value = strtol(filtervalue, NULL, 0);
					(*request).val = value;
				}
				//
				break;
			}
		}
	}
}
Ejemplo n.º 11
0
/* initializeCommand ()
**
** Initialize the BLITZ DISK file by writing out an empty directory.
*/
void initializeCommand () {

  if (commandOptionV) printf ("INITIALIZING THE FILE SYSTEM...\n");

  openDiskFile (0);               /* Existing = false */

  seekTo (4);                     /* Skip past "BLZd" magic number */
  writeInteger (0x73747562);      /* Magic number = "stub" */
  writeInteger (0);               /* Number of file */
  writeInteger (1);               /* Next Free Sector */

  if (commandOptionV) printf ("Number of files on disk = 0\n");
  if (commandOptionV) printf ("Next free sector = 1\n");
  if (commandOptionV) printf ("Number of available sectors = %d\n", numberSectorsOnDisk-1);

  closeFiles ();
}
Ejemplo n.º 12
0
void AMFWriter::writeNumber(double value){
	_lastReference=0;
	if(!amf0Preference && value<=AMF_MAX_INTEGER && round(value) == value) {
		writeInteger((Int32)value);
		return;
	}
	packet.write8(_amf3 ? AMF3_NUMBER : AMF_NUMBER); // marker
	packet.writeNumber<double>(value);
}
Ejemplo n.º 13
0
/* writeDirectory ()
**
** Print the directory back to the BLITZ DISK.
*/
void writeDirectory () {
  Entry * e = firstEntry;
  seekTo (8);
  writeInteger (numberOfFiles);
  writeInteger (nextFreeSector);
  while (e) {
    // printf ("writing next entry...\n");
    // printf ("\t%d\t\t%d\t\t%d\t\t%s\n",
    //         e->startingSector,
    //         e->sizeInBytes,
    //         e->lengthOfName,
    //         e->name);
    writeInteger (e->startingSector);
    writeInteger (e->sizeInBytes);
    writeInteger (e->lengthOfName);
    writeString (e->name, e->lengthOfName);
    e = e->next;
  }
}
Ejemplo n.º 14
0
    /* Write an integer to the Marshal object 
    */
    void Marshal::Write(int val)
    {
        writeDataType(MTYPE_INT);

        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);

        writeInteger(val);

        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);
    }
Ejemplo n.º 15
0
/**
 * A simple counter that outputs it's value on the
 * Serialport each time it is incremented. 
 * It is incremented every 400ms.
 */
void task_counter1(void)
{
	static uint8_t counter;
	if(getStopwatch2() > 400) // 400ms = 0.4s
	{
		writeString_P("CNT1 : ");
		writeInteger(counter, DEC);
		writeChar('\n');
		counter++;
		setStopwatch2(0); // Reset stopwatch
	}
}
Ejemplo n.º 16
0
/**
 * A second counter, with different interval (0.8s) and
 * binary output format. 
 */
void task_counter2(void)
{
	static uint8_t counter2;
	if(getStopwatch3() > 800) // 800ms = 0.8s
	{
		writeString_P("\t  CNT2 : ");
		writeInteger(counter2, BIN);
		writeChar('\n');
		counter2++;
		setStopwatch3(0); // Reset stopwatch
	}
}
Ejemplo n.º 17
0
void BinaryPropertyListPlan::writeIntegerArray(const int* integers, size_t size)
{
    size_t savedAggregateSize = ++m_currentAggregateSize;
    ASSERT(size);
    IntegerArrayMap::AddResult addResult = m_integerArrays.add(IntegerArray(integers, size), 0);
    if (!addResult.isNewEntry)
        return;
    for (size_t i = 0; i < size; ++i)
        writeInteger(integers[i]);
    addResult.iterator->value = m_currentObjectReference++;
    writeArrayObject(size);
    m_currentAggregateSize = savedAggregateSize;
}
Ejemplo n.º 18
0
void sendByteAndReceiveByte(void)
{
	if(getStopwatch1() > 500) 
	{
		I2CTWI_transmitByte(ARDUINO_WRITE_ADDRESS, speed);	//writing the speed of rp6	
			
		uint8_t someByteToRead = 0;
		someByteToRead = I2CTWI_readByte(ARDUINO_READ_ADDRESS); //read the maximum speed
		writeInteger(someByteToRead, DEC);
		getSpeedLimit(someByteToRead);       
		setStopwatch1(0);	
	}
}
Ejemplo n.º 19
0
    /* Write a SCXRegexWithIndex object to the Marshal object 
    */
    void Marshal::Write(const SCXRegexWithIndex& ri)
    {
        writeDataType(MTYPE_REGEX_INDEX);
        
        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);

        writeInteger((int) ri.index);

        CHECK_WRITE_ERROR(m_stream);

        Write(ri.regex->Get());
    }
Ejemplo n.º 20
0
    /* Write a vector of SCXRegexWithIndex object to the Marshal object 
    */
    void Marshal::Write(const vector<SCXRegexWithIndex>& vri)
    {
        writeDataType(MTYPE_VECTOR_REGEX_INDEX);

        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);

        int vecSize = (int) vri.size();
        writeInteger(vecSize);

        CHECK_WRITE_ERROR(m_stream);

        for(int i  = 0; i < vecSize; i++)
        {
           Write(vri[i]);
        }
    }
Ejemplo n.º 21
0
    /* Write a vector of wstring to the Marshal object 
    */
    void Marshal::Write(const vector<wstring>& vws)
    {
        writeDataType(MTYPE_VECTOR_WSTRING);

        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);

        int vecSize = (int) vws.size();
        writeInteger(vecSize);

        CHECK_WRITE_ERROR(m_stream);

        for(int i = 0; i < vecSize; i++)
        {
            Write(vws[i]);
        }
    }
Ejemplo n.º 22
0
int QCaInteger::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    typedef qcaobject::QCaObject QMocSuperClass;
    _id = QMocSuperClass::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: integerChanged((*reinterpret_cast< const long(*)>(_a[1])),(*reinterpret_cast< QCaAlarmInfo(*)>(_a[2])),(*reinterpret_cast< QCaDateTime(*)>(_a[3])),(*reinterpret_cast< const uint(*)>(_a[4]))); break;
        case 1: writeInteger((*reinterpret_cast< const long(*)>(_a[1]))); break;
        case 2: convertVariant((*reinterpret_cast< const QVariant(*)>(_a[1])),(*reinterpret_cast< QCaAlarmInfo(*)>(_a[2])),(*reinterpret_cast< QCaDateTime(*)>(_a[3]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Ejemplo n.º 23
0
    /* Write a wstring to the Marshal object 
    */
    void Marshal::Write(const wstring& ws)
    {
        writeDataType(MTYPE_WSTRING);

        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);

        int strSize = (int) (ws.length() * sizeof(wchar_t));
        writeInteger(strSize);

        CHECK_WRITE_ERROR(m_stream);

        vector<char> buf(strSize, '\0');
        memcpy(&buf[0], ws.c_str(), strSize);
        m_stream.write(&buf[0], strSize);
    
        // check for stream write error 
        CHECK_WRITE_ERROR(m_stream);
     }
Ejemplo n.º 24
0
static void serializeUntypedTerm(A2PWriter writer, ATerm value){
	int type = ATgetType(value);
	switch(type){
		case AT_INT:
			writeInteger(writer, (ATermInt) value);
			break;
		case AT_REAL:
			writeDouble(writer, (ATermReal) value);
			break;
		case AT_APPL:
			{
				ATermAppl appl = (ATermAppl) value;
				AFun fun = ATgetAFun(appl);
				if(ATisQuoted(fun) == ATfalse){
					A2PType expected = A2PnodeType();
					ATermList annotations = (ATermList) ATgetAnnotations(value);
					if(annotations == NULL){
						writeNode(writer, expected, appl);
					}else{
						if(((A2PNodeType) expected->theType)->declaredAnnotations == NULL){ fprintf(stderr, "Node term has annotations, but none are declared.\n"); exit(1); }
						
						writeAnnotatedNode(writer, expected, appl, annotations);
					}
				}else{
					if(ATgetArity(fun) != 0){ fprintf(stderr, "Quoted appl (assumed to be a string) has a non-zero arity.\n"); exit(1);}
					
					writeString(writer, appl);
				}
			}
			break;
		case AT_LIST:
			writeList(writer, A2PlistType(A2PvalueType()), (ATermList) value);
			break;
		default:
			fprintf(stderr, "Encountered unwriteable type: %d.\n", type);
			exit(1);
	}
}
Ejemplo n.º 25
0
void pilot::JSONFileHandler::writeUInt(const char* name, std::uint32_t value) {
	writeInteger(name, value);
}
Ejemplo n.º 26
0
void pilot::JSONFileHandler::writeShort(const char* name, std::int16_t value) {
	writeInteger(name, value);
}
Ejemplo n.º 27
0
void AMFWriter::writeObjectProperty(const string& name,Int32 value) {
	writePropertyName(name);
	writeInteger(value);
}
Ejemplo n.º 28
0
int main(void)
{
	initRP6Control(); // Always call this first! The Processor will not work
					  // correctly otherwise. 

	bars(2);
	writeString_P("\n\nRP6Control Selftest!\n\n"); 
	bars(2);
	setLEDs(0b1111);
	mSleep(50);
	initLCD(); 
	showScreenLCD("################", "################");

	mSleep(400);
	showScreenLCD("################", "################");
	showScreenLCD("RP6Control M32", "SELFTEST");

	mSleep(1000);
	
	uint8_t keynumber = 0;
	while(keynumber < 6)
	{
		uint8_t key = checkReleasedKeyEvent(); 
		if(key == keynumber)
		{
			keynumber++;
			showScreenLCD("PRESS BUTTON", "NUMBER ");
			writeIntegerLCD(keynumber,DEC);
			setLEDs(0b0000);
			writeString_P("### PRESS BUTTON NUMBER ");
			writeInteger(keynumber,DEC);
			writeString_P("!\n");
		}
	}
	
	
	showScreenLCD("Testing", "BEEPER & LEDS");
	mSleep(250);
	// Play a sound to indicate that our program starts:
	sound(50,50,100); setLEDs(0b0000);
	sound(80,50,100); setLEDs(0b0001);
	sound(100,50,100);setLEDs(0b0010);
	sound(120,50,100);setLEDs(0b0100);
	sound(140,50,100);setLEDs(0b1000);
	sound(160,50,100);setLEDs(0b1001);
	sound(180,50,100);setLEDs(0b1011);
	sound(200,50,100);setLEDs(0b1111);
	mSleep(400);
	setLEDs(0b0000);

	showScreenLCD("Testing", "EERPOM");
	
	test(1);
	writeString_P("\nEEPROM TEST\n");
	writeString_P("\nErasing 250 Bytes...\n");
	
	uint8_t cnt;
	for(cnt = 0; cnt < 250; cnt++)
	{
		SPI_EEPROM_writeByte(cnt, 0xFF);
		while(SPI_EEPROM_getStatus() & SPI_EEPROM_STAT_WIP);
	}

	writeString_P("...Done!\nWriting 250 Bytes to EEPROM:\n");
	for(cnt = 0; cnt < 250; cnt++)
	{
		writeIntegerLength(cnt, DEC, 3);
		SPI_EEPROM_writeByte(cnt, cnt);
		while(SPI_EEPROM_getStatus() & SPI_EEPROM_STAT_WIP);
		writeChar(',');
		if(cnt % 10 == 0) writeChar('\n');
	}
	
	mSleep(400);
	setLEDs(0b1111);
	writeString_P("\nReading and verifying:\n");
	
	for(cnt = 0; cnt < 250; cnt++)
	{
		uint8_t result = SPI_EEPROM_readByte(cnt);
		if(result != cnt)
		{
			writeString_P("\nEEPROM VERIFY ERROR!!!! EEPROM DAMAGED!!!\n");
			writeString_P("Data read: "); writeInteger(result,DEC);
			writeString_P(", should be: "); writeInteger(cnt,DEC); writeChar('\n');
			errors++;
		}
		else
			writeIntegerLength(result,DEC,3);
		writeChar(',');
		if(cnt % 10 == 0) writeChar('\n');
	}
	
	writeString_P("\nErasing 250 Bytes...\n");
	for(cnt = 0; cnt < 250; cnt++)
	{
		SPI_EEPROM_writeByte(cnt, 0xFF);
		while(SPI_EEPROM_getStatus() & SPI_EEPROM_STAT_WIP);
	}
	
	mSleep(400);
	setLEDs(0b0000);
	writeString_P("\nEEPROM TEST DONE!\n");
	writeString_P("\nI2C TWI TEST:\n");
	showScreenLCD("I2C TWI", "TEST");
	
	
	I2CTWI_initMaster(100);  
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);
	
	uint8_t runningLight = 1;
	for(cnt = 0; cnt < 24; cnt++)
	{
		writeIntegerLength(cnt,DEC,3);
		writeChar(':');
		writeIntegerLength(runningLight,DEC,3);
		writeChar(',');
		writeChar(' ');

		I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, 3, runningLight);
		I2CTWI_transmitByte(I2C_RP6_BASE_ADR, 29);
		uint8_t result = I2CTWI_readByte(I2C_RP6_BASE_ADR);
		if(result != runningLight) 
		{
			writeString_P("\nTWI TEST ERROR!\n");
			errors++;
		}
		runningLight <<= 1; 
		if(runningLight > 32) 
			runningLight = 1;
	
		if((cnt+1) % 6 == 0) writeChar('\n');
		mSleep(100);
	}
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, 3, 0);
	
	writeString_P("\nTWI TEST DONE!\n");
	writeString_P("\nMicrophone Test\n");
	writeString_P("Hit the Microphone three times with your finger!\n");
	showScreenLCD("MIC TEST:", "");
	
	#define PREPARE 1
	#define WAIT 2
	
	uint8_t state = PREPARE;

	startStopwatch2();
	while(true)
	{
		static uint8_t peak_count = 3;
		if(state == PREPARE)
		{
			if(getStopwatch2() > 250)
			{
				setCursorPosLCD(1, 6); 
				writeIntegerLengthLCD( peak_count, DEC, 1);
				dischargePeakDetector();
				state = WAIT;
				setStopwatch2(0);
			}
		}
		else if(state == WAIT)
		{
			uint8_t key = checkReleasedKeyEvent(); 
			if(key)
			{
				break;
			}
			if(getStopwatch2() > 50)
			{
				uint16_t tmp = getMicrophonePeak();
				if(tmp > 4)
				{
					externalPort.LEDS = 0;
					uint16_t i;
					uint8_t j;
					for(i = 0, j = 2; i < tmp; i+= 40)
					{
						if(i < 40)
						{
							externalPort.LEDS++;
						}
						else
						{
							externalPort.LEDS <<=1;
							externalPort.LEDS++;
						}
					}
					outputExt();
					if(tmp > 120)
					{
						state = PREPARE;
						peak_count--;
					}
					if(peak_count == 0)
						break;
				}
				else
					setLEDs(0b0000);
				setStopwatch2(0);
			}
		}
	}

	writeString_P("\nMICROPHONE TEST DONE!\n");
	showScreenLCD("ALL TESTS", "DONE!");
	
	writeString_P("\n\n\n\n");
	bars(2);
	writeString_P("\n\nALL TESTS DONE!\n\n");
	
	if(errors)
	{
		bars(4);
		writeString_P("\nERROR ERROR ERROR ERROR ERROR ERROR ERROR\n");
		writeString_P("\nATTENTION: TESTS FINISHED WITH ERRORS!!!\n");
		writeString_P("PLEASE CHECK RP6-M32 ASSEMBLY!!!\n\n");
		bars(4);
		writeString_P("\n\n");
	}
	
	// Now we just show a running light...
	startStopwatch1();
	
	uint8_t runLEDs = 1; 
	uint8_t dir = 0;
	
	while(true) 
	{
		if(getStopwatch1() > 100) {
			setLEDs(runLEDs); 
			if(dir == 0)
				runLEDs <<= 1; 
			else
				runLEDs >>= 1;
			if(runLEDs > 7 ) 
				dir = 1;			
			else if (runLEDs < 2 ) 
				dir = 0;
			setStopwatch1(0);
		}
	}
Ejemplo n.º 29
0
 /* Note: the following private methods serve as helper functions 
 */
 void Marshal::writeDataType(MarshalDataType val)
 {
     writeInteger((int) val);
 }
Ejemplo n.º 30
0
/**
 * This function gets called automatically if there was an I2C Error like
 * the slave sent a "not acknowledge" (NACK, error codes e.g. 0x20 or 0x30).
 */
void I2C_transmissionError(uint8_t errorState)
{
	writeString_P_WIFI("\nI2C ERROR - TWI STATE: 0x");
	writeInteger(errorState, HEX);
	writeChar_WIFI('\n');
}