نمایش نتایج: از 1 به 6 از 6
Like Tree1 لایک
  • 1 Post By Smead

موضوع: لچ کردن خروجی های gpio در ماژول esp8266

Threaded View

  1. #5
    Junior Member
    تاریخ عضویت
    May 2016
    نوشته ها
    7
    نقل قول نوشته اصلی توسط Smead نمایش پست ها
    https://www.arduino.cc/en/Tutorial/EEPROMWrite

    به این مثال توجه کن

    کد:
    #include <EEPROM.h>
    
    void setup()
    {
      Serial.begin(9600);
    
      uint addr = 0;
    
      // fake data
      struct { 
        uint val = 0;
        char str[20] = "";
      } data;
    
      // commit 512 bytes of ESP8266 flash (for "EEPROM" emulation)
      // this step actually loads the content (512 bytes) of flash into 
      // a 512-byte-array cache in RAM
      EEPROM.begin(512);
    
      // read bytes (i.e. sizeof(data) from "EEPROM"),
      // in reality, reads from byte-array cache
      // cast bytes into structure called data
      EEPROM.get(addr,data);
      Serial.println("Old values are: "+String(data.val)+","+String(data.str));
    
      // fiddle with the data "read" from EEPROM
      data.val += 5;
      if ( strcmp(data.str,"hello") == 0 )
          strncpy(data.str, "jerry",20);
      else 
          strncpy(data.str, "hello",20);
    
      // replace values in byte-array cache with modified data
      // no changes made to flash, all in local byte-array cache
      EEPROM.put(addr,data);
    
      // actually write the content of byte-array cache to
      // hardware flash.  flash write occurs if and only if one or more byte
      // in byte-array cache has been changed, but if so, ALL 512 bytes are 
      // written to flash
      EEPROM.commit();  
    
      // clear 'data' structure
      data.val = 0; 
      strncpy(data.str,"",20);
    
      // reload data for EEPROM, see the change
      //   OOPS, not actually reading flash, but reading byte-array cache (in RAM), 
      //   power cycle ESP8266 to really see the flash/"EEPROM" updated
      EEPROM.get(addr,data);
      Serial.println("New values are: "+String(data.val)+","+String(data.str));
    }
    
    void loop()
    {
      delay(1000);
    }
    همچنین بهتره از put و get بجای write و read استفاده کنین

    ممنون از لطف و پاسخ شما. حل شد
    مشکل من در EEPROM.commit بود که بعد از دستور put ننوشته بودم وگرنه با دستورات put و get هم امتحان کرده بودم.
    ویرایش توسط esmaeil57 : 01-16-2019 در ساعت 10:00 AM

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO