当前位置: 首页>>代码示例>>C++>>正文


C++ pgm_read_byte_near函数代码示例

本文整理汇总了C++中pgm_read_byte_near函数的典型用法代码示例。如果您正苦于以下问题:C++ pgm_read_byte_near函数的具体用法?C++ pgm_read_byte_near怎么用?C++ pgm_read_byte_near使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pgm_read_byte_near函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: calculateLux

// 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);
}
开发者ID:kincki,项目名称:contiki,代码行数:24,代码来源:ressources.c

示例2: params_get_channel

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];
}
开发者ID:13416795,项目名称:contiki,代码行数:37,代码来源:params.c

示例3: while

	//-----------------------------------------------------------------//
	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);
	}
开发者ID:hirakuni45,项目名称:AVR,代码行数:25,代码来源:monograph.cpp

示例4: pgm_read_byte_near

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;
      }
    }
  }
}
开发者ID:Fisch0204,项目名称:Qlockthree_D3,代码行数:24,代码来源:Renderer.cpp

示例5: PSTR

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');
}
开发者ID:SodaqMoja,项目名称:tph_demo,代码行数:15,代码来源:DataRecord.cpp

示例6: getPWMBrightness

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;
}
开发者ID:russells,项目名称:flashy3,代码行数:15,代码来源:leds.c

示例7: Serial_print_P

//************************************************************************
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);
	}
}
开发者ID:gaftech,项目名称:ArduinoTestSuite,代码行数:16,代码来源:ArduinoTestSuite.cpp

示例8: ows_spm

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;
	}
}
开发者ID:vir,项目名称:tinyowd,代码行数:48,代码来源:ows_spm.c

示例9: command

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);
}
开发者ID:pipoop,项目名称:hobby-device,代码行数:16,代码来源:GSwifi.cpp

示例10: get_eui64_from_eeprom

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;
}
开发者ID:1uk3,项目名称:contiki,代码行数:16,代码来源:contiki-raven-main.c

示例11: free

/**
 * 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);
}
开发者ID:AndreaGot,项目名称:arduinosketches,代码行数:31,代码来源:mysql.cpp

示例12: pgm_read_byte_near

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;
}
开发者ID:dfrobot-Andy,项目名称:SIM808_LIB,代码行数:17,代码来源:sim808ModemCore.cpp

示例13: usbFunctionRead

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;
}
开发者ID:derf,项目名称:fnordlicht-smd,代码行数:17,代码来源:usbload.c

示例14: reset

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();
}
开发者ID:aschwartzmann,项目名称:rx5808-pro-diversity,代码行数:46,代码来源:oled_128x64_adafruit_screens.cpp

示例15: while

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;
}
开发者ID:Tripod2K,项目名称:raspino,代码行数:17,代码来源:GSM3ShieldV1ModemCore.cpp


注:本文中的pgm_read_byte_near函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。