#pragma once
#ifdef USE_RP2

#include "esphome/core/preference_backend.h"

namespace esphome::rp2 {

class RP2Preferences final : public PreferencesMixin<RP2Preferences> {
 public:
  using PreferencesMixin<RP2Preferences>::make_preference;
  RP2Preferences();
  void setup();
  ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash) {
    return this->make_preference(length, type);
  }
  ESPPreferenceObject make_preference(size_t length, uint32_t type);
  bool sync();
  bool reset();

  uint32_t current_flash_offset = 0;

 protected:
  uint8_t *eeprom_sector_;
};

void setup_preferences();
void preferences_prevent_write(bool prevent);

}  // namespace esphome::rp2

DECLARE_PREFERENCE_ALIASES(esphome::rp2::RP2Preferences)

#endif  // USE_RP2
