mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
Compare commits
51 Commits
upsilon-de
...
upsilon-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8a1bc6149 | ||
|
|
b304a2ff7d | ||
|
|
50ee8021f3 | ||
|
|
ed7e0bd915 | ||
|
|
84d88a3e8d | ||
|
|
00b5d4b9fe | ||
|
|
2aee07ae55 | ||
|
|
41b2b64d80 | ||
|
|
473b0bbfcb | ||
|
|
58ef8cb95d | ||
|
|
5dce215165 | ||
|
|
f2f44f0f6f | ||
|
|
fbe542e5bf | ||
|
|
0a1b3bcaee | ||
|
|
f6e937a927 | ||
|
|
c4ed8f84d3 | ||
|
|
8e1b311be0 | ||
|
|
89e51166e7 | ||
|
|
e4961563e9 | ||
|
|
e72b0f633e | ||
|
|
0550b66c03 | ||
|
|
e41910e2f8 | ||
|
|
d91ae29607 | ||
|
|
3b90969b42 | ||
|
|
bd207cb845 | ||
|
|
917ba7ce83 | ||
|
|
9c9758fcb6 | ||
|
|
83ce9d5e86 | ||
|
|
d4f0c7d3e8 | ||
|
|
2837b240e9 | ||
|
|
0906dc919b | ||
|
|
9cda9d9e59 | ||
|
|
553f3fc682 | ||
|
|
9fdedecbff | ||
|
|
83c63a7011 | ||
|
|
9636964cb9 | ||
|
|
69d6ad5205 | ||
|
|
f9a123cc08 | ||
|
|
56f735e302 | ||
|
|
0a5e9e0889 | ||
|
|
8c949d7048 | ||
|
|
2f7edc5024 | ||
|
|
cd40938b26 | ||
|
|
0b54bf13f4 | ||
|
|
f5f11c6478 | ||
|
|
efda561425 | ||
|
|
15c96cefa6 | ||
|
|
400d03ebdb | ||
|
|
6f48adde7d | ||
|
|
3a573b1204 | ||
|
|
48598296cf |
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Omega is not working like it should? Let us know!
|
||||
about: Upsilon is not working like it should? Let us know!
|
||||
title: ''
|
||||
labels: 'Status: Triage, Type: Bug'
|
||||
assignees: ''
|
||||
@@ -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):**
|
||||
- Omega Version: [go to settings > about > Omega Version and type the version here]
|
||||
**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]
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for Omega
|
||||
about: Suggest an idea for Upsilon
|
||||
title: ''
|
||||
labels: 'Status: Triage, Type: Feature'
|
||||
assignees: ''
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
---
|
||||
name: OMEGA BETA ONLY - Bug report
|
||||
about: Omega 1.21 is not working like it should? Let us know!
|
||||
title: "[BETA-1.21] …"
|
||||
labels: 'Status: Triage, Type: Bug'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
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):**
|
||||
- Omega Version: [go to settings > about > Omega Version and type the version here]
|
||||
- Discord username: ..........#....
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Problems during installation
|
||||
about: Need help to install Omega?
|
||||
about: Need help to install Upsilon?
|
||||
title: ''
|
||||
labels: 'Status: Triage, Type: Installation issue'
|
||||
assignees: ''
|
||||
@@ -16,4 +16,4 @@ Copy/paste the logs here (If you have some)
|
||||
```
|
||||
|
||||
**Environment**
|
||||
- Omega Version: {go to settings > about > Omega Version and type the version here}
|
||||
- Upsilon Version: {go to settings > about > Upsilon Version and type the version here}
|
||||
|
||||
2
.github/workflows/ci-workflow.yml
vendored
2
.github/workflows/ci-workflow.yml
vendored
@@ -140,7 +140,7 @@ jobs:
|
||||
steps:
|
||||
- uses: numworks/setup-emscripten@v1
|
||||
with:
|
||||
sdk: latest-upstream
|
||||
sdk: 1.40.1-fastcomp
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
1
.github/workflows/metric-workflow.yml
vendored
1
.github/workflows/metric-workflow.yml
vendored
@@ -31,7 +31,6 @@ jobs:
|
||||
- name: Add comment
|
||||
uses: actions/github-script@v3.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.OMEGA_ROBOT_TOKEN }}
|
||||
script: |
|
||||
await github.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
||||
[submodule "apps/rpn"]
|
||||
path = apps/rpn
|
||||
url = https://github.com/Omega-Numworks/Omega-RPN.git
|
||||
url = https://github.com/Lauryy06/Upsilon-RPN.git
|
||||
[submodule "apps/atomic"]
|
||||
path = apps/atomic
|
||||
url = https://github.com/Lauryy06/atomic
|
||||
|
||||
17
Makefile
17
Makefile
@@ -13,7 +13,18 @@ include build/variants.mak
|
||||
include build/helpers.mk
|
||||
|
||||
ifeq (${MODEL}, n0100)
|
||||
EPSILON_APPS := $(filter-out reader,$(EPSILON_APPS))
|
||||
ifeq ($(filter reader,$(apps_list)),)
|
||||
$(warning reader app included, removing it on n0100. )
|
||||
EPSILON_APPS := $(filter-out reader,$(EPSILON_APPS))
|
||||
endif
|
||||
ifneq ($(words $(EPSILON_I18N)), 1)
|
||||
$(warning Only use 1 language on n0100, defaulting to en. )
|
||||
EPSILON_I18N := en
|
||||
endif
|
||||
ifeq ($(INCLUDE_ULAB), 1)
|
||||
$(warning Removing uLab on n0100. )
|
||||
INCLUDE_ULAB := 0
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (${MODEL}, n0110)
|
||||
@@ -26,6 +37,10 @@ ifdef FORCE_EXTERNAL
|
||||
apps_list = ${EPSILON_APPS}
|
||||
endif
|
||||
|
||||
ifeq ($(INCLUDE_ULAB), 1)
|
||||
SFLAGS += -DINCLUDE_ULAB
|
||||
endif
|
||||
|
||||
ifdef HOME_DISPLAY_EXTERNALS
|
||||
ifneq ($(filter external,$(apps_list)),)
|
||||
SFLAGS += -DHOME_DISPLAY_EXTERNALS
|
||||
|
||||
@@ -126,7 +126,7 @@ Vous aurez besoin de devkitPro et de devkitARM disponible dans votre `$PATH` (in
|
||||
```bash
|
||||
git clone --recursive https://github.com/Lauryy06/Upsilon.git
|
||||
cd Upsilon
|
||||
git checkout --recursive omega-dev
|
||||
git checkout --recursive upsilon-dev
|
||||
make PLATFORM=simulator TARGET=3ds -j
|
||||
```
|
||||
|
||||
@@ -143,6 +143,10 @@ Si vous avez besoin d'aide, n'hésitez pas à rejoindre notre serveur discord :
|
||||
<a href="https://discord.gg/Q9buEMduXG"><p align="center"><img alt="Omega Banner Discord" src="https://user-images.githubusercontent.com/12123721/86287349-54ef5800-bbe8-11ea-80c1-34eb1f93eebd.png" /></p></a>
|
||||
---
|
||||
|
||||
## Liens utiles
|
||||
* [Upsilon external (pour installer des applications supplémentaires et des fonds d'écran)](https://lauryy06.github.io/Upsilon-External/)
|
||||
* [Documentation d'ulab](https://micropython-ulab.readthedocs.io/en/latest/)
|
||||
|
||||
## Contribution
|
||||
|
||||
Pour contribuer, merci de lire le [Wiki d'Omega](https://github.com/Omega-Numworks/Omega/wiki/Contributing), les mêmes règles s'appliquent ici.
|
||||
|
||||
15
README.md
15
README.md
@@ -7,7 +7,7 @@
|
||||
<a href="https://discord.gg/Q9buEMduXG"><img alt="Discord" src="https://img.shields.io/discord/663420259851567114?color=blue&labelColor=292929&label=chat%20-%20discord&logo=discord&style=for-the-badge" /></a>
|
||||
</p>
|
||||
|
||||
> Vous ne comprenez pas l'anglais ? vous êtes francophone ? Regardez le [*LISEZ-MOI* français](./README.fr.md) !
|
||||
> Vous ne comprenez pas l'anglais ? Vous êtes francophone ? Regardez le [*LISEZ-MOI* français](./README.fr.md) !
|
||||
|
||||
## About
|
||||
|
||||
@@ -18,7 +18,7 @@ Upsilon is a fork of Omega, an user-made OS that runs on the Numworks calculator
|
||||
|
||||
### Some new features
|
||||
- Enhancements for the Kandinsky python module
|
||||
- A support for wallpapers
|
||||
- Support for wallpapers
|
||||
- Exernal apps
|
||||
- A custom theme
|
||||
- Operator overload for python
|
||||
@@ -240,7 +240,7 @@ You need devkitPro and devkitARM installed and in your path (instructions [here]
|
||||
```bash
|
||||
git clone --recursive https://github.com/Lauryy06/Upsilon.git
|
||||
cd Upsilon
|
||||
git checkout --recursive omega-dev
|
||||
git checkout --recursive upsilon-dev
|
||||
make PLATFORM=simulator TARGET=3ds -j
|
||||
```
|
||||
You can then put epsilon.3dsx on a SD card to run it from the HBC or use 3dslink to launch it over the network:
|
||||
@@ -259,15 +259,18 @@ Don't forget to put your pseudo instead of `{your pseudo, max 15 char}`. If you
|
||||
|
||||
<br>
|
||||
|
||||
If you need help, you can join our Discord server here : https://discord.gg/Q9buEMduXG
|
||||
If you need help, you can join our Discord server here : https://discord.gg/NFvzdCBTQn
|
||||
|
||||
<a href="https://discord.gg/Q9buEMduXG"><p align="center"><img alt="Omega Banner Discord" src="https://user-images.githubusercontent.com/12123721/86287349-54ef5800-bbe8-11ea-80c1-34eb1f93eebd.png" /></p></a>
|
||||
<a href="https://discord.gg/NFvzdCBTQn"><p align="center"><img alt="Omega Banner Discord" src="https://user-images.githubusercontent.com/12123721/86287349-54ef5800-bbe8-11ea-80c1-34eb1f93eebd.png" /></p></a>
|
||||
---
|
||||
## Useful links
|
||||
* [Upsilon external (to install additional apps and wallpapers)](https://lauryy06.github.io/Upsilon-External/)
|
||||
* [Ulab documentation](https://micropython-ulab.readthedocs.io/en/latest/)
|
||||
|
||||
## Contributing
|
||||
|
||||
To contribute, please refer to [Omega's Wiki](https://github.com/Omega-Numworks/Omega/wiki/Contributing), the same rules apply here.
|
||||
|
||||
|
||||
## Related repositories
|
||||
|
||||
Here are the main links toward Omega's different websites and repositories, that have been used for the creation of Upsilon.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Submodule apps/atomic updated: 64f2e38ed1...69f7a06ba5
@@ -75,13 +75,13 @@ void BatteryView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
assert(!m_isPlugged);
|
||||
// Low: Quite empty battery
|
||||
ctx->fillRect(KDRect(batteryInsideX, 0, 2*k_elementWidth, k_batteryHeight), Palette::BatteryLow);
|
||||
ctx->fillRect(KDRect(3*k_elementWidth+k_separatorThickness, 0, k_batteryWidth-5*k_elementWidth-2*k_separatorThickness, k_batteryHeight), Palette::BatteryInCharge);
|
||||
ctx->fillRect(KDRect(3*k_elementWidth+k_separatorThickness, 0, k_batteryWidth-5*k_elementWidth-2*k_separatorThickness, k_batteryHeight), KDColor::blend(Palette::Toolbar, Palette::Battery, 128));
|
||||
} else if (m_chargeState == Ion::Battery::Charge::SOMEWHERE_INBETWEEN) {
|
||||
assert(!m_isPlugged);
|
||||
// Middle: Half full battery
|
||||
constexpr KDCoordinate middleChargeWidth = batteryInsideWidth/2;
|
||||
ctx->fillRect(KDRect(batteryInsideX, 0, middleChargeWidth, k_batteryHeight), Palette::Battery);
|
||||
ctx->fillRect(KDRect(batteryInsideX+middleChargeWidth, 0, middleChargeWidth, k_batteryHeight), Palette::BatteryInCharge);
|
||||
ctx->fillRect(KDRect(batteryInsideX+middleChargeWidth, 0, middleChargeWidth, k_batteryHeight), KDColor::blend(Palette::Toolbar, Palette::Battery, 128));
|
||||
} else {
|
||||
assert(m_chargeState == Ion::Battery::Charge::FULL);
|
||||
// Full but not plugged: Full battery
|
||||
|
||||
@@ -29,6 +29,12 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
|
||||
|
||||
Context * context = App::app()->localContext();
|
||||
Preferences * preferences = Preferences::sharedPreferences();
|
||||
Poincare::ExpressionNode::ReductionContext reductionContext = Poincare::ExpressionNode::ReductionContext(context,
|
||||
preferences->complexFormat(), preferences->angleUnit(),
|
||||
GlobalPreferences::sharedGlobalPreferences()->unitFormat(),
|
||||
ExpressionNode::ReductionTarget::SystemForApproximation,
|
||||
ExpressionNode::SymbolicComputation::ReplaceAllDefinedSymbolsWithDefinition,
|
||||
Poincare::ExpressionNode::UnitConversion::Default);
|
||||
|
||||
PoincareHelpers::Reduce(&m_expression, context, ExpressionNode::ReductionTarget::SystemForAnalysis);
|
||||
|
||||
@@ -46,60 +52,108 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
|
||||
Expression a = polynomialCoefficients[2];
|
||||
Expression b = polynomialCoefficients[1];
|
||||
Expression c = polynomialCoefficients[0];
|
||||
|
||||
bool aIsNotOne = !(a.type() == ExpressionNode::Type::Rational && static_cast<const Rational &>(a).isOne());
|
||||
|
||||
|
||||
Expression delta = Subtraction::Builder(Power::Builder(b.clone(), Rational::Builder(2)), Multiplication::Builder(Rational::Builder(4), a.clone(), c.clone()));
|
||||
PoincareHelpers::Simplify(&delta, context, ExpressionNode::ReductionTarget::SystemForApproximation);
|
||||
|
||||
Expression alpha = Opposite::Builder(Division::Builder(b.clone(), Multiplication::Builder(Rational::Builder(2), a.clone())));
|
||||
PoincareHelpers::Simplify(&alpha, context, ExpressionNode::ReductionTarget::User);
|
||||
// Alpha is -b/2a, but because after we use -α, we immediately store -α=-(-b/2a)=b/2a.
|
||||
Expression minusAlpha = Division::Builder(b.clone(), Multiplication::Builder(Rational::Builder(2), a.clone()));
|
||||
PoincareHelpers::Reduce(&minusAlpha, context, ExpressionNode::ReductionTarget::SystemForApproximation);
|
||||
|
||||
Expression beta = Opposite::Builder(Division::Builder(delta.clone(), Multiplication::Builder(Rational::Builder(4), a.clone())));
|
||||
PoincareHelpers::Simplify(&beta, context, ExpressionNode::ReductionTarget::User);
|
||||
// Same thing for β
|
||||
Expression minusBeta = Division::Builder(delta.clone(), Multiplication::Builder(Rational::Builder(4), a.clone()));
|
||||
PoincareHelpers::Reduce(&minusBeta, context, ExpressionNode::ReductionTarget::SystemForApproximation);
|
||||
|
||||
enum MultiplicationTypeForA {
|
||||
Nothing,
|
||||
Minus,
|
||||
Parenthesis,
|
||||
Normal
|
||||
};
|
||||
|
||||
MultiplicationTypeForA multiplicationTypeForA;
|
||||
|
||||
if (a.type() == ExpressionNode::Type::Rational && static_cast<const Rational &>(a).isOne()) {
|
||||
multiplicationTypeForA = MultiplicationTypeForA::Nothing;
|
||||
}
|
||||
else if(a.type() == ExpressionNode::Type::Rational && static_cast<const Rational &>(a).isMinusOne()){
|
||||
multiplicationTypeForA = MultiplicationTypeForA::Minus;
|
||||
}
|
||||
else if (a.type() == ExpressionNode::Type::Addition) {
|
||||
multiplicationTypeForA = MultiplicationTypeForA::Parenthesis;
|
||||
}
|
||||
else {
|
||||
multiplicationTypeForA = MultiplicationTypeForA::Normal;
|
||||
}
|
||||
|
||||
PoincareHelpers::Simplify(&a, context, ExpressionNode::ReductionTarget::User);
|
||||
|
||||
/*
|
||||
* Because when can't apply reduce or simplify to keep the canonised
|
||||
* we must beautify the expression manually
|
||||
* Because when can't apply reduce or simplify to keep the
|
||||
* canonized form we must beautify the expression manually
|
||||
*/
|
||||
|
||||
Expression canonised;
|
||||
if (alpha.type() == ExpressionNode::Type::Opposite) {
|
||||
canonised = Addition::Builder(Symbol::Builder("x", strlen("x")), alpha.childAtIndex(0).clone());
|
||||
}
|
||||
else {
|
||||
canonised = Subtraction::Builder(Symbol::Builder("x", strlen("x")), alpha.clone());
|
||||
}
|
||||
canonised = Power::Builder(Parenthesis::Builder(canonised.clone()), Rational::Builder(2));
|
||||
if (aIsNotOne) {
|
||||
canonised = Multiplication::Builder(a.clone(), canonised.clone());
|
||||
}
|
||||
if (beta.type() == ExpressionNode::Type::Opposite) {
|
||||
canonised = Subtraction::Builder(canonised.clone(), beta.childAtIndex(0).clone());
|
||||
}
|
||||
else {
|
||||
canonised = Addition::Builder(canonised.clone(), beta.clone());
|
||||
}
|
||||
Expression xMinusAlphaPowerTwo;
|
||||
Expression alpha = getOppositeIfExists(minusAlpha, &reductionContext);
|
||||
|
||||
if (alpha.isUninitialized()) {
|
||||
PoincareHelpers::Simplify(&minusAlpha, context, ExpressionNode::ReductionTarget::User);
|
||||
xMinusAlphaPowerTwo = Power::Builder(Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), minusAlpha)), Rational::Builder(2));
|
||||
}
|
||||
else {
|
||||
PoincareHelpers::Simplify(&alpha, context, ExpressionNode::ReductionTarget::User);
|
||||
xMinusAlphaPowerTwo = Power::Builder(Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), alpha)), Rational::Builder(2));
|
||||
}
|
||||
|
||||
Expression xMinusAlphaPowerTwoWithFactor;
|
||||
|
||||
switch (multiplicationTypeForA)
|
||||
{
|
||||
case MultiplicationTypeForA::Nothing:
|
||||
xMinusAlphaPowerTwoWithFactor = xMinusAlphaPowerTwo;
|
||||
break;
|
||||
case MultiplicationTypeForA::Minus:
|
||||
xMinusAlphaPowerTwoWithFactor = Multiplication::Builder(a.clone(), xMinusAlphaPowerTwo);
|
||||
break;
|
||||
case MultiplicationTypeForA::Parenthesis:
|
||||
xMinusAlphaPowerTwoWithFactor = Multiplication::Builder(Parenthesis::Builder(a.clone()), xMinusAlphaPowerTwo);
|
||||
break;
|
||||
case MultiplicationTypeForA::Normal:
|
||||
xMinusAlphaPowerTwoWithFactor = Multiplication::Builder(a.clone(), xMinusAlphaPowerTwo);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
Expression canonized;
|
||||
Expression beta = getOppositeIfExists(minusBeta, &reductionContext);
|
||||
if (beta.isUninitialized()) {
|
||||
PoincareHelpers::Simplify(&minusBeta, context, ExpressionNode::ReductionTarget::User);
|
||||
canonized = Subtraction::Builder(xMinusAlphaPowerTwoWithFactor, minusBeta);
|
||||
}
|
||||
else {
|
||||
PoincareHelpers::Simplify(&beta, context, ExpressionNode::ReductionTarget::User);
|
||||
canonized = Addition::Builder(xMinusAlphaPowerTwoWithFactor, beta);
|
||||
}
|
||||
|
||||
Expression x0;
|
||||
Expression x1;
|
||||
|
||||
|
||||
if (delta.nullStatus(context) == ExpressionNode::NullStatus::Null) {
|
||||
// x0 = x1 = -b/(2a)
|
||||
x0 = Division::Builder(Opposite::Builder(b), Multiplication::Builder(Rational::Builder(2), a));
|
||||
x0 = Division::Builder(Opposite::Builder(b.clone()), Multiplication::Builder(Rational::Builder(2), a.clone()));
|
||||
m_numberOfSolutions = 1;
|
||||
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
|
||||
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::SystemForApproximation);
|
||||
}
|
||||
else {
|
||||
// x0 = (-b-sqrt(delta))/(2a)
|
||||
x0 = Division::Builder(Subtraction::Builder(Opposite::Builder(b.clone()), SquareRoot::Builder(delta.clone())), Multiplication::Builder(Rational::Builder(2), a.clone()));
|
||||
// x1 = (-b+sqrt(delta))/(2a)
|
||||
x1 = Division::Builder(Addition::Builder(Opposite::Builder(b), SquareRoot::Builder(delta.clone())), Multiplication::Builder(Rational::Builder(2), a));
|
||||
x1 = Division::Builder(Addition::Builder(Opposite::Builder(b.clone()), SquareRoot::Builder(delta.clone())), Multiplication::Builder(Rational::Builder(2), a.clone()));
|
||||
m_numberOfSolutions = 2;
|
||||
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
|
||||
PoincareHelpers::Simplify(&x1, context, ExpressionNode::ReductionTarget::User);
|
||||
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::SystemForApproximation);
|
||||
PoincareHelpers::Simplify(&x1, context, ExpressionNode::ReductionTarget::SystemForApproximation);
|
||||
if (x0.type() == ExpressionNode::Type::Unreal) {
|
||||
assert(x1.type() == ExpressionNode::Type::Unreal);
|
||||
m_numberOfSolutions = 0;
|
||||
@@ -109,40 +163,87 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
|
||||
Expression factorized;
|
||||
|
||||
if (m_numberOfSolutions == 2) {
|
||||
Expression firstFactor;
|
||||
Expression secondFactor;
|
||||
|
||||
Expression x0Opposite = getOppositeIfExists(x0, &reductionContext);
|
||||
if (x0Opposite.isUninitialized()) {
|
||||
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
|
||||
firstFactor = Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0);
|
||||
}
|
||||
else {
|
||||
PoincareHelpers::Simplify(&x0Opposite, context, ExpressionNode::ReductionTarget::User);
|
||||
firstFactor = Addition::Builder(Symbol::Builder("x", strlen("x")), x0Opposite);
|
||||
}
|
||||
if (x0.type() == ExpressionNode::Type::Opposite) {
|
||||
factorized = Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), x0.childAtIndex(0).clone()));
|
||||
}
|
||||
else {
|
||||
factorized = Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0.clone()));
|
||||
}
|
||||
|
||||
if (x1.type() == ExpressionNode::Type::Opposite) {
|
||||
factorized = Multiplication::Builder(factorized.clone(), Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), x1.childAtIndex(0).clone())));
|
||||
|
||||
Expression x1Opposite = getOppositeIfExists(x1, &reductionContext);
|
||||
if (x1Opposite.isUninitialized()) {
|
||||
PoincareHelpers::Simplify(&x1, context, ExpressionNode::ReductionTarget::User);
|
||||
secondFactor = Subtraction::Builder(Symbol::Builder("x", strlen("x")), x1);
|
||||
}
|
||||
else {
|
||||
factorized = Multiplication::Builder(factorized.clone(), Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), x1.clone())));
|
||||
PoincareHelpers::Simplify(&x1Opposite, context, ExpressionNode::ReductionTarget::User);
|
||||
secondFactor = Addition::Builder(Symbol::Builder("x", strlen("x")), x1Opposite);
|
||||
}
|
||||
|
||||
if (aIsNotOne) {
|
||||
factorized = Multiplication::Builder(a.clone(), factorized.clone());
|
||||
Expression solutionProduct = Multiplication::Builder(Parenthesis::Builder(firstFactor), Parenthesis::Builder(secondFactor));
|
||||
switch (multiplicationTypeForA)
|
||||
{
|
||||
case MultiplicationTypeForA::Nothing:
|
||||
factorized = solutionProduct;
|
||||
break;
|
||||
case MultiplicationTypeForA::Minus:
|
||||
factorized = Multiplication::Builder(a.clone(), solutionProduct);
|
||||
break;
|
||||
case MultiplicationTypeForA::Parenthesis:
|
||||
factorized = Multiplication::Builder(Parenthesis::Builder(a.clone()), solutionProduct);
|
||||
break;
|
||||
case MultiplicationTypeForA::Normal:
|
||||
factorized = Multiplication::Builder(a.clone(), solutionProduct);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m_numberOfSolutions == 1) {
|
||||
if (x0.type() == ExpressionNode::Type::Opposite) {
|
||||
factorized = Power::Builder(Parenthesis::Builder(Addition::Builder(Symbol::Builder("x", strlen("x")), x0.childAtIndex(0).clone())), Rational::Builder(2));
|
||||
Expression x0Opposite = getOppositeIfExists(x0, &reductionContext);
|
||||
Expression factor;
|
||||
if (x0Opposite.isUninitialized()) {
|
||||
PoincareHelpers::Simplify(&x0, context, ExpressionNode::ReductionTarget::User);
|
||||
factor = Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0);
|
||||
}
|
||||
else {
|
||||
factorized = Power::Builder(Parenthesis::Builder(Subtraction::Builder(Symbol::Builder("x", strlen("x")), x0.clone())), Rational::Builder(2));
|
||||
PoincareHelpers::Simplify(&x0Opposite, context, ExpressionNode::ReductionTarget::User);
|
||||
factor = Addition::Builder(Symbol::Builder("x", strlen("x")), x0Opposite);
|
||||
}
|
||||
|
||||
if (aIsNotOne) {
|
||||
factorized = Multiplication::Builder(a.clone(), factorized.clone());
|
||||
Expression solutionProduct = Power::Builder(Parenthesis::Builder(factor), Rational::Builder(2));
|
||||
switch (multiplicationTypeForA)
|
||||
{
|
||||
case MultiplicationTypeForA::Nothing:
|
||||
factorized = solutionProduct;
|
||||
break;
|
||||
case MultiplicationTypeForA::Minus:
|
||||
factorized = Multiplication::Builder(a.clone(), solutionProduct);
|
||||
break;
|
||||
case MultiplicationTypeForA::Parenthesis:
|
||||
factorized = Multiplication::Builder(Parenthesis::Builder(a.clone()), solutionProduct);
|
||||
break;
|
||||
case MultiplicationTypeForA::Normal:
|
||||
factorized = Multiplication::Builder(a.clone(), solutionProduct);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PoincareHelpers::Simplify(&delta, context, ExpressionNode::ReductionTarget::User);
|
||||
|
||||
m_layouts[0] = PoincareHelpers::CreateLayout(canonised);
|
||||
m_layouts[0] = PoincareHelpers::CreateLayout(canonized);
|
||||
if (m_numberOfSolutions > 0) {
|
||||
m_layouts[1] = PoincareHelpers::CreateLayout(factorized);
|
||||
m_layouts[2] = PoincareHelpers::CreateLayout(delta);
|
||||
@@ -156,6 +257,27 @@ void SecondDegreeListController::setExpression(Poincare::Expression e) {
|
||||
}
|
||||
}
|
||||
|
||||
Expression SecondDegreeListController::getOppositeIfExists(Expression e, Poincare::ExpressionNode::ReductionContext * reductionContext) {
|
||||
if (e.isNumber() && e.sign(reductionContext->context()) == ExpressionNode::Sign::Negative) {
|
||||
Number n = static_cast<Number&>(e);
|
||||
return std::move(n.setSign(ExpressionNode::Sign::Positive));
|
||||
}
|
||||
else if (e.type() == ExpressionNode::Type::Multiplication && e.numberOfChildren() > 0 && e.childAtIndex(0).isNumber() && e.childAtIndex(0).sign(reductionContext->context()) == ExpressionNode::Sign::Negative) {
|
||||
Multiplication m = static_cast<Multiplication&>(e);
|
||||
if (m.childAtIndex(0).type() == ExpressionNode::Type::Rational && static_cast<Rational&>(e).isMinusOne()) {
|
||||
// The negative numeral factor is -1, we just remove it
|
||||
m.removeChildAtIndexInPlace(0);
|
||||
} else {
|
||||
Expression firstChild = m.childAtIndex(0);
|
||||
Number n = static_cast<Number&>(firstChild);
|
||||
m.childAtIndex(0).setChildrenInPlace(n.setSign(ExpressionNode::Sign::Positive));
|
||||
}
|
||||
PoincareHelpers::Simplify(&m, reductionContext->context(), ExpressionNode::ReductionTarget::User);
|
||||
return std::move(m);
|
||||
}
|
||||
return Expression();
|
||||
}
|
||||
|
||||
I18n::Message SecondDegreeListController::messageAtIndex(int index) {
|
||||
if (m_numberOfSolutions > 0) {
|
||||
if (index == 0) {
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
void setExpression(Poincare::Expression e) override;
|
||||
|
||||
private:
|
||||
Poincare::Expression getOppositeIfExists(Poincare::Expression e, Poincare::ExpressionNode::ReductionContext * reductionContext);
|
||||
I18n::Message messageAtIndex(int index) override;
|
||||
int m_numberOfSolutions;
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ void HistoryViewCell::reloadSubviewHighlight() {
|
||||
m_ellipsis.setHighlighted(false);
|
||||
if (isHighlighted()) {
|
||||
if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Input) {
|
||||
m_inputView.setExpressionBackgroundColor(Palette::ListCellBackgroundSelected);
|
||||
m_inputView.setExpressionBackgroundColor(Palette::Select);
|
||||
} else if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Output) {
|
||||
m_scrollableOutputView.evenOddCell()->setHighlighted(true);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
apps += Code::App
|
||||
app_headers += apps/code/app.h
|
||||
|
||||
SFLAGS += -DHAS_CODE
|
||||
|
||||
app_code_src = $(addprefix apps/code/,\
|
||||
app.cpp \
|
||||
console_controller.cpp \
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
VariableBoxController * variableBoxController() { return &m_variableBoxController; }
|
||||
|
||||
static constexpr int k_pythonHeapSize = 100000;
|
||||
static constexpr int k_pythonHeapSize = 67000;
|
||||
|
||||
private:
|
||||
/* Python delegate:
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Abrunden"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "Mantisse und Exponent von x: (m,e)"
|
||||
PythonGamma = "Gamma-Funktion"
|
||||
PythonGetKeys = "Gedrückte Tasten erhalten"
|
||||
PythonGetPalette = "Themenpalette erhalten"
|
||||
PythonGetPixel = "Farbe von Pixel (x,y) zurückgeben"
|
||||
PythonGetrandbits = "Ganzzahl mit k Zufallsbits"
|
||||
@@ -77,11 +78,19 @@ PythonImportMatplotlibPyplot = "Matplotlib.pyplot-Modul importieren"
|
||||
PythonImportNumpy = "Ulab.numpy-Modul importieren"
|
||||
PythonImportScipy = "Ulab.scipy-Modul importieren"
|
||||
PythonImportOs = "OS-Modul importieren"
|
||||
PythonImportSys = "SYS-Modul importieren"
|
||||
PythonOsUname = "Informationen über das System holen"
|
||||
PythonOsGetlogin = "Benutzernamen holen"
|
||||
PythonOsRemove = "Datei namens Dateiname entfernen"
|
||||
PythonOsRename = "Datei umbenennen von Alt nach Neu"
|
||||
PythonOsListdir = "Dateien im Speicher auflisten"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
PythonImportTime = "Time-Modul importieren"
|
||||
PythonImportTurtle = "Turtle-Modul importieren"
|
||||
PythonIndex = "Index des ersten x-Vorkommens"
|
||||
@@ -145,7 +154,7 @@ PythonSleep = "Ausführung aussetzen für t Sekunden"
|
||||
PythonLocalTime = "Zeit in Tupel umwandeln"
|
||||
PythonMktime = "Tupel in Zeit umwandeln"
|
||||
PythonTime = "Abrufen des aktuellen Zeitstempels"
|
||||
PythonSetLocaltime = "Zeit aus einem Tupel von localtime()"
|
||||
PythonSetLocaltime = "Zeit aus einem Tupel einstellen"
|
||||
PythonRTCmode = "Aktuellen RTC-Modus abrufen"
|
||||
PythonSetRTCmode = "RTC-Modus festlegen"
|
||||
PythonSort = "Die Liste sortieren"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Floor"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "Mantissa and exponent of x: (m,e)"
|
||||
PythonGamma = "Gamma function"
|
||||
PythonGetKeys = "Get keys pressed"
|
||||
PythonGetPalette = "Get theme palette"
|
||||
PythonGetPixel = "Return pixel (x,y) color"
|
||||
PythonGetrandbits = "Integer with k random bits"
|
||||
@@ -139,7 +140,7 @@ PythonSleep = "Suspend the execution for t seconds"
|
||||
PythonLocalTime = "Convert time into tuple"
|
||||
PythonMktime = "Convert tuple into time"
|
||||
PythonTime = "Get the current timestamp"
|
||||
PythonSetLocaltime = "Set time from a tuple of localtime()"
|
||||
PythonSetLocaltime = "Set time from a tuple"
|
||||
PythonRTCmode = "Get current RTC mode"
|
||||
PythonSetRTCmode = "Set RTC mode"
|
||||
PythonSort = "Sort the list"
|
||||
@@ -175,11 +176,19 @@ PythonTurtleWrite = "Display a text"
|
||||
PythonUniform = "Floating point number in [a,b]"
|
||||
PythonImportTime = "Import time module"
|
||||
PythonImportOs = "Import os module"
|
||||
PythonImportSys = "Import sys module"
|
||||
PythonOsUname = "Get infos about the system"
|
||||
PythonOsGetlogin = "Get username"
|
||||
PythonOsRemove = "Remove file named filename"
|
||||
PythonOsRename = "Rename file oldname to newname"
|
||||
PythonOsListdir = "List files in memory"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
PythonTimePrefix = "time module function prefix"
|
||||
PythonTimeSleep = "Wait for n second"
|
||||
PythonMonotonic = "Return monotonic time"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Floor"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "Mantissa and exponent of x: (m,e)"
|
||||
PythonGamma = "Gamma function"
|
||||
PythonGetKeys = "Obtener teclas presionadas"
|
||||
PythonGetPalette = "Get theme palette"
|
||||
PythonGetPixel = "Return pixel (x,y) color"
|
||||
PythonGetrandbits = "Integer with k random bits"
|
||||
@@ -139,7 +140,7 @@ PythonSleep = "Suspend the execution for t seconds"
|
||||
PythonLocalTime = "Convertir el tiempo en tupla"
|
||||
PythonMktime = "Convertir tupla en tiempo"
|
||||
PythonTime = "Obtener la marca de tiempo actual"
|
||||
PythonSetLocaltime = "Establecer tiempo desde una tupla de localtime()"
|
||||
PythonSetLocaltime = "Establecer tiempo desde una tupla"
|
||||
PythonRTCmode = "Obtener el modo RTC actual"
|
||||
PythonSetRTCmode = "Establecer modo RTC"
|
||||
PythonSort = "Sort the list"
|
||||
@@ -175,11 +176,19 @@ PythonTurtleWrite = "Display a text"
|
||||
PythonUniform = "Floating point number in [a,b]"
|
||||
PythonImportTime = "Import time module"
|
||||
PythonImportOs = "Import os module"
|
||||
PythonImportSys = "Import sys module"
|
||||
PythonOsUname = " Información del sistema "
|
||||
PythonOsGetlogin = "Get username"
|
||||
PythonOsRemove = "Eliminar un archivo"
|
||||
PythonOsRename = "Renombrar archivo"
|
||||
PythonOsListdir = "Archivos de la lista"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
PythonTimePrefix = "time module function prefix"
|
||||
PythonTimeSleep = "Esperar n segundos"
|
||||
PythonMonotonic = "Tiempo monótono de retorno"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Partie entière"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "Mantisse et exposant de x : (m,e)"
|
||||
PythonGamma = "Fonction gamma"
|
||||
PythonGetKeys = "Obtenir les touches pressées"
|
||||
PythonGetPalette = "Obtient la palette du thème"
|
||||
PythonGetPixel = "Renvoie la couleur du pixel (x,y)"
|
||||
PythonGetrandbits = "Nombre aléatoire sur k bits"
|
||||
@@ -139,7 +140,7 @@ PythonSleep = "Suspend l'exécution t secondes"
|
||||
PythonLocalTime = "Convertir le temps en tuple"
|
||||
PythonMktime = "Convertir le tuple en temps"
|
||||
PythonTime = "Obtenir l'horodatage actuel"
|
||||
PythonSetLocaltime = "Définir l'heure à partir d'un tuple de localtime()"
|
||||
PythonSetLocaltime = "Définir l'heure à partir d'un tuple"
|
||||
PythonRTCmode = "Obtenir le mode RTC actuel"
|
||||
PythonSetRTCmode = "Définir le mode RTC"
|
||||
PythonSort = "Trie la liste"
|
||||
@@ -175,11 +176,19 @@ PythonTurtleWrite = "Affiche un texte"
|
||||
PythonUniform = "Nombre décimal dans [a,b]"
|
||||
PythonImportTime = "Importation du module temps"
|
||||
PythonImportOs = "Importation du module os"
|
||||
PythonImportSys = "Importation du module sys"
|
||||
PythonOsUname = "Donne des infos sur le système"
|
||||
PythonOsGetlogin = "Donne le nom d'utilisateur"
|
||||
PythonOsRemove = "Supprime le fichier nommé filename"
|
||||
PythonOsRename = "Renomme oldname en newname"
|
||||
PythonOsListdir = "Liste les fichiers"
|
||||
PythonSysExit = "Termine le programme"
|
||||
PythonSysPrintexception = "Imprime une exception"
|
||||
PythonSysByteorder = "L'ordre des octets du système"
|
||||
PythonSysImplementation = "Information sur Python"
|
||||
PythonSysModules = "Dictionnaire des modules chargés"
|
||||
PythonSysVersion = "Version du langage Python (string)"
|
||||
PythonSysVersioninfo = "Version du langage Python (tuple)"
|
||||
PythonTimePrefix = "Préfixe fonction du module temps"
|
||||
PythonTimeSleep = "Attendre n secondes"
|
||||
PythonMonotonic = "Retourne le temps monotone"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Egész része"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "X mantissája és kiállítója"
|
||||
PythonGamma = "Gamma funkció"
|
||||
PythonGetKeys = "Billentyűk lenyomva"
|
||||
PythonGetPalette = "Téma paletta beszerzése"
|
||||
PythonGetPixel = "Visszatéríti (x,y) színét"
|
||||
PythonGetrandbits = "Váletlenszám visszatérítése k biten"
|
||||
@@ -139,7 +140,7 @@ PythonSleep = "t másodpercre meg állitani a programmot"
|
||||
PythonLocalTime = "Idő konvertálása csomóvá"
|
||||
PythonMktime = "A tuple konvertálása az időben"
|
||||
PythonTime = "Az aktuális időbélyeg letöltése"
|
||||
PythonSetLocaltime = "Állítsd be az időt egy tufából a localtime()"
|
||||
PythonSetLocaltime = "Idő beállítása egy csomóból"
|
||||
PythonRTCmode = "Aktuális RTC mód"
|
||||
PythonSetRTCmode = "RTC mód beállítása"
|
||||
PythonSort = "A listát rendezni"
|
||||
@@ -199,3 +200,11 @@ PythonOsGetlogin = "Get username"
|
||||
PythonOsRemove = "Fájl törlése"
|
||||
PythonOsRename = "Fájl átnevezése"
|
||||
PythonOsListdir = "Fájlok listája"
|
||||
PythonImportSys = "sys modul importálása"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Parte intera"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "Mantissa ed esponente di x : (m,e)"
|
||||
PythonGamma = "Funzione gamma"
|
||||
PythonGetKeys = "Premere i tasti"
|
||||
PythonGetPalette = "Ottieni la tavolozza del tema"
|
||||
PythonGetPixel = "Restituisce colore del pixel(x,y)"
|
||||
PythonGetrandbits = "Numero aleatorio con k bit"
|
||||
@@ -84,6 +85,14 @@ PythonOsGetlogin = "Get username"
|
||||
PythonOsRemove = "Rimuovere un file"
|
||||
PythonOsRename = "Rinomina file"
|
||||
PythonOsListdir = "Elenca file"
|
||||
PythonImportSys = "Importa modulo sys"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
PythonIndex = "Indice prima occorrenza di x"
|
||||
PythonInput = "Inserire un valore"
|
||||
PythonInsert = "Inserire x in posizione i-esima"
|
||||
@@ -145,7 +154,7 @@ PythonSleep = "Sospende l'esecuzione t secondi"
|
||||
PythonLocalTime = "Converti il tempo in tuple"
|
||||
PythonMktime = "Converti tuple in tempo"
|
||||
PythonTime = "Ottieni il timestamp corrente"
|
||||
PythonSetLocaltime = "Imposta il tempo da una tupla di localtime()"
|
||||
PythonSetLocaltime = "Imposta il tempo da una tupla"
|
||||
PythonRTCmode = "Ottieni la modalità RTC corrente"
|
||||
PythonSetRTCmode = "Imposta modalità RTC"
|
||||
PythonSort = "Ordina l'elenco"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Vloer"
|
||||
PythonFmod = "a modulo b"
|
||||
PythonFrExp = "Mantisse en exponent van x: (m,e)"
|
||||
PythonGamma = "Gammafunctie"
|
||||
PythonGetKeys = "Get toetsen ingedrukt"
|
||||
PythonGetPalette = "Thema palet krijgen"
|
||||
PythonGetPixel = "Geef pixel (x,y) kleur (rgb)"
|
||||
PythonGetrandbits = "Integer met k willekeurige bits"
|
||||
@@ -83,6 +84,15 @@ PythonOsGetlogin = "Get username"
|
||||
PythonOsRemove = "Een bestand verwijderen"
|
||||
PythonOsRename = "Hernoem bestand"
|
||||
PythonOsListdir = "Lijstbestanden"
|
||||
PythonImportSys = "Importeer sys module"
|
||||
PythonImportSys = "Importeer sys module"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
PythonImportTurtle = "Importeer turtle module"
|
||||
PythonIndex = "Index van de eerste x aanwezigheden"
|
||||
PythonInput = "Wijs een waarde toe"
|
||||
@@ -145,7 +155,7 @@ PythonSleep = "Stel executie voor t seconden uit"
|
||||
PythonLocalTime = "Zet tijd om in tuple"
|
||||
PythonMktime = "Tuple omzetten in tijd"
|
||||
PythonTime = "Haal de huidige tijdstempel"
|
||||
PythonSetLocaltime = "Stel de tijd in vanaf een tuple van localtime()"
|
||||
PythonSetLocaltime = "Stel de tijd in vanaf een tuple"
|
||||
PythonRTCmode = "Huidige RTC-modus kregen"
|
||||
PythonSetRTCmode = "RTC-modus instellen"
|
||||
PythonSort = "Sorteer de lijst"
|
||||
|
||||
@@ -62,6 +62,7 @@ PythonFloor = "Parte inteira"
|
||||
PythonFmod = "a módulo b"
|
||||
PythonFrExp = "Coeficiente e expoente de x: (m, e)"
|
||||
PythonGamma = "Função gama"
|
||||
PythonGetKeys = "Obter teclas pressionadas"
|
||||
PythonGetPalette = "Obter paleta temática"
|
||||
PythonGetPixel = "Devolve a cor do pixel (x,y)"
|
||||
PythonGetrandbits = "Número inteiro aleatório com k bits"
|
||||
@@ -139,7 +140,7 @@ PythonSleep = "Suspender a execução por t segundos"
|
||||
PythonLocalTime = "Convert o tempo em tupla"
|
||||
PythonMktime = "Convert tuple em tempo"
|
||||
PythonTime = "Obter o estamp de tempo atual"
|
||||
PythonSetLocaltime = "Definir tempo a partir de uma tupla de localtime()"
|
||||
PythonSetLocaltime = "Definir tempo a partir de uma tupla"
|
||||
PythonRTCmode = "Obter o modo RTC atual"
|
||||
PythonSetRTCmode = "Definir o modo RTC"
|
||||
PythonSort = "Ordenar a lista"
|
||||
@@ -180,6 +181,14 @@ PythonOsGetlogin = "Get username"
|
||||
PythonOsRemove = "Remover um ficheiro"
|
||||
PythonOsRename = "Renomear ficheiro"
|
||||
PythonOsListdir = "Listar ficheiros"
|
||||
PythonImportSys = "Import sys module"
|
||||
PythonSysExit = "Terminate current program"
|
||||
PythonSysPrintexception = "Print exception"
|
||||
PythonSysByteorder = "The byte order of the system"
|
||||
PythonSysImplementation = "Information about Python"
|
||||
PythonSysModules = "Dictionary of loaded modules"
|
||||
PythonSysVersion = "Python language version (string)"
|
||||
PythonSysVersioninfo = "Python language version (tuple)"
|
||||
PythonTimePrefix = "time module function prefix"
|
||||
PythonTimeSleep = "Wait for n second"
|
||||
PythonMonotonic = "Return monotonic time"
|
||||
|
||||
@@ -69,6 +69,7 @@ PythonCommandFloor = "floor(x)"
|
||||
PythonCommandFmod = "fmod(a,b)"
|
||||
PythonCommandFrExp = "frexp(x)"
|
||||
PythonCommandGamma = "gamma(x)"
|
||||
PythonCommandGetKeys = "get_keys()"
|
||||
PythonCommandGetPalette = "get_palette()"
|
||||
PythonCommandGetPixel = "get_pixel(x,y)"
|
||||
PythonCommandGetrandbits = "getrandbits(k)"
|
||||
@@ -95,6 +96,8 @@ PythonCommandImportFromScipy = "from ulab import scipy as spy"
|
||||
PythonCommandImportRandom = "import random"
|
||||
PythonCommandImportOs = "import os"
|
||||
PythonCommandImportFromOs = "from os import *"
|
||||
PythonCommandImportSys = "import sys"
|
||||
PythonCommandImportFromSys = "from sys import *"
|
||||
PythonCommandImportTime = "import time"
|
||||
PythonCommandImportTurtle = "import turtle"
|
||||
PythonCommandIndex = "list.index(x)"
|
||||
@@ -204,6 +207,9 @@ PythonCommandNumpyTranspose = "ndarray.transpose()"
|
||||
PythonCommandNumpyTransposeWithoutArg = ".transpose()"
|
||||
PythonCommandNumpySort = "ndarray.sort()"
|
||||
PythonCommandNumpySortWithoutArg = ".sort()"
|
||||
PythonCommandNumpyFromBuffer = "ndarray.frombuffer(b)"
|
||||
PythonCommandNumpyToBytes = "ndarray.tobytes()"
|
||||
PythonCommandNumpyToBytesWithoutArg = ".tobytes()"
|
||||
PythonCommandNumpySetPrintOptions = "np.set_printoptions()"
|
||||
PythonCommandNumpyGetPrintOptions = "np.get_printoptions()"
|
||||
PythonCommandNumpyNdinfo = "np.ndinfo(a)"
|
||||
@@ -369,6 +375,14 @@ PythonOsCommandRename = "rename(oldname, newname)"
|
||||
PythonOsCommandRemoveWithoutArg = "remove(\x11)"
|
||||
PythonOsCommandRenameWithoutArg = "rename(\x11,)"
|
||||
PythonOsCommandListdir = "listdir()"
|
||||
PythonSysCommandExit = "exit()"
|
||||
PythonSysCommandPrintexception = "print_exception(exc)"
|
||||
PythonSysCommandPrintexceptionWithoutArg = "print_exception(\x11)"
|
||||
PythonSysCommandByteorder = "byteorder"
|
||||
PythonSysCommandImplementation = "implementation"
|
||||
PythonSysCommandModules = "modules"
|
||||
PythonSysCommandVersion = "version"
|
||||
PythonSysCommandVersioninfo = "version_info"
|
||||
PythonTurtleCommandBackward = "backward(x)"
|
||||
PythonTurtleCommandCircle = "circle(r)"
|
||||
PythonTurtleCommandColor = "color('c')"
|
||||
|
||||
@@ -102,7 +102,7 @@ void EditorView::GutterView::setOffset(KDCoordinate offset) {
|
||||
|
||||
KDSize EditorView::GutterView::minimalSizeForOptimalDisplay() const {
|
||||
int numberOfChars = 2; // TODO: Could be computed
|
||||
return KDSize(2 * k_margin + numberOfChars * Poincare::Preferences::sharedPreferences()->KDPythonFont()->glyphSize().width(), 0);
|
||||
return KDSize(2 * k_margin + numberOfChars * m_font->glyphSize().width(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <escher/palette.h>
|
||||
#include <ion/unicode/utf8_helper.h>
|
||||
#include <python/port/port.h>
|
||||
#include "../global_preferences.h"
|
||||
|
||||
extern "C" {
|
||||
#include "py/nlr.h"
|
||||
@@ -444,6 +445,11 @@ void PythonTextArea::addAutocompletion() {
|
||||
}
|
||||
|
||||
bool PythonTextArea::addAutocompletionTextAtIndex(int nextIndex, int * currentIndexToUpdate) {
|
||||
// If Autocomplete disable, skip this step
|
||||
if(!GlobalPreferences::sharedGlobalPreferences()->autocomplete()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The variable box should be loaded at this point
|
||||
const char * autocompletionTokenBeginning = nullptr;
|
||||
const char * autocompletionLocation = const_cast<char *>(cursorLocation());
|
||||
|
||||
@@ -135,7 +135,9 @@ const ToolboxMessageTree MatplotlibPyplotModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandColorGray, I18n::Message::PythonColorGray, false)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree NumpyNdarrayModuleChildren[] = {
|
||||
#if defined(INCLUDE_ULAB)
|
||||
|
||||
const ToolboxMessageTree NumpyNdarrayModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyArray),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyArange),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyConcatenate),
|
||||
@@ -147,15 +149,17 @@ const ToolboxMessageTree MatplotlibPyplotModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFull),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyLinspace),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyLogspace),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyCopy),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyDtype),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlat),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlatten),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyShape),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyReshape),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySize),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyTranspose),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySort),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFromBuffer),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyCopy, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyCopyWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyDtype, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyDtypeWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlat, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyFlatWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyFlatten, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyFlattenWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyShape, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyShapeWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyReshape, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyReshapeWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySize, I18n::Message::Default, false, I18n::Message::PythonCommandNumpySizeWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyTranspose, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyTransposeWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpySort, I18n::Message::Default, false, I18n::Message::PythonCommandNumpySortWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyToBytes, I18n::Message::Default, false, I18n::Message::PythonCommandNumpyToBytesWithoutArg)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree NumpyFunctionsModuleChildren[] = {
|
||||
@@ -254,7 +258,6 @@ const ToolboxMessageTree NumpyModuleChildren[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::NumpyLinalgModule, NumpyLinalgModuleChildren)
|
||||
};
|
||||
|
||||
#if !defined(DEVICE_N0100)
|
||||
const ToolboxMessageTree ScipyLinalgModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandScipyLinalgFunction, I18n::Message::PythonScipyLinalgFunction, false, I18n::Message::PythonCommandScipyLinalgFunctionWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandScipyLinalgChoSolve),
|
||||
@@ -291,16 +294,14 @@ const ToolboxMessageTree ScipyModuleChildren[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::ScipySpecialModule, ScipySpecialModuleChildren),
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
const ToolboxMessageTree UlabModuleChildren[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::NumpyModule, NumpyModuleChildren),
|
||||
#if !defined(DEVICE_N0100)
|
||||
ToolboxMessageTree::Node(I18n::Message::ScipyModule, ScipyModuleChildren),
|
||||
#endif
|
||||
ToolboxMessageTree::Leaf(I18n::Message::UlabDocumentation, I18n::Message::UlabDocumentationLink)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
const ToolboxMessageTree TurtleModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportTurtle, I18n::Message::PythonImportTurtle, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromTurtle, I18n::Message::PythonImportTurtle, false),
|
||||
@@ -364,8 +365,8 @@ const ToolboxMessageTree KandinskyModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillRect, I18n::Message::PythonFillRect),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillCircle, I18n::Message::PythonFillCircle),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillPolygon, I18n::Message::PythonFillPolygon),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetPalette, I18n::Message::PythonGetPalette)
|
||||
};
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetKeys, I18n::Message::PythonGetKeys),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetPalette, I18n::Message::PythonGetPalette)};
|
||||
|
||||
const ToolboxMessageTree IonModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportIon, I18n::Message::PythonImportIon, false),
|
||||
@@ -402,16 +403,31 @@ const ToolboxMessageTree OsModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonOsCommandListdir, I18n::Message::PythonOsListdir, false)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree SysModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportSys, I18n::Message::PythonImportSys, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromSys, I18n::Message::PythonImportSys, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandExit, I18n::Message::PythonSysExit, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandPrintexception, I18n::Message::PythonSysPrintexception, false, I18n::Message::PythonSysCommandPrintexceptionWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandByteorder, I18n::Message::PythonSysByteorder, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandImplementation, I18n::Message::PythonSysImplementation, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandModules, I18n::Message::PythonSysModules, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandVersion, I18n::Message::PythonSysVersion, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonSysCommandVersioninfo, I18n::Message::PythonSysVersioninfo, false)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree modulesChildren[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::MathModule, MathModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::CmathModule, CMathModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::MatplotlibPyplotModule, MatplotlibPyplotModuleChildren),
|
||||
#if defined(INCLUDE_ULAB)
|
||||
ToolboxMessageTree::Node(I18n::Message::UlabModule, UlabModuleChildren),
|
||||
#endif
|
||||
ToolboxMessageTree::Node(I18n::Message::TurtleModule, TurtleModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::RandomModule, RandomModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::KandinskyModule, KandinskyModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::IonModule, IonModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::OsModule, OsModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::SysModule, SysModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::TimeModule, TimeModuleChildren)
|
||||
};
|
||||
|
||||
@@ -678,9 +694,11 @@ KDCoordinate PythonToolbox::rowHeight(int j) {
|
||||
|
||||
bool PythonToolbox::selectLeaf(int selectedRow) {
|
||||
ToolboxMessageTree * node = (ToolboxMessageTree *)m_messageTreeModel->childAtIndex(selectedRow);
|
||||
#if defined(INCLUDE_ULAB)
|
||||
if(node->text() == I18n::Message::UlabDocumentationLink){
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
m_selectableTableView.deselectTable();
|
||||
if(node->insertedText() == I18n::Message::IonSelector){
|
||||
m_ionKeys.setSender(sender());
|
||||
|
||||
@@ -21,10 +21,10 @@ void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) cons
|
||||
const int nodeNameLength = m_scriptNode->nameLength();
|
||||
KDSize nameSize = k_font->stringSize(nodeName, nodeNameLength);
|
||||
const KDCoordinate nodeNameY = k_topMargin;
|
||||
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, KDColorBlack, backgroundColor, nodeNameLength);
|
||||
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, Palette::PrimaryText, backgroundColor, nodeNameLength);
|
||||
// If it is needed, draw the parentheses
|
||||
if (m_scriptNode->type() == ScriptNode::Type::WithParentheses) {
|
||||
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, KDColorBlack, backgroundColor);
|
||||
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, Palette::PrimaryText, backgroundColor);
|
||||
}
|
||||
|
||||
/* If it exists, draw the source name. If it did not fit, we would have put
|
||||
|
||||
@@ -8,11 +8,9 @@ bool ScriptStore::ScriptNameIsFree(const char * baseName) {
|
||||
return ScriptBaseNamed(baseName).isNull();
|
||||
}
|
||||
|
||||
// Here we add "base" script
|
||||
ScriptStore::ScriptStore() {
|
||||
addScriptFromTemplate(ScriptTemplate::Squares());
|
||||
addScriptFromTemplate(ScriptTemplate::Parabola());
|
||||
addScriptFromTemplate(ScriptTemplate::Mandelbrot());
|
||||
addScriptFromTemplate(ScriptTemplate::Polynomial());
|
||||
|
||||
}
|
||||
|
||||
void ScriptStore::deleteAllScripts() {
|
||||
|
||||
@@ -5,103 +5,9 @@ namespace Code {
|
||||
constexpr ScriptTemplate emptyScriptTemplate(".py", "\x01" R"(from math import *
|
||||
)");
|
||||
|
||||
constexpr ScriptTemplate squaresScriptTemplate("squares.py", "\x01" R"(from math import *
|
||||
from turtle import *
|
||||
def squares(angle=0.5):
|
||||
reset()
|
||||
L=330
|
||||
speed(10)
|
||||
penup()
|
||||
goto(-L/2,-L/2)
|
||||
pendown()
|
||||
for i in range(660):
|
||||
forward(L)
|
||||
left(90+angle)
|
||||
L=L-L*sin(angle*pi/180)
|
||||
hideturtle())");
|
||||
|
||||
constexpr ScriptTemplate mandelbrotScriptTemplate("mandelbrot.py", "\x01" R"(# This script draws a Mandelbrot fractal set
|
||||
# N_iteration: degree of precision
|
||||
import kandinsky
|
||||
def mandelbrot(N_iteration):
|
||||
for x in range(320):
|
||||
for y in range(222):
|
||||
# Compute the mandelbrot sequence for the point c = (c_r, c_i) with start value z = (z_r, z_i)
|
||||
z = complex(0,0)
|
||||
# Rescale to fit the drawing screen 320x222
|
||||
c = complex(3.5*x/319-2.5, -2.5*y/221+1.25)
|
||||
i = 0
|
||||
while (i < N_iteration) and abs(z) < 2:
|
||||
i = i + 1
|
||||
z = z*z+c
|
||||
# Choose the color of the dot from the Mandelbrot sequence
|
||||
rgb = int(255*i/N_iteration)
|
||||
col = kandinsky.color(int(rgb*0.82),int(rgb*0.13),int(rgb*0.18))
|
||||
# Draw a pixel colored in 'col' at position (x,y)
|
||||
kandinsky.set_pixel(x,y,col))");
|
||||
|
||||
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from math import *
|
||||
# roots(a,b,c) computes the solutions of the equation a*x**2+b*x+c=0
|
||||
def roots(a,b,c):
|
||||
delta = b*b-4*a*c
|
||||
if delta == 0:
|
||||
return -b/(2*a)
|
||||
elif delta > 0:
|
||||
x_1 = (-b-sqrt(delta))/(2*a)
|
||||
x_2 = (-b+sqrt(delta))/(2*a)
|
||||
return x_1, x_2
|
||||
else:
|
||||
return None)");
|
||||
|
||||
constexpr ScriptTemplate parabolaScriptTemplate("parabola.py", "\x01" R"(from matplotlib.pyplot import *
|
||||
from math import *
|
||||
|
||||
g=9.81
|
||||
|
||||
def x(t,v_0,alpha):
|
||||
return v_0*cos(alpha)*t
|
||||
def y(t,v_0,alpha,h_0):
|
||||
return -0.5*g*t**2+v_0*sin(alpha)*t+h_0
|
||||
|
||||
def vx(v_0,alpha):
|
||||
return v_0*cos(alpha)
|
||||
def vy(t,v_0,alpha):
|
||||
return -g*t+v_0*sin(alpha)
|
||||
|
||||
def t_max(v_0,alpha,h_0):
|
||||
return (v_0*sin(alpha)+sqrt((v_0**2)*(sin(alpha)**2)+2*g*h_0))/g
|
||||
|
||||
def simulation(v_0=15,alpha=pi/4,h_0=2):
|
||||
tMax=t_max(v_0,alpha,h_0)
|
||||
accuracy=1/10**(floor(log10(tMax))-1)
|
||||
T_MAX=floor(tMax*accuracy)+1
|
||||
X=[x(t/accuracy,v_0,alpha) for t in range(T_MAX)]
|
||||
Y=[y(t/accuracy,v_0,alpha,h_0) for t in range(T_MAX)]
|
||||
VX=[vx(v_0,alpha) for t in range(T_MAX)]
|
||||
VY=[vy(t/accuracy,v_0,alpha) for t in range(T_MAX)]
|
||||
for i in range(T_MAX):
|
||||
arrow(X[i],Y[i],VX[i]/accuracy,VY[i]/accuracy)
|
||||
grid()
|
||||
show())");
|
||||
|
||||
const ScriptTemplate * ScriptTemplate::Empty() {
|
||||
return &emptyScriptTemplate;
|
||||
}
|
||||
|
||||
const ScriptTemplate * ScriptTemplate::Squares() {
|
||||
return &squaresScriptTemplate;
|
||||
}
|
||||
|
||||
const ScriptTemplate * ScriptTemplate::Mandelbrot() {
|
||||
return &mandelbrotScriptTemplate;
|
||||
}
|
||||
|
||||
const ScriptTemplate * ScriptTemplate::Polynomial() {
|
||||
return &polynomialScriptTemplate;
|
||||
}
|
||||
|
||||
const ScriptTemplate * ScriptTemplate::Parabola() {
|
||||
return ¶bolaScriptTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ class ScriptTemplate {
|
||||
public:
|
||||
constexpr ScriptTemplate(const char * name, const char * value) : m_name(name), m_value(value) {}
|
||||
static const ScriptTemplate * Empty();
|
||||
static const ScriptTemplate * Squares();
|
||||
static const ScriptTemplate * Mandelbrot();
|
||||
static const ScriptTemplate * Polynomial();
|
||||
static const ScriptTemplate * Parabola();
|
||||
const char * name() const { return m_name; }
|
||||
const char * content() const { return m_value + Script::StatusSize(); }
|
||||
const char * value() const { return m_value; }
|
||||
|
||||
@@ -13,6 +13,7 @@ ScipySignalModule = "signal"
|
||||
ScipySpecialModule = "special"
|
||||
NumpyNdarray = "ndarray"
|
||||
OsModule = "os"
|
||||
SysModule = "sys"
|
||||
TimeModule = "time"
|
||||
TurtleModule = "turtle"
|
||||
UlabModule = "ulab"
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Code {
|
||||
}
|
||||
|
||||
void toolboxIonKeys::toolboxIonView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(rect, Palette::GrayBright);
|
||||
ctx->strokeRect(rect, Palette::GrayDark);
|
||||
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20));
|
||||
|
||||
ctx->fillRect(rect, Palette::WallScreen);
|
||||
ctx->strokeRect(rect, Palette::ListCellBorder);
|
||||
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20),KDFont::LargeFont,Palette::PrimaryText,Palette::WallScreen);
|
||||
|
||||
}
|
||||
|
||||
View * toolboxIonKeys::view(){
|
||||
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
|
||||
private:
|
||||
constexpr static size_t k_maxNumberOfDisplayedItems = (Ion::Display::Height - Metric::TitleBarHeight - Metric::PopUpTopMargin) / ScriptNodeCell::k_simpleItemHeight + 2; // +2 if the cells are cropped on top and at the bottom
|
||||
constexpr static size_t k_maxScriptNodesCount = 32; // Chosen without particular reasons
|
||||
constexpr static size_t k_maxScriptNodesCount = 64; // Chosen without particular reasons (Number of functions in the variables box)
|
||||
constexpr static int k_totalBuiltinNodesCount = 107;
|
||||
constexpr static uint8_t k_scriptOriginsCount = 3;
|
||||
constexpr static uint8_t k_scriptOriginsCount = 8; // Number of scripts loaded in the variable box
|
||||
constexpr static uint8_t k_subtitleCellType = NodeCellType; // We don't care as it is not selectable
|
||||
constexpr static uint8_t k_itemCellType = LeafCellType; // So that upper class NestedMenuController knows it's a leaf
|
||||
constexpr static KDCoordinate k_subtitleRowHeight = 23;
|
||||
|
||||
@@ -30,11 +30,23 @@ 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; }
|
||||
void setBrightnessLevel(int brightnessLevel);
|
||||
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
|
||||
@@ -44,6 +56,11 @@ 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) {}
|
||||
I18n::Language m_language;
|
||||
@@ -53,6 +70,11 @@ 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;
|
||||
};
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -711,6 +711,54 @@ const ToolboxMessageTree Electromagnetism[] = {
|
||||
|
||||
};
|
||||
|
||||
const ToolboxMessageTree Resistivity[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Silver, I18n::Message::Rstvt_Silver, false, I18n::Message::Rstvt_Silver),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Copper, I18n::Message::Rstvt_Copper, false, I18n::Message::Rstvt_Copper),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Gold, I18n::Message::Rstvt_Gold, false, I18n::Message::Rstvt_Gold),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Aluminium, I18n::Message::Rstvt_Aluminium, false, I18n::Message::Rstvt_Aluminium),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Calcium, I18n::Message::Rstvt_Calcium, false, I18n::Message::Rstvt_Calcium),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Tungsten, I18n::Message::Rstvt_Tungsten, false, I18n::Message::Rstvt_Tungsten),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Zinc, I18n::Message::Rstvt_Zinc, false, I18n::Message::Rstvt_Zinc),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Cobalt, I18n::Message::Rstvt_Cobalt, false, I18n::Message::Rstvt_Cobalt),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Nickel, I18n::Message::Rstvt_Nickel, false, I18n::Message::Rstvt_Nickel),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Lithium, I18n::Message::Rstvt_Lithium, false, I18n::Message::Rstvt_Lithium),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Iron, I18n::Message::Rstvt_Iron, false, I18n::Message::Rstvt_Iron),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Platinum, I18n::Message::Rstvt_Platinum, false, I18n::Message::Rstvt_Platinum),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Tin, I18n::Message::Rstvt_Tin, false, I18n::Message::Rstvt_Tin),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Sea_water, I18n::Message::Rstvt_Sea_water, false, I18n::Message::Rstvt_Sea_water),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Water, I18n::Message::Rstvt_Water, false, I18n::Message::Rstvt_Water),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Air, I18n::Message::Rstvt_Air, false, I18n::Message::Rstvt_Air),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Wood, I18n::Message::Rstvt_Wood, false, I18n::Message::Rstvt_Wood),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Glass, I18n::Message::Rstvt_Glass, false, I18n::Message::Rstvt_Glass)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree Conductivity[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Silver, I18n::Message::Cndcvt_Silver, false, I18n::Message::Cndcvt_Silver),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Copper, I18n::Message::Cndcvt_Copper, false, I18n::Message::Cndcvt_Copper),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Gold, I18n::Message::Cndcvt_Gold, false, I18n::Message::Cndcvt_Gold),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Aluminium, I18n::Message::Cndcvt_Aluminium, false, I18n::Message::Cndcvt_Aluminium),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Calcium, I18n::Message::Cndcvt_Calcium, false, I18n::Message::Cndcvt_Calcium),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Tungsten, I18n::Message::Cndcvt_Tungsten, false, I18n::Message::Cndcvt_Tungsten),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Zinc, I18n::Message::Cndcvt_Zinc, false, I18n::Message::Cndcvt_Zinc),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Cobalt, I18n::Message::Cndcvt_Cobalt, false, I18n::Message::Cndcvt_Cobalt),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Nickel, I18n::Message::Cndcvt_Nickel, false, I18n::Message::Cndcvt_Nickel),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Lithium, I18n::Message::Cndcvt_Lithium, false, I18n::Message::Cndcvt_Lithium),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Iron, I18n::Message::Cndcvt_Iron, false, I18n::Message::Cndcvt_Iron),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Platinum, I18n::Message::Cndcvt_Platinum, false, I18n::Message::Cndcvt_Platinum),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Tin, I18n::Message::Cndcvt_Tin, false, I18n::Message::Cndcvt_Tin),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Sea_water, I18n::Message::Cndcvt_Sea_water, false, I18n::Message::Cndcvt_Sea_water),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Water, I18n::Message::Cndcvt_Water, false, I18n::Message::Cndcvt_Water),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Air, I18n::Message::Cndcvt_Air, false, I18n::Message::Cndcvt_Air),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Wood, I18n::Message::Cndcvt_Wood, false, I18n::Message::Cndcvt_Wood),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::Glass, I18n::Message::Cndcvt_Glass, false, I18n::Message::Cndcvt_Glass)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree Electricity[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::ElementalChargeTag, I18n::Message::ElementalCharge, false, I18n::Message::ElementalCharge),
|
||||
ToolboxMessageTree::Node(I18n::Message::ResistivityConstants, Resistivity),
|
||||
ToolboxMessageTree::Node(I18n::Message::ConductivityConstants, Conductivity)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree ParticleMass[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::ElectronMassTag, I18n::Message::ElectronMass, false, I18n::Message::ElectronMass),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::MuonMassTag, I18n::Message::MuonMass, false, I18n::Message::MuonMass),
|
||||
@@ -788,6 +836,7 @@ const ToolboxMessageTree PlanckUnits[] = {
|
||||
const ToolboxMessageTree Physics[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::FundamentalConstants, FundamentalConstants),
|
||||
ToolboxMessageTree::Node(I18n::Message::Electromagnetism, Electromagnetism),
|
||||
ToolboxMessageTree::Node(I18n::Message::Electricity, Electricity),
|
||||
ToolboxMessageTree::Node(I18n::Message::NuclearConstants, Nuclear),
|
||||
ToolboxMessageTree::Node(I18n::Message::Thermodynamics, Thermodynamics),
|
||||
ToolboxMessageTree::Node(I18n::Message::Gravitation, Gravitation),
|
||||
@@ -805,15 +854,15 @@ const ToolboxMessageTree menu[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::LogCommandWithArg, I18n::Message::BasedLogarithm),
|
||||
ToolboxMessageTree::Node(I18n::Message::Calculation, calculChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::ComplexNumber, complexChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Combinatorics, combinatoricsChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Probability, probabilityChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Unit, unitChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Arithmetic, arithmeticChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Matrices, matricesChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Probability, probabilityChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Vectors, vectorsChildren),
|
||||
#if LIST_ARE_DEFINED
|
||||
ToolboxMessageTree::Node(I18n::Message::Lists,listsChildren),
|
||||
#endif
|
||||
ToolboxMessageTree::Node(I18n::Message::Unit, unitChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Combinatorics, combinatoricsChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::RandomAndApproximation, randomAndApproximationChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::HyperbolicTrigonometry, trigonometryChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::Fluctuation, predictionChildren),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
MathVariableBoxEmptyController::MathVariableBoxEmptyView::MathVariableBoxEmptyView() :
|
||||
ModalViewEmptyView(),
|
||||
m_layoutExample(0.5f, 0.5f, KDColorBlack, Palette::WallScreen)
|
||||
m_layoutExample(0.5f, 0.5f, Palette::PrimaryText, Palette::WallScreen)
|
||||
{
|
||||
initMessageViews();
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.8 KiB |
27
apps/reader/README.md
Normal file
27
apps/reader/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Thanks
|
||||
Thanks to [Gabriel79](https://github.com/Gabriel79) for the original reader app, his source code available [here](https://github.com/Gabriel79/OmegaWithReaderTutorial) and the [tutorial](https://www.codingame.com/playgrounds/55846/reader-faire-une-application-pour-omega-sur-numworks/introduction) to code it !
|
||||
|
||||
---
|
||||
|
||||
# Rich text format
|
||||
Reader app supports now a rich text format :
|
||||
|
||||
* `$` around a mathematical expression **without spaces** to render it
|
||||
* `%` around a color-code (see below) to change the color of the text
|
||||
### Color codes :
|
||||
|code|color|
|
||||
| --:| ---:|
|
||||
|`%\last_color%`|Stop using last color|
|
||||
|`%r%`|Red|
|
||||
|`%rl%`|Light red|
|
||||
|`%m%`|Magenta|
|
||||
|`%t%`|Turquoise|
|
||||
|`%pk%`|Pink|
|
||||
|`%pp%`|Purple|
|
||||
|`%b%`|Blue|
|
||||
|`%bl%`|Light blue|
|
||||
|`%br%`|Brown|
|
||||
|`%o%`|Orange|
|
||||
|`%g%`|Green|
|
||||
|`%gl%`|Light green|
|
||||
|`%c%`|Cyan|
|
||||
@@ -27,19 +27,21 @@ bool ReadBookController::handleEvent(Ion::Events::Event event) {
|
||||
m_readerView.previousPage();
|
||||
return true;
|
||||
}
|
||||
if(event == Ion::Events::Back || event == Ion::Events::Home) {
|
||||
savePosition();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ReadBookController::viewDidDisappear() {
|
||||
savePosition();
|
||||
}
|
||||
|
||||
void ReadBookController::savePosition() const {
|
||||
int pageOffset = m_readerView.getPageOffset();
|
||||
Ion::Storage::Record::ErrorStatus status = Ion::Storage::sharedStorage()->createRecordWithFullName(m_file->name, &pageOffset, sizeof(pageOffset));
|
||||
BookSave save = m_readerView.getBookSave();
|
||||
|
||||
Ion::Storage::Record::ErrorStatus status = Ion::Storage::sharedStorage()->createRecordWithFullName(m_file->name, &save, sizeof(save));
|
||||
if(Ion::Storage::Record::ErrorStatus::NameTaken == status) {
|
||||
Ion::Storage::Record::Data data;
|
||||
data.buffer = &pageOffset;
|
||||
data.size = sizeof(pageOffset);
|
||||
data.buffer = &save;
|
||||
data.size = sizeof(save);
|
||||
status = Ion::Storage::sharedStorage()->recordNamed(m_file->name).setValue(data);
|
||||
}
|
||||
}
|
||||
@@ -47,11 +49,14 @@ void ReadBookController::savePosition() const {
|
||||
void ReadBookController::loadPosition() {
|
||||
Ion::Storage::Record r = Ion::Storage::sharedStorage()->recordNamed(m_file->name);
|
||||
if(Ion::Storage::sharedStorage()->hasRecord(r)) {
|
||||
int pageOffset = *(static_cast<const int*>(r.value().buffer));
|
||||
m_readerView.setPageOffset(pageOffset);
|
||||
BookSave save = *(static_cast<const BookSave*>(r.value().buffer));
|
||||
m_readerView.setBookSave(save);
|
||||
}
|
||||
else {
|
||||
m_readerView.setPageOffset(0);
|
||||
m_readerView.setBookSave({
|
||||
0,
|
||||
Palette::PrimaryText
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,9 @@ class ReadBookController : public ViewController {
|
||||
public:
|
||||
ReadBookController(Responder * parentResponder);
|
||||
View * view() override;
|
||||
|
||||
void setBook(const External::Archive::File& file);
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
|
||||
void viewDidDisappear() override;
|
||||
void savePosition() const;
|
||||
void loadPosition();
|
||||
private:
|
||||
|
||||
@@ -110,4 +110,21 @@ int filesWithExtension(const char* extension, External::Archive::File* files, in
|
||||
}
|
||||
#endif
|
||||
|
||||
const char * EndOfPrintableWord(const char * word, const char * end) {
|
||||
if (word == end) {
|
||||
return word;
|
||||
}
|
||||
UTF8Decoder decoder(word);
|
||||
CodePoint codePoint = decoder.nextCodePoint();
|
||||
const char * result = word;
|
||||
while (codePoint != '\n' && codePoint != ' ' && codePoint != '%') {
|
||||
result = decoder.stringPosition();
|
||||
if (result >= end) {
|
||||
break;
|
||||
}
|
||||
codePoint = decoder.nextCodePoint();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
#define __UTILITY_H__
|
||||
|
||||
#include <apps/external/archive.h>
|
||||
#include <ion/unicode/code_point.h>
|
||||
#include <ion/unicode/utf8_decoder.h>
|
||||
|
||||
namespace Reader
|
||||
{
|
||||
@@ -9,6 +11,7 @@ namespace Reader
|
||||
bool stringEndsWith(const char* str, const char* end);
|
||||
int filesWithExtension(const char* extension, External::Archive::File* files, int filesSize);
|
||||
void stringNCopy(char* dest, int max, const char* src, int len);
|
||||
|
||||
const char * EndOfPrintableWord(const char * word, const char * end);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,10 +1,22 @@
|
||||
|
||||
#include "word_wrap_view.h"
|
||||
#include "utility.h"
|
||||
#include <poincare/expression.h>
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include <poincare/undefined.h>
|
||||
|
||||
namespace Reader
|
||||
{
|
||||
|
||||
WordWrapTextView::WordWrapTextView() :
|
||||
PointerTextView(GlobalPreferences::sharedGlobalPreferences()->font()),
|
||||
m_pageOffset(0),
|
||||
m_nextPageOffset(0),
|
||||
m_length(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WordWrapTextView::nextPage() {
|
||||
if(m_nextPageOffset >= m_length) {
|
||||
return;
|
||||
@@ -29,12 +41,35 @@ void WordWrapTextView::previousPage() {
|
||||
const char * endOfWord = text() + m_pageOffset - 1;
|
||||
const char * startOfWord = UTF8Helper::BeginningOfWord(text(), endOfWord);
|
||||
|
||||
KDSize textSize = KDSizeZero;
|
||||
|
||||
KDPoint textEndPosition(m_frame.width() - k_margin, m_frame.height() - k_margin);
|
||||
|
||||
while(startOfWord>=text()) {
|
||||
startOfWord = UTF8Helper::BeginningOfWord(text(), endOfWord);
|
||||
endOfWord = UTF8Helper::EndOfWord(startOfWord);
|
||||
KDSize textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
|
||||
endOfWord = UTF8Helper::EndOfWord(startOfWord);
|
||||
|
||||
if (*startOfWord == '%') {
|
||||
if (updateTextColorBackward(startOfWord)) {
|
||||
endOfWord = startOfWord - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (*startOfWord == '$' && *(endOfWord-1) == '$') {
|
||||
const int wordMaxLength = 128;
|
||||
char word[wordMaxLength];
|
||||
stringNCopy(word, wordMaxLength, startOfWord + 1, endOfWord-startOfWord-2);
|
||||
Poincare::Expression expr = Poincare::Expression::Parse(word, nullptr);
|
||||
if (expr.isUninitialized()) {
|
||||
expr = Poincare::Undefined::Builder();
|
||||
}
|
||||
Poincare::Layout layout = Shared::PoincareHelpers::CreateLayout(expr);
|
||||
textSize = layout.layoutSize();
|
||||
|
||||
}
|
||||
else {
|
||||
textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
|
||||
}
|
||||
KDPoint textStartPosition = KDPoint(textEndPosition.x()-textSize.width(), textEndPosition.y());
|
||||
|
||||
if(textStartPosition.x() < k_margin) {
|
||||
@@ -84,37 +119,85 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
|
||||
const char * endOfFile = text() + m_length;
|
||||
const char * startOfWord = text() + m_pageOffset;
|
||||
const char * endOfWord = UTF8Helper::EndOfWord(startOfWord);
|
||||
const char * endOfWord = EndOfPrintableWord(startOfWord, endOfFile);
|
||||
KDPoint textPosition(k_margin, k_margin);
|
||||
|
||||
const int wordMaxLength = 128;
|
||||
char word[wordMaxLength];
|
||||
|
||||
Poincare::Layout layout;
|
||||
|
||||
enum class ToDraw {
|
||||
Text,
|
||||
Expression,
|
||||
Nothing
|
||||
};
|
||||
|
||||
ToDraw toDraw = ToDraw::Text;
|
||||
|
||||
const int charWidth = m_font->glyphSize().width();
|
||||
const int charHeight = m_font->glyphSize().height();
|
||||
|
||||
int nextLineOffset = charHeight;
|
||||
|
||||
KDSize textSize = KDSizeZero;
|
||||
|
||||
|
||||
while(startOfWord < endOfFile) {
|
||||
KDSize textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
|
||||
|
||||
if (*startOfWord == '%') { // Look for color keyword (ex '%bl%')
|
||||
if (updateTextColorForward(startOfWord)) {
|
||||
startOfWord = endOfWord + 1;
|
||||
endOfWord = EndOfPrintableWord(startOfWord, endOfFile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (*startOfWord == '$' && *(endOfWord-1) == '$') { // Look for expression
|
||||
stringNCopy(word, wordMaxLength, startOfWord + 1, endOfWord-startOfWord-2);
|
||||
Poincare::Expression expr = Poincare::Expression::Parse(word, nullptr);
|
||||
if (expr.isUninitialized()) {
|
||||
expr = Poincare::Undefined::Builder();
|
||||
}
|
||||
layout = Shared::PoincareHelpers::CreateLayout(expr);
|
||||
textSize = layout.layoutSize();
|
||||
toDraw = ToDraw::Expression;
|
||||
}
|
||||
else {
|
||||
textSize = m_font->stringSizeUntil(startOfWord, endOfWord);
|
||||
stringNCopy(word, wordMaxLength, startOfWord, endOfWord-startOfWord);
|
||||
toDraw = ToDraw::Text;
|
||||
}
|
||||
|
||||
KDPoint nextTextPosition = KDPoint(textPosition.x()+textSize.width(), textPosition.y());
|
||||
|
||||
if(nextTextPosition.x() > m_frame.width() - k_margin) { // Right overflow
|
||||
textPosition = KDPoint(k_margin, textPosition.y() + textSize.height());
|
||||
textPosition = KDPoint(k_margin, textPosition.y() + nextLineOffset);
|
||||
nextTextPosition = KDPoint(k_margin + textSize.width(), textPosition.y());
|
||||
nextLineOffset = charHeight;
|
||||
}
|
||||
if (nextLineOffset < textSize.height()) {
|
||||
nextLineOffset = textSize.height();
|
||||
}
|
||||
|
||||
if(textPosition.y() + textSize.height() > m_frame.height() - k_margin) { // Bottom overflow
|
||||
break;
|
||||
}
|
||||
|
||||
stringNCopy(word, wordMaxLength, startOfWord, endOfWord-startOfWord);
|
||||
ctx->drawString(word, textPosition, m_font, m_textColor, m_backgroundColor);
|
||||
if (toDraw == ToDraw::Expression) {
|
||||
layout.draw(ctx, textPosition, m_textColor);
|
||||
}
|
||||
else if (toDraw == ToDraw::Text) {
|
||||
ctx->drawString(word, textPosition, m_font, m_textColor, m_backgroundColor);
|
||||
}
|
||||
|
||||
while(*endOfWord == ' ' || *endOfWord == '\n') {
|
||||
if(*endOfWord == ' ') {
|
||||
nextTextPosition = KDPoint(nextTextPosition.x() + charWidth, nextTextPosition.y());
|
||||
}
|
||||
else {
|
||||
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + charHeight);
|
||||
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + nextLineOffset);
|
||||
nextLineOffset = charHeight;
|
||||
}
|
||||
++endOfWord;
|
||||
}
|
||||
@@ -123,6 +206,10 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
//two times the same word if the break below is used
|
||||
startOfWord = endOfWord;
|
||||
|
||||
if (endOfWord >= endOfFile) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(nextTextPosition.y() + textSize.height() > m_frame.height() - k_margin) { // If out of page, quit
|
||||
break;
|
||||
}
|
||||
@@ -130,22 +217,181 @@ void WordWrapTextView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
nextTextPosition = KDPoint(k_margin, nextTextPosition.y());
|
||||
}
|
||||
if(nextTextPosition.x() > m_frame.width() - k_margin) { // Go to line if right overflow
|
||||
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + textSize.height());
|
||||
nextTextPosition = KDPoint(k_margin, nextTextPosition.y() + nextLineOffset);
|
||||
nextLineOffset = charHeight;
|
||||
}
|
||||
|
||||
textPosition = nextTextPosition;
|
||||
endOfWord = UTF8Helper::EndOfWord(startOfWord);
|
||||
endOfWord = EndOfPrintableWord(startOfWord+1, endOfFile);
|
||||
}
|
||||
|
||||
m_nextPageOffset = startOfWord - text();
|
||||
};
|
||||
|
||||
int WordWrapTextView::getPageOffset() const {
|
||||
return m_pageOffset;
|
||||
BookSave WordWrapTextView::getBookSave() const {
|
||||
return {
|
||||
m_pageOffset,
|
||||
m_textColor
|
||||
};
|
||||
}
|
||||
|
||||
void WordWrapTextView::setPageOffset(int o) {
|
||||
m_pageOffset = o;
|
||||
void WordWrapTextView::setBookSave(BookSave save) {
|
||||
m_pageOffset = save.offset;
|
||||
m_textColor = save.color;
|
||||
}
|
||||
|
||||
}
|
||||
bool WordWrapTextView::updateTextColorForward(const char * colorStart) const {
|
||||
|
||||
if (*(colorStart + 1) == '\\') {
|
||||
m_textColor = Palette::PrimaryText;
|
||||
return (*(colorStart + 3) == '%' || *(colorStart + 4) == '%');
|
||||
}
|
||||
|
||||
int keySize = 1;
|
||||
KDColor lastColor = m_textColor;
|
||||
|
||||
switch (*(colorStart+1))
|
||||
{
|
||||
case 'r':
|
||||
if (*(colorStart+2) == 'l') {
|
||||
m_textColor = Palette::RedLight;
|
||||
keySize = 2;
|
||||
}
|
||||
else {
|
||||
m_textColor = Palette::Red;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
m_textColor = Palette::Magenta;
|
||||
break;
|
||||
case 't':
|
||||
m_textColor = Palette::Turquoise;
|
||||
break;
|
||||
case 'p':
|
||||
if (*(colorStart+2) == 'k') {
|
||||
m_textColor = Palette::Pink;
|
||||
keySize = 2;
|
||||
}
|
||||
else if (*(colorStart+2) == 'p') {
|
||||
m_textColor = Palette::Purple;
|
||||
keySize = 2;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if (*(colorStart+2) == 'r') {
|
||||
m_textColor = Palette::Brown;
|
||||
keySize = 2;
|
||||
}
|
||||
if (*(colorStart+2) == 'l') {
|
||||
m_textColor = Palette::BlueLight;
|
||||
keySize = 2;
|
||||
}
|
||||
else {
|
||||
m_textColor = Palette::Blue;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
m_textColor = Palette::Orange;
|
||||
break;
|
||||
case 'g':
|
||||
if (*(colorStart+2) == 'l') {
|
||||
m_textColor = Palette::GreenLight;
|
||||
keySize = 2;
|
||||
}
|
||||
else {
|
||||
m_textColor = Palette::Green;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
m_textColor = Palette::Cyan;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*(colorStart + keySize + 1) != '%') {
|
||||
m_textColor = lastColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WordWrapTextView::updateTextColorBackward(const char * colorStart) const {
|
||||
|
||||
if (*(colorStart++) != '\\') {
|
||||
return false;
|
||||
}
|
||||
|
||||
int keySize = 1;
|
||||
KDColor lastColor = m_textColor;
|
||||
switch (*(colorStart+1))
|
||||
{
|
||||
case 'r':
|
||||
if (*(colorStart+2) == 'l') {
|
||||
m_textColor = Palette::RedLight;
|
||||
keySize = 2;
|
||||
}
|
||||
else {
|
||||
m_textColor = Palette::Red;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
m_textColor = Palette::Magenta;
|
||||
break;
|
||||
case 't':
|
||||
m_textColor = Palette::Turquoise;
|
||||
break;
|
||||
case 'p':
|
||||
if (*(colorStart+2) == 'k') {
|
||||
m_textColor = Palette::Pink;
|
||||
keySize = 2;
|
||||
}
|
||||
else if (*(colorStart+2) == 'p') {
|
||||
m_textColor = Palette::Purple;
|
||||
keySize = 2;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if (*(colorStart+2) == 'r') {
|
||||
m_textColor = Palette::Brown;
|
||||
keySize = 2;
|
||||
}
|
||||
if (*(colorStart+2) == 'l') {
|
||||
m_textColor = Palette::BlueLight;
|
||||
keySize = 2;
|
||||
}
|
||||
else {
|
||||
m_textColor = Palette::Blue;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
m_textColor = Palette::Orange;
|
||||
break;
|
||||
case 'g':
|
||||
if (*(colorStart+2) == 'l') {
|
||||
m_textColor = Palette::GreenLight;
|
||||
keySize = 2;
|
||||
}
|
||||
else {
|
||||
m_textColor = Palette::Green;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
m_textColor = Palette::Cyan;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*(colorStart + keySize + 1) != '%') {
|
||||
m_textColor = lastColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,20 +7,28 @@
|
||||
namespace Reader
|
||||
{
|
||||
|
||||
struct BookSave {
|
||||
int offset;
|
||||
KDColor color;
|
||||
};
|
||||
|
||||
class WordWrapTextView : public PointerTextView {
|
||||
public:
|
||||
WordWrapTextView() : PointerTextView(GlobalPreferences::sharedGlobalPreferences()->font()) {};
|
||||
WordWrapTextView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void setText(const char*, int length);
|
||||
void nextPage();
|
||||
void previousPage();
|
||||
int getPageOffset() const;
|
||||
void setPageOffset(int o);
|
||||
protected:
|
||||
int m_pageOffset = 0;
|
||||
mutable int m_nextPageOffset = 0;
|
||||
int m_length = 0;
|
||||
BookSave getBookSave() const;
|
||||
void setBookSave(BookSave save);
|
||||
private:
|
||||
bool updateTextColorForward(const char * colorStart) const;
|
||||
bool updateTextColorBackward(const char * colorStart) const;
|
||||
static const int k_margin = 10;
|
||||
int m_pageOffset;
|
||||
mutable int m_nextPageOffset;
|
||||
int m_length;
|
||||
mutable KDColor m_textColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
2
apps/rpn
2
apps/rpn
Submodule apps/rpn updated: 67d66295b0...b51172c32f
@@ -11,6 +11,7 @@ app_settings_src = $(addprefix apps/settings/,\
|
||||
main_controller_prompt_update.cpp:+update \
|
||||
sub_menu/about_controller.cpp \
|
||||
sub_menu/accessibility_controller.cpp \
|
||||
sub_menu/code_options_controller.cpp \
|
||||
sub_menu/about_controller_official.cpp:+official \
|
||||
sub_menu/about_controller_non_official.cpp:-official \
|
||||
sub_menu/exam_mode_controller_official.cpp:+official \
|
||||
@@ -24,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,11 +15,20 @@ 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_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)};
|
||||
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)};
|
||||
constexpr SettingsMessageTree s_contributorsChildren[23] = {SettingsMessageTree(I18n::Message::Developers), SettingsMessageTree(I18n::Message::QuentinGuidee), SettingsMessageTree(I18n::Message::JoachimLeFournis), SettingsMessageTree(I18n::Message::MaximeFriess), SettingsMessageTree(I18n::Message::JeanBaptisteBoric), SettingsMessageTree(I18n::Message::SandraSimmons), SettingsMessageTree(I18n::Message::David), SettingsMessageTree(I18n::Message::DamienNicolet), SettingsMessageTree(I18n::Message::EvannDreumont), SettingsMessageTree(I18n::Message::SzaboLevente), SettingsMessageTree(I18n::Message::VenceslasDuet), SettingsMessageTree(I18n::Message::CharlotteThomas), SettingsMessageTree(I18n::Message::AntoninLoubiere), SettingsMessageTree(I18n::Message::CyprienMejat), SettingsMessageTree(I18n::Message::BetaTesters), SettingsMessageTree(I18n::Message::TimeoArnouts), SettingsMessageTree(I18n::Message::JulieC), SettingsMessageTree(I18n::Message::LelahelHideux), SettingsMessageTree(I18n::Message::Madil), SettingsMessageTree(I18n::Message::HilaireLeRoux), SettingsMessageTree(I18n::Message::HectorNussbaumer), SettingsMessageTree(I18n::Message::RaphaelDyda), SettingsMessageTree(I18n::Message::ThibautC)};
|
||||
|
||||
// Code Settings
|
||||
#ifdef HAS_CODE
|
||||
constexpr SettingsMessageTree s_codeChildren[2] = {SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren), SettingsMessageTree(I18n::Message::Autocomplete)};
|
||||
#endif
|
||||
constexpr SettingsMessageTree s_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)};
|
||||
|
||||
|
||||
constexpr SettingsMessageTree s_modelAboutChildren[9] = {SettingsMessageTree(I18n::Message::Username), SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::UpsilonVersion), SettingsMessageTree(I18n::Message::MicroPythonVersion), SettingsMessageTree(I18n::Message::Battery), SettingsMessageTree(I18n::Message::MemUse), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId), SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren)};
|
||||
|
||||
MainController::MainController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate) :
|
||||
@@ -31,9 +40,11 @@ MainController::MainController(Responder * parentResponder, InputEventHandlerDel
|
||||
m_localizationController(this, Metric::CommonTopMargin, LocalizationController::Mode::Language),
|
||||
m_accessibilityController(this),
|
||||
m_dateTimeController(this),
|
||||
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);
|
||||
@@ -62,7 +73,7 @@ bool MainController::handleEvent(Ion::Events::Event event) {
|
||||
}
|
||||
if (model()->childAtIndex(selectedRow())->numberOfChildren() == 0) {
|
||||
if (model()->childAtIndex(selectedRow())->label() == promptMessage()) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
globalPreferences->setShowPopUp(!globalPreferences->showPopUp());
|
||||
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
|
||||
return true;
|
||||
@@ -103,6 +114,10 @@ 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 {
|
||||
subController = &m_preferencesController;
|
||||
}
|
||||
@@ -202,9 +217,6 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell;
|
||||
int childIndex = -1;
|
||||
switch (model()->childAtIndex(index)->label()) {
|
||||
case I18n::Message::FontSizes:
|
||||
childIndex = GlobalPreferences::sharedGlobalPreferences()->font() == KDFont::LargeFont ? 0 : 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
#include "sub_menu/accessibility_controller.h"
|
||||
#include "sub_menu/datetime_controller.h"
|
||||
#include "sub_menu/exam_mode_controller.h"
|
||||
#include "sub_menu/code_options_controller.h"
|
||||
#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 {
|
||||
|
||||
@@ -22,10 +24,13 @@ extern const Shared::SettingsMessageTree s_symbolChildren[4];
|
||||
extern const Shared::SettingsMessageTree s_symbolFunctionChildren[3];
|
||||
extern const Shared::SettingsMessageTree s_modelMathOptionsChildren[6];
|
||||
extern const Shared::SettingsMessageTree s_modelFontChildren[2];
|
||||
extern const Shared::SettingsMessageTree s_codeChildren[2];
|
||||
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 {
|
||||
@@ -70,9 +75,11 @@ private:
|
||||
LocalizationController m_localizationController;
|
||||
AccessibilityController m_accessibilityController;
|
||||
DateTimeController m_dateTimeController;
|
||||
CodeOptionsController m_codeOptionsController;
|
||||
ExamModeController m_examModeController;
|
||||
AboutController m_aboutController;
|
||||
PreferencesController m_preferencesController;
|
||||
UsbInfoController m_usbInfoController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,12 +10,15 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
|
||||
SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren),
|
||||
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::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,26 +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::FontSizes, s_modelFontChildren),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
{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::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
|
||||
|
||||
@@ -10,12 +10,15 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
|
||||
SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren),
|
||||
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::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;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ bool AccessibilityController::handleEvent(Ion::Events::Event event) {
|
||||
int redGamma, greenGamma, blueGamma;
|
||||
KDIonContext::sharedContext()->gamma.gamma(redGamma, greenGamma, blueGamma);
|
||||
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
if ((event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) && (selectedRow() <= 2)) {
|
||||
if (selectedRow() == 0) {
|
||||
invertEnabled = !invertEnabled;
|
||||
}
|
||||
|
||||
74
apps/settings/sub_menu/code_options_controller.cpp
Normal file
74
apps/settings/sub_menu/code_options_controller.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "code_options_controller.h"
|
||||
#include <assert.h>
|
||||
#include "../../global_preferences.h"
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
CodeOptionsController::CodeOptionsController(Responder * parentResponder) :
|
||||
GenericSubController(parentResponder),
|
||||
m_preferencesController(this)
|
||||
{
|
||||
m_chevronCell.setMessageFont(KDFont::LargeFont);
|
||||
m_switchCell.setMessageFont(KDFont::LargeFont);
|
||||
}
|
||||
|
||||
bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
switch (selectedRow()){
|
||||
case 1:
|
||||
GlobalPreferences::sharedGlobalPreferences()->setAutocomplete(!GlobalPreferences::sharedGlobalPreferences()->autocomplete());
|
||||
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
|
||||
break;
|
||||
|
||||
default:
|
||||
GenericSubController * subController = nullptr;
|
||||
subController = &m_preferencesController;
|
||||
subController->setMessageTreeModel(m_messageTreeModel->childAtIndex(selectedRow()));
|
||||
StackViewController * stack = stackController();
|
||||
m_lastSelect = selectedRow();
|
||||
stack->push(subController);
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return GenericSubController::handleEvent(event);
|
||||
}
|
||||
|
||||
HighlightCell * CodeOptionsController::reusableCell(int index, int type) {
|
||||
assert(type == 0);
|
||||
assert(index >= 0 && index < k_totalNumberOfCell);
|
||||
if (index == 0) {
|
||||
return &m_chevronCell;
|
||||
}
|
||||
return &m_switchCell;
|
||||
}
|
||||
|
||||
int CodeOptionsController::reusableCellCount(int type) {
|
||||
assert(type == 0);
|
||||
return k_totalNumberOfCell;
|
||||
}
|
||||
|
||||
void CodeOptionsController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
GenericSubController::willDisplayCellForIndex(cell, index);
|
||||
I18n::Message thisLabel = m_messageTreeModel->childAtIndex(index)->label();
|
||||
|
||||
if (thisLabel == I18n::Message::FontSizes){
|
||||
MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell;
|
||||
myTextCell->setMessage(thisLabel);
|
||||
GlobalPreferences::sharedGlobalPreferences()->font() == KDFont::LargeFont
|
||||
? myTextCell->setSubtitle(I18n::Message::LargeFont)
|
||||
: myTextCell->setSubtitle(I18n::Message::SmallFont);
|
||||
}
|
||||
#ifdef HAS_CODE
|
||||
else if (thisLabel == I18n::Message::Autocomplete) {
|
||||
MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell;
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->autocomplete());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
25
apps/settings/sub_menu/code_options_controller.h
Normal file
25
apps/settings/sub_menu/code_options_controller.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef SETTINGS_CODE_OPTIONS_CONTROLLER_H
|
||||
#define SETTINGS_CODE_OPTIONS_CONTROLLER_H
|
||||
|
||||
#include "generic_sub_controller.h"
|
||||
#include "preferences_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class CodeOptionsController : public GenericSubController {
|
||||
public:
|
||||
CodeOptionsController(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;
|
||||
private:
|
||||
constexpr static int k_totalNumberOfCell = 2;
|
||||
PreferencesController m_preferencesController;
|
||||
MessageTableCellWithChevronAndMessage m_chevronCell;
|
||||
MessageTableCellWithSwitch m_switchCell;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -26,7 +26,7 @@ DateTimeController::DateTimeController(Responder * parentResponder) :
|
||||
bool DateTimeController::handleEvent(Ion::Events::Event event) {
|
||||
bool clockEnabled = Ion::RTC::mode() != Ion::RTC::Mode::Disabled;
|
||||
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
if (selectedRow() == 0) {
|
||||
clockEnabled = !clockEnabled;
|
||||
if (clockEnabled) {
|
||||
|
||||
@@ -27,7 +27,7 @@ void PreferencesController::didBecomeFirstResponder() {
|
||||
}
|
||||
|
||||
bool PreferencesController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||
/* Generic behaviour of preference menu*/
|
||||
assert(m_messageTreeModel->label() != I18n::Message::DisplayMode || selectedRow() != numberOfRows()-1); // In that case, events OK and EXE are handled by the cell
|
||||
setPreferenceWithValueIndex(m_messageTreeModel->label(), selectedRow());
|
||||
|
||||
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,3 +458,44 @@ 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"
|
||||
Cndcvt_Aluminium = "3.77·10^7_S_m^-1"
|
||||
Cndcvt_Calcium = "2.98·10^7_S_m^-1"
|
||||
Cndcvt_Tungsten = "1.79·10^7_S_m^-1"
|
||||
Cndcvt_Zinc = "1.69·10^7_S_m^-1"
|
||||
Cndcvt_Cobalt = "1.60·10^7_S_m^-1"
|
||||
Cndcvt_Nickel = "1.43·10^7_S_m^-1"
|
||||
Cndcvt_Lithium = "1.08·10^7_S_m^-1"
|
||||
Cndcvt_Iron = "1.00·10^7_S_m^-1"
|
||||
Cndcvt_Platinum = "9.43·10^6_S_m^-1"
|
||||
Cndcvt_Tin = "9.17·10^6_S_m^-1"
|
||||
Cndcvt_Sea_water = "4.80_S_m^-1"
|
||||
Cndcvt_Water = "5.00·10^-3_S_m^-1"
|
||||
Cndcvt_Air = "1.00·10^-13_S_m^-1"
|
||||
Cndcvt_Glass = "1.00·10^-13_S_m^-1"
|
||||
Cndcvt_Wood = "1.00·10^-3_S_m^-1"
|
||||
Rstvt_Silver = "1.59·10^-8_Ω_m"
|
||||
Rstvt_Copper = "1.68·10^-8_Ω_m"
|
||||
Rstvt_Gold = "2.44·10^-8_Ω_m"
|
||||
Rstvt_Aluminium = "2.65·10^-8_Ω_m"
|
||||
Rstvt_Calcium = "3.36·10^-8_Ω_m"
|
||||
Rstvt_Tungsten = "5.60·10^-8_Ω_m"
|
||||
Rstvt_Zinc = "5.90·10^-8_Ω_m"
|
||||
Rstvt_Cobalt = "6.24·10^-8_Ω_m"
|
||||
Rstvt_Nickel = "6.99·10^-8_Ω_m"
|
||||
Rstvt_Lithium = "9.28·10^-8_Ω_m"
|
||||
Rstvt_Iron = "9.70·10^-8_Ω_m"
|
||||
Rstvt_Platinum = "1.06·10^-7_Ω_m"
|
||||
Rstvt_Tin = "1.09·10^-7_Ω_m"
|
||||
Rstvt_Sea_water = "2.1·10^-1_Ω_m"
|
||||
Rstvt_Water = "1.01·10^3_Ω_m"
|
||||
Rstvt_Air = "1.00·10^9_Ω_m"
|
||||
Rstvt_Glass = "5.00·10^14_Ω_m"
|
||||
Rstvt_Wood = "1.00·10^3_Ω_m"
|
||||
|
||||
@@ -24,13 +24,13 @@ void AbstractScrollableMultipleExpressionsView::ContentCell::setHighlighted(bool
|
||||
// Do not call HighlightCell::setHighlighted to avoid marking all cell as dirty
|
||||
m_highlighted = highlight;
|
||||
KDColor defaultColor = backgroundColor();
|
||||
KDColor color = highlight && m_selectedSubviewPosition == SubviewPosition::Center ? Palette::ExpressionInputBackground : defaultColor;
|
||||
KDColor color = highlight && m_selectedSubviewPosition == SubviewPosition::Center ? Palette::Select : defaultColor;
|
||||
m_centeredExpressionView.setBackgroundColor(color);
|
||||
color = highlight && m_selectedSubviewPosition == SubviewPosition::Right ? Palette::ExpressionInputBackground : defaultColor;
|
||||
color = highlight && m_selectedSubviewPosition == SubviewPosition::Right ? Palette::Select : defaultColor;
|
||||
m_rightExpressionView.setBackgroundColor(color);
|
||||
m_approximateSign.setBackgroundColor(defaultColor);
|
||||
if (leftExpressionView()) {
|
||||
color = highlight && m_selectedSubviewPosition == SubviewPosition::Left ? Palette::ExpressionInputBackground : defaultColor;
|
||||
color = highlight && m_selectedSubviewPosition == SubviewPosition::Left ? Palette::Select : defaultColor;
|
||||
leftExpressionView()->setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Avogadro-Konstante"
|
||||
GasTag = "Gaskonstante"
|
||||
Electromagnetism = "Elektromagnetismus"
|
||||
CoulombTag = "Coulomb-Konstante"
|
||||
ConductivityConstants = "Leitfähigkeitskonstanten"
|
||||
Electricity = "Elektrizität"
|
||||
ResistivityConstants = "Konstanten der Widerstandsfähigkeit"
|
||||
Silver = "Silber"
|
||||
Copper = "Kupfer"
|
||||
Gold = "Gold"
|
||||
Aluminium = "Aluminium"
|
||||
Calcium = "Kalzium"
|
||||
Tungsten = "Wolfram"
|
||||
Zinc = "Zink"
|
||||
Cobalt = "Kobalt"
|
||||
Nickel = "Nickel"
|
||||
Lithium = "Lithium"
|
||||
Iron = "eisen"
|
||||
Platinum = "Platin"
|
||||
Tin = "Zinn"
|
||||
Sea_water = "Meerwasser"
|
||||
Water = "Wasser"
|
||||
Air = "Luft"
|
||||
Glass = "Glas"
|
||||
Wood = "Holz"
|
||||
Vacuum_permittivityTag = "Vakuum-Durchlässigkeit"
|
||||
Vacuum_permeabilityTag = "Vakuumdurchlässigkeit"
|
||||
PlanckTag = "Planck - Konstante"
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Avogadro Constant"
|
||||
GasTag = "Gas Constant"
|
||||
Electromagnetism = "Electromagnetism"
|
||||
CoulombTag = "Coulomb Constant"
|
||||
ConductivityConstants = "Conductivity constants"
|
||||
Electricity = "Electricity"
|
||||
ResistivityConstants = "Resistivity Constants"
|
||||
Silver = "Silver"
|
||||
Copper = "Copper"
|
||||
Gold = "Gold"
|
||||
Aluminium = "Aluminium"
|
||||
Calcium = "Calcium"
|
||||
Tungsten = "Tungsten"
|
||||
Zinc = "Zinc"
|
||||
Cobalt = "Cobalt"
|
||||
Nickel = "Nickel"
|
||||
Lithium = "Lithium"
|
||||
Iron = "Iron"
|
||||
Platinum = "Platinum"
|
||||
Tin = "Tin"
|
||||
Sea_water = "Sea Water"
|
||||
Water = "Water"
|
||||
Air = "Air"
|
||||
Glass = "Glass"
|
||||
Wood = "Wood"
|
||||
Vacuum_permittivityTag = "Vacuum permittivity"
|
||||
Vacuum_permeabilityTag = "Vacuum permeability"
|
||||
PlanckTag = "Planck Constant"
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Constante de Avogadro"
|
||||
GasTag = "Constante de gas"
|
||||
Electromagnetism = "Electromagnetismo"
|
||||
CoulombTag = "Constante de Coulomb"
|
||||
ConductivityConstants = "Constantes de conductividad"
|
||||
Electricity = "Electricidad"
|
||||
ResistivityConstants = "Constantes de resistividad"
|
||||
Silver = "Plata"
|
||||
Copper = "cobre"
|
||||
Gold = "Oro"
|
||||
Aluminium = "Aluminio"
|
||||
Calcium = "Calcio"
|
||||
Tungsten = "Tungsteno"
|
||||
Zinc = "Zinc"
|
||||
Cobalt = "Cobalto"
|
||||
Nickel = "Níquel"
|
||||
Lithium = "Litio"
|
||||
Iron = "Hierro"
|
||||
Platinum = "Platino"
|
||||
Tin = "Tin"
|
||||
Sea_water = "Agua de mar"
|
||||
Water = "Agua"
|
||||
Air = "Aire"
|
||||
Glass = "Vidrio"
|
||||
Wood = "Madera"
|
||||
Vacuum_permittivityTag = "Permisividad de vacío"
|
||||
Vacuum_permeabilityTag = "Permeabilidad al vacío"
|
||||
PlanckTag = "Constante de Planck"
|
||||
|
||||
@@ -429,6 +429,27 @@ BoltzmannTag = "Constante de Boltzmann"
|
||||
AvogadroTag = "Constante d'Avogadro"
|
||||
GasTag = "Constante des gaz parfaits"
|
||||
Electromagnetism = "Electromagnétisme"
|
||||
ConductivityConstants = "Constantes de Conductivité"
|
||||
Electricity = "Electricité"
|
||||
ResistivityConstants = "Constantes de Resistivité"
|
||||
Silver = "Argent"
|
||||
Copper = "Cuivre"
|
||||
Gold = "Or"
|
||||
Aluminium = "Aluminium"
|
||||
Calcium = "Calcium"
|
||||
Tungsten = "Tungstène"
|
||||
Zinc = "Zinc"
|
||||
Cobalt = "Cobalt"
|
||||
Nickel = "Nickel"
|
||||
Lithium = "Lithium"
|
||||
Iron = "Fer"
|
||||
Platinum = "Platine"
|
||||
Tin = "Étain"
|
||||
Sea_water = "Eau de mer"
|
||||
Water = "Eau"
|
||||
Air = "Air"
|
||||
Glass = "Verre"
|
||||
Wood = "Bois"
|
||||
CoulombTag = "Constante de Coulomb"
|
||||
EscapeVelocity = "Vitesse de libération"
|
||||
EscapeVelocityFromEarth = "De la Terre"
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Avogadro Állandó"
|
||||
GasTag = "Gázállandó"
|
||||
Electromagnetism = "Elektromágnesesség"
|
||||
CoulombTag = "Coulomb állandó"
|
||||
ConductivityConstants = "Vezetőképességi konstansok"
|
||||
Electricity = "Elektromosság"
|
||||
ResistivityConstants = "Ellenállósági konstansok"
|
||||
Silver = "Ezüst"
|
||||
Copper = "Réz"
|
||||
Gold = "Arany"
|
||||
Aluminium = "Alumínium"
|
||||
Calcium = "Kalcium"
|
||||
Tungsten = "Wolfram"
|
||||
Zinc = "Cink"
|
||||
Cobalt = "Cobalt"
|
||||
Nickel = "Nickel"
|
||||
Lithium = "Lítium"
|
||||
Iron = "Vas"
|
||||
Platinum = "Platina"
|
||||
Tin = "Bádog"
|
||||
Sea_water = "Tengeri víz"
|
||||
Water = "Víz"
|
||||
Air = "Air"
|
||||
Glass = "Üveg"
|
||||
Wood = "Wood"
|
||||
Vacuum_permittivityTag = "Vákuum-engedély"
|
||||
Vacuum_permeabilityTag = "Vákuumpermeabilitás"
|
||||
PlanckTag = "Planck Állandó"
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Costanto di Avogadro"
|
||||
GasTag = "Costante dei gas"
|
||||
Electromagnetism = "Elettromagnetismo"
|
||||
CoulombTag = "Costante di coulomb"
|
||||
ConductivityConstants = "Costanti di conducibilità"
|
||||
Electricity = "Elettricità"
|
||||
ResistivityConstants = "Costanti di resistività"
|
||||
Silver = "Argento"
|
||||
Copper = "Rame"
|
||||
Gold = "Oro"
|
||||
Aluminium = "Aluminio"
|
||||
Calcium = "Calcio"
|
||||
Tungsten = "Tungsteno"
|
||||
Zinc = "Zinco"
|
||||
Cobalt = "Cobalto"
|
||||
Nickel = "Nichel"
|
||||
Lithium = "Litio"
|
||||
Iron = "Ferro"
|
||||
Platinum = "Platino"
|
||||
Tin = "Stagno"
|
||||
Sea_water = "Acqua di mare"
|
||||
Water = "Acqua"
|
||||
Air = "Aria"
|
||||
Glass = "Vetro"
|
||||
Wood = "Legno"
|
||||
Vacuum_permittivityTag = "Permittività del vuoto"
|
||||
Vacuum_permeabilityTag = "Permeabilità al vuoto"
|
||||
PlanckTag = "Costante di Planck"
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Avogadroconstante"
|
||||
GasTag = "Gasconstante"
|
||||
Electromagnetism = "Elektromagnetisme"
|
||||
CoulombTag = "Coulombconstante"
|
||||
ConductivityConstants = "Geleidingsconstanten"
|
||||
Electricity = "Elektriciteit"
|
||||
ResistivityConstants = "Weerstandsconstanten"
|
||||
Silver = "Zilver"
|
||||
Copper = "Koper"
|
||||
Gold = "Goud"
|
||||
Aluminium = "Aluminium"
|
||||
Calcium = "Calcium"
|
||||
Tungsten = "Tungsten"
|
||||
Zinc = "Zink"
|
||||
Cobalt = "Kobalt"
|
||||
Nickel = "Nikkel"
|
||||
Lithium = "Lithium"
|
||||
Iron = "IJzer"
|
||||
Platinum = "Platina"
|
||||
Tin = "Tin"
|
||||
Sea_water = "Zeewater"
|
||||
Water = "Water"
|
||||
Air = "Lucht"
|
||||
Glass = "Glas"
|
||||
Wood = "Hout"
|
||||
Vacuum_permittivityTag = "Elektrische veldconstante"
|
||||
Vacuum_permeabilityTag = "Magnetische veldconstante"
|
||||
PlanckTag = "Planckconstante"
|
||||
|
||||
@@ -430,6 +430,27 @@ AvogadroTag = "Constante Avogadro"
|
||||
GasTag = "Constante de gás"
|
||||
Electromagnetism = "Eletromagnetismo"
|
||||
CoulombTag = "Constante de Coulomb"
|
||||
ConductivityConstants = "Constantes de condutividade"
|
||||
Electricity = "Electricidade"
|
||||
ResistivityConstants = "Constantes de resistividade"
|
||||
Silver = "Prata"
|
||||
Copper = "Cobre"
|
||||
Gold = "Ouro"
|
||||
Aluminium = "Alumínio"
|
||||
Calcium = "Cálcio"
|
||||
Tungsten = "Tungsténio"
|
||||
Zinc = "Zinco"
|
||||
Cobalt = "Cobalto"
|
||||
Nickel = "Níquel"
|
||||
Lithium = "Lítio"
|
||||
Iron = "Ferro de engomar"
|
||||
Platinum = "Platina"
|
||||
Tin = "Lata"
|
||||
Sea_water = "Água do mar"
|
||||
Water = "Água"
|
||||
Air = "Ar"
|
||||
Glass = "Vidro"
|
||||
Wood = "Madeira"
|
||||
Vacuum_permittivityTag = "Permissividade a vácuo"
|
||||
Vacuum_permeabilityTag = "Permeabilidade ao vácuo"
|
||||
PlanckTag = "Constante de Planck"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user