[Bêta] PythonExtra.
Posté le 29/10/2022 09:49
PythonExtra est un add-in Python alternatif pour (à ce stade) Graph 35+E II, Prizm et Graph 90+E. L'objectif est de fournir plus de fonctionnalités : modules standard,
getkey(), fonctions de dessin plus performantes, etc.
Version Bêta 0.2
Graph 35+E II / Prizm / Graph 90+E : PythonExtra-pe-0.2.0-beta.zip
Aperçu de PythonExtra sur Graph 90+E. (Cliquez pour agrandir)
Description sommaire des fonctionnalités :
- Compile pour Graph 90+E (fx-CG 10/20/50) et Graph 35+E II (fx-9860G III)
- Peu de RAM sur Graph 35+E II (c'est difficile d'en trouver sur ce modèle)
- Un shell pas trop mal (saisie rapide, scrolling) avec de bonnes performances
- Plein de modules standard
- array, builtins, cmath, collections, io, math, random, struct, sys, time
- Le module spécifique CASIO : casioplot (fidèle à part sur les polices)
- Un nouveau module gint avec les fonctionnalités avancées de gint :
- Pour l'instant, une bonne partie de <gint/display.h> et <gint/keyboard.h>
- Donc getkey() (attente de touche) ainsi que keydown() (test instantané) !
- Et des fonctions de dessin rapides comme dline() ou drect()
Le plan actuel :
- Être sensiblement compatible avec l'appli Python officielle.
- Pousser les fonctionnalités ajoutées pour vraiment relever le niveau de Python !
- Si du temps de développement se débloque : support autres Graph mono (pas de promesses).
Updates et screenshots à venir. Je n'ai pas l'intention d'implémenter un million de fonctionnalités, juste ce qu'il faut pour s'assurer que ça ne finisse pas mal documenté et non maintenu comme CasioPython.
Dépôt Git :
https://gitea.planet-casio.com/Lephenixnoir/PythonExtra
PythonExtra est notamment possible grâce à l'aide précieuse de
Mb88.
Comparaison directe
Dans l'exemple ci-dessous (
réalisé par Mb88), un Flappy Bird déjà bien optimisé (dessin partiel etc, à gauche) est accéléré un bon gros coup en utilisant PythonExtra et le module
gint pour le dessin (à droite).
Contexte historique
Aux
journées APMEP 2022, redgl0w racontait comment le port MicroPython pour Numworks n'était finalement pas super difficile. Moi je parlais de comment un port maison résoudrait le problème de
getkey(), et Critor m'a convaincu d'essayer sur-le-champ.
En fin de compte, j'ai clôné MicroPython Dimanche à midi et à 1 heure du matin j'avais un port fonctionnel avec
getkey() sur ma Graph 90+E (que j'ai d'ailleurs montré à CASIO Lundi, pour la démo). Comme quoi, des fois ça marche tout seul !
(Enfin, le début marche tout seul. Faire une bonne UI et gérer tous les détails ensuite c'est une autre paire de manches !)
Fichier joint
Citer : Posté le 26/12/2024 20:47 | #
English
Hi, While using the input() function, how do I enter ASCII symbols which are not exposed on the Casio fx-CG50 keypad? For example, I created the following program:
print(s)
At the prompt "s?", I want to enter symbols which are normally available on the en-US keyboard, such as:
PythonExtra: MicroPython v1.23.0-preview.169.g8c5f68f16 on 2024-03-19; sh7305 with sh-4a
Calculator: Casio fx-CG50, OS 3.80.0212
(I have tried to search for keywords on this thread. But my French is limited, I don't know what the equivalent keywords are in French, so my apologies if this has already been answered.)
Francais (Google Translate)
Bonjour, lors de l'utilisation de la fonction 'input()', comment puis-je entrer des symboles ASCII qui ne sont pas exposés sur le clavier Casio fx-CG50? Par exemple, J'ai créé le programme suivant:
print(s)
À l'invite «s?», je veux entrer des symboles qui sont normalement disponibles sur le clavier en-US, comme :
PythonExtra: MicroPython v1.23.0-preview.169.g8c5f68f16 on 2024-03-19; sh7305 with sh-4a
Calculatrice: Casio fx-CG50, OS 3.80.0212
(J'ai essayé de rechercher des mots-clés sur ce fil. Mais mon français est limité, je ne sais pas quels sont les mots-clés équivalents en français, donc mes excuses si cela a déjà été répondu.)
Merci.
Citer : Posté le 26/12/2024 21:04 | #
"_" is the "(-)" key with no modifiers, ":" is "0" with shift or "(-)" with alpha, but yes it seems like i can't input the others. You may be able to get around that limitation by making special codes ? For example :0 for ~ or similar. You can definitely type them in the regular python's editor though.
Caltos : G35+EII, G90+E (briquée )
Citer : Posté le 26/12/2024 21:34 | #
That's on me, I don't think I programmed that!
I can make a note of that, I'm busy enough in this period that I'd invite you to ping for it, and let me know if it's urgent-ish.
Citer : Posté le 26/12/2024 22:27 | #
English: Not urgent for the small demo program that I am writing right now. I need to enter a backslash-escaped octal byte sequence representing a UTF-8 encoded unicode character. For example, the string "\342\210\241" represents the character U+2221. Instead of the backslash "\", I can use the ÷ (division) button, which renders as forwardslash symbol "/", and just make my parser accept any substitute for the backslash symbol.
However, longer term, this will become an important usability issue. Because I notice the same limitation in the REPL mode (i.e. SHELL mode). For example, I cannot enter a question mark symbol "?" in REPL, so I cannot even type the line input("s?") in REPL. Another example, the python3 modulus operator is the percent symbol "%", so I cannot type the expression 32 % 7 in REPL.
French: Pas urgent pour le petit programme de démo que j'écris en ce moment. J'ai besoin d'entrer une séquence d'octets octals avec échappement de barre oblique inverse représentant un caractère unicode encodé en UTF-8. Par exemple, la chaîne « \342\210\241 » représente le caractère U+2221. Au lieu de la barre oblique inverse « \ », je peux utiliser le bouton ÷ (division), qui s'affiche comme symbole de barre oblique «/», et faire en sorte que mon analyseur accepte tout substitut du symbole de barre oblique inverse.
Cependant, à plus long terme, cela deviendra un problème important d'utilisabilité. Parce que je remarque la même limitation dans le mode REPL (c'est-à-dire le mode SHELL). Par exemple, je ne peux pas entrer un symbole de point d'interrogation «?» dans REPL, donc je ne peux même pas taper la ligne input("s?") en REPL. Un autre exemple, l'opérateur modulo python3 est le symbole de pourcentage «%», donc je ne peux pas taper l'expression 32 % 7 en REPL.
Citer : Posté le 27/12/2024 19:58 | #
English
While I have you on this topic, perhaps I can provide some feedback on the bottom-right icon related to this feature? I have some usability problems:
* It is difficult to read some of the icons, particularly the small "a" and the large "A". On my calculator, they are rendered in a dark-red or orange color, which is difficult to read over the black background. The "1" is white, which is far easier to read. I think I would prefer all of them to be white, for the sake of readability.
* The ultra small "lock" icon in the bottom right corner of the circle is almost impossible for me to see, even with my reading glasses.
* The "downarrow" icon that replaces the "lock" icon is so small, I needed a magnifying glass to see what it was. I'm not sure I know what the "downarrow" means. It seems to activate when a button is pressed, so is it just a "button is pressed" indicator?
* I can't seem to figure out the state transition diagram for all the various SHIFT, ALPHA, and SHIFT-ALPHA buttons. In other words, I don't understand how the keypad mode goes from "a" to "A" to "S" to "1". I often want to get to the "1" state, but I find myself stuck in all the other states except for the "1" state. I am wildly pressing the various combination of SHIFT, ALPHA, and SHIFT-ALPHA multiple times, then suddenly I get to the "1" state.
No urgency for me. But when you get to the work of supporting the 95 printable ASCII symbols (0x20 to 0x7E) in the input() function, maybe you can take the opportunity to review the readability of the bottom-right icons.
Francais
Pendant que je vous parle de ce sujet, je peux peut-être vous donner mon avis sur l'icône en bas à droite liée à cette fonctionnalité ? J'ai quelques problèmes d'utilisation :
* Il est difficile de lire certaines icônes, en particulier le petit « a » et le grand « A ». Sur ma calculatrice, elles sont rendues en rouge foncé ou en orange, ce qui est difficile à lire sur le fond noir. Le « 1 » est blanc, ce qui est beaucoup plus facile à lire. Je pense que je préférerais qu'elles soient toutes blanches, pour des raisons de lisibilité.
* L'icône ultra petite en forme de « cadenas » dans le coin inférieur droit du cercle est presque impossible à voir pour moi, même avec mes lunettes de lecture.
* L'icône « flèche vers le bas » qui remplace l'icône « cadenas » est si petite que j'ai eu besoin d'une loupe pour voir ce que c'était. Je ne suis pas sûr de savoir ce que signifie la « flèche vers le bas ». Elle semble s'activer lorsqu'un bouton est enfoncé, alors s'agit-il simplement d'un indicateur « bouton enfoncé » ?
* Je n'arrive pas à comprendre le diagramme de transition d'état pour tous les différents boutons SHIFT, ALPHA et SHIFT-ALPHA. En d'autres termes, je ne comprends pas comment le mode clavier passe de « a » à « A » à « S » à « 1 ». Je veux souvent atteindre l'état « 1 », mais je me retrouve bloqué dans tous les autres états à l'exception de l'état « 1 ». J'appuie frénétiquement sur les différentes combinaisons de SHIFT, ALPHA et SHIFT-ALPHA plusieurs fois, puis soudainement j'arrive à l'état « 1 ».
Aucune urgence pour moi. Mais lorsque vous vous attaquerez à la prise en charge des 95 symboles ASCII imprimables (0x20 à 0x7E) dans la fonction input(), vous pourrez peut-être en profiter pour vérifier la lisibilité des icônes en bas à droite.
Citer : Posté le 27/12/2024 21:07 | #
Thanks for the feedback! It's a feature intended to make typing on the calculator keyboard more convenient. In truth, I feel it works really well. But I'm not sure I explained anywhere how it works. ^^"
You have four modes:
- base ("1" symbol): obtained by not inputting anything
- shift ("S" symbol): obtained by inputting SHIFT
- letters ("a" symbol): obtained by inputting ALPHA
- capital letters ("A" symbol): obtained by inputting both SHIFT and ALPHA
And you can input the SHIFT and ALPHA keys in two ways (example with ALPHA):
- (#1) "Locked method": press ALPHA then release it: in this case the effect becomes permanent, indicated by the lock icon, and remains until you press ALPHA again
- (#2) "Down method": press ALPHA and keep it pressed while you type in some text: in this case the effect only lasts as long as you keep ALPHA pressed, indicated by the arrow down icon, and goes away when you release it
The two following sequences are always equivalent:
- Press ALPHA, release it, type some stuff, then press and release ALPHA again ("ALPHA locked")
- Press ALPHA, keep it pressed while you type some stuff, then release it when you're done ("ALPHA down")
This is intended to reduce the amount of key presses when you need to type in text that alternates frequently between letters, capital letters, and digits/punctuation, compared to the way CASIO handles it.
For instance, assume you want to type in "variableName", starting in base mode ("1"). You notice you have a lot of small letters so you go permanently into letters mode ("a") by pressing ALPHA then releasing it. Then you press the 8 keys needed to write the word variable. Then you have the N, which is a capital letter. It's not really worth changing mode permanently just to type one letter. So you press SHIFT, which sends you into capital letters mode ("A") temporarily, and while it's still down you type the N which comes out capital. By typing while SHIFT was still pressed you have used the "down method". Thus, when you release SHIFT, you're back in letters mode ("a"). And you can type the rest of the name. The whole sequence looks like:
[ALPHA]↓↑
# you are now permanently in "a" mode
[2]↓↑ [X,O,T]↓↑ [6]↓↑ [(]↓↑ [X,O,T]↓↑ [log]↓↑ [→]↓↑ [cos]↓↑
# you have now typed "variable"
[SHIFT]↓ [8]↓↑ [SHIFT]↑
# this sequence goes into "A" mode for just one key
# you now have "variableN" and are back in "a" mode
[X,O,T]↓↑ [7]↓↑ [cos]↓↑
[ALPHA]↓↑
# last ALPHA sends you back to "1" mode, if desired
The expected way to go back to "1" is to release all keys, look at the current mode (which is always locked), and then cancel out whatever is shown. So if you're in "S" mode press/release SHIFT, if you're in "a" mode press/release ALPHA, if you're in "A" mode (which should be rare) do both.
I'll try to follow your recommendations. So:
- A way to remove all modifiers and get back to "1" would be desirable. I'd suggest AC/ON for this but it's already used to clear the line. Do you have any suggestions?
- I'll add an option to make the icons bigger and more legible. Speaking of which, is the font size fine for you?
Citer : Posté le 28/12/2024 00:19 | #
English
Ah, I understand now, you have implemented the SHIFT and ALPHA modifier keys as they would be implemented on a computer keyboard, so that SHIFT and the letter button can be pressed at the same time. Three problems:
1) It is not conventional on a calculator to use the concurrent press of *two* buttons to invoke a function or feature. The only exception that I know is the HP-50g, which I argue has the worst UI in the history of calculators, so I don't think we should strive to emulate it. :-P
2) It requires 2 hands. Not everyone has 2 hands. :-) But even people with 2 hands, sometimes we are using the other hand for some other purpose.
3) The ALPHA letters on the CG50 buttons are printed in dark-red over black. Even in moderately good light, they are incredibly difficult to read. I am frequently forced to tilt the calculator to different angles, to catch the reflected light in different ways, to read the letters. If I am holding down the SHIFT (or ALPHA) button, I cannot tilt the calculator in various ways, without accidentally releasing the modifier button. In other words, I would probably not use the "hold-down" feature of the SHIFT and ALPHA modifiers.
I can definitely see that your system would be more efficient, if the user is able to use it. So maybe this can be made into a user-selectable option?
With regards to a quick-exit feature to the "1" mode, the only thing I can think of is holding down the SHIFT and ALPHA buttons at the same time, assuming your keypad driver supports that combination. Or a double-tap on SHIFT or ALPHA, if the driver supports double-clicks.
An option to increase readability of the bottom-right icons is to separate the "lock" and "downarrow" icons from the "a/A/S/1" icons, so that they can be made larger. I agree that this is not as aesthetically pleasing as superimposing them, but the current "lock" and "downarrow" icons are too microscopic.
Another option is to move these icons to the top-left corner instead of the bottom-right. First, that location seems more consistent with the other Casio apps. Second, the left-side is consistent with the left side location of the SHIFT and ALPHA buttons. Third, you have the option increasing the vertical height of the header bar (e.g. use the equivalent of 1.5 lines or 2 lines) without serious impact to the rest of the display below.
With regards to the overall font size, the black letters on white background (or their inverse on the menu bar) are quite readable even without my reading glasses. It would be great to have the option of increasing the font size by 1.5X or 2X on-demand, but this is not critical. However, if the letters are colored (e.g. red or yellow, like the icons), they become hard to read at the current font size.
One final thought on keypad data entry: Typing on a calculator keypad without QWERTY arrangement is torture. I wonder if it's possible to create a virtual keyboard (à la mobile phone) which is opened and closed by a soft menu button. The user can use the arrow keys to select the letters, hitting EXE to enter each letter. I think you'd need 4 rows, to get the shifted symbols above the 0-9 buttons, but in the current font, there seems to be enough space on the screen. Yes, I know this would be a heck of a lot of work. Just an idea... :-)
Ok, one more random idea: the OPTN button could be the CTRL key if that becomes needed at some point.
Francais
(désolé, ce post est trop long...)
Citer : Posté le 28/12/2024 00:45 | #
Thinking about your SHIFT and ALPHA keys some more, I may have misunderstood your system. I now realize that I am not *forced* to use the "hold-down" feature. I could just always press-and-release the SHIFT and ALPHA buttons.
I think the reason I was confused by your system is because there is a coupling between the SHIFT and ALPHA keys. I think my expectation of the SHIFT and ALPHA behavior was the following:
SHIFT always toggles between "1" and "S":
* If in "1" or "a" or "A": SHIFT goes to "S".
* If in "S", SHIFT goes to "1".
ALPHA cycles through "a", "A", and "1":
* If in "1" or "S": ALPHA goes to "a"
* If in "a": ALPHA goes to "A".
* If in "A": ALPHA goes to "1".
In this way, I can always hit SHIFT (at most twice) or ALPHA (at most thrice) to get back to "1".
Citer : Posté le 28/12/2024 12:03 | #
Right, you're indeed not required to do the multi-key presses. If you don't use them however, there's a missed opportunity to use a single press/release of ALPHA as "alpha mode for the next key" and a double one as "alpha mode locked", which is what CASIO does.
In the end, I'm 100% open to having options for that, and I'll experiment. I should have some time later today to handle some of your requests. Quick summary, so I don't forget anything:
- A way to input special characters in the shell (will take some effort)
- Option for more legible mode indicators (black and white only, down arrow + lock larger and on the right)
- Options for other SHIFT/ALPHA input modes such as disabling "down" style (avoids surprising down arrow icons + accidental presses compared to just not using it) and the independent SHIFT/ALPHA behaviors (should be fairly easy)
- Font sizes: was on the TODO list (takes effort because the fonts need to be drawn ^^"; lower priority)
- Visual keyboard: why not? (will take some effort, lower priority)
Citer : Posté le 28/12/2024 18:30 | #
Yes, I think your list captures the important points. Moving the icons to the top-left might was motivated by using 2 icons side-by-side (for readability), but avoiding the bleed into the space needed by the F6 menu label.
With regards to the press-hold button sequence, I feel that it is faster and easier on a calculator to tap a modifier button (e.g. ALPHA) multiple times then press another button, rather than to do a press-modifier-hold then press another button at the same time. I don't have hard evidence, just my intuition.
The initial proof of concept for the virtual keyboard might be something similar to the CHAR menu of the default Python app, which shows 95 characters in a 19x5 grid. A QWERTY arrangement may be something for the future. Unlike the Python CHAR menu, it would be nice if the virtual keyboard remained active after entering each character so that variable names can be typed without shifting in and out of the virtual keyboard. It occurs to me that the OPTN button could be used as the "Select" function (instead of EXE), so that the right thumb can navigate the arrow keys, and the left thumb can select the character.
I have a slightly tangential request while we are on this topic: Can you point me to the general location in your PythonExtra git repo where this text-based UI of PythonExtra is implemented? I have been contemplating doing a port of my RPN calculator app for TI-83+/TI-84+ to the Casio CG50 and 9750GIII platforms. I don't have a lot of spare time right now, but I managed to get a "hello world" program working on your gint/fxSDK platform. However, I need a lot more than a "hello world": I need proportional and monospace fonts, keyboard reading and dispatching, a blinking cursor, a soft menu bar, memory management, and so on. When I found your PythonExtra app, I realized that you have already implemented much of what I need: I basically need PythonExtra without all of the MicroPython getting in the way. :-) The hardest part is finding the 10-20 hours of week of uninterrupted coding time, but I think I can get started around April or May of 2025.
Citer : Posté le 30/12/2024 20:49 | #
Speaking of UI, you may be interested in the JustUI library Lephé also made for gint/fxSDK (it looks somewhat similar to the PythonEx UI), though the documentation for it isn't really complete in my taste