Skip to content

Commit

Permalink
wip display to namespace need to fix display mock
Browse files Browse the repository at this point in the history
  • Loading branch information
orlopau committed Dec 10, 2024
1 parent 260ce44 commit addb68a
Show file tree
Hide file tree
Showing 31 changed files with 264 additions and 330 deletions.
23 changes: 23 additions & 0 deletions code/include/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include "button.h"
#include <cstdio>
#include <math.h>

namespace Display
{
void begin();
void drawOpener();
void display(float weight, unsigned long time);
void promptText(const char *prompt, const char *subtext);
void centerText(const char *text, const uint8_t size);
void modeSwitcher(const char *current, const uint8_t index, const uint8_t count, float batV, float batPercentage, bool batCharging);
void switcher(const char *title, const uint8_t index, const uint8_t count, const char *options[]);
void recipeSummary(const char *name, const char *description, const char *url);
void recipeConfigCoffeeWeight(const char *header, unsigned int weightMg, unsigned int waterWeightMl);
void recipeConfigRatio(const char *header, uint32_t coffee, uint32_t water);
void recipeInsertCoffee(int32_t weightMg, uint32_t requiredWeightMg);
void recipePour(const char *text, int32_t weightToPourMg, uint64_t timeToFinishMs, bool isPause, uint8_t pourIndex, uint8_t pours);
void espressoShot(uint32_t currentTimeMs, uint32_t timeToFinishMs, int32_t currentWeightMg, uint32_t targetWeightMg, bool waiting);
void text(const char *text);
void clear();
};
Empty file.
25 changes: 0 additions & 25 deletions code/src/display.h

This file was deleted.

20 changes: 9 additions & 11 deletions code/src/embedded/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "modes/mode_espresso.h"
#include "modes/mode_calibrate.h"
#include "modes/mode_recipe.h"
#include "u8g_display.h"
#include "display.h"
#include "update.h"
#include "interface.h"
#include "battery.h"
Expand All @@ -22,7 +22,6 @@
#define TAG "MAIN"

DefaultWeightSensor weightSensor;
U8GDisplay display(PIN_I2C_SDA, PIN_I2C_SCL, U8G2_R1);
Stopwatch stopwatch;

void saveScale(float scale)
Expand All @@ -34,12 +33,12 @@ void saveScale(float scale)
weightSensor.setScale(scale);
}

ModeScale modeDefault(weightSensor, display, stopwatch);
ModeEspresso modeEspresso(weightSensor, display, stopwatch);
ModeCalibration modeCalibration(display, stopwatch, saveScale);
ModeRecipes modeRecipes(weightSensor, display, RECIPES, RECIPE_COUNT);
ModeScale modeDefault(weightSensor, stopwatch);
ModeEspresso modeEspresso(weightSensor, stopwatch);
ModeCalibration modeCalibration(stopwatch, saveScale);
ModeRecipes modeRecipes(weightSensor, RECIPES, RECIPE_COUNT);
Mode *modes[] = {&modeDefault, &modeRecipes, &modeEspresso, &modeCalibration};
ModeManager modeManager(modes, 4, display);
ModeManager modeManager(modes, 4);

Interface::EncoderDirection encoderDirection;

Expand All @@ -63,8 +62,8 @@ void setup()
Battery::init();

//////// DISPLAY ////////
display.begin();
display.drawOpener();
Display::begin();
Display::drawOpener();

//////// WEIGHT SENSOR ////////
LoadCell::begin();
Expand Down Expand Up @@ -105,7 +104,7 @@ void setup()
//////// UPDATES ////////
if (digitalRead(PIN_UPDATE_FIRMWARE) == LOW)
{
Updater::update_firmware(display);
Updater::update_firmware();
}

ESP_LOGI(TAG, "Setup finished!");
Expand All @@ -120,7 +119,6 @@ void loop()
{
Interface::update();
weightSensor.update();
display.update();
modeManager.update();

#ifdef PERF
Expand Down
Loading

0 comments on commit addb68a

Please sign in to comment.