mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Compare commits
4 Commits
upsilon-de
...
upsilon-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8a1bc6149 | ||
|
|
b304a2ff7d | ||
|
|
50ee8021f3 | ||
|
|
ed7e0bd915 |
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -23,5 +23,7 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
**Device (please complete the following information):**
|
||||
- The device on which you're running Upsilon (computer, n0110, n0100, etc...)
|
||||
- Upsilon Version: [go to settings > about > Upsilon Version and type the version here]
|
||||
- Upsilon commit: [settings > about > click one time on epsilon version]
|
||||
|
||||
@@ -138,7 +138,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
Ion::LED::updateColorWithPlugAndCharge();
|
||||
}
|
||||
if (event == Ion::Events::USBEnumeration) {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
if (Ion::USB::isPlugged() && GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() != 3) {
|
||||
App::Snapshot * activeSnapshot = (s_activeApp == nullptr ? appSnapshotAtIndex(0) : s_activeApp->snapshot());
|
||||
/* Just after a software update, the battery timer does not have time to
|
||||
* fire before the calculator enters DFU mode. As the DFU mode blocks the
|
||||
@@ -147,7 +147,9 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
* pictogram. */
|
||||
updateBatteryState();
|
||||
if (switchTo(usbConnectedAppSnapshot())) {
|
||||
Ion::USB::DFU();
|
||||
Ion::USB::DFU(true, GlobalPreferences::sharedGlobalPreferences()->dfuStatus(), GlobalPreferences::sharedGlobalPreferences()->getDfuLevel());
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuResetStep();
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
// Update LED when exiting DFU mode
|
||||
Ion::LED::updateColorWithPlugAndCharge();
|
||||
bool switched = switchTo(activeSnapshot);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
apps += Geometry::App
|
||||
app_headers += apps/geometry/app.h
|
||||
|
||||
app_geometry_src = $(addprefix apps/geometry/,\
|
||||
app.cpp \
|
||||
list/figures_controller.cpp \
|
||||
list/definition_type_controller.cpp \
|
||||
list/figure_type_controller.cpp \
|
||||
list/figure_parameters_controller.cpp \
|
||||
list/objects_controller.cpp \
|
||||
list/message_table_cell_with_selector.cpp \
|
||||
figure_store.cpp \
|
||||
graph/graph_controller.cpp \
|
||||
graph/banner_view.cpp \
|
||||
)
|
||||
|
||||
apps_src += $(app_geometry_src)
|
||||
|
||||
app_images += apps/geometry/geometry_icon.png
|
||||
|
||||
i18n_files += $(call i18n_with_universal_for,geometry/base)
|
||||
|
||||
$(eval $(call depends_on_image,apps/geometry/app.cpp,apps/geometry/geometry_icon.png))
|
||||
@@ -1,48 +0,0 @@
|
||||
#include "app.h"
|
||||
#include "geometry_icon.h"
|
||||
#include "apps/apps_container.h"
|
||||
#include "apps/i18n.h"
|
||||
|
||||
namespace Geometry
|
||||
{
|
||||
|
||||
I18n::Message App::Descriptor::name()
|
||||
{
|
||||
return I18n::Message::GeometryApp;
|
||||
}
|
||||
|
||||
I18n::Message App::Descriptor::upperName()
|
||||
{
|
||||
return I18n::Message::GeometryAppCapital;
|
||||
}
|
||||
|
||||
const Image * App::Descriptor::icon()
|
||||
{
|
||||
return ImageStore::GeometryIcon;
|
||||
}
|
||||
|
||||
App * App::Snapshot::unpack(Container * container)
|
||||
{
|
||||
return new (container->currentAppBuffer()) App(this);
|
||||
}
|
||||
|
||||
App::Descriptor * App::Snapshot::descriptor()
|
||||
{
|
||||
static Descriptor descriptor;
|
||||
return &descriptor;
|
||||
}
|
||||
|
||||
App::App(Snapshot * snapshot) :
|
||||
TextFieldDelegateApp(snapshot, &m_tabViewController),
|
||||
m_figuresController(&m_stackViewController),
|
||||
m_stackViewController(&m_tabViewController, &m_figuresController),
|
||||
m_graphController(&m_graphAlternateEmptyViewController, this, &m_graphHeader, nullptr, nullptr, nullptr),
|
||||
m_graphAlternateEmptyViewController(&m_graphHeader, &m_graphController, &m_graphController),
|
||||
m_graphHeader(&m_graphStackViewController, &m_graphAlternateEmptyViewController, &m_graphController),
|
||||
m_graphStackViewController(&m_tabViewController, &m_graphHeader),
|
||||
m_otherViewController(&m_tabViewController),
|
||||
m_tabViewController(&m_modalViewController, snapshot, &m_stackViewController, &m_graphAlternateEmptyViewController, &m_otherViewController)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef GEOMETRY_H
|
||||
#define GEOMETRY_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "list/figures_controller.h"
|
||||
#include "graph/graph_controller.h"
|
||||
#include "other/other_view_controller.h"
|
||||
#include "../shared/text_field_delegate_app.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class App : public Shared::TextFieldDelegateApp {
|
||||
public:
|
||||
class Descriptor : public ::App::Descriptor {
|
||||
public:
|
||||
I18n::Message name() override;
|
||||
I18n::Message upperName() override;
|
||||
const Image * icon() override;
|
||||
};
|
||||
class Snapshot : public ::App::Snapshot, public TabViewDataSource {
|
||||
public:
|
||||
App * unpack(Container * container) override;
|
||||
Descriptor * descriptor() override;
|
||||
};
|
||||
private:
|
||||
App(Snapshot * snapshot);
|
||||
|
||||
FiguresController m_figuresController;
|
||||
StackViewController m_stackViewController;
|
||||
GraphController m_graphController;
|
||||
AlternateEmptyViewController m_graphAlternateEmptyViewController;
|
||||
StackViewController m_graphStackViewController;
|
||||
ButtonRowController m_graphHeader;
|
||||
OtherViewController m_otherViewController;
|
||||
TabViewController m_tabViewController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,6 +0,0 @@
|
||||
GeometryApp = "Geometry"
|
||||
GeometryAppCapital = "GEOMETRY"
|
||||
AddFigure = "Ajouter une figure"
|
||||
FigureType = "Type de figure"
|
||||
DefinitionType = "Définition de la figure"
|
||||
ParametersChoice = "Choix des paramètres"
|
||||
@@ -1,24 +0,0 @@
|
||||
FiguresTab = "Figures"
|
||||
NoFigures = "Aucune figure à afficher"
|
||||
OtherTab = "TODO"
|
||||
Coordinates = "Coordonnées"
|
||||
Middle = "Milieu"
|
||||
VectorProject = "Projeté vectoriel"
|
||||
OrthogonalProject = "Projeté orthogonal"
|
||||
CartesianEquation = "Equation cartésienne"
|
||||
LinearEquation = "Equation linéaire"
|
||||
Points = "Points"
|
||||
PointAndVector = "Point et vecteur"
|
||||
Parallele = "Parallèle"
|
||||
Perpendicular = "Perpendiculaire"
|
||||
PointAndRadius = "Point et rayon"
|
||||
Diameter = "Diamètre"
|
||||
TwoPoints = "Deux points"
|
||||
Segment = "Segment"
|
||||
Angle = "Angle"
|
||||
Area = "Surface"
|
||||
Point = "Point"
|
||||
Line = "Droite"
|
||||
Circle = "Cercle"
|
||||
Vector = "Vecteur"
|
||||
Indicator = "Indicateur"
|
||||
@@ -1 +0,0 @@
|
||||
#include "figure_store.h"
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef FIGURE__STORE__H
|
||||
#define FIGURE__STORE__H
|
||||
|
||||
#include "../shared/expression_model_store.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class FigureStore: Shared::ExpressionModelStore {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef POINCARE_FIGURE_H
|
||||
#define POINCARE_FIGURE_H
|
||||
|
||||
#include "figure_type.h"
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class FigureNode : public TreeNode {
|
||||
public:
|
||||
virtual size_t size() const override = 0;
|
||||
|
||||
virtual int numberOfChildren() const override { return 0; }
|
||||
|
||||
virtual FigureType type() const = 0;
|
||||
virtual FigureDefinitionType definitionType() const = 0;
|
||||
};
|
||||
|
||||
class Figure : public TreeHandle {
|
||||
public:
|
||||
Figure(const FigureNode * node) : TreeHandle(node) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef GEOMETRY_FIGURE_TYPE_H
|
||||
#define GEOMETRY_FIGURE_TYPE_H
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
enum class FigureType {
|
||||
None = 0, // Used to trigger assert in debug mode
|
||||
Expression, // It's not a real figure type but we use it to build figures like points
|
||||
|
||||
Point,
|
||||
|
||||
Line,
|
||||
Circle,
|
||||
Vector,
|
||||
Indicator
|
||||
};
|
||||
|
||||
enum class FigureDefinitionType {
|
||||
PointByCoordinates
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef FIGURES_H
|
||||
#define FIGURES_H
|
||||
|
||||
#include "point_by_coordinates.h"
|
||||
|
||||
#endif
|
||||
@@ -1 +0,0 @@
|
||||
#include "point.h"
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef GEOMETRY_POINT_H
|
||||
#define GEOMETRY_POINT_H
|
||||
|
||||
#include "figure.h"
|
||||
namespace Geometry {
|
||||
|
||||
class PointNode : public FigureNode {
|
||||
virtual FigureType type() const override { return FigureType::Point; }
|
||||
};
|
||||
|
||||
class Point : public Figure {
|
||||
public:
|
||||
Point(const PointNode * n) : Figure(n) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef POINT_BY_COORDINATES_H
|
||||
#define POINT_BY_COORDINATES_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include "point.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class PointByCoordinatesNode : public PointNode {
|
||||
public:
|
||||
virtual size_t size() const override { return sizeof(PointByCoordinatesNode); }
|
||||
virtual int numberOfChildren() const override { return 2; }
|
||||
virtual FigureDefinitionType definitionType() const override { return FigureDefinitionType::PointByCoordinates; }
|
||||
#if POINCARE_TREE_LOG
|
||||
void logNodeName(std::ostream & stream) const override {
|
||||
stream << "PointByCoordinates";
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class PointByCoordinates : public Figure {
|
||||
public:
|
||||
PointByCoordinates(const PointByCoordinatesNode * n) : Figure(n) {}
|
||||
static PointByCoordinates Builder(Expression x, Expression y) { return TreeHandle::FixedArityBuilder<PointByCoordinates, PointByCoordinatesNode>({x, x}); }
|
||||
static int numberOfParameters() { return 2; }
|
||||
static FigureType parameterTypeAtIndex(int i) { return FigureType::Expression; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -1,15 +0,0 @@
|
||||
#include "banner_view.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
BannerView::BannerView(
|
||||
Responder * parentResponder,
|
||||
InputEventHandlerDelegate * inputEventHandlerDelegate,
|
||||
TextFieldDelegate * textFieldDelegate
|
||||
) :
|
||||
Shared::XYBannerView(parentResponder, inputEventHandlerDelegate, textFieldDelegate)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef GEOMETRY_BANNER_VIEW_H
|
||||
#define GEOMETRY_BANNER_VIEW_H
|
||||
|
||||
#include "../../shared/xy_banner_view.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class BannerView : public Shared::XYBannerView {
|
||||
public:
|
||||
BannerView(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, TextFieldDelegate * textFieldDelegate);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "graph_controller.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
GraphController::GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Shared::InteractiveCurveViewRange/*TODO -> Store*/ * store, Shared::CurveViewCursor * cursor, uint32_t * rangeVersion) :
|
||||
InteractiveCurveViewController(parentResponder, inputEventHandlerDelegate, header, store, nullptr, cursor, rangeVersion)
|
||||
{
|
||||
/* WHEREIWAS: Now i must make the app launch again without crash, by replacing the multiples nullptr that I used... */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef GRAPH_VIEW_CONTROLLER_H
|
||||
#define GRAPH_VIEW_CONTROLLER_H
|
||||
|
||||
#include "../shared/interactive_curve_view_controller.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class GraphController : public Shared::InteractiveCurveViewController {
|
||||
public:
|
||||
GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Shared::InteractiveCurveViewRange * store, Shared::CurveViewCursor * cursor, uint32_t * rangeVersion);
|
||||
|
||||
virtual Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return nullptr; } //TOIMPLEMENT
|
||||
virtual Shared::CurveView * curveView() override { return nullptr; } //TOIMPLEMENT
|
||||
virtual void reloadBannerView() override { } //TOIMPLEMENT
|
||||
virtual bool handleEnter() override { return false; } //TOIMPLEMENT
|
||||
virtual void initCursorParameters() override { } //TOIMPLEMENT
|
||||
virtual bool moveCursorVertically(int direction) override { return false; } //TOIMPLEMENT
|
||||
virtual uint32_t rangeVersion() override { return 0; } //TOIMPLEMENT
|
||||
virtual bool cursorMatchesModel() override { return false; } //TOIMPLEMENT
|
||||
virtual Poincare::Coordinate2D<double> xyValues(int curveIndex, double t, Poincare::Context * context) const override { return Poincare::Coordinate2D<double>(0, 0); } //TOIMPLEMENT
|
||||
virtual bool closestCurveIndexIsSuitable(int newIndex, int currentIndex) const override { return false; }
|
||||
virtual int selectedCurveIndex() const override { return 0; }
|
||||
virtual int numberOfCurves() const override { return 0; }
|
||||
|
||||
/* AlternateEmptyViewDefaultDelegate */
|
||||
virtual bool isEmpty() const override { return false; }
|
||||
virtual I18n::Message emptyMessage() override { return I18n::Message::NoFigures; }
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,147 +0,0 @@
|
||||
#include "figure_type_controller.h"
|
||||
#include "../figures/figures.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
static constexpr I18n::Message sPointDefinitionsMessages[] = {
|
||||
I18n::Message::Coordinates,
|
||||
I18n::Message::Middle,
|
||||
I18n::Message::VectorProject,
|
||||
I18n::Message::OrthogonalProject
|
||||
};
|
||||
static const uint8_t sPointDefinitionsMessagesCount = sizeof(sPointDefinitionsMessages) / sizeof(I18n::Message);
|
||||
|
||||
|
||||
static constexpr I18n::Message sLineDefinitionMessages[] = {
|
||||
I18n::Message::CartesianEquation,
|
||||
I18n::Message::LinearEquation,
|
||||
I18n::Message::Points,
|
||||
I18n::Message::PointAndVector,
|
||||
I18n::Message::Parallele,
|
||||
I18n::Message::Perpendicular
|
||||
};
|
||||
static const uint8_t sLineDefinitionsMessagesCount = sizeof(sLineDefinitionMessages) / sizeof(I18n::Message);
|
||||
|
||||
|
||||
static constexpr I18n::Message sCircleDefinitionsMessages[] = {
|
||||
I18n::Message::PointAndRadius,
|
||||
I18n::Message::Diameter,
|
||||
I18n::Message::CartesianEquation,
|
||||
};
|
||||
static const uint8_t sCircleDefinitionsMessagesCount = sizeof(sCircleDefinitionsMessages) / sizeof(I18n::Message);
|
||||
|
||||
|
||||
static constexpr I18n::Message sVectorDefinitionsMessages[] = {
|
||||
I18n::Message::Coordinates,
|
||||
I18n::Message::TwoPoints
|
||||
};
|
||||
static const uint8_t sVectorDefinitionsMessagesCount = sizeof(sVectorDefinitionsMessages) / sizeof(I18n::Message);
|
||||
|
||||
|
||||
static constexpr I18n::Message sIndicatorDefinitionsMessages[] = {
|
||||
I18n::Message::Segment,
|
||||
I18n::Message::Angle,
|
||||
I18n::Message::Area,
|
||||
};
|
||||
static const uint8_t sIndicatorDefinitionsMessagesCount = sizeof(sIndicatorDefinitionsMessages) / sizeof(I18n::Message);
|
||||
|
||||
|
||||
DefinitionTypeController::DefinitionTypeController(Responder * parentResponder, FigureParametersController * parametersController):
|
||||
ViewController(parentResponder),
|
||||
m_lastSelectedRow(0),
|
||||
m_selectableTableView(this),
|
||||
m_messages(nullptr),
|
||||
m_figureType(FigureType::None),
|
||||
m_parametersController(parametersController)
|
||||
{
|
||||
for (int i = 0; i < k_numberOfCells; i ++) {
|
||||
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||
}
|
||||
}
|
||||
|
||||
void DefinitionTypeController::viewWillAppear() {
|
||||
assert(m_figureType != FigureType::None && m_messages != nullptr);
|
||||
selectRow(m_lastSelectedRow);
|
||||
m_selectableTableView.reloadData(); // We reload the cell of the table view to update their message
|
||||
}
|
||||
|
||||
void DefinitionTypeController::didBecomeFirstResponder() {
|
||||
//App::app()->snapshot()->setActivePage(App::Snapshot::Page::Distribution);
|
||||
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
bool DefinitionTypeController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
m_lastSelectedRow = selectedRow();
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
m_parametersController->setParametersInfoFunctions(PointByCoordinates::numberOfParameters, PointByCoordinates::parameterTypeAtIndex);
|
||||
stack->push(m_parametersController);
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Back) {
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
stack->pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HighlightCell * DefinitionTypeController::reusableCell(int index) {
|
||||
assert(index >= 0);
|
||||
assert(index < k_numberOfCells);
|
||||
return &m_cells[index];
|
||||
}
|
||||
|
||||
void DefinitionTypeController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
MessageTableCellWithChevron * myCell = (MessageTableCellWithChevron *)cell;
|
||||
myCell->setMessage(m_messages[index]);
|
||||
}
|
||||
|
||||
int DefinitionTypeController::numberOfRows() const {
|
||||
switch (m_figureType) {
|
||||
case FigureType::Point:
|
||||
return sPointDefinitionsMessagesCount;
|
||||
break;
|
||||
case FigureType::Line:
|
||||
return sLineDefinitionsMessagesCount;
|
||||
break;
|
||||
case FigureType::Circle:
|
||||
return sCircleDefinitionsMessagesCount;
|
||||
break;
|
||||
case FigureType::Vector:
|
||||
return sVectorDefinitionsMessagesCount;
|
||||
break;
|
||||
case FigureType::Indicator:
|
||||
return sIndicatorDefinitionsMessagesCount;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DefinitionTypeController::setFigureType(FigureType figureType) {
|
||||
m_figureType = figureType;
|
||||
switch (m_figureType) {
|
||||
case FigureType::Point:
|
||||
m_messages = sPointDefinitionsMessages;
|
||||
break;
|
||||
case FigureType::Line:
|
||||
m_messages = sLineDefinitionMessages;
|
||||
break;
|
||||
case FigureType::Circle:
|
||||
m_messages = sCircleDefinitionsMessages;
|
||||
break;
|
||||
case FigureType::Vector:
|
||||
m_messages = sVectorDefinitionsMessages;
|
||||
break;
|
||||
case FigureType::Indicator:
|
||||
m_messages = sIndicatorDefinitionsMessages;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#ifndef GEOMETRY_DEFINITION_TYPE_CONTROLLER_H
|
||||
#define GEOMETRY_DEFINITION_TYPE_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "apps/i18n.h"
|
||||
#include "../figures/figure_type.h"
|
||||
#include "figure_parameters_controller.h"
|
||||
|
||||
namespace Geometry {
|
||||
/**
|
||||
* \brief DefinitionTypeController is a controller to choose how the figure is defined
|
||||
*/
|
||||
class DefinitionTypeController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||
public:
|
||||
DefinitionTypeController(Responder * parentResponder, FigureParametersController * parametersController);
|
||||
|
||||
/* ViewController */
|
||||
View * view() override { return &m_selectableTableView; }
|
||||
// We want to avoid using half of the screen just for titles
|
||||
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||
const char * title() override { return I18n::translate(I18n::Message::DefinitionType); }
|
||||
|
||||
/* Responder */
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
|
||||
/* ViewController */
|
||||
void didBecomeFirstResponder() override;
|
||||
void viewWillAppear() override;
|
||||
TELEMETRY_ID("FigureType");
|
||||
|
||||
/* SelectableTableViewDataSource */
|
||||
int numberOfRows() const override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
KDCoordinate cellHeight() override { return k_cellHeight; }
|
||||
HighlightCell * reusableCell(int index) override;
|
||||
int reusableCellCount() const override { return k_numberOfCells; }
|
||||
|
||||
/* Customs methods */
|
||||
void setFigureType(FigureType type);
|
||||
private:
|
||||
constexpr static KDCoordinate k_cellHeight = Metric::ParameterCellHeight;
|
||||
constexpr static int k_numberOfCells = 6;
|
||||
int m_lastSelectedRow;
|
||||
MessageTableCellWithChevron m_cells[k_numberOfCells];
|
||||
SelectableTableView m_selectableTableView;
|
||||
const I18n::Message * m_messages;
|
||||
FigureType m_figureType;
|
||||
FigureParametersController * m_parametersController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
#include "figure_parameters_controller.h"
|
||||
#include "../app.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
FigureParametersController::FigureParametersController(Responder * parentResponder):
|
||||
ViewController(parentResponder),
|
||||
m_lastSelectedRow(0),
|
||||
m_selectableTableView(this),
|
||||
m_okButton(&m_selectableTableView, I18n::Message::Ok, Invocation([](void * context, void * sender) {
|
||||
FigureParametersController * parameterController = (FigureParametersController *) context;
|
||||
parameterController->returnToMenu();
|
||||
return true;
|
||||
}, this))
|
||||
{
|
||||
for (int i = 0; i < k_choiceCells; i++) {
|
||||
m_choicesCells[i].setParentResponder(&m_selectableTableView);
|
||||
}
|
||||
for (int i = 0; i < k_textCells; i++) {
|
||||
m_textCells[i].setParentResponder(&m_selectableTableView);
|
||||
m_textCells[i].textField()->setDelegates(this, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FigureParametersController::setParametersInfoFunctions(NumberOfParametersFunction numberOfParametersFunction, TypeOfParametersAtIndexFunction typeOfParametersAtIndexFunction) {
|
||||
m_numberOfParametersFunction = numberOfParametersFunction;
|
||||
m_typeOfParametersAtIndexFunction = typeOfParametersAtIndexFunction;
|
||||
}
|
||||
|
||||
void FigureParametersController::didBecomeFirstResponder() {
|
||||
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
void FigureParametersController::viewWillAppear() {
|
||||
selectRow(m_lastSelectedRow);
|
||||
}
|
||||
|
||||
void FigureParametersController::returnToMenu() {
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
stack->pop();
|
||||
stack->pop();
|
||||
stack->pop();
|
||||
}
|
||||
|
||||
/* ListViewDataSource */
|
||||
int FigureParametersController::typeAtLocation(int i, int j) {
|
||||
if (j == m_numberOfParametersFunction()) {
|
||||
return 0; // It's equivalent to "None", so we can use it for button cell
|
||||
}
|
||||
return (int) m_typeOfParametersAtIndexFunction(j);
|
||||
}
|
||||
|
||||
int FigureParametersController::reusableCellCount(int type) {
|
||||
if (type == 0) {
|
||||
return 1;
|
||||
}
|
||||
return type == (int) FigureType::Expression ? k_textCells: k_choiceCells;
|
||||
}
|
||||
|
||||
HighlightCell * FigureParametersController::reusableCell(int index, int type) {
|
||||
if (type == 0) {
|
||||
return &m_okButton;
|
||||
}
|
||||
if (type == (int) FigureType::Expression) {
|
||||
return &m_textCells[index];
|
||||
}
|
||||
return &m_choicesCells[index];
|
||||
}
|
||||
|
||||
int FigureParametersController::numberOfRows() const {
|
||||
return m_numberOfParametersFunction() + 1;
|
||||
}
|
||||
KDCoordinate FigureParametersController::rowHeight(int j) {
|
||||
if (j == numberOfRows()-1) {
|
||||
return Metric::ParameterCellHeight+k_buttonMargin;
|
||||
}
|
||||
return Metric::ParameterCellHeight;
|
||||
}
|
||||
|
||||
KDCoordinate FigureParametersController::cumulatedHeightFromIndex(int j) {
|
||||
if (j == numberOfRows()) {
|
||||
return j*Metric::ParameterCellHeight+k_buttonMargin;
|
||||
}
|
||||
return Metric::ParameterCellHeight*j;
|
||||
}
|
||||
|
||||
int FigureParametersController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
return (offsetY - 1) / Metric::ParameterCellHeight;
|
||||
}
|
||||
|
||||
void FigureParametersController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
|
||||
}
|
||||
|
||||
bool FigureParametersController::textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) {
|
||||
return (event == Ion::Events::Down && selectedRow() < numberOfRows()-1)
|
||||
|| (event == Ion::Events::Up && selectedRow() > 0)
|
||||
|| TextFieldDelegate::textFieldShouldFinishEditing(textField, event);
|
||||
}
|
||||
|
||||
bool FigureParametersController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
|
||||
m_selectableTableView.reloadCellAtLocation(0, selectedRow());
|
||||
m_selectableTableView.reloadData();
|
||||
textField->setText(text);
|
||||
if (event == Ion::Events::EXE || event == Ion::Events::OK) {
|
||||
m_selectableTableView.selectCellAtLocation(selectedColumn(), selectedRow() + 1);
|
||||
} else {
|
||||
m_selectableTableView.handleEvent(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#ifndef GEOMETRY_FIGURE_PARAMETERS_CONTROLLER_H
|
||||
#define GEOMETRY_FIGURE_PARAMETERS_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "apps/i18n.h"
|
||||
#include "message_table_cell_with_selector.h"
|
||||
#include "../figures/figure.h"
|
||||
#include "../../shared/parameter_text_field_delegate.h"
|
||||
#include "../../shared/input_event_handler_delegate.h"
|
||||
#include "../../shared/button_with_separator.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
typedef int (*NumberOfParametersFunction)();
|
||||
typedef FigureType (*TypeOfParametersAtIndexFunction)(int);
|
||||
|
||||
/**
|
||||
* \brief Controller returning the parameter choosen by the user to define the figure
|
||||
*/
|
||||
class FigureParametersController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource, public Shared::ParameterTextFieldDelegate, public Shared::InputEventHandlerDelegate {
|
||||
public:
|
||||
FigureParametersController(Responder * parentResponder);
|
||||
void setParametersInfoFunctions(NumberOfParametersFunction numberOfParametersFunction, TypeOfParametersAtIndexFunction typeOfParametersAtIndexFunction);
|
||||
void returnToMenu();
|
||||
/* ViewController */
|
||||
const char * title() override { return I18n::translate(I18n::Message::ParametersChoice); }
|
||||
// We want to avoid using half of the screen just for titles
|
||||
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||
View * view() override { return &m_selectableTableView; };
|
||||
|
||||
/* Responder */
|
||||
void didBecomeFirstResponder() override;
|
||||
void viewWillAppear() override;
|
||||
|
||||
/* ListViewDataSource */
|
||||
int typeAtLocation(int i, int j) override;
|
||||
int reusableCellCount(int type) override; // TO IMPLEMENT
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int numberOfRows() const override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
|
||||
/* InputEventHandlerDelegate */
|
||||
bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
|
||||
bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
|
||||
|
||||
private:
|
||||
SelectableTableView m_selectableTableView;
|
||||
constexpr static int k_textCells = 2;
|
||||
constexpr static int k_choiceCells = 3;
|
||||
constexpr static int k_buttonMargin = 6;
|
||||
int m_lastSelectedRow;
|
||||
MessageTableCellWithEditableText m_textCells[k_textCells];
|
||||
MessageTableCellWithSelector m_choicesCells[k_choiceCells];
|
||||
ButtonWithSeparator m_okButton;
|
||||
NumberOfParametersFunction m_numberOfParametersFunction;
|
||||
TypeOfParametersAtIndexFunction m_typeOfParametersAtIndexFunction;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
#include "figure_type_controller.h"
|
||||
#include "apps/i18n.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
static FigureType sTypes[] = {
|
||||
FigureType::Point,
|
||||
FigureType::Line,
|
||||
FigureType::Circle,
|
||||
FigureType::Vector,
|
||||
FigureType::Indicator
|
||||
};
|
||||
|
||||
static I18n::Message sMessages[] = {
|
||||
I18n::Message::Point,
|
||||
I18n::Message::Line,
|
||||
I18n::Message::Circle,
|
||||
I18n::Message::Vector,
|
||||
I18n::Message::Indicator
|
||||
};
|
||||
|
||||
FigureTypeController::FigureTypeController(Responder * parentResponder, DefinitionTypeController * definitionTypeController) :
|
||||
ViewController(parentResponder),
|
||||
m_lastSelectedRow(0),
|
||||
m_selectableTableView(this),
|
||||
m_definitionTypeController(definitionTypeController),
|
||||
m_messages(sMessages)
|
||||
{
|
||||
for (int i = 0; i < k_numberOfCells; i ++) {
|
||||
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||
}
|
||||
}
|
||||
|
||||
void FigureTypeController::viewWillAppear() {
|
||||
selectRow(m_lastSelectedRow);
|
||||
}
|
||||
|
||||
void FigureTypeController::didBecomeFirstResponder() {
|
||||
//App::app()->snapshot()->setActivePage(App::Snapshot::Page::Distribution);
|
||||
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
bool FigureTypeController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
m_lastSelectedRow = selectedRow();
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
m_definitionTypeController->setFigureType(sTypes[selectedRow()]);
|
||||
stack->push(m_definitionTypeController);
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Back ) {
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
stack->pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HighlightCell * FigureTypeController::reusableCell(int index) {
|
||||
assert(index >= 0);
|
||||
assert(index < k_numberOfCells);
|
||||
return &m_cells[index];
|
||||
}
|
||||
|
||||
void FigureTypeController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
MessageTableCellWithChevron * myCell = (MessageTableCellWithChevron *)cell;
|
||||
myCell->setMessage(m_messages[index]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef GEOMETRY_FIGURE_TYPE_CONTROLLER_H
|
||||
#define GEOMETRY_FIGURE_TYPE_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "definition_type_controller.h"
|
||||
|
||||
namespace Geometry {
|
||||
/**
|
||||
* \brief FigureTypeController is a controller that is used to select the type of
|
||||
* figure to be created.
|
||||
*/
|
||||
class FigureTypeController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||
public:
|
||||
FigureTypeController(Responder * parentResponder, DefinitionTypeController * definitionController);
|
||||
|
||||
/* ViewController */
|
||||
View * view() override { return &m_selectableTableView; }
|
||||
// We want to avoid using half of the screen just for titles
|
||||
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||
const char * title() override { return I18n::translate(I18n::Message::FigureType); }
|
||||
|
||||
/* Responder */
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void didBecomeFirstResponder() override;
|
||||
|
||||
/* ViewController */
|
||||
void viewWillAppear() override;
|
||||
TELEMETRY_ID("FigureType");
|
||||
|
||||
/* TableViewDataSource */
|
||||
int numberOfRows() const override { return k_numberOfRows; }
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
KDCoordinate cellHeight() override { return k_cellHeight; }
|
||||
HighlightCell * reusableCell(int index) override;
|
||||
int reusableCellCount() const override { return k_numberOfCells; }
|
||||
private:
|
||||
constexpr static KDCoordinate k_cellHeight = Metric::ParameterCellHeight;
|
||||
constexpr static int k_numberOfCells = 5;
|
||||
constexpr static int k_numberOfRows = 5;
|
||||
int m_lastSelectedRow;
|
||||
MessageTableCellWithChevron m_cells[k_numberOfCells];
|
||||
SelectableTableView m_selectableTableView;
|
||||
DefinitionTypeController * m_definitionTypeController;
|
||||
I18n::Message * m_messages;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
#include "figures_controller.h"
|
||||
#include "definition_type_controller.h"
|
||||
#include <apps/i18n.h>
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
FiguresController::FiguresController(Responder * parentResponder):
|
||||
ViewController(parentResponder),
|
||||
m_selectableTableView(this, this, this, this),
|
||||
m_addFigureCell(),
|
||||
m_emptyCell(),
|
||||
m_figureTypeController(this, &m_definitionTypeController),
|
||||
m_definitionTypeController(&m_figureTypeController, &m_parametersController),
|
||||
m_parametersController(&m_definitionTypeController)
|
||||
{
|
||||
m_addFigureCell.setMessage(I18n::Message::AddFigure);
|
||||
}
|
||||
|
||||
bool FiguresController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
if (isAddFigureRow(selectedRow())) {
|
||||
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||
stack->push(&m_figureTypeController);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (event == Ion::Events::Up && selectedRow() == 0) {
|
||||
m_selectableTableView.deselectTable();
|
||||
assert(selectedRow() == -1);
|
||||
Container::activeApp()->setFirstResponder(parentResponder()->parentResponder());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FiguresController::didBecomeFirstResponder() {
|
||||
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
|
||||
HighlightCell * FiguresController::reusableCell(int index, int type) {
|
||||
assert(index >= 0);
|
||||
if (type == 2) {
|
||||
return &m_emptyCell;
|
||||
}
|
||||
return &m_addFigureCell;
|
||||
}
|
||||
|
||||
void FiguresController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||
if (i == 0) {
|
||||
return;
|
||||
}
|
||||
EvenOddCell * myCell = (EvenOddCell *)cell;
|
||||
myCell->setEven(j%2 == 0);
|
||||
myCell->setHighlighted(i == selectedColumn() && j == selectedRow());
|
||||
myCell->reloadCell();
|
||||
}
|
||||
|
||||
bool FiguresController::isAddFigureRow(int j) {
|
||||
return j == 0;
|
||||
}
|
||||
|
||||
int FiguresController::reusableCellCount(int type) {
|
||||
if (type > 1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FiguresController::typeAtLocation(int i, int j) {
|
||||
if (isAddFigureRow(j)) {
|
||||
return i + 2;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#ifndef FIGURES_CONTROLLER_H
|
||||
#define FIGURES_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "figure_type_controller.h"
|
||||
|
||||
namespace Geometry
|
||||
{
|
||||
/**
|
||||
* \brief FiguresController is a controller to show the list of the figures
|
||||
*/
|
||||
class FiguresController : public ViewController, public SelectableTableViewDataSource, public SelectableTableViewDelegate, public TableViewDataSource {
|
||||
public:
|
||||
FiguresController(Responder * parentResponder);
|
||||
|
||||
/* ViewController */
|
||||
View * view() override { return &m_selectableTableView; }
|
||||
const char * title() override { return I18n::translate(I18n::Message::FiguresTab); }
|
||||
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||
/* Responder */
|
||||
bool handleEvent(Ion::Events::Event event) override; // TO IMPLEMENT
|
||||
void didBecomeFirstResponder() override;
|
||||
|
||||
/* TableView */
|
||||
int numberOfRows() const override { return 1; } // TO IMPLEMENT
|
||||
int numberOfColumns() const override { return 2; } // TO IMPLEMENT
|
||||
KDCoordinate columnWidth(int i) { return i == 0 ? 50 : 150; } // TO IMPLEMENT
|
||||
KDCoordinate rowHeight(int j) { return 50; } // TO IMPLEMENT
|
||||
HighlightCell * reusableCell(int index, int type); // TO IMPLEMENT
|
||||
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; // TO IMPLEMENT
|
||||
int reusableCellCount(int type);
|
||||
int typeAtLocation(int i, int j); // TO IMPLEMENT
|
||||
|
||||
private:
|
||||
/* Customs methods */
|
||||
bool isAddFigureRow(int j); // TO IMPLEMENT
|
||||
|
||||
SelectableTableView m_selectableTableView;
|
||||
EvenOddMessageTextCell m_addFigureCell;
|
||||
EvenOddCell m_emptyCell;
|
||||
FigureTypeController m_figureTypeController;
|
||||
DefinitionTypeController m_definitionTypeController;
|
||||
FigureParametersController m_parametersController;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "message_table_cell_with_selector.h"
|
||||
#include <escher/container.h>
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
MessageTableCellWithSelector::MessageTableCellWithSelector(ToolboxMessageTree * root, const KDFont * font) :
|
||||
Responder(nullptr),
|
||||
MessageTableCell((I18n::Message)0, font),
|
||||
m_objectsRoot(root),
|
||||
m_selectedMessage(nullptr),
|
||||
m_toolbox(this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool MessageTableCellWithSelector::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
Container::activeApp()->displayModalViewController(&m_toolbox, 0.f, 0.f, Metric::PopUpTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef ESHER_MESSAGE_TABLE_CELL_WITH_OBJECT_SELECTOR_H_
|
||||
#define ESHER_MESSAGE_TABLE_CELL_WITH_OBJECT_SELECTOR_H_
|
||||
|
||||
#include <escher/message_table_cell_with_buffer.h>
|
||||
#include <escher/toolbox_message_tree.h>
|
||||
#include "objects_controller.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class MessageTableCellWithSelector : public Responder, public MessageTableCell {
|
||||
public:
|
||||
MessageTableCellWithSelector(ToolboxMessageTree * root = nullptr, const KDFont * font = KDFont::SmallFont);
|
||||
ToolboxMessageTree * getSelectedMessage() const { return m_selectedMessage; };
|
||||
bool handleEvent(Ion::Events::Event event);
|
||||
Responder * responder() override {
|
||||
return this;
|
||||
}
|
||||
private:
|
||||
ToolboxMessageTree * m_objectsRoot;
|
||||
ToolboxMessageTree * m_selectedMessage;
|
||||
ObjectsController m_toolbox;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
#include "objects_controller.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
ObjectsController::ObjectsController(Responder * responder) :
|
||||
NestedMenuController(this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ObjectsController::numberOfRows() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ObjectsController::reusableCellCount(int type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ObjectsController::typeAtLocation(int i, int j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ObjectsController::selectLeaf(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HighlightCell * ObjectsController::leafCellAtIndex(int index) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HighlightCell * ObjectsController::nodeCellAtIndex(int index) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef GEOMETRY_OBJECTS_CONTROLLER_H
|
||||
#define GEOMETRY_OBJECTS_CONTROLLER_H
|
||||
|
||||
#include <escher/nested_menu_controller.h>
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class ObjectsController : public NestedMenuController {
|
||||
public:
|
||||
ObjectsController(Responder * parentResponder);
|
||||
virtual int numberOfRows() const override;
|
||||
virtual int reusableCellCount(int type) override;
|
||||
virtual int typeAtLocation(int i, int j) override;
|
||||
virtual bool selectLeaf(int selectedRow) override;
|
||||
virtual HighlightCell * leafCellAtIndex(int index) override;
|
||||
virtual HighlightCell * nodeCellAtIndex(int index) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef OTHER_VIEW_CONTROLLER_H
|
||||
#define OTHER_VIEW_CONTROLLER_H
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class OtherViewController : public ViewController {
|
||||
public:
|
||||
OtherViewController(Responder * parentResponder):
|
||||
ViewController(parentResponder) {}
|
||||
View * view() override { return nullptr; }
|
||||
const char * title() override { return I18n::translate(I18n::Message::OtherTab); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -30,6 +30,15 @@ public:
|
||||
void setTempExamMode(ExamMode examMode);
|
||||
bool showPopUp() const { return m_showPopUp; }
|
||||
void setShowPopUp(bool showPopUp) { m_showPopUp = showPopUp; }
|
||||
bool dfuStatus() const { return m_dfuUnlocked; }
|
||||
void setDfuStatus(bool status) { m_dfuUnlocked=status; }
|
||||
int dfuCurrentStep() const { return m_dfuStep; }
|
||||
void dfuIncreaseStep() { m_dfuStep++; }
|
||||
void dfuResetStep() { m_dfuStep = 0; }
|
||||
int getDfuLevel() const { return m_dfuProtectLevel; }
|
||||
void setDfuLevel(int level) { m_dfuProtectLevel = level; }
|
||||
bool showDfuDeacAlert() const { return m_showDeacAlert; }
|
||||
void setDfuDeacAlert(bool value) { m_showDeacAlert = value; }
|
||||
bool autocomplete() const { return m_autoComplete; }
|
||||
void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; }
|
||||
int brightnessLevel() const { return m_brightnessLevel; }
|
||||
@@ -37,6 +46,7 @@ public:
|
||||
const KDFont * font() const { return m_font; }
|
||||
void setFont(const KDFont * font) { m_font = font; }
|
||||
constexpr static int NumberOfBrightnessStates = 15;
|
||||
constexpr static int DfuUnlockStep = 3;
|
||||
private:
|
||||
static_assert(I18n::NumberOfLanguages > 0, "I18n::NumberOfLanguages is not superior to 0"); // There should already have been an error when processing an empty EPSILON_I18N flag
|
||||
static_assert(I18n::NumberOfCountries > 0, "I18n::NumberOfCountries is not superior to 0"); // There should already have been an error when processing an empty EPSILON_COUNTRIES flag
|
||||
@@ -46,6 +56,10 @@ private:
|
||||
m_examMode(ExamMode::Unknown),
|
||||
m_tempExamMode(ExamMode::Standard),
|
||||
m_showPopUp(true),
|
||||
m_dfuUnlocked(false),
|
||||
m_dfuStep(0),
|
||||
m_dfuProtectLevel(0),
|
||||
m_showDeacAlert(true),
|
||||
m_autoComplete(true),
|
||||
m_brightnessLevel(Ion::Backlight::MaxBrightness),
|
||||
m_font(KDFont::LargeFont) {}
|
||||
@@ -56,6 +70,10 @@ private:
|
||||
mutable ExamMode m_examMode;
|
||||
mutable ExamMode m_tempExamMode;
|
||||
bool m_showPopUp;
|
||||
bool m_dfuUnlocked;
|
||||
int m_dfuStep;
|
||||
int m_dfuProtectLevel; // 0: default; 1: OmegaMode; 2: Paranoid; 3: Paranoid++
|
||||
bool m_showDeacAlert;
|
||||
bool m_autoComplete;
|
||||
int m_brightnessLevel;
|
||||
const KDFont * m_font;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Default,geometry,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
||||
HidePython,geometry,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
||||
Default,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
||||
HidePython,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
||||
|
||||
|
@@ -2,3 +2,5 @@ Apps = "Anwendungen"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Diese Anwendung ist im"
|
||||
ForbidenAppInExamMode2 = "Prüfungsmodus nicht erlaubt."
|
||||
DfuWarning1 = "DFU-Schutzwarnung"
|
||||
DfuWarning2 = "Mehr Informationen: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applications"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "This application is"
|
||||
ForbidenAppInExamMode2 = "forbidden in exam mode"
|
||||
DfuWarning1 = "DFU Protection Warning"
|
||||
DfuWarning2 = "More informations: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Aplicaciones"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Esta aplicación está prohibida"
|
||||
ForbidenAppInExamMode2 = "en el modo de examen"
|
||||
DfuWarning1 = "Advertencia de protección DFU"
|
||||
DfuWarning2 = "Más información: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applications"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Cette application n'est"
|
||||
ForbidenAppInExamMode2 = "pas autorisée en mode examen."
|
||||
DfuWarning1 = "Alerte protection DFU"
|
||||
DfuWarning2 = "Plus d'infos: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Alkalmazások"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Ez az alkalmazás"
|
||||
ForbidenAppInExamMode2 = "tilos vizsga módban"
|
||||
DfuWarning1 = "DFU védelmi figyelmeztetés"
|
||||
DfuWarning2 = "További információk: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applicazioni"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Questa applicazione è"
|
||||
ForbidenAppInExamMode2 = "proibita nella modalità d'esame"
|
||||
DfuWarning1 = "Avviso protezione DFU"
|
||||
DfuWarning2 = "Più informazioni: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applicaties"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Deze applicatie is"
|
||||
ForbidenAppInExamMode2 = "uitgesloten in examenstand"
|
||||
DfuWarning1 = "DFU-beveiligingswaarschuwing"
|
||||
DfuWarning2 = "Meer informatie: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Aplicações"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Esta aplicação é"
|
||||
ForbidenAppInExamMode2 = "proibida no Modo de Exame"
|
||||
DfuWarning1 = "Aviso de proteção DFU"
|
||||
DfuWarning2 = "Mais informações: bit.ly/upsiDfu"
|
||||
|
||||
@@ -87,9 +87,33 @@ Controller::Controller(Responder * parentResponder, SelectableTableViewDataSourc
|
||||
}
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::Six) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuIncreaseStep();
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuCurrentStep() >= GlobalPreferences::DfuUnlockStep && !GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorPurple);
|
||||
Ion::LED::setBlinking(500, 0.5f);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(true);
|
||||
App::app()->displayWarning(I18n::Message::DfuWarning1, I18n::Message::DfuWarning2);
|
||||
return true;
|
||||
} else if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuResetStep();
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
}
|
||||
}
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
AppsContainer * container = AppsContainer::sharedAppsContainer();
|
||||
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuResetStep();
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
|
||||
int index = selectionDataSource()->selectedRow()*k_numberOfColumns+selectionDataSource()->selectedColumn()+1;
|
||||
#ifdef HOME_DISPLAY_EXTERNALS
|
||||
if (index >= container->numberOfApps()) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.8 KiB |
@@ -25,6 +25,8 @@ app_settings_src = $(addprefix apps/settings/,\
|
||||
sub_menu/contributors_controller.cpp \
|
||||
sub_menu/math_options_controller.cpp \
|
||||
sub_menu/selectable_view_with_messages.cpp \
|
||||
sub_menu/usb_info_controller.cpp \
|
||||
sub_menu/usb_protection_level_controller.cpp \
|
||||
)
|
||||
|
||||
SFLAGS += -DOMEGA_STATE="$(OMEGA_STATE)"
|
||||
|
||||
@@ -15,6 +15,8 @@ constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[4] = {SettingsMess
|
||||
constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)};
|
||||
constexpr SettingsMessageTree s_modelDateTimeChildren[3] = {SettingsMessageTree(I18n::Message::ActivateClock), SettingsMessageTree(I18n::Message::Date), SettingsMessageTree(I18n::Message::Time)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
constexpr SettingsMessageTree s_usbLevelSelector[3] = {SettingsMessageTree(I18n::Message::USBDefaultLevel), SettingsMessageTree(I18n::Message::USBLowLevel), SettingsMessageTree(I18n::Message::USBParanoidLevel)}; // , SettingsMessageTree(I18n::Message::USBMegaParanoidLevel)
|
||||
constexpr SettingsMessageTree s_usbSteps[2] = {SettingsMessageTree(I18n::Message::USBProtection), SettingsMessageTree(I18n::Message::USBLevelProtect, s_usbLevelSelector)};
|
||||
constexpr SettingsMessageTree s_symbolFunctionChildren[3] = {SettingsMessageTree(I18n::Message::SymbolDefaultFunction), SettingsMessageTree(I18n::Message::SymbolArgDefaultFunction), SettingsMessageTree(I18n::Message::SymbolArgFunction)};
|
||||
constexpr SettingsMessageTree s_modelMathOptionsChildren[6] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren), SettingsMessageTree(I18n::Message::SymbolFunction, s_symbolFunctionChildren), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren)};
|
||||
constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)};
|
||||
@@ -41,7 +43,8 @@ MainController::MainController(Responder * parentResponder, InputEventHandlerDel
|
||||
m_codeOptionsController(this),
|
||||
m_examModeController(this),
|
||||
m_aboutController(this),
|
||||
m_preferencesController(this)
|
||||
m_preferencesController(this),
|
||||
m_usbInfoController(this)
|
||||
{
|
||||
for (int i = 0; i < k_numberOfSimpleChevronCells; i++) {
|
||||
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||
@@ -111,6 +114,8 @@ bool MainController::handleEvent(Ion::Events::Event event) {
|
||||
subController = &m_dateTimeController;
|
||||
} else if (title == I18n::Message::MathOptions) {
|
||||
subController = &m_mathOptionsController;
|
||||
} else if (title == I18n::Message::UsbSetting) {
|
||||
subController = &m_usbInfoController;
|
||||
} else if (title == I18n::Message::CodeApp) {
|
||||
subController = &m_codeOptionsController;
|
||||
} else {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "sub_menu/localization_controller.h"
|
||||
#include "sub_menu/math_options_controller.h"
|
||||
#include "sub_menu/preferences_controller.h"
|
||||
#include "sub_menu/usb_info_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@@ -28,6 +29,8 @@ extern const Shared::SettingsMessageTree s_modelDateTimeChildren[3];
|
||||
extern const Shared::SettingsMessageTree s_accessibilityChildren[6];
|
||||
extern const Shared::SettingsMessageTree s_contributorsChildren[23];
|
||||
extern const Shared::SettingsMessageTree s_modelAboutChildren[9];
|
||||
extern const Shared::SettingsMessageTree s_usbLevelSelector[3];
|
||||
extern const Shared::SettingsMessageTree s_usbSteps[2];
|
||||
extern const Shared::SettingsMessageTree s_model;
|
||||
|
||||
class MainController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource {
|
||||
@@ -76,6 +79,7 @@ private:
|
||||
ExamModeController m_examModeController;
|
||||
AboutController m_aboutController;
|
||||
PreferencesController m_preferencesController;
|
||||
UsbInfoController m_usbInfoController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::BetaPopUp),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren),
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
#include "main_controller.h"
|
||||
#include "../exam_mode_configuration.h"
|
||||
#include <apps/i18n.h>
|
||||
|
||||
#include "../exam_mode_configuration.h"
|
||||
#include "main_controller.h"
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::Country),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::Country),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
||||
#ifdef HAS_CODE
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
I18n::Message MainController::promptMessage() const {
|
||||
return I18n::Message::Default;
|
||||
return I18n::Message::Default;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Settings
|
||||
|
||||
@@ -15,8 +15,10 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
||||
#ifdef HAS_CODE
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
#endif SettingsMessageTree(I18n::Message::UpdatePopUp),
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::UpdatePopUp),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
@@ -100,6 +100,22 @@ bool AboutController::handleEvent(Ion::Events::Event event) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if(childLabel == I18n::Message::Battery){
|
||||
MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)m_selectableTableView.selectedCell();
|
||||
char batteryLevel[15];
|
||||
if(strchr(myCell->accessoryText(), '%') == NULL){
|
||||
int batteryLen = Poincare::Integer((int) ((Ion::Battery::voltage() - 3.6) * 166)).serialize(batteryLevel, 15);
|
||||
batteryLevel[batteryLen] = '%';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
}else{
|
||||
int batteryLen = Poincare::Number::FloatNumber(Ion::Battery::voltage()).serialize(batteryLevel, 15, Poincare::Preferences::PrintFloatMode::Decimal, 3);
|
||||
batteryLevel[batteryLen] = 'V';
|
||||
batteryLevel[batteryLen+1] = '\0';
|
||||
}
|
||||
|
||||
myCell->setAccessoryText(batteryLevel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
134
apps/settings/sub_menu/usb_info_controller.cpp
Normal file
134
apps/settings/sub_menu/usb_info_controller.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
#include "usb_info_controller.h"
|
||||
|
||||
#include <apps/i18n.h>
|
||||
#include <apps/settings/main_controller.h>
|
||||
#include <assert.h>
|
||||
#include <ion/storage.h>
|
||||
#include <poincare/preferences.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "../../apps_container.h"
|
||||
#include "../../global_preferences.h"
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
UsbInfoController::UsbInfoController(Responder *parentResponder) : GenericSubController(parentResponder),
|
||||
m_usbprotectlevel(this),
|
||||
m_dfuLevel(KDFont::LargeFont, KDFont::SmallFont),
|
||||
m_contentView(&m_selectableTableView) {
|
||||
for (int i = 0; i < k_maxSwitchCells; i++) {
|
||||
m_switchCells[i].setMessageFont(KDFont::LargeFont);
|
||||
//Ancien code au cas ou on souhaite ajouter d'autres éléments dans le menu
|
||||
// m_cell[i].setMessageFont(KDFont::LargeFont);
|
||||
// m_cell[i].setAccessoryFont(KDFont::SmallFont);
|
||||
// m_cell[i].setAccessoryTextColor(Palette::SecondaryText);
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbInfoController::handleEvent(Ion::Events::Event event) {
|
||||
if ((Ion::Events::OK == event || Ion::Events::EXE == event) && selectedRow() == 0) {
|
||||
if(GlobalPreferences::sharedGlobalPreferences()->showDfuDeacAlert()){
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuDeacAlert(false);
|
||||
Container::activeApp()->displayWarning(I18n::Message::USBDeacAlert1, I18n::Message::USBDeacAlert2);
|
||||
return true;
|
||||
}
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorPurple);
|
||||
Ion::LED::setBlinking(500, 0.5f);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(true);
|
||||
Container::activeApp()->displayWarning(I18n::Message::DfuWarning1, I18n::Message::DfuWarning2);
|
||||
} else {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
}
|
||||
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
|
||||
AppsContainer::sharedAppsContainer()->redrawWindow(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus() && event != Ion::Events::USBPlug && event != Ion::Events::USBEnumeration) {
|
||||
Container::activeApp()->displayWarning(I18n::Message::UsbSetting, I18n::Message::USBSettingDeact);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((Ion::Events::OK == event || Ion::Events::EXE == event) && selectedRow() == 1) {
|
||||
GenericSubController *subController = &m_usbprotectlevel;
|
||||
subController->setMessageTreeModel(m_messageTreeModel->childAtIndex(1));
|
||||
StackViewController *stack = stackController();
|
||||
m_lastSelect = selectedRow();
|
||||
stack->push(subController);
|
||||
return true;
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuDeacAlert(true);
|
||||
return GenericSubController::handleEvent(event);
|
||||
}
|
||||
|
||||
HighlightCell *UsbInfoController::reusableCell(int index, int type) {
|
||||
assert(type == 2 || type == 1);
|
||||
if (type == 2) {
|
||||
assert(index >= 0 && index < k_maxSwitchCells);
|
||||
return &m_switchCells[index];
|
||||
}
|
||||
return &m_dfuLevel;
|
||||
}
|
||||
|
||||
int UsbInfoController::reusableCellCount(int type) {
|
||||
assert(type == 2 || type == 1);
|
||||
if (type == 2) {
|
||||
return k_maxSwitchCells;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void UsbInfoController::willDisplayCellForIndex(HighlightCell *cell, int index) {
|
||||
GenericSubController::willDisplayCellForIndex(cell, index);
|
||||
|
||||
if (index == 0) {
|
||||
MessageTableCellWithSwitch *myCell = (MessageTableCellWithSwitch *)cell;
|
||||
SwitchView *mySwitch = (SwitchView *)myCell->accessoryView();
|
||||
mySwitch->setState(!GlobalPreferences::sharedGlobalPreferences()->dfuStatus());
|
||||
} else if (index == 1) {
|
||||
MessageTableCellWithChevronAndMessage *mcell = (MessageTableCellWithChevronAndMessage *)cell;
|
||||
int currentLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
if (currentLevel == 0) {
|
||||
// mcell->setSubtitle(I18n::Message::USBDefaultLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBDefaultLevelDesc);
|
||||
} else if (currentLevel == 1) {
|
||||
// mcell->setSubtitle(I18n::Message::USBLowLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBLowLevelDesc);
|
||||
} else if (currentLevel == 2) {
|
||||
// mcell->setSubtitle(I18n::Message::USBParanoidLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBParanoidLevelDesc);
|
||||
} else {
|
||||
// mcell->setSubtitle(I18n::Message::USBMegaParanoidLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBMegaParanoidLevelDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int UsbInfoController::typeAtLocation(int i, int j) {
|
||||
switch (j) {
|
||||
case 0:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void UsbInfoController::didEnterResponderChain(Responder *previousFirstResponder) {
|
||||
m_contentView.reload();
|
||||
|
||||
if (numberOfInfoLines() > 0) {
|
||||
I18n::Message infoMessages[] = {I18n::Message::USBE16_expl1, I18n::Message::USBE16_expl2, I18n::Message::USBE16_expl3};
|
||||
m_contentView.setMessages(infoMessages, numberOfInfoLines());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
apps/settings/sub_menu/usb_info_controller.h
Normal file
36
apps/settings/sub_menu/usb_info_controller.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef SETTINGS_USB_INFO_CONTROLLER_H
|
||||
#define SETTINGS_USB_INFO_CONTROLLER_H
|
||||
|
||||
#include "generic_sub_controller.h"
|
||||
#include "preferences_controller.h"
|
||||
#include "selectable_view_with_messages.h"
|
||||
#include "usb_protection_level_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class UsbInfoController : public GenericSubController {
|
||||
public:
|
||||
UsbInfoController(Responder* parentResponder);
|
||||
View* view() override { return &m_contentView; }
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
TELEMETRY_ID("UsbInfo");
|
||||
void didEnterResponderChain(Responder* previousFirstResponder) override;
|
||||
|
||||
HighlightCell* reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
void willDisplayCellForIndex(HighlightCell* cell, int index) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
|
||||
private:
|
||||
static constexpr int k_numberOfInfoE16MessageLines = 3;
|
||||
int numberOfInfoLines() const { return k_numberOfInfoE16MessageLines; };
|
||||
static constexpr int k_maxSwitchCells = 1;
|
||||
MessageTableCellWithSwitch m_switchCells[k_maxSwitchCells];
|
||||
UsbProtectionLevelController m_usbprotectlevel;
|
||||
MessageTableCellWithChevronAndMessage m_dfuLevel;
|
||||
SelectableViewWithMessages m_contentView;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
77
apps/settings/sub_menu/usb_protection_level_controller.cpp
Normal file
77
apps/settings/sub_menu/usb_protection_level_controller.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "usb_protection_level_controller.h"
|
||||
|
||||
#include <apps/i18n.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../../apps_container.h"
|
||||
#include "../../global_preferences.h"
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
UsbProtectionLevelController::UsbProtectionLevelController(Responder *parentResponder) : GenericSubController(parentResponder) {
|
||||
for (int i = 0; i < k_maxNumberOfCells; i++) {
|
||||
m_cell[i].setMessageFont(KDFont::LargeFont);
|
||||
m_cell[i].setAccessoryFont(KDFont::SmallFont);
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbProtectionLevelController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
for (int i = 0; i < k_maxNumberOfCells; i++) {
|
||||
m_cell[i].setAccessoryText("");
|
||||
}
|
||||
if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBLowLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(1);
|
||||
} else if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBDefaultLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(0);
|
||||
} else if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBParanoidLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(2);
|
||||
} else if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBMegaParanoidLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(3);
|
||||
}
|
||||
|
||||
StackViewController * stack = stackController();
|
||||
stack->pop();
|
||||
return true;
|
||||
} else {
|
||||
return GenericSubController::handleEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
HighlightCell *UsbProtectionLevelController::reusableCell(int index, int type) {
|
||||
assert(index >= 0 && index < k_maxNumberOfCells);
|
||||
return &m_cell[index];
|
||||
}
|
||||
|
||||
int UsbProtectionLevelController::reusableCellCount(int type) {
|
||||
return k_maxNumberOfCells;
|
||||
}
|
||||
|
||||
void UsbProtectionLevelController::willDisplayCellForIndex(HighlightCell *cell, int index) {
|
||||
GenericSubController::willDisplayCellForIndex(cell, index);
|
||||
I18n::Message childLabel = m_messageTreeModel->childAtIndex(index)->label();
|
||||
MessageTableCellWithBuffer *messageComp = (MessageTableCellWithBuffer *)cell;
|
||||
|
||||
int currentLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
|
||||
if (childLabel == I18n::Message::USBLowLevel && currentLevel == 1) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
} else if (childLabel == I18n::Message::USBDefaultLevel && currentLevel == 0) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
} else if (childLabel == I18n::Message::USBParanoidLevel && currentLevel == 2) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
} else if (childLabel == I18n::Message::USBMegaParanoidLevel && currentLevel == 3) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
}
|
||||
}
|
||||
|
||||
int UsbProtectionLevelController::typeAtLocation(int i, int j) {
|
||||
return 0;
|
||||
}
|
||||
} // namespace Settings
|
||||
24
apps/settings/sub_menu/usb_protection_level_controller.h
Normal file
24
apps/settings/sub_menu/usb_protection_level_controller.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef SETTINGS_USB_PROTECTION_LEVEL_CONTROLLER_H
|
||||
#define SETTINGS_USB_PROTECTION_LEVEL_CONTROLLER_H
|
||||
|
||||
#include "generic_sub_controller.h"
|
||||
#include <escher.h>
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class UsbProtectionLevelController : public GenericSubController {
|
||||
public:
|
||||
UsbProtectionLevelController(Responder * parentResponder);
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
private:
|
||||
static constexpr int k_maxNumberOfCells = 3;
|
||||
MessageTableCellWithBuffer m_cell[k_maxNumberOfCells];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "Kein Symbol "
|
||||
ExamModeModeNoSymNoText = "Kein Symbol kein Text "
|
||||
ExamModeModeDutch = "Niederländisch "
|
||||
USBE16_expl1= "USB-Schutz schützt Ihren"
|
||||
USBE16_expl2= "Taschenrechner vor"
|
||||
USBE16_expl3= "unbeabsichtigter Verriegelung"
|
||||
USBProtection= "USB-Schutz"
|
||||
USBSettingDeact = "Bitte schalte den Schutz ein"
|
||||
USBLevelProtect = "Akzeptierte Updates"
|
||||
USBDefaultLevel = "Basierend auf Upsilon"
|
||||
USBLowLevel = "Basierend auf Omega"
|
||||
USBParanoidLevel = "Nur Python"
|
||||
USBMegaParanoidLevel = "Nichts"
|
||||
USBDeacAlert1 = "Ändern Sie diesen Parameter nur,"
|
||||
USBDeacAlert2 = "wenn Sie wissen, was Sie tun!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "No sym "
|
||||
ExamModeModeNoSymNoText = "No sym no text "
|
||||
ExamModeModeDutch = "Dutch "
|
||||
USBE16_expl1= "The USB protection protects"
|
||||
USBE16_expl2= "the calculator from"
|
||||
USBE16_expl3= "unintentional locking"
|
||||
USBProtection= "USB Protection"
|
||||
USBSettingDeact = "Please turn on the protection"
|
||||
USBLevelProtect = "Updates accepted"
|
||||
USBDefaultLevel = "Based on Upsilon"
|
||||
USBLowLevel = "Based on Omega"
|
||||
USBParanoidLevel = "Python Only"
|
||||
USBMegaParanoidLevel = "None"
|
||||
USBDeacAlert1 = "Change this parameter only if"
|
||||
USBDeacAlert2 = "you know what you are doing !"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Estándar "
|
||||
ExamModeModeNoSym = "Sin simbólico "
|
||||
ExamModeModeNoSymNoText = "Sin simbólico sin texto "
|
||||
ExamModeModeDutch = "Holandés "
|
||||
USBE16_expl1= "La protección USB protege"
|
||||
USBE16_expl2= "su calculadora del"
|
||||
USBE16_expl3= "bloqueo involuntario"
|
||||
USBProtection= "Protección USB"
|
||||
USBSettingDeact = "Enciende la protección"
|
||||
USBLevelProtect = "Actualizaciones aceptadas"
|
||||
USBDefaultLevel = "Basado en Upsilon"
|
||||
USBLowLevel = "Basado en Omega"
|
||||
USBParanoidLevel = "Solo Python"
|
||||
USBMegaParanoidLevel = "Ninguno"
|
||||
USBDeacAlert1 = "¡Cambie este parámetro solo"
|
||||
USBDeacAlert2 = "si sabe lo que está haciendo!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "Sans symbolique "
|
||||
ExamModeModeNoSymNoText = "Sans symbolique ni texte "
|
||||
ExamModeModeDutch = "Dutch "
|
||||
USBE16_expl1= "La protection USB protège votre"
|
||||
USBE16_expl2= "calculatrice contre un verrouillage"
|
||||
USBE16_expl3= "non-intentionnel"
|
||||
USBProtection= "Protection USB"
|
||||
USBSettingDeact = "Veuillez activer la protection"
|
||||
USBLevelProtect = "Mise à jour acceptées"
|
||||
USBDefaultLevel = "Basées sur Upsilon"
|
||||
USBLowLevel = "Basées sur Omega"
|
||||
USBParanoidLevel = "Aucune"
|
||||
USBMegaParanoidLevel = "Aucune"
|
||||
USBDeacAlert1 = "Ne modifiez ce paramètre que"
|
||||
USBDeacAlert2 = "si vous savez ce que vous faites !"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Normál "
|
||||
ExamModeModeNoSym = "Szimbólikus nélkül "
|
||||
ExamModeModeNoSymNoText = "Szimbólikus és szöveg nélkül "
|
||||
ExamModeModeDutch = "Holland "
|
||||
USBE16_expl1= "Az USB-védelem megvédi"
|
||||
USBE16_expl2= "a számológépet a nem"
|
||||
USBE16_expl3= "szándékos reteszeléstől"
|
||||
USBProtection= "USB védelem"
|
||||
USBSettingDeact = "Kérjük, kapcsolja be a védelmet"
|
||||
USBLevelProtect = "Elfogadott frissítések"
|
||||
USBDefaultLevel = "Upsilon alapján"
|
||||
USBLowLevel = "Omega alapján"
|
||||
USBParanoidLevel = "Csak Python"
|
||||
USBMegaParanoidLevel = "Egyik sem"
|
||||
USBDeacAlert1 = "Csak akkor módosítsa ezt a"
|
||||
USBDeacAlert2 = "paramétert, ha tudja, mit csinál!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "Nessun simbolo "
|
||||
ExamModeModeNoSymNoText = "Nessun simbolo nessun testo "
|
||||
ExamModeModeDutch = "Olandese "
|
||||
USBE16_expl1= "La protezione USB protegge"
|
||||
USBE16_expl2= "la calcolatrice dal"
|
||||
USBE16_expl3= "blocco involontario"
|
||||
USBProtection= "Protezione USB"
|
||||
USBSettingDeact = "Si prega di attivare la protezione"
|
||||
USBLevelProtect = "Aggiornamenti accettati"
|
||||
USBDefaultLevel = "Basato su Upsilon"
|
||||
USBLowLevel = "A base di Omega"
|
||||
USBParanoidLevel = "Solo Python"
|
||||
USBMegaParanoidLevel = "Nessuno"
|
||||
USBDeacAlert1 = "Cambia questo parametro solo"
|
||||
USBDeacAlert2 = "se sai cosa stai facendo !"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standaard "
|
||||
ExamModeModeNoSym = "Geen sym "
|
||||
ExamModeModeNoSymNoText = "Geen sym geen tekst "
|
||||
ExamModeModeDutch = "Nederlands "
|
||||
USBE16_expl1= "USB-beveiliging beschermt uw"
|
||||
USBE16_expl2= "rekenmachine tegen"
|
||||
USBE16_expl3= "onbedoelde vergrendeling"
|
||||
USBProtection= "USB-beveiliging"
|
||||
USBSettingDeact = "Schakel a.u.b. de bescherming in"
|
||||
USBLevelProtect = "Updates geaccepteerd"
|
||||
USBDefaultLevel = "Gebaseerd op Upsilon"
|
||||
USBLowLevel = "Op basis van Omega"
|
||||
USBParanoidLevel = "Alleen Python"
|
||||
USBMegaParanoidLevel = "Geen"
|
||||
USBDeacAlert1 = "Wijzig deze parameter alleen"
|
||||
USBDeacAlert2 = "als u weet wat u doet!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Padrão "
|
||||
ExamModeModeNoSym = "Sem sym "
|
||||
ExamModeModeNoSymNoText = "Sem sym sem texto "
|
||||
ExamModeModeDutch = "holandês "
|
||||
USBE16_expl1= "A proteção USB protege"
|
||||
USBE16_expl2= "sua calculadora contra"
|
||||
USBE16_expl3= "bloqueios não intencionais"
|
||||
USBProtection= "Proteção USB"
|
||||
USBSettingDeact = "Por favor, ligue a proteção"
|
||||
USBLevelProtect = "Atualizações aceitas"
|
||||
USBDefaultLevel = "Baseado em Upsilon"
|
||||
USBLowLevel = "Baseado em Ômega"
|
||||
USBParanoidLevel = "Apenas Python"
|
||||
USBMegaParanoidLevel = "Nenhum"
|
||||
USBDeacAlert1 = "Mude este parâmetro somente"
|
||||
USBDeacAlert2 = "se você souber o que está fazendo!"
|
||||
|
||||
@@ -458,6 +458,11 @@ HartreeConstant = "4.3597447222071·10^-18_J"
|
||||
MagneticFluxQuantum = "2.067833848·10^-15_Wb"
|
||||
ConductanceQuantum = "7.748091729·10^-5_S"
|
||||
CirculationQuantum = "3.6369475516·10^-4_m^2_s^-1"
|
||||
UsbSetting = "USB"
|
||||
USBDefaultLevelDesc = "L0"
|
||||
USBLowLevelDesc = "L1"
|
||||
USBParanoidLevelDesc = "L2"
|
||||
USBMegaParanoidLevelDesc = "L3"
|
||||
Cndcvt_Silver = "6.30·10^7_S_m^-1"
|
||||
Cndcvt_Copper = "5.96·10^7_S_m^-1"
|
||||
Cndcvt_Gold = "4.11·10^7_S_m^-1"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
app_usb_src = $(addprefix apps/usb/,\
|
||||
app.cpp \
|
||||
usb_connected_controller.cpp \
|
||||
usb_view.cpp \
|
||||
)
|
||||
|
||||
apps_src += $(app_usb_src)
|
||||
|
||||
@@ -27,6 +27,7 @@ App::App(Snapshot * snapshot) :
|
||||
}
|
||||
|
||||
bool App::processEvent(Ion::Events::Event e) {
|
||||
// Impossible de gérer mes events ici lorsqu'on active le DFU
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide."
|
||||
ConnectedMessage4 = "Drücken Sie die Zurück-Taste am"
|
||||
ConnectedMessage5 = "Taschenrechner oder Kabel abziehen,"
|
||||
ConnectedMessage6 = "um die Verbindung zu trennen."
|
||||
DfuStatus1 = "Status des Rechners:"
|
||||
DfuStatusProtected = "GESCHÜTZT"
|
||||
DfuStatusUnProtected = "UNGESCHÜTZT"
|
||||
USBProtectionLevel0 = "Standardschutz"
|
||||
USBProtectionLevel1 = "Omega Schutz"
|
||||
USBProtectionLevel2 = "Systemschutz"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Press the BACK key of your"
|
||||
ConnectedMessage5 = "calculator or unplug it to"
|
||||
ConnectedMessage6 = "disconnect it."
|
||||
DfuStatus1 = "Calculator status:"
|
||||
DfuStatusProtected = "PROTECTED"
|
||||
DfuStatusUnProtected = "UNPROTECTED"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
|
||||
@@ -4,4 +4,10 @@ ConnectedMessage2 = "nuestra página desde su ordenador"
|
||||
ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Pulse el botón RETURN de la"
|
||||
ConnectedMessage5 = "calculadora o desenchúfela para"
|
||||
ConnectedMessage6 = "desconectarla."
|
||||
ConnectedMessage6 = "desconectarla."
|
||||
DfuStatus1 = "Estado de la calculadora:"
|
||||
DfuStatusProtected = "PROTEGIDO"
|
||||
DfuStatusUnProtected = "DESABRIGADO"
|
||||
USBProtectionLevel0 = "Protección predeterminada"
|
||||
USBProtectionLevel1 = "Protección Omega"
|
||||
USBProtectionLevel2 = "Protección del sistema"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Appuyez sur la touche RETOUR"
|
||||
ConnectedMessage5 = "de la calculatrice ou débranchez-la"
|
||||
ConnectedMessage6 = "pour la déconnecter."
|
||||
DfuStatus1 = "Etat de la calculatrice:"
|
||||
DfuStatusProtected = "PROTÉGÉE"
|
||||
DfuStatusUnProtected = "NON PROTÉGÉE"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "fel getomega.dev/ide ra."
|
||||
ConnectedMessage4 = "Nyomjon majd a VISSZA gombra"
|
||||
ConnectedMessage5 = "vagy huzza ki a kábelt azért"
|
||||
ConnectedMessage6 = "hogy a másolás véget érjen."
|
||||
DfuStatus1 = "Számológép állapota:"
|
||||
DfuStatusProtected = "VÉDETT"
|
||||
DfuStatusUnProtected = "VÉDTELEN"
|
||||
USBProtectionLevel0 = "Alapértelmezett védelem"
|
||||
USBProtectionLevel1 = "Omega védelem"
|
||||
USBProtectionLevel2 = "Rendszervédelem"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Premere sul tasto INDIETRO della"
|
||||
ConnectedMessage5 = "calcolatrice o scollegatela per"
|
||||
ConnectedMessage6 = "disconnetterla."
|
||||
DfuStatus1 = "Stato della calcolatrice:"
|
||||
DfuStatusProtected = "PROTETTO"
|
||||
DfuStatusUnProtected = "INDIFESO"
|
||||
USBProtectionLevel0 = "Protezione predefinita"
|
||||
USBProtectionLevel1 = "Protezione Omega"
|
||||
USBProtectionLevel2 = "Protezione del sistema"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Druk op de TERUG toets van je"
|
||||
ConnectedMessage5 = "rekenmachine of verwijder de"
|
||||
ConnectedMessage6 = " kabel om hem los te koppelen."
|
||||
DfuStatus1 = "Rekenmachine status:"
|
||||
DfuStatusProtected = "BESCHERMD"
|
||||
DfuStatusUnProtected = "NIET BESCHERMD"
|
||||
USBProtectionLevel0 = "Standaardbeveiliging"
|
||||
USBProtectionLevel1 = "Omega Bescherming"
|
||||
USBProtectionLevel2 = "Systeembeveiliging"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Pressione o botão RETURN na"
|
||||
ConnectedMessage5 = "calculadora ou desligue-a para a"
|
||||
ConnectedMessage6 = "desconectar."
|
||||
DfuStatus1 = "Status da calculadora:"
|
||||
DfuStatusProtected = "PROTEGIDO"
|
||||
DfuStatusUnProtected = "DESPROTEGIDO"
|
||||
USBProtectionLevel0 = "Proteção padrão"
|
||||
USBProtectionLevel1 = "Proteção Ômega"
|
||||
USBProtectionLevel2 = "Proteção do sistema"
|
||||
|
||||
@@ -1,42 +1,140 @@
|
||||
#include "usb_connected_controller.h"
|
||||
#include <apps/i18n.h>
|
||||
#include "../global_preferences.h"
|
||||
|
||||
namespace USB {
|
||||
|
||||
static I18n::Message sUSBConnectedMessages[] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6};
|
||||
|
||||
static KDColor sUSBConnectedFGColors[] = {
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText,
|
||||
KDColorWhite,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText};
|
||||
|
||||
static KDColor sUSBConnectedBGColors[] = {
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard};
|
||||
|
||||
USBConnectedController::USBConnectedController() :
|
||||
ViewController(nullptr),
|
||||
m_messageView(sUSBConnectedMessages, sUSBConnectedFGColors, sUSBConnectedBGColors, 8)
|
||||
namespace USB
|
||||
{
|
||||
}
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesProtection0[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::USBProtectionLevel0};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesProtection1[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::USBProtectionLevel1};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesProtection2[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::USBProtectionLevel2};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesUnProtected[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::DfuStatusUnProtected};
|
||||
|
||||
static KDColor sUSBConnectedFGColors[] = {
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText,
|
||||
KDColorWhite,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText};
|
||||
|
||||
static KDColor sUSBConnectedBGColors[] = {
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard};
|
||||
|
||||
USBConnectedController::USBConnectedController() : ViewController(nullptr), step(0), already_init(false), m_messageView(sUSBConnectedMessagesProtection0, sUSBConnectedFGColors, sUSBConnectedBGColors, 10)
|
||||
{
|
||||
if(already_init){
|
||||
return;
|
||||
}
|
||||
if (step == 0 && GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
{
|
||||
getMessageView()->update(sUSBConnectedMessagesUnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
}else if(step == 0){
|
||||
if(GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() == 1){
|
||||
getMessageView()->update(sUSBConnectedMessagesProtection1, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
}else if(GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() == 2){
|
||||
getMessageView()->update(sUSBConnectedMessagesProtection2, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
}
|
||||
}
|
||||
// else if (step == 1 && GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// {
|
||||
// getMessageView()->update(sUSBConnectedMessages2UnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// }
|
||||
// else if (step == 1 && !GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// {
|
||||
// getMessageView()->update(sUSBConnectedMessages2Protected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// }
|
||||
already_init = true;
|
||||
}
|
||||
|
||||
// bool USBConnectedController::handleEvent(Ion::Events::Event event)
|
||||
// {
|
||||
// if (event.isKeyboardEvent())
|
||||
// {
|
||||
// // Ne fonctionne pas pour l'instant fait bugger les events
|
||||
// // if (step == 0)
|
||||
// // {
|
||||
// // if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessagesUnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessagesProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // step = 1;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessages2UnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessages2Protected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // step = 0;
|
||||
// // }
|
||||
// return false;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define USB_USB_CONNECTED_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "../shared/message_view.h"
|
||||
#include "usb_view.h"
|
||||
|
||||
namespace USB {
|
||||
|
||||
@@ -10,9 +10,12 @@ class USBConnectedController : public ViewController {
|
||||
public:
|
||||
USBConnectedController();
|
||||
View * view() override { return &m_messageView; }
|
||||
bool handleEvent(Ion::Events::Event event) override { return false; }
|
||||
USBView * getMessageView() {return &m_messageView; }
|
||||
bool handleEvent(Ion::Events::Event event) override { return false; };
|
||||
private:
|
||||
MessageView m_messageView;
|
||||
int step;
|
||||
bool already_init;
|
||||
USBView m_messageView;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
56
apps/usb/usb_view.cpp
Normal file
56
apps/usb/usb_view.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "usb_view.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace USB {
|
||||
USBView::USBView(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages) {
|
||||
m_numberOfMessages = numberOfMessages < k_maxNumberOfMessages ? numberOfMessages : k_maxNumberOfMessages;
|
||||
for (uint8_t i = 0; i < m_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFont(i == 0 ? KDFont::LargeFont : KDFont::SmallFont);
|
||||
m_messageTextViews[i].setMessage(messages[i]);
|
||||
m_messageTextViews[i].setAlignment(0.5f, 0.5f);
|
||||
m_messageTextViews[i].setTextColor(fgcolors[i]);
|
||||
m_messageTextViews[i].setBackgroundColor(bgcolors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void USBView::drawRect(KDContext *ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::BackgroundHard);
|
||||
}
|
||||
|
||||
View *USBView::subviewAtIndex(int index) {
|
||||
if (index >= m_numberOfMessages) {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
return &(m_messageTextViews[index]);
|
||||
}
|
||||
|
||||
void USBView::update(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages){
|
||||
m_numberOfMessages = numberOfMessages < k_maxNumberOfMessages ? numberOfMessages : k_maxNumberOfMessages;
|
||||
for (uint8_t i = 0; i < m_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFont(i == 0 ? KDFont::LargeFont : KDFont::SmallFont);
|
||||
m_messageTextViews[i].setMessage(messages[i]);
|
||||
m_messageTextViews[i].setAlignment(0.5f, 0.5f);
|
||||
m_messageTextViews[i].setTextColor(fgcolors[i]);
|
||||
m_messageTextViews[i].setBackgroundColor(bgcolors[i]);
|
||||
}
|
||||
reload();
|
||||
}
|
||||
|
||||
void USBView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
void USBView::layoutSubviews(bool force) {
|
||||
if (m_numberOfMessages == 0) {
|
||||
return;
|
||||
}
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate titleHeight = m_messageTextViews[0].minimalSizeForOptimalDisplay().height();
|
||||
KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height();
|
||||
m_messageTextViews[0].setFrame(KDRect(0, k_titleMargin, width, titleHeight), force);
|
||||
for (uint8_t i = 1; i < m_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFrame(KDRect(0, k_paragraphHeight + (i - 1) * textHeight, width, textHeight), force);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/usb/usb_view.h
Normal file
30
apps/usb/usb_view.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef USB_VIEW_H
|
||||
#define USB_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
namespace USB
|
||||
{
|
||||
class USBView : public View
|
||||
{
|
||||
public:
|
||||
USBView(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages);
|
||||
void drawRect(KDContext *ctx, KDRect rect) const override;
|
||||
void reload();
|
||||
void update(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages);
|
||||
protected:
|
||||
int numberOfSubviews() const override { return m_numberOfMessages; }
|
||||
View *subviewAtIndex(int index) override;
|
||||
void layoutSubviews(bool force = false) override;
|
||||
|
||||
private:
|
||||
constexpr static KDCoordinate k_titleMargin = 30;
|
||||
constexpr static KDCoordinate k_paragraphHeight = 80;
|
||||
constexpr static uint8_t k_maxNumberOfMessages = 10;
|
||||
MessageTextView m_messageTextViews[k_maxNumberOfMessages];
|
||||
uint8_t m_numberOfMessages;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,7 +8,7 @@ EPSILON_VERSION ?= 15.5.0
|
||||
OMEGA_VERSION ?= 1.22.1
|
||||
# OMEGA_USERNAME ?= N/A
|
||||
OMEGA_STATE ?= public
|
||||
EPSILON_APPS ?= geometry calculation rpn graph code statistics probability solver atomic sequence regression reader settings external
|
||||
EPSILON_APPS ?= calculation rpn graph code statistics probability solver atomic sequence regression reader settings external
|
||||
SUBMODULES_APPS = atomic rpn
|
||||
EPSILON_I18N ?= en fr nl pt it de es hu
|
||||
EPSILON_COUNTRIES ?= WW CA DE ES FR GB IT NL PT US
|
||||
|
||||
29
build/device/secure_ext.py
Normal file
29
build/device/secure_ext.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
MAGIK_CODE = [0x64, 0x6c, 0x31, 0x31, 0x23, 0x39, 0x38, 0x33, 0x35]
|
||||
MAGIK_POS = [0x03, 0xb, 0x44f]
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
print("Patching external bin...")
|
||||
ext_path = os.path.join(os.getcwd(), sys.argv[1])
|
||||
if not os.path.isfile(ext_path):
|
||||
print("Error: File not found!")
|
||||
sys.exit(-1)
|
||||
file = open(ext_path, "r+b")
|
||||
first_packet = bytearray(file.read(2048))
|
||||
for b in first_packet:
|
||||
if b != 255:
|
||||
print("Error: Invalid file! (maybe already patched?)")
|
||||
sys.exit(-1)
|
||||
|
||||
for i in range(4):
|
||||
first_packet[MAGIK_POS[0] + i] = MAGIK_CODE[i]
|
||||
for i in range(4):
|
||||
first_packet[MAGIK_POS[1] + i] = MAGIK_CODE[i + 5]
|
||||
for i in range(len(MAGIK_CODE)):
|
||||
first_packet[MAGIK_POS[2] + i] = MAGIK_CODE[i]
|
||||
|
||||
file.seek(0)
|
||||
file.write(first_packet)
|
||||
print("External bin Patched!")
|
||||
@@ -27,11 +27,11 @@ $(BUILD_DIR)/%.map: $(BUILD_DIR)/%.elf
|
||||
@echo "LDMAP $@"
|
||||
$(Q) $(LD) $^ $(LDFLAGS) -Wl,-M -Wl,-Map=$@ -o /dev/null
|
||||
|
||||
.PHONY: %_memory_map
|
||||
%_memory_map: $(BUILD_DIR)/%.map
|
||||
@echo "========== MEMORY MAP ========="
|
||||
$(Q) awk -f build/device/memory_map.awk < $<
|
||||
@echo "==============================="
|
||||
.PHONY: mapfile
|
||||
mapfile:
|
||||
$(BUILD_DIR)/%.map: $(BUILD_DIR)/%.elf
|
||||
@echo "LDMAP $@"
|
||||
$(Q) $(LD) $^ $(LDFLAGS) -Wl,-M -Wl,-Map=$@ -o /dev/null
|
||||
|
||||
.PHONY: openocd
|
||||
openocd:
|
||||
@@ -72,3 +72,4 @@ binpack: $(BUILD_DIR)/flasher.light.bin $(BUILD_DIR)/epsilon.onboarding.two_bina
|
||||
cp $(BUILD_DIR)/epsilon.onboarding.internal.bin $(BUILD_DIR)/epsilon.onboarding.external.bin $(BUILD_DIR)/binpack
|
||||
cd $(BUILD_DIR) && for binary in flasher.light.bin epsilon.onboarding.internal.bin epsilon.onboarding.external.bin; do shasum -a 256 -b binpack/$${binary} > binpack/$${binary}.sha256;done
|
||||
cd $(BUILD_DIR) && tar cvfz binpack-$(MODEL)-`git rev-parse HEAD | head -c 7`.tgz binpack/*
|
||||
$(PYTHON) build/device/secure_ext.py $(BUILD_DIR)/epsilon.onboarding.external.bin
|
||||
@@ -20,7 +20,6 @@ public:
|
||||
virtual void scrollToCell(int i, int j);
|
||||
HighlightCell * cellAtLocation(int i, int j);
|
||||
void reloadCellAtLocation(int i, int j);
|
||||
void reloadVisibleCells();
|
||||
protected:
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
const char * className() const override;
|
||||
@@ -35,7 +34,6 @@ protected:
|
||||
void setHorizontalCellOverlap(KDCoordinate o) { m_horizontalCellOverlap = o; }
|
||||
void setVerticalCellOverlap(KDCoordinate o) { m_verticalCellOverlap = o; }
|
||||
|
||||
void reloadVisibleCells();
|
||||
void reloadCellAtLocation(int i, int j);
|
||||
HighlightCell * cellAtLocation(int i, int j);
|
||||
TableViewDataSource * dataSource();
|
||||
|
||||
@@ -47,7 +47,7 @@ void TableView::layoutSubviews(bool force) {
|
||||
* otherwise the table's size might be miscomputed...
|
||||
* FIXME:
|
||||
* Finally, this solution is not optimal at all since
|
||||
* layoutSubviews is called twice over m_contentView. */
|
||||
* layoutSubviews is called twice over m_contentView. */
|
||||
m_contentView.layoutSubviews(force);
|
||||
ScrollView::layoutSubviews(force);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ bool isPlugged();
|
||||
bool isEnumerated(); // Speed-enumerated, to be accurate
|
||||
void clearEnumerationInterrupt();
|
||||
|
||||
void DFU(bool exitWithKeyboard = true);
|
||||
void DFU(bool exitWithKeyboard = true, bool unlocked = false, int level = 0);
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ void ion_main(int argc, const char * const argv[]) {
|
||||
Ion::USB::enable();
|
||||
while (!Ion::USB::isEnumerated()) {
|
||||
}
|
||||
Ion::USB::DFU(false);
|
||||
Ion::USB::DFU(false, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@ void initMPU() {
|
||||
Cache::dmb();
|
||||
|
||||
// 1.2 Disable fault exceptions
|
||||
CORTEX.SHCRS()->setMEMFAULTENA(false);
|
||||
CORTEX.SHCRS()->setMEMFAULTENA(true);
|
||||
CORTEX.SHCRS()->setBUSFAULTENA(true);
|
||||
CORTEX.SHCRS()->setUSGFAULTENA(true);
|
||||
|
||||
// 1.3 Disable the MPU and clear the control register
|
||||
MPU.CTRL()->setENABLE(false);
|
||||
@@ -121,7 +123,7 @@ void init() {
|
||||
initClocks();
|
||||
|
||||
// The bootloader leaves its own after flashing
|
||||
//SYSCFG.MEMRMP()->setMEM_MODE(SYSCFG::MEMRMP::MemMode::MainFlashmemory);
|
||||
// SYSCFG.MEMRMP()->setMEM_MODE(SYSCFG::MEMRMP::MemMode::MainFlashmemory);
|
||||
// Ensure right location of interrupt vectors
|
||||
CORTEX.VTOR()->setVTOR((void*)&InitialisationVector);
|
||||
|
||||
|
||||
@@ -63,6 +63,14 @@ SECTIONS {
|
||||
. = ALIGN(4);
|
||||
*(.text.start)
|
||||
*(.text.abort)
|
||||
*(.text.uf_abort)
|
||||
*(.text.bf_abort)
|
||||
*(.text.nmi_abort)
|
||||
*(.text.abort_init)
|
||||
*(.text.abort_core)
|
||||
*(.text.abort_sleeping)
|
||||
*(.text.abort_economy)
|
||||
*(.text.abort_screen)
|
||||
*(.text.isr_systick)
|
||||
*(.text.__assert)
|
||||
*(.text.memcpy)
|
||||
@@ -89,6 +97,123 @@ SECTIONS {
|
||||
|
||||
/* 'abort' dependencies */
|
||||
*(.text._ZN3Ion6Device5Reset4coreEv)
|
||||
*(.text._ZN3Ion3LED8setColorE7KDColor)
|
||||
*(.text._ZN3Ion3LED11setBlinkingEtf)
|
||||
*(.text._ZN3Ion6Device3LED*)
|
||||
*(.text._ZNK3Ion6Device4Regs3TIMINS1_8RegisterItEEE4CCMREv)
|
||||
*(.text._ZNK3Ion6Device4Regs3TIMINS1_8RegisterItEEE4BaseEv)
|
||||
*(.text._ZNK3Ion6Device4Regs3*)
|
||||
*(.text.___ZN3Ion6Device4Regs8*)
|
||||
*(.text._ZNK3Ion6Device4Regs3TIMINS1_8RegisterItEEE4CCMREv)
|
||||
*(.text._ZNK3Ion6Device4Regs3TIMINS1_8RegisterItEEE4CCMREv*)
|
||||
*(.text._ZN3Ion6Device5Board15initPeripheralsEb)
|
||||
*(.text._ZN3Ion6Device9Backlight4initEv)
|
||||
*(.text._ZN3Ion6Device6Timing4initEv)
|
||||
*(.text._ZN3Ion6Timing6msleepEj)
|
||||
*(.text._ZN3Ion6Device8Keyboard4initEv)
|
||||
*(.text._ZN3Ion6Device7Battery8initGPIOEv)
|
||||
*(.text._ZN3Ion6Device3USB8initGPIOEv)
|
||||
*(.text._ZN3Ion6Device9Backlight8setLevelEh)
|
||||
*(.text._ZN3Ion6Device6Timing19setSysTickFrequencyEi)
|
||||
*(.text._ZN3Ion6Device5Board17setClockFrequencyENS1_9FrequencyE)
|
||||
*(.text._ZN3Ion6Device9Backlight10sendPulsesEi)
|
||||
*(.text._ZN3Ion6Device5Board19shutdownPeripheralsEb)
|
||||
*(.text._ZN3Ion6Device6Timing8shutdownEv)
|
||||
*(.text._ZN3Ion6Device8Keyboard8shutdownEv)
|
||||
*(.text._ZN9KDContext10drawStringEPKc7KDPointPK6KDFont7KDColorS6_i)
|
||||
*(.text._ZNK8TextArea11ContentView12drawStringAtEP9KDContextiiPKci7KDColorS5_S4_S4_S5_*)
|
||||
*(.text._ZL11KDPointZero*)
|
||||
*(.text._ZGVZN12KDIonContext13sharedContextEvE7context)
|
||||
*(.text._ZZN12KDIonContext13sharedContextEvE7context)
|
||||
*(.text._ZN12KDIonContext13sharedContextEv)
|
||||
*(.text._ZN20KDPostProcessContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN26KDPostProcessInvertContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN12KDIonContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN24KDPostProcessZoomContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN25KDPostProcessGammaContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN16KDRealIonContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN3Ion7Display15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZNK6KDRect15intersectedWithERKS_)
|
||||
*(.text._ZN7KDColor6RGB888Ehhh)
|
||||
*(.text._ZN3Ion6Device7Display14setDrawingAreaE6KDRectNS1_11OrientationE)
|
||||
*(.text.powf)
|
||||
*(.text._ZN9KDContext16pushOrPullStringEPKc7KDPointPK6KDFont7KDColorS6_ibPi)
|
||||
*(.text._ZNK7KDPoint12translatedByES_)
|
||||
*(.text._ZNK6KDRect12translatedByE7KDPoint)
|
||||
*(.text._Z7toGammai)
|
||||
*(.text._ZN3Ion7Display8pullRectE6KDRectP7KDColor)
|
||||
*(.text._ZN24KDPostProcessZoomContext8pullRectE6KDRectP7KDColor)
|
||||
*(.text._ZN16KDRealIonContext8pullRectE6KDRectP7KDColor)
|
||||
*(.text._ZN25KDPostProcessGammaContext8pullRectE6KDRectP7KDColor)
|
||||
*(.text._ZN12KDIonContext8pullRectE6KDRectP7KDColor)
|
||||
*(.text._ZN26KDPostProcessInvertContext8pullRectE6KDRectP7KDColor)
|
||||
*(.text._ZN20KDPostProcessContext8pullRectE6KDRectP7KDColor)
|
||||
*(.text.sqrtf)
|
||||
*(.text._ZN11UTF8Decoder13nextCodePointEv)
|
||||
*(.text._ZN7KDColor5blendES_S_h)
|
||||
*(.text._ZN9KDContext17blendRectWithMaskE6KDRect7KDColorPKhPS1_)
|
||||
*(.text.scalbnf)
|
||||
*(.text._ZNK6KDRect10intersectsERKS_)
|
||||
*(.text._ZN9KDContext18fillRectWithPixelsE6KDRectPK7KDColorPS1_)
|
||||
*(.text._ZN9KDContext15setClippingRectE6KDRect)
|
||||
*(.text._ZN9KDContext9setOriginE7KDPoint)
|
||||
*(.text._ZN20KDPostProcessContext9setOriginE7KDPoint)
|
||||
*(.text._ZN20KDPostProcessContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN26KDPostProcessInvertContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN20KDPostProcessContext8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN12KDIonContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN12KDIonContext8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN26KDPostProcessInvertContext8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN24KDPostProcessZoomContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN24KDPostProcessZoomContext8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN25KDPostProcessGammaContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN25KDPostProcessGammaContext8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN16KDRealIonContext15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZN16KDRealIonContext8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN3Ion7Display8pushRectE6KDRectPK7KDColor)
|
||||
*(.text._ZN3Ion7Display15pushRectUniformE6KDRect7KDColor)
|
||||
*(.text._ZNK6KDRect7isEmptyEv)
|
||||
*(.text._ZN20KDPostProcessContext15setClippingRectE6KDRect)
|
||||
*(.text._ZNK6KDFont17indexForCodePointE9CodePoint)
|
||||
*(.text._ZNK6KDFont26fetchGrayscaleGlyphAtIndexEhPh)
|
||||
*(.text.LZ4_decompress_safe)
|
||||
*(.text.LZ4_wildCopy)
|
||||
*(.text.*DFU*)
|
||||
*(.text.*isEnumerated*)
|
||||
*(.text._ZN3Ion3USB6enableEv)
|
||||
*(.text._ZN3Ion7Battery5levelEv)
|
||||
*(.text._ZN3Ion7Battery7voltageEv)
|
||||
*(.text._ZN3Ion3USB9isPluggedEv)
|
||||
*(.text.*sleepConfiguration*)
|
||||
*(.text.*onOnOffKeyDown*)
|
||||
*(.text.*WakeUp*)
|
||||
*(.text._ZN3Ion6Device9Backlight*)
|
||||
*(.text._ZN3Ion9Backlight*)
|
||||
|
||||
/* Rodata Truc Relou */
|
||||
*(.text._ZNK10Statistics5Store6medianEi)
|
||||
*(.text._ZNK10Regression5Store12meanOfColumnEiib)
|
||||
*(.text._ZNK6Shared15DoublePairStore11sumOfColumnEiib)
|
||||
*(.text._ZNK10Statistics5Store13firstQuartileEi)
|
||||
*(.text._ZNK10Regression5Store23squaredValueSumOfColumnEiib)
|
||||
*(.text._ZNK10Regression5Store16varianceOfColumnEiib)
|
||||
*(.text._ZNK10Statistics5Store8maxValueEi)
|
||||
*(.text._ZNK10Regression5Store25standardDeviationOfColumnEiib)
|
||||
*(.text._ZNK10Statistics5Store13thirdQuartileEi)
|
||||
*(.text._ZNK10Statistics5Store8minValueEi)
|
||||
*(.text._ZNK6Shared8Interval18IntervalParameters*)
|
||||
*(.text._ZN6Shared8Interval18IntervalParameters*)
|
||||
*(.text.sqrt)
|
||||
*(.text.log)
|
||||
*(.text._ZN17GlobalPreferences23sharedGlobalPreferencesEv)
|
||||
*(.text._ZNK10Statistics5Store16sumOfOccurrencesEi)
|
||||
*(.text.floor)
|
||||
*(.text.ceil)
|
||||
*(.text._ZNK10Statistics5Store21frequenciesAreIntegerEi)
|
||||
*(.text._ZNK10Statistics5Store34sortedElementAtCumulatedPopulationEidb)
|
||||
*(.text._ZNK10Statistics5Store33sortedElementAtCumulatedFrequencyEidb)
|
||||
*(.text.round)
|
||||
*(.text._ZNK10Statistics5Store8minIndexEPdi*)
|
||||
|
||||
/* 'standby' dependencies '*/
|
||||
*(.text._ZN3Ion6Device5Power20internalFlashStandbyEv)
|
||||
@@ -113,7 +238,49 @@ SECTIONS {
|
||||
/* 'start' dependencies */
|
||||
*(.rodata._ZN3Ion6Device4RegsL5GPIOAE)
|
||||
*(.rodata._ZN3Ion6Device4RegsL5GPIOBE)
|
||||
*(.rodata._ZN3Ion6Device3LED6ConfigL7RGBPinsE)
|
||||
*(.rodata._ZN3Ion6Device5Board4initEv.str1.4)
|
||||
*(.rodata._ZL12KDColorWhite*)
|
||||
*(.rodata._ZL10KDColorRed*)
|
||||
*(.rodata._ZL12KDColorBlack*)
|
||||
*(.rodata._ZN3Ion6Device3SWD6ConfigL4PinsE)
|
||||
*(.rodata._ZN3Ion6Device7Display6ConfigL8FSMCPinsE)
|
||||
*(.rodata._ZZN3Ion6Device7Display9initPanelEvE11calibration)
|
||||
*(.rodata._ZN3Ion6Device3USB6ConfigL5DmPinE)
|
||||
*(.rodata._ZN3Ion6Device3USB6ConfigL5DpPinE)
|
||||
*(.rodata._ZN3Ion6Device3USB6ConfigL7VbusPinE)
|
||||
*(.rodata._ZN3Ion6Device8Keyboard6ConfigL10ColumnPinsE)
|
||||
*(.rodata._ZN3Ion6Device8Keyboard6ConfigL7RowPinsE)
|
||||
*(.rodata._ZZN3Ion6Device3USB12shutdownGPIOEvE4Pins)
|
||||
*(.rodata._ZN6KDFont16privateLargeFontE)
|
||||
*(.rodata.abort.str1.1)
|
||||
*(.rodata.uf_abort.str1.1)
|
||||
*(.rodata.bf_abort.str1.1)
|
||||
*(.rodata.nmi_abort.str1.1)
|
||||
*(.rodata.abort_screen.str1.1)
|
||||
*(.rodata._ZL5table*)
|
||||
*(.rodata._ZL15glyphDataOffset*)
|
||||
*(.rodata._ZL11KDPointZero*)
|
||||
*(.rodata._ZL9glyphData*)
|
||||
*(.rodata._ZN4CodeL14HighlightColorE*)
|
||||
*(.rodata._ZTV12KDIonContext)
|
||||
*(.rodata._ZTV16KDRealIonContext)
|
||||
*(.rodata._ZTV24KDPostProcessZoomContext)
|
||||
*(.rodata._ZTV25KDPostProcessGammaContext)
|
||||
*(.rodata._ZTV26KDPostProcessInvertContext)
|
||||
*(.rodata.bp)
|
||||
*(.rodata.dp_h)
|
||||
*(.rodata.dp_l)
|
||||
*(.rodata._ZN11MicroPython5Color5ParseEPvNS0_4ModeE*)
|
||||
*(.rodata._ZN9Clipboard10storedTextEv*)
|
||||
*(.rodata._ZN8Sequence14ListController27toolboxForInputEventHandlerEP17InputEventHandler*)
|
||||
*(.rodata._ZN8Sequence23TypeParameterController25willDisplayCellAtLocationEP13HighlightCellii*)
|
||||
*(.rodata._ZN6KDFont16privateSmallFontE)
|
||||
*(.rodata._ZN4I18nL23CountryPreferencesArrayE)
|
||||
*(.rodata.abort_sleeping.str1.1)
|
||||
*(.rodata.abort_core.str1.1)
|
||||
*(.rodata.dfu_bootloader)
|
||||
*(.rodata)
|
||||
} >INTERNAL_FLASH
|
||||
|
||||
.exam_mode_buffer ORIGIN(EXTERNAL_FLASH) : {
|
||||
|
||||
@@ -18,11 +18,11 @@ ISR InitialisationVector[INITIALISATION_VECTOR_SIZE]
|
||||
= {
|
||||
(ISR)&_stack_start, // Stack start
|
||||
start, // Reset service routine,
|
||||
0, // NMI service routine,
|
||||
nmi_abort, // NMI service routine,
|
||||
abort, // HardFault service routine,
|
||||
0, // MemManage service routine,
|
||||
0, // BusFault service routine,
|
||||
0, // UsageFault service routine,
|
||||
bf_abort, // BusFault service routine,
|
||||
uf_abort, // UsageFault service routine,
|
||||
0, 0, 0, 0, // Reserved
|
||||
0, // SVCall service routine,
|
||||
0, // DebugMonitor service routine,
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void bf_abort();
|
||||
void uf_abort();
|
||||
void nmi_abort();
|
||||
void abort_init();
|
||||
void abort_core(const char *);
|
||||
void abort_sleeping();
|
||||
void abort_economy();
|
||||
void abort_screen(const char *);
|
||||
void start();
|
||||
void abort();
|
||||
void isr_systick();
|
||||
|
||||
@@ -1,45 +1,52 @@
|
||||
#include "isr.h"
|
||||
#include <drivers/battery.h>
|
||||
#include <drivers/cache.h>
|
||||
#include <drivers/external_flash.h>
|
||||
#include <drivers/led.h>
|
||||
#include <drivers/power.h>
|
||||
#include <drivers/reset.h>
|
||||
#include <drivers/usb.h>
|
||||
#include <drivers/wakeup.h>
|
||||
#include <ion.h>
|
||||
#include <ion/battery.h>
|
||||
#include <ion/led.h>
|
||||
#include <ion/rtc.h>
|
||||
#include <ion/usb.h>
|
||||
#include <kandinsky.h>
|
||||
#include <regs/config/pwr.h>
|
||||
#include <regs/config/rcc.h>
|
||||
#include <regs/regs.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ion.h>
|
||||
|
||||
#include "../drivers/board.h"
|
||||
#include "../drivers/rtc.h"
|
||||
#include "../drivers/reset.h"
|
||||
#include "../drivers/rtc.h"
|
||||
#include "../drivers/timing.h"
|
||||
#include "isr.h"
|
||||
|
||||
typedef void (*cxx_constructor)();
|
||||
|
||||
extern "C" {
|
||||
extern char _data_section_start_flash;
|
||||
extern char _data_section_start_ram;
|
||||
extern char _data_section_end_ram;
|
||||
extern char _bss_section_start_ram;
|
||||
extern char _bss_section_end_ram;
|
||||
extern cxx_constructor _init_array_start;
|
||||
extern cxx_constructor _init_array_end;
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort() {
|
||||
#ifdef NDEBUG
|
||||
Ion::Device::Reset::core();
|
||||
#else
|
||||
while (1) {
|
||||
}
|
||||
#endif
|
||||
extern char _data_section_start_flash;
|
||||
extern char _data_section_start_ram;
|
||||
extern char _data_section_end_ram;
|
||||
extern char _bss_section_start_ram;
|
||||
extern char _bss_section_end_ram;
|
||||
extern cxx_constructor _init_array_start;
|
||||
extern cxx_constructor _init_array_end;
|
||||
}
|
||||
|
||||
/* In order to ensure that this method is execute from the external flash, we
|
||||
* forbid inlining it.*/
|
||||
|
||||
static void __attribute__((noinline)) external_flash_start() {
|
||||
/* Init the peripherals. We do not initialize the backlight in case there is
|
||||
/* Init the peripherals. We do not initialize the backlight in case there is
|
||||
* an on boarding app: indeed, we don't want the user to see the LCD tests
|
||||
* happening during the on boarding app. The backlight will be initialized
|
||||
* after the Power-On Self-Test if there is one or before switching to the
|
||||
* home app otherwise. */
|
||||
Ion::Device::Board::initPeripherals(false);
|
||||
|
||||
return ion_main(0, nullptr);
|
||||
Ion::Device::Board::initPeripherals(false);
|
||||
return ion_main(0, nullptr);
|
||||
}
|
||||
|
||||
/* This additional function call 'jump_to_external_flash' serves two purposes:
|
||||
@@ -61,7 +68,155 @@ static void __attribute__((noinline)) external_flash_start() {
|
||||
* internal flash to the external flash. */
|
||||
|
||||
static void __attribute__((noinline)) jump_to_external_flash() {
|
||||
external_flash_start();
|
||||
external_flash_start();
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort_init() {
|
||||
Ion::Device::Board::shutdownPeripherals(true);
|
||||
Ion::Device::Board::initPeripherals(false);
|
||||
Ion::Timing::msleep(100);
|
||||
Ion::Backlight::init();
|
||||
Ion::LED::setColor(KDColorRed);
|
||||
Ion::Backlight::setBrightness(180);
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort_economy() {
|
||||
int brightness = Ion::Backlight::brightness();
|
||||
bool plugged = Ion::USB::isPlugged();
|
||||
while (brightness > 0) {
|
||||
brightness--;
|
||||
Ion::Backlight::setBrightness(brightness);
|
||||
Ion::Timing::msleep(50);
|
||||
if(plugged || (!plugged && Ion::USB::isPlugged())){
|
||||
Ion::Backlight::setBrightness(180);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ion::Backlight::shutdown();
|
||||
while (1) {
|
||||
Ion::Device::Power::sleepConfiguration();
|
||||
Ion::Device::WakeUp::onUSBPlugging();
|
||||
Ion::Device::WakeUp::onChargingEvent();
|
||||
Ion::Device::Power::internalFlashSuspend(true);
|
||||
if (!plugged && Ion::USB::isPlugged()) {
|
||||
break;
|
||||
}
|
||||
plugged = Ion::USB::isPlugged();
|
||||
};
|
||||
Ion::Device::Board::setStandardFrequency(Ion::Device::Board::Frequency::High);
|
||||
Ion::Backlight::init();
|
||||
Ion::Backlight::setBrightness(180);
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort_sleeping() {
|
||||
if (Ion::Battery::level() != Ion::Battery::Charge::EMPTY) {
|
||||
return;
|
||||
}
|
||||
// we don't use Ion::Power::suspend because we don't want to move the exam buffer into the internal
|
||||
Ion::Device::Board::shutdownPeripherals(true);
|
||||
bool plugged = Ion::USB::isPlugged();
|
||||
while (1) {
|
||||
Ion::Device::Battery::initGPIO();
|
||||
Ion::Device::USB::initGPIO();
|
||||
Ion::Device::LED::init();
|
||||
Ion::Device::Power::sleepConfiguration();
|
||||
Ion::Device::Board::shutdownPeripherals(true);
|
||||
Ion::Device::WakeUp::onUSBPlugging();
|
||||
Ion::Device::WakeUp::onChargingEvent();
|
||||
Ion::Device::Power::internalFlashSuspend(true);
|
||||
Ion::Device::USB::initGPIO();
|
||||
if (!plugged && Ion::USB::isPlugged()) {
|
||||
break;
|
||||
}
|
||||
plugged = Ion::USB::isPlugged();
|
||||
}
|
||||
Ion::Device::Board::setStandardFrequency(Ion::Device::Board::Frequency::High);
|
||||
abort_init();
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort_core(const char * text) {
|
||||
Ion::Timing::msleep(100);
|
||||
int counting;
|
||||
while (true) {
|
||||
counting = 0;
|
||||
if (Ion::Battery::level() == Ion::Battery::Charge::EMPTY) {
|
||||
abort_sleeping();
|
||||
abort_screen(text);
|
||||
}
|
||||
|
||||
Ion::USB::enable();
|
||||
Ion::Battery::Charge previous_state = Ion::Battery::level();
|
||||
while (!Ion::USB::isEnumerated()) {
|
||||
if (Ion::Battery::level() == Ion::Battery::Charge::LOW) {
|
||||
if (previous_state != Ion::Battery::Charge::LOW) {
|
||||
previous_state = Ion::Battery::Charge::LOW;
|
||||
counting = 0;
|
||||
}
|
||||
Ion::Timing::msleep(500);
|
||||
if (counting >= 20) {
|
||||
abort_sleeping();
|
||||
abort_screen(text);
|
||||
counting = -1;
|
||||
}
|
||||
counting++;
|
||||
|
||||
} else {
|
||||
if (previous_state == Ion::Battery::Charge::LOW) {
|
||||
previous_state = Ion::Battery::level();
|
||||
counting = 0;
|
||||
}
|
||||
Ion::Timing::msleep(100);
|
||||
if (counting >= 300) {
|
||||
abort_economy();
|
||||
counting = -1;
|
||||
}
|
||||
counting++;
|
||||
}
|
||||
}
|
||||
Ion::USB::DFU(false, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort_screen(const char * text){
|
||||
KDRect screen = KDRect(0, 0, Ion::Display::Width, Ion::Display::Height);
|
||||
Ion::Display::pushRectUniform(KDRect(0, 0, Ion::Display::Width, Ion::Display::Height), KDColor::RGB24(0xffffff));
|
||||
KDContext* ctx = KDIonContext::sharedContext();
|
||||
ctx->setOrigin(KDPointZero);
|
||||
ctx->setClippingRect(screen);
|
||||
ctx->drawString("UPSILON CRASH", KDPoint(90, 10), KDFont::LargeFont, KDColorRed, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("An error occurred", KDPoint(10, 30), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("If you have some important data, please", KDPoint(10, 45), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("use bit.ly/upsiBackup to backup them.", KDPoint(10, 60), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("YOU WILL LOSE ALL YOUR DATA", KDPoint(10, 85), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("→ You can try to reboot by presssing the", KDPoint(10, 110), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("reset button at the back of the calculator", KDPoint(10, 125), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("→ If Upsilon keeps crashing, you can connect", KDPoint(10, 140), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("the calculator to a computer or a phone", KDPoint(10, 160), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString("and try to reinstall Upsilon", KDPoint(10, 175), KDFont::SmallFont, KDColorBlack, KDColor::RGB24(0xffffff));
|
||||
ctx->drawString(text, KDPoint(220, 200), KDFont::SmallFont, KDColorRed, KDColor::RGB24(0xffffff));
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) abort() {
|
||||
abort_init();
|
||||
abort_screen("HARDFAULT");
|
||||
abort_core("HARDFAULT");
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) nmi_abort() {
|
||||
abort_init();
|
||||
abort_screen("NMIFAULT");
|
||||
abort_core("NMIFAULT");
|
||||
}
|
||||
|
||||
void __attribute__((noinline)) bf_abort() {
|
||||
abort_init();
|
||||
abort_screen("BUSFAULT");
|
||||
abort_core("BUSFAULT");
|
||||
}
|
||||
void __attribute__((noinline)) uf_abort() {
|
||||
abort_init();
|
||||
abort_screen("USAGEFAULT");
|
||||
abort_core("USAGEFAULT");
|
||||
}
|
||||
|
||||
/* When 'start' is executed, the external flash is supposed to be shutdown. We
|
||||
@@ -69,27 +224,27 @@ static void __attribute__((noinline)) jump_to_external_flash() {
|
||||
* (just in case 'start' was to be called from the external flash). */
|
||||
|
||||
void __attribute__((noinline)) start() {
|
||||
/* This is where execution starts after reset.
|
||||
/* This is where execution starts after reset.
|
||||
* Many things are not initialized yet so the code here has to pay attention. */
|
||||
|
||||
/* Copy data section to RAM
|
||||
/* Copy data section to RAM
|
||||
* The data section is R/W but its initialization value matters. It's stored
|
||||
* in Flash, but linked as if it were in RAM. Now's our opportunity to copy
|
||||
* it. Note that until then the data section (e.g. global variables) contains
|
||||
* garbage values and should not be used. */
|
||||
size_t dataSectionLength = (&_data_section_end_ram - &_data_section_start_ram);
|
||||
memcpy(&_data_section_start_ram, &_data_section_start_flash, dataSectionLength);
|
||||
size_t dataSectionLength = (&_data_section_end_ram - &_data_section_start_ram);
|
||||
memcpy(&_data_section_start_ram, &_data_section_start_flash, dataSectionLength);
|
||||
|
||||
/* Zero-out the bss section in RAM
|
||||
/* Zero-out the bss section in RAM
|
||||
* Until we do, any uninitialized global variable will be unusable. */
|
||||
size_t bssSectionLength = (&_bss_section_end_ram - &_bss_section_start_ram);
|
||||
memset(&_bss_section_start_ram, 0, bssSectionLength);
|
||||
size_t bssSectionLength = (&_bss_section_end_ram - &_bss_section_start_ram);
|
||||
memset(&_bss_section_start_ram, 0, bssSectionLength);
|
||||
|
||||
/* Initialize the FPU as early as possible.
|
||||
/* Initialize the FPU as early as possible.
|
||||
* For example, static C++ objects are very likely to manipulate float values */
|
||||
Ion::Device::Board::initFPU();
|
||||
Ion::Device::Board::initFPU();
|
||||
|
||||
/* Call static C++ object constructors
|
||||
/* Call static C++ object constructors
|
||||
* The C++ compiler creates an initialization function for each static object.
|
||||
* The linker then stores the address of each of those functions consecutively
|
||||
* between _init_array_start and _init_array_end. So to initialize all C++
|
||||
@@ -97,30 +252,30 @@ void __attribute__((noinline)) start() {
|
||||
* call the pointed function. */
|
||||
#define SUPPORT_CPP_GLOBAL_CONSTRUCTORS 0
|
||||
#if SUPPORT_CPP_GLOBAL_CONSTRUCTORS
|
||||
for (cxx_constructor * c = &_init_array_start; c<&_init_array_end; c++) {
|
||||
(*c)();
|
||||
}
|
||||
for (cxx_constructor* c = &_init_array_start; c < &_init_array_end; c++) {
|
||||
(*c)();
|
||||
}
|
||||
#else
|
||||
/* In practice, static initialized objects are a terrible idea. Since the init
|
||||
/* In practice, static initialized objects are a terrible idea. Since the init
|
||||
* order is not specified, most often than not this yields the dreaded static
|
||||
* init order fiasco. How about bypassing the issue altogether? */
|
||||
if (&_init_array_start != &_init_array_end) {
|
||||
abort();
|
||||
}
|
||||
if (&_init_array_start != &_init_array_end) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
Ion::Device::Board::init();
|
||||
Ion::Device::Board::init();
|
||||
|
||||
/* At this point, we initialized clocks and the external flash but no other
|
||||
/* At this point, we initialized clocks and the external flash but no other
|
||||
* peripherals. */
|
||||
|
||||
jump_to_external_flash();
|
||||
jump_to_external_flash();
|
||||
|
||||
abort();
|
||||
abort();
|
||||
}
|
||||
|
||||
void __attribute__((interrupt, noinline)) isr_systick() {
|
||||
auto t = Ion::Device::Timing::MillisElapsed;
|
||||
t++;
|
||||
Ion::Device::Timing::MillisElapsed = t;
|
||||
auto t = Ion::Device::Timing::MillisElapsed;
|
||||
t++;
|
||||
Ion::Device::Timing::MillisElapsed = t;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ namespace Ion {
|
||||
namespace Device {
|
||||
namespace USB {
|
||||
|
||||
void Calculator::PollAndReset(bool exitWithKeyboard) {
|
||||
void Calculator::PollAndReset(bool exitWithKeyboard, bool unlock, int level) {
|
||||
char serialNumber[Ion::Device::SerialNumber::Length+1];
|
||||
Ion::Device::SerialNumber::copy(serialNumber);
|
||||
Calculator c(serialNumber);
|
||||
|
||||
|
||||
/* Leave DFU mode if the Back key is pressed, the calculator unplugged or the
|
||||
* USB core soft-disconnected. */
|
||||
@@ -19,6 +20,10 @@ void Calculator::PollAndReset(bool exitWithKeyboard) {
|
||||
uint8_t exitKeyColumn = Ion::Device::Keyboard::columnForKey(exitKey);
|
||||
|
||||
Ion::Device::Keyboard::activateRow(exitKeyRow);
|
||||
c.m_dfuInterface.setLevel(level);
|
||||
if (unlock) {
|
||||
c.m_dfuInterface.unlockDfu();
|
||||
}
|
||||
|
||||
while (!(exitWithKeyboard && !c.isErasingAndWriting() && Ion::Device::Keyboard::columnIsActive(exitKeyColumn)) &&
|
||||
Ion::USB::isPlugged() &&
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace USB {
|
||||
|
||||
class Calculator : public Device {
|
||||
public:
|
||||
static void PollAndReset(bool exitWithKeyboard)
|
||||
static void PollAndReset(bool exitWithKeyboard, bool unlocked, int level)
|
||||
__attribute__((section(".dfu_entry_point"))) // Needed to pinpoint this symbol in the linker script
|
||||
__attribute__((used)) // Make sure this symbol is not discarded at link time
|
||||
; // Return true if reset is needed
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user