Updated to use the new plugin APIs

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 7 years ago
parent 50c92bddf7
commit 94b7d13990

@ -36,11 +36,9 @@ static struct {
bool someSettingFlag;
} testSettings;
void setup () {
Kaleidoscope.use(&EEPROMSettings);
/* Use other plugins that make use of the EEPROM */
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, /* Other plugins that use EEPROM... */);
void setup () {
Kaleidoscope.setup();
settingsBase = EEPROMSettings.requestSlice(sizeof(testSettings));

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-EEPROM-Settings -- Basic EEPROM settings plugin for Kaleidoscope.
* Copyright (C) 2017 Gergely Nagy
* Copyright (C) 2017, 2018 Gergely Nagy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-EEPROM-Settings.h>
// *INDENT-OFF*
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -37,14 +38,15 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
};
// *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings);
void setup() {
Serial.begin(9600);
Kaleidoscope.setup();
Kaleidoscope.use(&EEPROMSettings);
while (!Serial) {
}

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-EEPROM-Settings -- Basic EEPROM settings plugin for Kaleidoscope.
* Copyright (C) 2017 Gergely Nagy
* Copyright (C) 2017, 2018 Gergely Nagy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,11 +26,9 @@ bool EEPROMSettings::is_valid_;
bool EEPROMSettings::sealed_;
uint16_t EEPROMSettings::next_start_ = sizeof(EEPROMSettings::settings);
EEPROMSettings::EEPROMSettings(void) {
}
void EEPROMSettings::begin(void) {
EventHandlerResult EEPROMSettings::onSetup() {
EEPROM.get(0, settings_);
return EventHandlerResult::OK;
}
bool EEPROMSettings::isValid(void) {
@ -65,6 +63,9 @@ uint16_t EEPROMSettings::requestSlice(uint16_t size) {
if (sealed_)
return 0;
Serial.print("requestSlice; size=");
Serial.println(size);
uint16_t start = next_start_;
next_start_ += size;
@ -97,6 +98,13 @@ void EEPROMSettings::version(uint8_t ver) {
update();
}
// Legacy V1 API
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void EEPROMSettings::begin() {
::EEPROMSettings.onSetup();
}
#endif
}
kaleidoscope::EEPROMSettings EEPROMSettings;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-EEPROM-Settings -- Basic EEPROM settings plugin for Kaleidoscope.
* Copyright (C) 2017 Gergely Nagy
* Copyright (C) 2017, 2018 Gergely Nagy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,11 +22,11 @@
#include <EEPROM.h>
namespace kaleidoscope {
class EEPROMSettings : public KaleidoscopePlugin {
class EEPROMSettings : public kaleidoscope::Plugin {
public:
EEPROMSettings(void);
EEPROMSettings(void) {}
void begin(void) final;
EventHandlerResult onSetup();
static void update(void);
static bool isValid(void);
@ -39,6 +39,11 @@ class EEPROMSettings : public KaleidoscopePlugin {
static uint16_t crc(void);
static uint16_t used(void);
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
protected:
void begin();
#endif
private:
static uint16_t next_start_;
static bool is_valid_;

Loading…
Cancel
Save