Ejemplo n.º 1
0
// simplified lux equation approximation using tables
unsigned short calculateLux(unsigned char channel0, unsigned char channel1)
{
	unsigned long lux = 0;
	// lookup count from channel value
	unsigned short count0 = pgm_read_byte_near(countLut[channel0&0b01111111]);
	unsigned short count1 = pgm_read_byte_near(countLut[channel1&0b01111111]);

	// calculate ratio
	unsigned char ratio = 128; // default

	// avoid division by zero - count1 cannot be greater than count0
	if((count0) && (count1 <= count0))
		ratio = ((count1 * 128) / count0);

	// calculate lux
	lux = (((count0-count1) * pgm_read_byte_near(ratioLut[ratio]))  / 256);

	// if lux is over MAXLUX, put MAXLUX as maximum
	if(lux > MAXLUX)
		lux = MAXLUX;

return ((unsigned short) lux);
}
Ejemplo n.º 2
0
uint8_t
params_get_channel(void) {
  uint8_t x[2];
  *(uint16_t *)x = eeprom_read_word ((uint16_t *)&eemem_channel);
/* Don't return an invalid channel number */
  if( (x[0]<11) || (x[0] > 26)) x[1]=x[0];
/* Do exclusive or test on the two values read */
  if((uint8_t)x[0]!=(uint8_t)~x[1]) {//~x[1] can promote comparison to 16 bit
/* Verification fails, rewrite everything */
    uint8_t i,buffer[32];
    PRINTD("EEPROM is corrupt, rewriting with defaults.\n");
#if CONTIKI_CONF_RANDOM_MAC
    PRINTD("Generating random EUI64 MAC\n");
    generate_new_eui64(&buffer);
    randomeui64=1;
#else
    for (i=0;i<sizeof(default_mac_address);i++) buffer[i] = pgm_read_byte_near(default_mac_address+i);
#endif
/* eeprom_write_block should not be interrupted */
    cli();
    eeprom_write_block(&buffer,  &eemem_mac_address, sizeof(eemem_mac_address));
    for (i=0;i<sizeof(default_server_name);i++) buffer[i] = pgm_read_byte_near(default_server_name+i);
    eeprom_write_block(&buffer,  &eemem_server_name, sizeof(eemem_server_name));
    for (i=0;i<sizeof(default_domain_name);i++) buffer[i] = pgm_read_byte_near(default_domain_name+i);
    eeprom_write_block(&buffer,  &eemem_domain_name, sizeof(eemem_domain_name));
    eeprom_write_word(&eemem_panid  , PARAMS_PANID);
    eeprom_write_word(&eemem_panaddr, PARAMS_PANADDR);
    eeprom_write_byte(&eemem_txpower, PARAMS_TXPOWER);
    eeprom_write_word(&eemem_nodeid, PARAMS_NODEID);
    x[0] = PARAMS_CHANNEL;
    x[1]= ~x[0];
    eeprom_write_word((uint16_t *)&eemem_channel, *(uint16_t *)x);
    sei();
  }
/* Always returns a valid channel */
  return x[0];
}
Ejemplo n.º 3
0
	//-----------------------------------------------------------------//
	void monograph::draw_string_center_P(const char* text)
	{
		int16_t xx = 0;
		int16_t yy = font_height_;
		char ch;
		int16_t l = 0;
		const char* p = text;
		while((ch = pgm_read_byte_near(p)) != 0) {
			p++;
			if(ch == '\n') {
				if(xx < l) xx = l;
				l = 0;
				yy += font_height_;
			} else {
				l += font_width_;
			}
		}
		if(xx < l) xx = l;
		--p;
		ch = pgm_read_byte_near(p);
		if(ch == '\n') yy -= font_height_;

		draw_string_P(64 - xx / 2, 32 - yy / 2, text);
	}
Ejemplo n.º 4
0
void Renderer::setMenuText(const char* menuText, eTextPos textPos, word matrix[16]) {
  if ( strlen(menuText) == 2 ) {
    for (byte i = 0; i < 5; i++) {
      for (byte j = 0; j < strlen(menuText); j++) {
        if (!isNumber(menuText[j])) {
          matrix[textPos + i] |= pgm_read_byte_near(&(staben[menuText[j] - 'A'][i])) << (5 + ((j + 1) % 2) * 6);
        }
        else {
          matrix[textPos + i] |= pgm_read_byte_near(&(ziffernB[menuText[j] - '0'][i])) << (5 + ((j + 1) % 2) * 5);
        }
      }
    }
  }
  else if ( strlen(menuText) == 1 ) {
    for (byte i = 0; i < 5; i++) {
      if (!isNumber(menuText[0])) {
        matrix[textPos + i] |= pgm_read_byte_near(&(staben[menuText[0] - 'A'][i])) << 8;
      }
      else {
        matrix[textPos + i] |= pgm_read_byte_near(&(ziffernB[menuText[0] - '0'][i])) << 8;
      }
    }
  }
}
Ejemplo n.º 5
0
void DataRecord_t::addHeaderToString(String & str)
{
  str.reserve(100);
  PGM_P ptr = PSTR("ts"
      ",temp_sht21,hum_sht21,temp_bmp85,pres_bmp85"
      ",batteryVoltage"
      );
  char c;
  do {
    c = pgm_read_byte_near(ptr++);
    if (c) {
      str += c;
    }
  } while (c != '\0');
}
Ejemplo n.º 6
0
static uint8_t getPWMBrightness(uint8_t led)
{
	uint8_t sreg;
	uint8_t ret;

	sreg = SREG;
	cli();
	if (ledStatuses[led].pwmSequence) {
		ret = pgm_read_byte_near(ledStatuses[led].pwmSequence);
	} else {
		ret = 0;
	}
	SREG = sreg;
	return ret;
}
Ejemplo n.º 7
0
//************************************************************************
void Serial_print_P(prog_char *flashMemStr)
{
char	theChar;
int		ii;

	ii		=	0;
#if (FLASHEND > 0x10000)
	while (theChar	=	pgm_read_byte_far(flashMemStr + ii++))
#else
	while (theChar	=	pgm_read_byte_near(flashMemStr + ii++))
#endif
	{
		Serial.print(theChar);
	}
}
Ejemplo n.º 8
0
void ows_spm()
{
	uint8_t cmd = ows_recv();
	uint16_t addr = ows_recv() << 8;
	addr |= ows_recv();
	switch(cmd) {
	case 0x33: /* read program memory page */
		ow_crc16_reset();
		for(uint8_t i = 0; i < PGM_PAGE_SIZE; ++i) {
			uint8_t c = pgm_read_byte_near(addr++);
			ows_send(c);
			ow_crc16_update(c);
		}
		addr = ow_crc16_get();
		ows_send(addr >> 8);
		ows_send(addr & 0xFF);
		break;
	case 0x3C: /* fill program memory page write buffer, return crc */
		ow_crc16_reset();
		for(uint8_t i = 0; i < PGM_PAGE_SIZE; i += 2) {
			uint16_t w;
			uint8_t c = ows_recv();
			ow_crc16_update(c);
			w = c << 8;
			c = ows_recv();
			w |= c;
			boot_page_fill(addr + i, w);
		}
		addr = ow_crc16_get();
		ows_send(addr >> 8);
		ows_send(addr & 0xFF);
		break;
	case 0x5A: /* write page buffer */
		write_page(addr);
		ows_send(0);
		ows_send(0);
		ows_send(0);
		break;
	case 0xA5: /* read eeprom page */
		break;
	case 0xAA: /* write eeprom page */
		break;
	case 0xC3: /* jump to address */
		break;
	case 0xCC: /* read device id and page size */
		break;
	}
}
Ejemplo n.º 9
0
void GSwifi::writeCert() {
    // Binary format, store in memory
    command( "AT+TCERTADD=cacert,0,753,1", GSCOMMANDMODE_NORMAL );

    resetResponse(GSCOMMANDMODE_NORMAL);

    // ESCAPE 'W' is written in pgm too (thus +2)
    for (uint16_t i=0; i<753 + 2; i++) {
        uint8_t read = pgm_read_byte_near(der + i);
        serial_->write( read );
        Serial.print( read, HEX );
    }

    setBusy(true);
    waitResponse(GS_TIMEOUT);
}
Ejemplo n.º 10
0
static bool get_eui64_from_eeprom(uint8_t macptr[8]) {
	size_t size = 8;
	if(settings_get(SETTINGS_KEY_EUI64, 0, (unsigned char*)macptr, &size)==SETTINGS_STATUS_OK) {
      PRINTD("<=Get EEPROM MAC address.\n");
      return true;		
    }
#if JACKDAW_CONF_RANDOM_MAC
    PRINTA("--Generating random MAC address.\n");
    generate_new_eui64(macptr);
#else
    {uint8_t i;for (i=0;i<8;i++) macptr[i] = pgm_read_byte_near(default_mac_address+i);}
#endif
    settings_add(SETTINGS_KEY_EUI64,(unsigned char*)macptr,8);
    PRINTA("->Set EEPROM MAC address.\n");
	return true;
}
Ejemplo n.º 11
0
/**
 * cmd_query_P - Execute a SQL statement
 *
 * This method executes the query specified as a character array that is
 * located in program memory. It copies the query to the local buffer then
 * calls the run_query() method to execute the query.
 *
 * If a result set is available after the query executes, the field
 * packets and rows can be read separately using the get_field() and
 * get_row() methods.
 *
 * query[in]       SQL statement (using PROGMEM)
 *
 * Returns boolean - True = a result set is available for reading
*/
boolean Connector::cmd_query_P(const char *query)
{
  int query_len = (int)strlen_P(query);

  if (buffer != NULL)
    free(buffer);

  buffer = (byte *)malloc(query_len+5);

  // Write query to packet
  for (int c = 0; c < query_len; c++)
    buffer[c+5] = pgm_read_byte_near(query+c);

  // Send the query
  return run_query(query_len);
}
Ejemplo n.º 12
0
size_t SIM808ModemCore::writePGM(PROGMEM prog_char str[], bool CR){
	int i = 0;
	char c;

	do{
		c = pgm_read_byte_near(str+i);
		if (c != 0){
			write(c);
		}
		i++;
	} while (c != 0);
	if (CR){
		print("\r\n");
	}

	return 1;
}
Ejemplo n.º 13
0
uchar usbFunctionRead(uchar *data, uchar len)
{
    if(len > bytes_remaining)
        len = bytes_remaining;
    bytes_remaining -= len;

    for (uint8_t i = 0; i < len; i++) {
        *data = pgm_read_byte_near((void *)flash_address.word);
        data++;
        flash_address.word++;
    }

    /* flash led on activity */
    PORTD ^= _BV(PD5);

    return len;
}
void screens::updateEditChannelFilter(uint8_t channel_id, const uint8_t *channel_filter, const uint16_t *channelFreqTable, const uint8_t *channelNames) {

    int screen_line;
    int ce_ct;
    int ce_ct_adj;

    reset();
    drawTitleBox(PSTR2("FILTER EDIT"));

    display.display();
    screen_line = 1;

    display.fillRect(0, 10*2+12, display.width(), 10, WHITE);
    for (ce_ct=(channel_id-2);ce_ct<=(channel_id+2);ce_ct++) {
        if ((ce_ct>=CHANNEL_MIN-1) && (ce_ct<=CHANNEL_MAX+1)) {
            ce_ct_adj = ce_ct;
        } else if (ce_ct <= CHANNEL_MIN) {
            ce_ct_adj = (CHANNEL_MAX+1) + ce_ct;
        } else {
            ce_ct_adj = (CHANNEL_MIN-1) + abs((CHANNEL_MAX+1)-ce_ct);
        }

        display.setCursor(5,10*screen_line+3);
        display.setTextColor(screen_line == 3 ? BLACK : WHITE);

        if ((ce_ct_adj == (CHANNEL_MIN-1)) || (ce_ct_adj == (CHANNEL_MAX+1))) {
            display.print(PSTR2("EXIT"));
        } else {
                        
            //Display Channel Name
            display.print(pgm_read_byte_near(channelNames + ce_ct_adj), HEX);
            
            //Display Channel Freq
            display.print(PSTR2(" ("));
            display.print(pgm_read_word_near(channelFreqTable + ce_ct_adj), DEC);
            display.print(PSTR2("): "));

            //Display Channel Status On/Off
            display.print((bitRead(channel_filter[ce_ct_adj / 8], ce_ct_adj - (ce_ct_adj / 8) * 8)) == 1 ? PSTR2("On ") : PSTR2("Off"));
        }
        screen_line++;
    }


    display.display();
}
Ejemplo n.º 15
0
size_t GSM3ShieldV1ModemCore::writePGM(PROGMEM const prog_char str[], bool CR)
{
	int i=0;
	char c;
	
	do
	{	
		c=pgm_read_byte_near(str + i); 
		if(c!=0)
			write(c);
		i++;
	} while (c!=0);
	if(CR)
		print("\r");
		
	return 1;
}
Ejemplo n.º 16
0
void GPRSbee::requestAT(const __FlashStringHelper *commandF, byte respMaxNumOflines, long timeOutInMS) {

  byte commandLength = 0;
  
  prog_char *commandFPtr = (prog_char*) commandF;

  while(pgm_read_byte_near( commandFPtr + commandLength ) != '\0' ) commandLength++;
  
  char command[commandLength+1];
  
  memcpy_P(command, commandF, (commandLength + 1));
  
  command[commandLength] = '\0';
  
  requestAT(command, respMaxNumOflines, timeOutInMS);
  
}
Ejemplo n.º 17
0
//21
void IndOtkazDT(void)
{
	unsigned int R0;
	unsigned char R1;
	unsigned char R3;
	SetCursor(0,0);

	for(R1=0;R1<=15;++R1)
	{		
		R0=500;
		while(R0--)         _WDR(); 
		R3=pgm_read_byte_near(&OtkazDT[R1]);
		if(R3>=192)
		R3=R3-64;
		SPDR=R3;
	}
}
Ejemplo n.º 18
0
void updateSounds() {
	if(playingSound < 0)
		return;

	Sound* s = &sounds[playingSound];
	soundPhase++;

	for(uint8_t i = 0; i < CHANNELS; i++) {
		if(captureChannels & (1<<i)) {
			Oscillator* o = &osc[i];
			switch(playingSound) {
			case SOUND_GOLD:
				o->amp -= 32000/12;
				if(soundPhase == 6)
					o->frequency = HZ_TO_FREQ(2710);
				break;

			case SOUND_JUMP:
				o->frequency += 20;
				if(soundPhase > 17)
					o->amp -= 32000/8;
				break;

			case SOUND_HURT:
				o->frequency -= 5;
				o->amp -= 32000/10;
				if(soundPhase == 3) {
					o->waveform = PULSE;
					o->frequency = 150;
				}
				break;

			case SOUND_GAME_OVER:
				o->frequency -= 150;
				o->amp -= 32000/150;
				if((soundPhase & 15) == 0)
					o->frequency = HZ_TO_FREQ(1500);
				break;
			}
		}
	}

	// stop sound?
	if(soundPhase >= pgm_read_byte_near(&s->length))
		stopSound();
}
Ejemplo n.º 19
0
void easyT6963::drawAnim(uint8_t x,uint8_t y, const uint8_t **string_table, int l,uint8_t height,uint8_t bytewidth){ //Position x, Position y, String of Images , Number of Images ,HEIGHT,BYTEWIDTH show bmp2c Picturefile
    uint8_t bitmap,a,h,i;
	int j;
	char* PicName;	 
	for (a = 0; a < l; a++) {
		PicName = (char*) pgm_read_word(&(string_table[a]));
		//PicName = pgm_read_word(&(string_table[a]));
		j = 0;
		for (h = 0; h < height-1; h++) {
			graphicGoTo(x,y+h);
			for (i = 0; i < bytewidth; i++){  
				bitmap = pgm_read_byte_near(PicName+(i+j));
				writeDisplayData(bitmap);
			}
			j = j + bytewidth;
		}
    }
}
void dump_sensors(uint16_t digital, uint8_t analog) {
    uint8_t pin;
    uint8_t value;
    while(1) {
        if (USART_RXBufferData_Available(&BT_data) && '*' == USART_RXBuffer_GetByte(&BT_data))
            return;
        bt_putchar(':');
        for (pin=0; pin<10; pin++) 
            if (digital & (1<<pin))
                bt_putchar(read_input('0'+pin)+48);
        for (pin=0; pin<6; pin++) 
            if (analog & (1<<pin)) {
                value = read_analog(pgm_read_byte_near(muxPosPins+pin), 0);
                put_hex_nibble(value>>4);
                put_hex_nibble(value&0xF);
            }
        _delay_ms(5);
    }
Ejemplo n.º 21
0
int puts_progmem(const char *string)
{
    while(true)
    {
        char nextChar = pgm_read_byte_near(string++); 
        if(nextChar == '\0')
            break;
        
        putchar(nextChar);
    }
    
    putchar('\n');

    /* puts: "On success, a non-negative value is returned. On error, the function returns
       EOF and sets the error indicator (ferror)." */
    return 0;
    
} /* End of puts_progmem */
Ejemplo n.º 22
0
static void showplaytime(uint8_t minutes, uint8_t seconds, uint8_t invert)
{
  char buffer[4];
  
  if (invert)
  {
    itoa(seconds, buffer, 10); 
    if (seconds < 10)
    {
      lcd_putc(pgm_read_byte_near(&invertmap[buffer[0]-'0']));
      lcd_putc('O');
    }
    else
    {
      lcd_putc(pgm_read_byte_near(&invertmap[buffer[1]-'0']));
      lcd_putc(pgm_read_byte_near(&invertmap[buffer[0]-'0']));
    }
    
    lcd_putc(':');
    
    itoa(minutes, buffer, 10); 
    if (minutes < 10)
    {
      lcd_putc(pgm_read_byte_near(&invertmap[buffer[0]-'0']));
      lcd_putc('O');
    }
    else
    {
      lcd_putc(pgm_read_byte_near(&invertmap[buffer[1]-'0']));
      lcd_putc(pgm_read_byte_near(&invertmap[buffer[0]-'0']));
    }
  }
  else
  {
    itoa(minutes, buffer, 10); 
    if (minutes < 10)
    {
      lcd_putc('0');
    }
    lcd_puts(buffer);
    
    lcd_putc(':');
    
    itoa(seconds, buffer, 10); 
    if (seconds < 10)
    {
      lcd_putc('0');
    }
    lcd_puts(buffer);
  }
}
Ejemplo n.º 23
0
inline void readConfig() {
	// read EEPROM items
	eeprom_read_block(&time, &(eeConfig.time), sizeof(time));
	if (time.set != 1 && time.set != 0)
		time = Time(); // clear on invalid value
	eeprom_read_block(&alarm, &(eeConfig.alarm), sizeof(alarm));
	if (alarm.set != 1 && alarm.set != 0)
		alarm = Time(); // clear on invalid value
	uint8_t nConfig = eeprom_read_byte(&(eeConfig.nConfig));
	if (nConfig > 0 && nConfig <= F_COUNT) {
		eeprom_read_block(&config, &(eeConfig.config), nConfig);
		for (uint8_t i = 0; i < nConfig; i++)
			config[i] = fixConfigValue(i, config[i]); 
	} else
		nConfig = 0; // assume no stored config -- all default
	// read defaults if needed
	for (uint8_t i = nConfig; i < F_COUNT; i++)
       config[i] = pgm_read_byte_near(&PGM_CONFIG_DEFAULT[i]);
}
Ejemplo n.º 24
0
//----------------------------------------------------------
void morseC(char c)
{
  int indx;
  unsigned char i,cc;

  indx = chkC(c);

  if (0 <= indx) {
    for (i=0; i < 6; i++) {
      cc = pgm_read_byte_near(arC + i + indx*6); // get morse code

      if (cc == 1)
        mDot();
      else if (cc ==2)
        mDash();
    }
    mcSpace();
  }
}
Ejemplo n.º 25
0
static void
flash_page(uint32_t page, uint8_t *buf)
{
    uint16_t i;
    uint8_t sreg;

#ifdef TFTP_DEBUG_DO_NOT_FLASH
    return;
#endif

    for(i = 0; i < SPM_PAGESIZE; i ++)
	if(buf[i] != pgm_read_byte_near(page + i))
	    goto commit_changes;
    return;					/* no changes */

 commit_changes:
    /* Disable interrupts. */
    sreg = SREG;
    cli();
    
    eeprom_busy_wait();

    boot_page_erase(page);
    boot_spm_busy_wait();

    for(i = 0; i < SPM_PAGESIZE; i += 2) {
	/* Set up little-endian word. */
	uint16_t w = *buf++;
	w += (*buf++) << 8;
        
	boot_page_fill (page + i, w);
    }

    boot_page_write (page);
    boot_spm_busy_wait();

    /* Reenable RWW-section again. */
    boot_rww_enable ();

    /* Re-enable interrupts (if they were ever enabled). */
    SREG = sreg;
}
Ejemplo n.º 26
0
uchar usbFunctionRead(uchar *data, uchar len)
{
    if(len > bytes_remaining)
        len = bytes_remaining;
    bytes_remaining -= len;

    for (uint8_t i = 0; i < len; i++) {
        if(request == USBASP_FUNC_READEEPROM)
            *data = eeprom_read_byte((void *)flash_address.word);
        else
            *data = pgm_read_byte_near((void *)flash_address.word);
        data++;
        flash_address.word++;
    }

    /* flash led on activity */
    PORTC ^= _BV(PC4);

    return len;
}
Ejemplo n.º 27
0
void loop () {
    unsigned char cl, b;
    unsigned short d, c = 0;

    while (c < l_size) {
        d = pgm_read_word_near (l + c);
        c += 2;
    
        for (cl = 0; cl < NL; cl ++) {
            b = pgm_read_byte_near (l + c++);
            digitalWrite (L[cl], b ? HIGH : LOW);
        }
    
        delay (d);
    }
  
    for (cl = 0; cl < NL; cl++) 
        digitalWrite (L[cl], LOW);
    
    delay (1000);
}
Ejemplo n.º 28
0
/* This calculates a CRC16 for the program memory starting at 
   address 0x0000 and going up to count-1 */
uint16_t
pgmcrc(uint16_t count) {
    uint16_t carry;
    uint16_t crc = 0xffff;
	uint16_t addr = 0; 

    while(addr != count) {
        int i = 8;

        bload_check();

        crc ^= pgm_read_byte_near(addr++);
        while(i--)
        {
            carry = crc & 0x0001;
            crc >>= 1;
            if (carry) crc ^= 0xA001;
        }
    }
    return crc;
}
Ejemplo n.º 29
0
void EncodeNSendMessage::SendJSONdiscoverRegister(WiFiClient localclient , bool bDiscoverRegister, String MacAddr)
{
	gsBufferWiFi="";
	gsBufferWiFi+='{';
	if(bDiscoverRegister)
	{
		SendJSONobject("Job", "Discovered", false);
		SendJSONobject("NodeID", (char *)MacAddr.c_str(), false); 
		Serial.println(gsBufferWiFi);		// for debug
	}
	else
	{
		SendJSONobject("Job", "Registered", false);
		SendJSONobject("NodeID",(char *)MacAddr.c_str(), false); 
		SendJSONobject("Result", "Authorized", false); 
	}
	gsBufferWiFi+="\"ThingList\":[";
	localclient.print(gsBufferWiFi.c_str());

	// nested thing message
	{
		int i;
		//thing1
		gsBufferWiFi="";
		for(i = 0 ; i < strlen(gJSONthings1) ; i++) 
		{
			gsBufferWiFi+=(char)pgm_read_byte_near(gJSONthings1 + i);
			if(i>MAX_WIFI_STRING_LENGTH)
			{
				localclient.print(gsBufferWiFi.c_str());
				gsBufferWiFi="";
			}
		}
		localclient.print(gsBufferWiFi.c_str());
		
	
	}
	
	localclient.print("]}\n");
}
Ejemplo n.º 30
0
void parseCommand (char * cmdstr)
{
    int8_t cmd=-1;
    int16_t num=0;
    
    if (DebugOutput==DEBUG_FULLOUTPUT)  {
  		Serial.print("parseCommand:"); Serial.println(cmdstr); 
    }
    char * actpos = strtok(cmdstr," ");   // see a nice explaination of strtok here:  http://www.reddit.com/r/arduino/comments/2h9l1l/using_the_strtok_function/
    
    if (actpos) 
    {
        if (DebugOutput==DEBUG_FULLOUTPUT)  {
    			Serial.print("actpos:"); Serial.println(actpos);
        }
        int i;
        strup(actpos);
        
        for (i=0;(i<NUM_COMMANDS)&&(cmd==-1);i++)
        {
          if (!strcmp_FM(actpos,(uint_farptr_t_FM)atCommands[i].atCmd))  {
            // Serial.print ("partype="); Serial.println (pgm_read_byte_near(&(atCommands[i].partype)));
            switch (pgm_read_byte_near(&(atCommands[i].partype))) 
            {
               case PARTYPE_UINT: actpos=strtok(NULL," ");  if (get_uint(actpos, &num)) cmd=i ; break;
               case PARTYPE_INT:  actpos=strtok(NULL," ");  if (get_int(actpos, &num)) cmd=i ; break;
               case PARTYPE_STRING: actpos+=3; if (*actpos) cmd=i; break;
               default: cmd=i; actpos=0; break;
            }
          }
        }  
    }

    if (cmd>-1) { 
      // Serial.print("cmd:");Serial.print(cmd);Serial.print("numpar:");
      // Serial.print(num);Serial.print("stringpar:");Serial.println(actpos);
      performCommand(cmd,num,actpos,0);        
    } 
    else Serial.println("???");      // command not recognized!                
}