Work on EEPROM-Stuff
This commit is contained in:
@@ -1,55 +1,82 @@
|
||||
#include <Arduino.h>
|
||||
#include <ESPUI.h>
|
||||
#include <EEPROM.h>
|
||||
#include "lubeapp.h"
|
||||
|
||||
uint16_t button1;
|
||||
uint16_t switchOne;
|
||||
uint16_t status;
|
||||
extern sLubeConfig LubeConfig;
|
||||
|
||||
void initWebUI();
|
||||
uint16_t tab_lube;
|
||||
uint16_t tab_wheel;
|
||||
uint16_t tab_tank;
|
||||
uint16_t num_lubedist_normal;
|
||||
uint16_t num_lubedist_rain;
|
||||
|
||||
uint16_t num_wheel_width;
|
||||
uint16_t num_wheel_ratio;
|
||||
uint16_t num_wheel_rim;
|
||||
uint16_t button_wheelcalc;
|
||||
uint16_t num_wheel_ppr;
|
||||
uint16_t num_wheel_dist;
|
||||
uint16_t button_wheel;
|
||||
|
||||
void slider( Control* sender, int type ) {
|
||||
void numberCall(Control *sender, int type)
|
||||
{
|
||||
Serial.print("Slider: ID: ");
|
||||
Serial.print(sender->id);
|
||||
Serial.print(sender->label);
|
||||
Serial.print(", Value: ");
|
||||
Serial.println( sender->value );
|
||||
}
|
||||
|
||||
|
||||
void initWebUI (void){
|
||||
|
||||
uint16_t tab_lube = ESPUI.addControl( ControlType::Tab, "Schmierung", "Schmierung" );
|
||||
uint16_t tab_tank = ESPUI.addControl( ControlType::Tab, "Tank", "Tank" );
|
||||
uint16_t tab_wifi = ESPUI.addControl( ControlType::Tab, "WiFi", "WiFi" );
|
||||
|
||||
ESPUI.addControl( ControlType::Slider, "Distanz Normal", "10000", ControlColor::Alizarin, tab_lube, &slider );
|
||||
ESPUI.addControl( ControlType::Slider, "Distanz Regen", "10000", ControlColor::Alizarin, tab_lube, &slider );
|
||||
/*
|
||||
// shown above all tabs
|
||||
status = ESPUI.addControl( ControlType::Label, "Status:", "Stop", ControlColor::Turquoise );
|
||||
|
||||
uint16_t select1 = ESPUI.addControl( ControlType::Select, "Select:", "", ControlColor::Alizarin, tab1, &selectExample );
|
||||
ESPUI.addControl( ControlType::Option, "Option1", "Opt1", ControlColor::Alizarin, select1 );
|
||||
ESPUI.addControl( ControlType::Option, "Option2", "Opt2", ControlColor::Alizarin, select1 );
|
||||
ESPUI.addControl( ControlType::Option, "Option3", "Opt3", ControlColor::Alizarin, select1 );
|
||||
|
||||
ESPUI.addControl( ControlType::Text, "Text Test:", "a Text Field", ControlColor::Alizarin, tab1, &textCall );
|
||||
|
||||
// tabbed controls
|
||||
ESPUI.addControl( ControlType::Label, "Millis:", "0", ControlColor::Emerald, tab1 );
|
||||
button1 = ESPUI.addControl( ControlType::Button, "Push Button", "Press", ControlColor::Peterriver, tab1, &buttonCallback );
|
||||
ESPUI.addControl( ControlType::Button, "Other Button", "Press", ControlColor::Wetasphalt, tab1, &buttonExample );
|
||||
ESPUI.addControl( ControlType::PadWithCenter, "Pad with center", "", ControlColor::Sunflower, tab2, &padExample );
|
||||
ESPUI.addControl( ControlType::Pad, "Pad without center", "", ControlColor::Carrot, tab3, &padExample );
|
||||
switchOne = ESPUI.addControl( ControlType::Switcher, "Switch one", "", ControlColor::Alizarin, tab3, &switchExample );
|
||||
ESPUI.addControl( ControlType::Switcher, "Switch two", "", ControlColor::None, tab3, &otherSwitchExample );
|
||||
ESPUI.addControl( ControlType::Slider, "Slider one", "30", ControlColor::Alizarin, tab1, &slider );
|
||||
ESPUI.addControl( ControlType::Slider, "Slider two", "100", ControlColor::Alizarin, tab3, &slider );
|
||||
ESPUI.addControl( ControlType::Number, "Number:", "50", ControlColor::Alizarin, tab3, &numberCall );
|
||||
*/
|
||||
|
||||
ESPUI.begin("ESPUI Control");
|
||||
Serial.println(sender->value);
|
||||
}
|
||||
|
||||
void wheelcalc(Control *sender, int type)
|
||||
{
|
||||
static uint32_t wheel_ppr = 0;
|
||||
static uint32_t wheel_dist = 0;
|
||||
|
||||
if (sender->id == num_wheel_ppr)
|
||||
wheel_ppr = sender->value.toInt();
|
||||
if (sender->id == num_wheel_dist)
|
||||
wheel_dist = sender->value.toInt();
|
||||
|
||||
if (type == B_UP && sender->id == button_wheelcalc)
|
||||
{
|
||||
LubeConfig.TireWidth_mm = ESPUI.getControl(num_wheel_width)->value.toInt();
|
||||
LubeConfig.RimDiameter_Inch = ESPUI.getControl(num_wheel_rim)->value.toInt();
|
||||
LubeConfig.TireWidthHeight_Ratio = ESPUI.getControl(num_wheel_ratio)->value.toInt();
|
||||
wheel_dist = (uint32_t)((((((float)LubeConfig.TireWidthHeight_Ratio / 100.0) * (float)LubeConfig.TireWidth_mm) * 2.0) + ((float)LubeConfig.RimDiameter_Inch * 25.4)) * 3.1416);
|
||||
ESPUI.updateControlValue(num_wheel_dist, String(wheel_dist));
|
||||
}
|
||||
if (type == B_UP && sender->id == button_wheel)
|
||||
{
|
||||
LubeConfig.DistancePerRevolution_mm = wheel_dist;
|
||||
LubeConfig.PulsePerRevolution = wheel_ppr;
|
||||
|
||||
EEPROM.begin(512);
|
||||
EEPROM.put(0, LubeConfig);
|
||||
EEPROM.commit();
|
||||
EEPROM.end();
|
||||
}
|
||||
}
|
||||
|
||||
void initWebUI(void)
|
||||
{
|
||||
|
||||
tab_lube = ESPUI.addControl(ControlType::Tab, "Schmierung", "Schmierung");
|
||||
tab_wheel = ESPUI.addControl(ControlType::Tab, "Wegesignal", "Wegesignal");
|
||||
tab_tank = ESPUI.addControl(ControlType::Tab, "Tank", "Tank");
|
||||
|
||||
num_lubedist_normal = ESPUI.addControl(ControlType::Number, "Distanz Normal (m)", String(LubeConfig.DistancePerLube_Default), ControlColor::Wetasphalt, tab_lube, &numberCall);
|
||||
num_lubedist_rain = ESPUI.addControl(ControlType::Number, "Distanz Regen (m)", String(LubeConfig.DistancePerLube_Rain), ControlColor::Wetasphalt, tab_lube, &numberCall);
|
||||
|
||||
num_wheel_width = ESPUI.addControl(ControlType::Number, "Reifenbreite (mm)", String(LubeConfig.TireWidth_mm), ControlColor::Dark, tab_wheel, &wheelcalc);
|
||||
num_wheel_ratio = ESPUI.addControl(ControlType::Number, "Höhe/Breite-Verhältniss", String(LubeConfig.TireWidthHeight_Ratio), ControlColor::Dark, tab_wheel, &wheelcalc);
|
||||
num_wheel_rim = ESPUI.addControl(ControlType::Number, "Felgendurchmesser (Zoll)", String(LubeConfig.RimDiameter_Inch), ControlColor::Dark, tab_wheel, &wheelcalc);
|
||||
button_wheelcalc = ESPUI.addControl(ControlType::Button, "Abrollumfang", "Berechnen", ControlColor::Dark, tab_wheel, &wheelcalc);
|
||||
num_wheel_dist = ESPUI.addControl(ControlType::Number, "Strecke pro Umdrehung (mm)", String(LubeConfig.DistancePerRevolution_mm), ControlColor::Wetasphalt, tab_wheel, &wheelcalc);
|
||||
num_wheel_ppr = ESPUI.addControl(ControlType::Number, "Pulse pro Umdrehung", String(LubeConfig.PulsePerRevolution), ControlColor::Wetasphalt, tab_wheel, &wheelcalc);
|
||||
button_wheel = ESPUI.addControl(ControlType::Button, "Wegesignal", "Speichern", ControlColor::Wetasphalt, tab_wheel, &wheelcalc);
|
||||
|
||||
ESPUI.addControl(ControlType::Number, "Tankinhalt maximal (ml)", String(LubeConfig.tankCapacity_ml), ControlColor::Wetasphalt, tab_tank, &numberCall);
|
||||
ESPUI.addControl(ControlType::Number, "Tankinhalt Warnung (%)", String(LubeConfig.TankRemindAtPercentage), ControlColor::Wetasphalt, tab_tank, &numberCall);
|
||||
|
||||
ESPUI.begin("Souko's ChainLube Mk1");
|
||||
}
|
||||
|
Reference in New Issue
Block a user