Example #1
0
const char *get_prio_name(uint_fast8_t prio)
{
    static char name[5];
    if (prio >= OS::PROCESS_COUNT) {
        strcpy_P(name, str_unknown);
    } else {
#if scmRTOS_PRIORITY_ORDER == 1
        prio = OS::PROCESS_COUNT - prio - 1;
#endif
        if (prio == OS::PROCESS_COUNT-1 ) {
            strcpy_P(name, str_idle);
        } else {
            char *p = name;
            *p++ = 'p';
            *p++ = 'r';
            uint8_t tens = '0';
            while (prio >= 10) {
                ++tens;
                prio -= 10;
            }
            if (tens != '0')
                *p++ = tens;
            *p++ = '0'+prio;
            *p = 0;
        }
    }
        
    return name;
}
Example #2
0
/* getTimestamp() - returns a string containing variables related with time 
 * and date.
 *
 * It returns a string containing variables related with time and date. These 
 * values are the last taken from RTC
 */
char* WaspRTC::getTimestamp() 
{
	// define local buffer
	char buffer[40];
	char error_string[20];
	
	// buffer <-- "%s, %02u/%02u/%02u, %02u:%02u:%02u"
	strcpy_P(buffer,  (char*)pgm_read_word(&(table_RTC[17])));	
	// error_string <-- "error"
	strcpy_P(error_string,  (char*)pgm_read_word(&(table_RTC[18])));		
	
	switch (day) 
	{
	case 1:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_1, year, month, date, hour, minute, second);
			break;
	case 2:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_2, year, month, date, hour, minute, second);
			break;
	case 3:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_3, year, month, date, hour, minute, second);
			break;
	case 4:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_4, year, month, date, hour, minute, second);
			break;
	case 5:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_5, year, month, date, hour, minute, second);
			break;
	case 6:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_6, year, month, date, hour, minute, second);
			break;
	case 7:	snprintf(timeStamp, sizeof(timeStamp), buffer, DAY_7, year, month, date, hour, minute, second);
			break;
	default:snprintf(timeStamp, sizeof(timeStamp), error_string);
			break;
  }
  return timeStamp;
}
Example #3
0
bool CardReader::findGeneratedBy(char* buf, char* genBy) {
  // Slic3r & S3D
  const char* generatedByString = PSTR("generated by ");
  char* pos = strstr_P(buf, generatedByString);
  if (pos) {
    pos += strlen_P(generatedByString);
    size_t i = 0;
    while (i < GENBY_SIZE - 1 && *pos >= ' ') {
      char c = *pos++;
      if (c == '"' || c == '\\') {
        // Need to escape the quote-mark for JSON
        if (i > GENBY_SIZE - 3) break;
        genBy[i++] = '\\';
      }
      genBy[i++] = c;
    }
    genBy[i] = 0;
    return true;
  }

  // CURA
  const char* slicedAtString = PSTR(";Sliced at: ");
  pos = strstr_P(buf, slicedAtString);
  if (pos) {
    strcpy_P(genBy, PSTR("Cura"));
    return true;
  }

  // UNKNOWN
  strcpy_P(genBy, PSTR("Unknown"));
  return false;
}
byte ESP8266_Simple::startHttpServer(unsigned port, unsigned long (* requestHandler)(char *buffer, int bufferLength), unsigned int maxBufferSize)
{
  char cmdBuffer[64];
  byte responseCode;
  
  this->httpServerRequestHandler = requestHandler;
  this->httpServerMaxBufferSize = maxBufferSize;
  
  // Enter MUX mode
  responseCode = this->sendCommand(F("AT+CIPMUX=1"));
  if(responseCode != ESP8266_OK) return responseCode;
  
  // Set Server Timeout
  memset(cmdBuffer,0,sizeof(cmdBuffer));
  strcpy_P(cmdBuffer, PSTR("AT+CIPSTO=,"));
  ultoa(this->generalCommandTimeoutMicroseconds/1000/1000, cmdBuffer+strlen(cmdBuffer), 10);    
  this->sendCommand(cmdBuffer);
  
  // Start Server
  memset(cmdBuffer,0,sizeof(cmdBuffer));
  strcpy_P(cmdBuffer, PSTR("AT+CIPSERVER=1,"));
  itoa(port, cmdBuffer+strlen(cmdBuffer), 10);    
  responseCode = this->sendCommand(cmdBuffer);
  if(responseCode != ESP8266_OK) return responseCode;
    
  return ESP8266_OK;
}
static void lcd_material_select_details_callback(uint8_t nr)
{
    uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET());
    if (nr == 0)
    {
        
    }
    else if (nr <= count)
    {
        char buffer[32];
        char* c = buffer;
        nr -= 1;
        
        if (led_glow_dir)
        {
            c = float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)), c, PSTR("mm"));
            while(c < buffer + 10) *c++ = ' ';
            strcpy_P(c, PSTR("Flow:"));
            c += 5;
            c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)), c, PSTR("%"));
        }else{
            c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)), c, PSTR("C"));
            *c++ = ' ';
            c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)), c, PSTR("C"));
            while(c < buffer + 10) *c++ = ' ';
            strcpy_P(c, PSTR("Fan: "));
            c += 5;
            c = int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)), c, PSTR("%"));
        }
        lcd_lib_draw_string(5, 53, buffer);
    }else{
        lcd_lib_draw_string_centerP(53, PSTR("Modify the settings"));
    }
}
unsigned int ESP8266_Simple::GET(unsigned long serverIp, int port, char *requestPathAndResponseBuffer, int bufferLength, const __FlashStringHelper *httpHost, int bodyResponseOnlyFromLine)
{
  if(!serverIp)                       return ESP8266_ERROR;
  if(!requestPathAndResponseBuffer)   return ESP8266_ERROR;
  
  char serverIpBuffer[strlen_P((const char *)serverIp)+1];
  strcpy_P(serverIpBuffer, (const char *) serverIp); 
  
  int  httpResponseCode = 0;
  byte responseCode;
  
  if(httpHost && strlen_P((const char *)httpHost))
  {
    char httpHostBuffer[strlen_P((const char *)httpHost)+1];
    strcpy_P(httpHostBuffer, (const char *)httpHost);
    responseCode = this->sendHttpRequest(serverIp, port, requestPathAndResponseBuffer, bufferLength, httpHostBuffer, bodyResponseOnlyFromLine, &httpResponseCode); 
  } 
  else
  {
    responseCode = this->sendHttpRequest(serverIp, port, requestPathAndResponseBuffer, bufferLength, NULL, bodyResponseOnlyFromLine, &httpResponseCode);     
  }
  
  if(responseCode != ESP8266_OK)
  {
    return responseCode;
  }
  
  return httpResponseCode;
}
Example #7
0
void gui_gyro_calib_loop()
{
	uint8_t value;
	char tmp[20];

	gui_dialog_P(PSTR("Gyroscope"));
	disp.LoadFont(F_TEXT_M);
	uint8_t h_t = disp.GetTextHeight();

	if(gui_gyro_calib.wait_cnt < WAIT_TIME)
	{
		//print message
		strcpy_P(tmp, PSTR("Keep device calm!"));
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + 1 );
		gui_gyro_calib.wait_cnt += 1;
		return;
	}
	else if(gui_gyro_calib.wait_cnt <= (WAIT_TIME + N_OF_SAMPLES))
	{
		strcpy_P(tmp, PSTR("Calibrating ..."));
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + 1 );

		gui_gyro_calib.bias.x += (float) fc.gyro.raw.x;
		gui_gyro_calib.bias.y += (float) fc.gyro.raw.y;
		gui_gyro_calib.bias.z += (float) fc.gyro.raw.z;
		gui_gyro_calib.wait_cnt += 1;
	}
	else if(gui_gyro_calib.wait_cnt == (WAIT_TIME + N_OF_SAMPLES + 1))
	{
		gui_gyro_calib.bias.x /= (float) N_OF_SAMPLES;
		gui_gyro_calib.bias.y /= (float) N_OF_SAMPLES;
		gui_gyro_calib.bias.z /= (float) N_OF_SAMPLES;
		gui_gyro_calib.wait_cnt += 1;
	}

	//draw frame
	disp.DrawRectangle(BAR_X1_POS , GUI_DIALOG_TOP + 1 + h_t, BAR_X2_POS, GUI_DIALOG_TOP + 1 + h_t + BAR_HEIGHT, 1, 0);

	//draw bar
	value = uint8_t( BAR_MAX_LENGHT * ( float( gui_gyro_calib.wait_cnt - WAIT_TIME ) / N_OF_SAMPLES ) + 1.5);
	disp.DrawRectangle(BAR_X1_POS , GUI_DIALOG_TOP + 2 + h_t , BAR_X1_POS + value, GUI_DIALOG_TOP + h_t + BAR_HEIGHT, 1, 1);



	//menu
	disp.LoadFont(F_TEXT_S);
	gui_raligh_text_P(PSTR("back"), GUI_DISP_WIDTH - 2, GUI_DIALOG_BOTTOM - 4);

	if(gui_gyro_calib.wait_cnt == (WAIT_TIME + N_OF_SAMPLES + 2))
	{	//if complete

		//add menu option
		gui_caligh_text_P(PSTR("save"), GUI_DISP_WIDTH / 2, GUI_DIALOG_BOTTOM - 4);

		//print message
		disp.LoadFont(F_TEXT_M);
		strcpy_P(tmp, PSTR("Done!"));
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP +1 );
	}
}
Example #8
0
bool EspDrv::sendCmdGet(const __FlashStringHelper* cmd, const __FlashStringHelper* startTag, const __FlashStringHelper* endTag, char* outStr, int outStrLen)
{
	char _startTag[strlen_P((char*)startTag)+1];
	strcpy_P(_startTag,  (char*)startTag);

	char _endTag[strlen_P((char*)endTag)+1];
	strcpy_P(_endTag,  (char*)endTag);

	return sendCmdGet(cmd, _startTag, _endTag, outStr, outStrLen);
}
Example #9
0
void gui_dialog_set_P(const char * title, const char * msg, uint8_t style, uint8_cb * cb)
{
	char tmp1[21];
	char tmp2[64];

	strcpy_P(tmp1, title);
	strcpy_P(tmp2, msg);

	gui_dialog_set(tmp1, tmp2, style, cb);
}
Example #10
0
/* Obtain the control code string */
void MIDI_ControlString(uint8_t command, char* buffer)
{
   uint8_t i;
   for(i = 0; FLASH_GET_PGM_BYTE(&MidiLookUpTable[i].MIDI_Commands); i++)
   {
      if( command == FLASH_GET_PGM_BYTE(&MidiLookUpTable[i].MIDI_Commands) )
      {
         strcpy_P(buffer, FLASH_GET_PGM_WORD(&MidiLookUpTable[i].MIDI_CommandString));
         return;
      }
   }
   strcpy_P(buffer, MIDI_UNDEFINED_STRING);
}
static char* lcd_menu_material_settings_store_callback(uint8_t nr)
{
    uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET());
    if (nr == 0)
        strcpy_P(card.longFilename, PSTR("< RETURN"));
    else if (nr > count)
        strcpy_P(card.longFilename, PSTR("New preset"));
    else{
        eeprom_read_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr - 1), 8);
        card.longFilename[8] = '\0';
    }
    return card.longFilename;
}
Example #12
0
/* ----------------------------------------------------------------------------
 * initialization of Art-Net
 */
void
artnet_init(void)
{

  ARTNET_DEBUG("Init\n");
  /* read Art-Net port */
  artnet_port = CONF_ARTNET_PORT;
  /* read netconfig */
  artnet_netConfig = NETCONFIG_DEFAULT;

  /* read subnet */
  artnet_subNet = SUBNET_DEFAULT;
  artnet_inputUniverse = CONF_ARTNET_INUNIVERSE;
  artnet_outputUniverse = CONF_ARTNET_OUTUNIVERSE;
#ifdef CONF_ARTNET_SEND_POLL_REPLY
  artnet_sendPollReplyOnChange = 1;
#else
  artnet_sendPollReplyOnChange = 0;
#endif
  strcpy_P(artnet_shortName, PSTR("e6ArtNode"));
  strcpy_P(artnet_longName, PSTR("e6ArtNode hostname: " CONF_HOSTNAME));

  set_CONF_ARTNET_OUTPUT_IP(&artnet_outputTarget);

  /* dmx storage connection */
  artnet_conn_id = dmx_storage_connect(artnet_inputUniverse);
  if (artnet_conn_id != -1)
  {
    artnet_connected = TRUE;
    ARTNET_DEBUG("Connection to dmx-storage established! id:%d\r\n",
                 artnet_conn_id);
  }
  else
  {
    artnet_connected = FALSE;
    ARTNET_DEBUG("Connection to dmx-storage couldn't be established!\r\n");
  }

  /* net_init */
  artnet_netInit();

  /* annouce that we are here  */
  ARTNET_DEBUG("send PollReply\n");
  artnet_sendPollReply(&all_ones_addr);

  /* enable PollReply on changes */
  artnet_sendPollReplyOnChange = TRUE;
  ARTNET_DEBUG("init complete\n");
  return;
}
Example #13
0
static void drawDate()
{
	// Get day string
	char day[BUFFSIZE_STR_DAYS];
	strcpy_P(day, days[timeDate.date.day]);

	// Get month string
	char month[BUFFSIZE_STR_MONTHS];
	strcpy_P(month, months[timeDate.date.month]);

	// Draw date
	char buff[BUFFSIZE_DATE_FORMAT];
	sprintf_P(buff, PSTR(DATE_FORMAT), day, timeDate.date.date, month, timeDate.date.year);
	draw_string(buff,false,12,0);
}
byte ESP8266_Simple::setWifiMode(byte mode)
{
  char modeBuff[12];
  strcpy_P(modeBuff, PSTR("AT+CWMODE="));
  itoa((int)mode,modeBuff+10,10);
  return this->sendCommand(modeBuff);
}
long ESP8266_Simple::connectToWifi(const char *SSID, const char *Password)
{
  byte returnValue;
  unsigned long previousTimeout = this->generalCommandTimeoutMicroseconds;
  
  // First set to client mode
  returnValue = this->setWifiMode(ESP8266_STATION);
  if(returnValue != ESP8266_OK) return returnValue;
  
  // Not sure if a QAP is a good idea here?
  /*
    returnValue = this->disconnectFromWifi();
    if(returnValue != ESP8266_OK) return returnValue;
  */
  
  
  char atCmd[11];
  strcpy_P(atCmd, PSTR("AT+CWJAP=\"")); // PSTR monkeying to save a few bytes
  const char *cmdParts[] = {
    atCmd,
    SSID,
    "\",\"",
    Password,
    "\""
  };
  
  // Connecting to Wifi takes a while
  this->generalCommandTimeoutMicroseconds = max((long)5*1000*1000, this->generalCommandTimeoutMicroseconds);

  returnValue = this->sendCommand((const char **)cmdParts,(byte)5, (char *)NULL,(int)0, (byte)1);
  this->generalCommandTimeoutMicroseconds = previousTimeout;
  return returnValue;
}
Example #16
0
uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist) {
    uint8_t i=0;
    char ref[maxcmdlength+1];
    char* itemstr;
    ref[0]='\0';
    /* check if we are behind the first word */
    while(buffer[i]) {
        if(!isgraph(buffer[i++]))
            return 0;
    }
    for(;;) {
        itemstr = (char*)pgm_read_word(cmdlist);
        if(itemstr==NULL)
            break;
        cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
        if(!strncmp_P(buffer, itemstr, i)) {
            if(!ref[0]) {
                strcpy_P(ref, itemstr);
            } else {
                ref[stridentcnt_P(ref, itemstr)]='\0';
            }
        }
    }
    i = strcmp(buffer, ref);
    if(i)
        strcpy(buffer, ref);
    return ~i;
}
Example #17
0
U8 chb_get_rand()
{
    if (radio_id == CHB_AT86RF230)
    {
        // part ID AT86RF230 does not support true random number generation
        char buf[50];
        
        // nothing to be done here. print warning & return.
        strcpy_P(buf, chb_err_not_supported);
        Serial.print(buf);
        return 0;
    }
    else if ((radio_id == CHB_AT86RF212) || (radio_id == CHB_AT86RF231))
    {
        U8 i, rnd, tmp;

        rnd = tmp = 0;
        for (i=0; i<4; i++)
        {
            tmp = chb_reg_read(PHY_RSSI);
            tmp >>= 5;
            tmp &= 0x03;
            rnd |= tmp << (i*2);
            chb_delay_us(5);
        }
        return rnd;
    }
Example #18
0
//write data on eeprom
int8_t CfgCmd(char *inbuffer)
{
	int adresa = 18;
	//char *scriu;
	char comanda[7];
	int8_t i;

	for (i = 0; i < 20; ++i)
	{
		strcpy_P(comanda, (char*) pgm_read_word(&(comenzi[i]))); // Necessary casts and dereferencing, just copy.
		if (strstr(inbuffer, comanda) != 0)
		{

			inbuffer += strlen(comanda) + 1;
			adresa = 18 * (2 + i);
//#if DEBUG
			//Serial.print("Scriu la adresa ");
			Serial.print(adresa);
			//Serial.print(": ");
			Serial.println(inbuffer);
//#endif
			eeprom_write_block(inbuffer, (int*) adresa, 18);
			//EEPROM.updateBlock(inbuffer, adresa, 18);
			return 1;
		}
	}
	return 0;
}
byte ESP8266_Simple::sendCommand(const __FlashStringHelper *cmd)
{
  char cmdBuffer[strlen_P((const char *)cmd)+1];
  strcpy_P(cmdBuffer, (const char *) cmd); 
  
  return this->sendCommand(cmdBuffer, NULL, 0);  
}
//************************************************************************
//*	returns true if no errors, false if there is an error
boolean	ATS_Test_PWMPinWithHelper(uint8_t pwmPinToTest, uint8_t helperpin)
{
boolean	passedOK;
char	testName[64];
char	errorString[48];
char	numString[8];
uint8_t	timerNumber;



	strcpy_P(testName, gTextMsg_PWMoutput);
	sprintf(numString, "%02d", pwmPinToTest);
	strcat(testName, numString);

	passedOK		=	true;
	errorString[0]	=	0;
	

	//*	is pin1 a timer?
	timerNumber	=	digitalPinToTimer(pwmPinToTest);
	if (timerNumber != NOT_ON_TIMER)
	{
		passedOK	=	ATS_TestTimer(pwmPinToTest, helperpin, testName, errorString);
	}
	else
	{
		//*	we should not get here
		passedOK	=	false;
	}

	ATS_PrintTestStatus(testName, passedOK);

	
	return(passedOK);
}
Example #21
0
void logger_stop()
{
	if (!logger_active())
		return;

	if (fc.logger_state == LOGGER_WAIT_FOR_GPS)
	{
		char text[32];
		strcpy_P(text, PSTR("No GPS fix during flight!"));

		logger_comment(text);
	}

	fc.logger_state = LOGGER_IDLE;

	switch (config.logger.format)
	{
		case(LOGGER_IGC):
			igc_stop();
		break;

		case(LOGGER_KML):
			kml_stop();
		break;

		case(LOGGER_RAW):
			raw_step();
		break;
	}
}
//************************************************************************
//*	returns true if no errors, false if there is an error
int	ATS_Test_DigitalPinWithHelper(uint8_t digitalPinToTest, uint8_t helperpin)
{
boolean	passedOK;
int		pinValue;
char	testName[64];
char	numString[32];

	strcpy_P(testName, gTextMsg_DigitalRW);
	sprintf(numString, "%02d", digitalPinToTest);
	strcat(testName, numString);

	passedOK	=	true;
	
	//*	test senario 1
	pinMode(digitalPinToTest, OUTPUT);
	pinMode(helperpin, INPUT);

	digitalWrite(digitalPinToTest, HIGH);
	pinValue	=	digitalRead(helperpin);
	if (pinValue != HIGH)
	{
		passedOK	=	false;
	}

	digitalWrite(digitalPinToTest, LOW);
	pinValue	=	digitalRead(helperpin);
	if (pinValue != LOW)
	{
		passedOK	=	false;
	}

	
	//*	now reverse the input/output
	pinMode(digitalPinToTest, INPUT);
	pinMode(helperpin, OUTPUT);
	
	digitalWrite(helperpin, HIGH);
	pinValue	=	digitalRead(digitalPinToTest);
	if (pinValue != HIGH)
	{
		passedOK	=	false;
	}

	digitalWrite(helperpin, LOW);
	pinValue	=	digitalRead(digitalPinToTest);
	if (pinValue != LOW)
	{
		passedOK	=	false;
	}


	if (! passedOK)
	{
		sprintf(numString, " (helper pin=%02d)", helperpin);
		strcat(testName, numString);
	}
	ATS_PrintTestStatus(testName, passedOK);
	return(passedOK);
}
void PusherClient::getPusherInfoItem(int index, String& text)
{
	char* ptr = (char*)pgm_read_word(&(pusherInfos[index]));
	int len = strlen_P(ptr);
	char buffer[len+1];
	strcpy_P(buffer, ptr);
	text = buffer;
}
Example #24
0
String & String::append(const __FlashStringHelper *pgmstr)
{
	unsigned int length = strlen_P((const char PROGMEM *)pgmstr);
	unsigned int newlen = len + length;
	if (length == 0 || !reserve(newlen)) return *this;
	strcpy_P(buffer + len, (const char PROGMEM *)pgmstr);
	len = newlen;
	return *this;
}
Example #25
0
/**
 @brief	make response header such as html, gif, jpeg, zip, etc.
 */
void make_http_response_head(
	uint8_t * buf, 	/**< pointer to response header to be made */
	uint8_t type, 	/**< response type */
	uint32_t len	/**< size of response file / document */
	)
{
	PGM_P head = 0;
	uint8_t tmp[16];

	switch (type) {

		case PTYPE_HTML :
			head = RES_HTMLHEAD_OK;
			break;

		case PTYPE_GIF :
			head = RES_GIFHEAD_OK;
			break;

		case PTYPE_TEXT :
			head = RES_TEXTHEAD_OK;
			break;

		case PTYPE_JPEG :
			head = RES_JPEGHEAD_OK;
			break;

		case PTYPE_FLASH :
			head = RES_FLASHHEAD_OK;
			break;

		case PTYPE_MPEG :
			head = RES_MPEGHEAD_OK;
			break;

		case PTYPE_PDF :
			head = RES_PDFHEAD_OK;
			break;

		case PTYPE_ZIP :
			head = RES_ZIPHEAD_OK;
			break;

		default:
#ifdef HTTP_DEBUG
			xSerialPrint_P(PSTR("\r\n\r\nHTTP RESPONSE HEADER UNKNOWN-\r\n"));
#endif
			break;
	}

	sprintf((char *)tmp,"%ld", len);

	strcpy_P((char *)buf, head);
	strcat((char *)buf, (const char *)tmp);
	strcat_P((char *)buf, PSTR("\r\n\r\n\0"));
}
Example #26
0
String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
{
	if (!reserve(length)) {
		invalidate();
		return *this;
	}
	len = length;
	strcpy_P(buffer, (PGM_P)pstr);
	return *this;
}
// result can have maximum length of : sign + 3 digits integer part + point + 3 digits fraction part + '\0' = 9 bytes;
// only 1, 2 or 3 decimals allowed.
// returns pointer to the string
// fixed7_23 is used to prevent overflow
char * tempToString(char s[9], fixed23_9 rawValue, uint8_t numDecimals, uint8_t maxLength){ 
	if(rawValue == INT_MIN){
		strcpy_P(s, PSTR("null")); 
		return s;
	}
	if(tempControl.cc.tempFormat == 'F'){
		rawValue = (rawValue * 9) / 5 + (32 << 9); // convert to Fahrenheit first
	}
	return fixedPointToString(s, rawValue, numDecimals, maxLength);
}
byte ESP8266_Simple::sendCommand(const __FlashStringHelper *cmd, char *responseBuffer, int responseBufferLength, byte getResponseFromLine)
{
  char cmdBuffer[strlen_P((const char *)cmd)+1];
  strcpy_P(cmdBuffer, (const char *) cmd); 
  
  // WHY DOES THIS NOT WORK??
  // return this->sendCommand((const char **)&cmdBuffer, 1, responseBuffer, responseBufferLength, getResponseFromLine);
  
  return this->sendCommand((const char *)cmdBuffer, responseBuffer, responseBufferLength, getResponseFromLine);
}
Example #29
0
/*
 * Sets caption for value true (green button) if different from false (red button) caption
 */
void BDButton::setCaptionPGMForValueTrue(const char * aPGMCaption) {
    if (USART_isBluetoothPaired()) {
        uint8_t tCaptionLength = strlen_P(aPGMCaption);
        if (tCaptionLength < STRING_BUFFER_STACK_SIZE) {
            char tStringBuffer[STRING_BUFFER_STACK_SIZE];
            strcpy_P(tStringBuffer, aPGMCaption);
            sendUSARTArgsAndByteBuffer(FUNCTION_BUTTON_SET_CAPTION_FOR_VALUE_TRUE, 1, mButtonHandle, tCaptionLength, tStringBuffer);
        }
    }
}
unsigned int ESP8266_Simple::GET(const __FlashStringHelper *serverIp, int port, char *requestPathAndResponseBuffer, int bufferLength, const __FlashStringHelper *httpHost, int bodyResponseOnlyFromLine)
{
  if(!serverIp)                       return ESP8266_ERROR;
  char serverIpBuffer[strlen_P((const char *)serverIp)+1];
  strcpy_P(serverIpBuffer, (const char *) serverIp); 
  
  unsigned long serverIpLong;
  this->ipConvertDatatypeFromTo(serverIpBuffer, serverIpLong);
  return this->GET(serverIpLong, port, requestPathAndResponseBuffer, bufferLength, httpHost, bodyResponseOnlyFromLine);
}