π
<-

Outils communautaires de programmation fx-92 SC+

:fxesp32b: :fxesp32n: :fxesp32v:

Re: Outils communautaires de programmation fx-92 SC+

Unread postby Krevo_ » 12 Oct 2019, 11:31

A part ça, ça reste très impressionnant comme outil !!

Au passage j'ai du installé Firefox dans la machine virtuelle parce que de base avec IE11 l'url du programme fx92sc+ est trop longue et ça le faisait planter. lol.
Découvrez mon projet principal : Casio Basic Web Interpreter, le basic Casio dans votre navigateur web !
User avatar
Krevo_Premium
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 89.3%
 
Posts: 39
Joined: 06 Oct 2019, 17:32
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: Krevo_
GitHub: Krevo

Re: Outils communautaires de programmation fx-92 SC+

Unread postby ptijoz » 12 Oct 2019, 11:36

Bravo IE ! les URL de cette longueur là, ça n'avait sans doute pas été envisagé !!
User avatar
ptijoz
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 34.8%
 
Posts: 335
Images: 0
Joined: 17 Oct 2018, 15:38
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Outils communautaires de programmation fx-92 SC+

Unread postby critor » 15 Oct 2019, 09:46

La dernière participation reçue utilise la variable θ (orientation tortue, non affectable directement et donc classable dans le code avec les variables x et y je pense).
Il serait donc pratique de la rajouter au lexer.

Merci. :)
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 50.4%
 
Posts: 42146
Images: 16490
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: Outils communautaires de programmation fx-92 SC+

Unread postby Lephe » 15 Oct 2019, 10:26

C'est chose faite, il ne manquait que le côté lexer. J'ai rajouté un test avec :)
User avatar
LephePartenaire
Niveau 11: LV (Légende Vivante)
Niveau 11: LV (Légende Vivante)
Level up: 16.8%
 
Posts: 387
Images: 42
Joined: 15 Jun 2018, 19:53
Gender: Male
Calculator(s):
MyCalcs profile

Re: Outils communautaires de programmation fx-92 SC+

Unread postby critor » 15 Oct 2019, 11:05

Super, quelle rapidité ! :)

Alors voici la dernière version du convertisseur en touches fx-92+SC qui va avec :
Code: Select all
#!/usr/bin/python3.7


import sys
import getopt

from lexer import UrlLexer, TextLexer, T

#---
# Main program
#---

usage_string = """
usage: {} <in_url> <out_file> <[options...]

Input mode:
Input is a wes.casio.com URL ("https://...F908313200333500")

#""".format(sys.argv[0]).strip()

E_KEYPRESS=1
E_LEFTCLIC=2
E_WAIT    =3

events=[]

K_F1   =112
K_F2   =113
K_F3   =114
K_F4   =115
K_F5   =116
K_F6   =117
K_F7   =118
K_F8   =119
K_F9   =120
K_F10  =121
K_F11  =122
K_F12  =123
K_LEFT = 37
K_RIGHT= 39
K_UP   = 38
K_DOWN = 40
K_0    = 96
K_1    = 97
K_2    = 98
K_3    = 99
K_4    =100
K_5    =101
K_6    =102
K_7    =103
K_8    =104
K_9    =105
K_DEC  =110
K_PLUS =107
K_MINUS=109
K_STAR =106
K_SLASH=111
K_LP   = 53
K_RP   =219
K_EQUAL=187
K_X    = 88
K_Y    = 89
K_ENTER= 13

def usage(exitcode=None):
    print(usage_string, file=sys.stderr)

    if exitcode is not None:
        sys.exit(exitcode)

def i2leb(v,n):
    v=int(v)
    data=bytearray([])
    while(v):
        data.append(v%256)
        v>>=8
        n-=1
    while(n>0):
      data.append(0)
      n-=1
    return data

def a2leb(a,n):
    data=bytearray([])
    for k in a:
        data.extend(i2leb(k,n))
    return data

def s2utf16(s):
    data=bytearray([])
    for k in range(len(s)):
        data.extend(i2leb(ord(s[k]),2))
    return data

s_window="fx-92+ Speciale College Emulator.exe|fx-92+ Spéciale Collège Emulator|#32770"
s_end=i2leb(4*2,4)+s2utf16("$END")
d_delay=100

def addclick(x,y):
    events.append([E_LEFTCLIC,x,y])
    addwait(d_delay)

def addwait(t):
    events.append([E_WAIT,t])

def addkey(k):
    events.append([E_KEYPRESS,k])
    addwait(d_delay)

def addkeys(a):
    for k in a:
      addkey(k)

def lexer2keys(lex):
    addkey(K_F4)
    addclick(30,40)
    addclick(80,65)
    addwait(2000)
    addkeys([K_F3,K_1])
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(65,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(105,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(145,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(180,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(220,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(260,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(260,475)
    addkeys([K_F3,K_8])
    addkeys([K_F1,K_F3,K_DOWN,K_4,K_1,K_4])
    stack=[]
    iparam=0
    while not lex.at_end():
        t=lex.lex()
        # script instructions
        if(t.type==T.FORWARD):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_1])
        elif(t.type==T.ROTATE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_2])
        elif(t.type==T.ORIENT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_3])
        elif(t.type==T.GOTO):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_4])
        elif(t.type==T.PENDOWN):
            addkeys([K_F5,K_DOWN,K_1])
        elif(t.type==T.PENUP):
            addkeys([K_F5,K_DOWN,K_2])
        elif(t.type==T.SETVAR):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_3])
        elif(t.type==T.INPUT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_4])
        elif(t.type==T.MESSAGE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_DOWN,K_1])
        elif(t.type==T.PRINT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_DOWN,K_2])
        elif(t.type==T.STYLE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_DOWN,K_3])
        elif(t.type==T.WAIT):
            addkeys([K_F5,K_DOWN,K_DOWN,K_4])
        elif(t.type==T.REPEAT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_1])
        elif(t.type==T.REPEAT_END):
            stack.append(t.type)
            stack=stack[:-1]
            addkey(K_DOWN)
        elif(t.type==T.WHILE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_2])
        elif(t.type==T.WHILE_END):
            stack=stack[:-1]
            (K_DOWN)
        elif(t.type==T.IF):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_3])
        elif(t.type==T.IF_END):
            stack=stack[:-1]
            addkey(K_DOWN)
        elif(t.type==T.IFELSE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_4])
        elif(t.type==T.ELSE):
            addkey(K_DOWN)
        elif(t.type==T.IFELSE_END):
            stack=stack[:-1]
            addkey(K_DOWN)
        # instructions separator bytes
        elif(t.type==T.NOP):
            addkeys([K_F5,K_UP,K_3])
        elif(t.type==T.EOL):
            pass
        elif(t.type==T.END):
            pass
        elif(t.type==T.PARAM):
            tin=stack[len(stack)-1]
            if(tin in [T.REPEAT,T.WHILE,T.IF,T.IFELSE]):
                addkeys([K_ENTER,K_ENTER])
            if(tin in [T.FORWARD,T.ROTATE,T.ORIENT,T.PRINT]):
                addkeys([K_ENTER,K_ENTER])
                stack=stack[:-1]
            if(tin==T.GOTO):
                iparam+=1
                if(iparam==2):
                    addkeys([K_ENTER,K_ENTER])
                    stack=stack[:-1]
                else:
                    addkey(K_ENTER)
            if(tin==T.INPUT):
                addkey(K_ENTER)
                stack=stack[:-1]
            if(tin==T.SETVAR):
                iparam+=1
                if(iparam==2):
                    addkey(K_ENTER)
                    stack=stack[:-1]
                else:
                    addkey(K_ENTER)
        # numeric values
        elif(t.type==T.CONST):
            if(stack[len(stack)-1] in [T.MESSAGE,T.STYLE]):
                addkey(K_1+t.args[0]-1)
            else:
              if(t.args[0]==3.141592653589793):
                addkey(K_F1)
                addclick(160,635)
              else:
                s=""
                d=0
                n=t.args[0]
                if(n<0):
                    addkey(K_F1)
                    addclick([65,445])
                    s+="[(-)]"
                n=abs(n)
                ni=n//1
                nd=n%1
                if(not(ni) and not(nd)):
                    addkey(K_0)
                    s+="[0]"
                else :
                    if(ni):
                        ss=""
                        tevents=bytearray()
                        while(ni):
                            tevents.append(K_0+int(ni%10))
                            ss="["+str(int(ni%10))+"]"+ss
                            ni//=10
                        tevents.reverse()
                        addkeys(tevents)
                        s+=ss
                    if(nd):
                       addkey(K_DEC)
                       s+="[,]"
                       while(nd):
                           d=int(10*nd)
                           if(abs((round(10*nd)-10*nd)/nd)<0.000001):
                               d=round(10*nd)
                               nd=0
                           addkey(K_0+d)
                           s+="["+str(d)+"]"
                           nd=10*nd%1
        # variables
        elif(t.type==T.VAR):
            if(stack[len(stack)-1]==T.SETVAR and iparam==1 or stack[len(stack)-1]==T.INPUT):
                addkeys([K_RIGHT,K_1+"ABCDEFM".index(t.args[0])])
            else:
                if(t.args[0]=="theta"):
                    addkeys([K_F5,K_UP,K_UP,K_1])
                elif(t.args[0] in "xy"):
                    addkey(t.args[0]=="x" and K_X or K_Y)
                else:
                    addkey(K_F2)
                    k="ABCDEFM".index(t.args[0])
                    addclick([65,105,145,180,220,260,260][k],[445,445,445,445,445,445,475][k])
        # operators
        elif(t.type==T.PLUS):
            addkey(K_PLUS)
        elif(t.type==T.MINUS):
            addkey(K_MINUS)
        elif(t.type==T.STAR):
            addkey(K_STAR)
        elif(t.type==T.SLASH):
            addkey(K_SLASH)
        elif(t.type==T.EXP):
            addclick(260,380)
        # relations
        elif(t.type==T.EQUAL):
            addkey(K_EQUAL)
        elif(t.type==T.REL):
            addkeys([K_F5,K_2+["!=",">","<",">=","<="].index(t.args[0])])
        # separator chars
        elif(t.type==T.LPAR):
            addkey(K_LP)
        elif(t.type==T.RPAR):
            addkey(K_RP)
        elif(t.type==T.SEMI):
            addkeys([K_F1,K_3])
        # functions
        elif(t.type==T.FUN):
            # with only keys
            if(t.args[0]=='Ent'):
                addkeys([K_F1,K_STAR])
            elif(t.args[0]=='EntEx'):
                addkeys([K_F1,K_SLASH])
            elif(t.args[0]=='Rnd'):
                addkeys([K_F1,K_0])
            elif(t.args[0]=='Arond'):
                addkeys([K_F2,K_0])
            elif(t.args[0]=='RanInt'):
                addkeys([K_F2,K_DEC])
            # with mouse click
            elif(t.args[0]=='sqrt'):
                addkey(K_F1)
                addclick(105,380)
            elif(t.args[0]=='cbrt'):
                addkey(K_F1)
                addclick(220,380)
            elif(t.args[0]=='GCD'):
                addkey(K_F1)
                addclick(65,410)
            elif(t.args[0]=='LCM'):
                addkey(K_F1)
                addclick(105,410)
            elif(t.args[0] in ['log10','exp10']):
                if t.args[0]=='exp10':
                    addkey(K_F1)
                addclick(220,410)
            elif(t.args[0] in ['log','exp']):
                if t.args[0]=='exp':
                    addkey(K_F1)
                addclick(260,410)
            elif(t.args[0]=='Abs'):
                addclick(145,445)
            elif(t.args[0] in ['sin','asin']):
                if t.args[0]=='asin':
                    addkey(K_F1)
                addclick(180,445)
            elif(t.args[0] in ['cos','acos']):
                if t.args[0]=='acos':
                    addkey(K_F1)
                addclick(220,445)
            elif(t.args[0] in ['tan','atan']):
                if t.args[0]=='atan':
                    addkey(K_F1)
                addclick(260,445)
            else:
                print(t,"WARNING : UNKNOWN FUNCTION")
        else:
            print(t,"WARNING : UNKNOWN TOKEN")

def main():
    # Read command-line arguments
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], "hus",
            ["help"])
        opts = dict(opts)

        if len(sys.argv) == 1 or "-h" in opts or "--help" in opts:
            usage(0)

        if len(args) < 2:
            usage(1)

    except getopt.GetoptError as e:
        print("error:", e, file=sys.stderr)
        print("Try '{} --help' for details.".format(sys.argv[0]), file=sys.stderr)
        sys.exit(1)

    program = args[0]
    file = args[1]

    lex = UrlLexer(program)

    lex.rewind()
    lexer2keys(lex)

    datab=a2leb([0x1E848A,0x0F4275,0x01,0x00,0x00,0x0640,0x0384,0x0640,0x0384,0x3F800000],4)
    datab.extend(i2leb(1+len(events),4))
    datab.extend(a2leb([0x64,0x01010101,0x03340101,0x00,0x01,0x07B1DE00],4))
    datab.extend(a2leb([0x08,0x030078,0x00,0x00,0x0152,0x02CA,0x00,0x01,0x00],4))
    datab.extend(i2leb(2*len(s_window),4))
    datab.extend(s2utf16(s_window))
    datab.extend(i2leb(0x00,4))
    datab.extend(i2leb(2*5,4)+s2utf16("$NEXT"))
    datab.extend(s_end)
    for k in events:
        if(k[0]==E_KEYPRESS):
            datab.extend(a2leb([0x05,0x32,k[1],0xFF,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x00],4))
            datab.extend(s_end)
        elif(k[0]==E_WAIT):
            datab.extend(a2leb([0x07,k[1],k[1],0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00],4))
            datab.extend(s_end)
        elif(k[0]==E_LEFTCLIC):
            datab.extend(a2leb([0x03,0x32,0x01,0x01,k[1],k[2],0x00,0x01,0x00,0x00,0x00,0x00],4))
            datab.extend(s_end)
    f=open(file,"wb+")
    f.write(datab)
    f.close()

    return 0

if __name__ == "__main__":
    sys.exit(main())
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 50.4%
 
Posts: 42146
Images: 16490
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: Outils communautaires de programmation fx-92 SC+

Unread postby Krevo_ » 15 Oct 2019, 11:50

J'ai un problème avec le convertisseur.
J'ai voulu faire une version un peu rusée pour améliorer mon score au concours de tracé.

J'ai donc un programme avec :
Code: Select all
,3484525421→M

cf http://wes.casio.com/math/index.php?q=I-295A+U-000000000000+M-0E00000000+S-000410110000100E0010B300D365+E-F90B2E33343834353235343231004000F901F903F901F902

Et quand j'utilise le script python pour convertir et générer un fichier de macro, quand j'utilise ce fichier de macro ça tape ceci :
Code: Select all
,348452542099999984515079631819389760494232177734→M


http://wes.casio.com/math/index.php?q=I-295A+U-000000000000+M-0E00000000+S-000410110000100E0010B300D365+E-F90B2E333438343532353432303939393939393834353135303739363331383139333839373630343934323332313737373334004000F901F903F901F903F901F902

Du coup, ça prend + d'octets (et le programme complet ne rentre plus en mémoire) et ce n'est pas fidèle à mon programme de départ, ce qui risque de poser problème lors de l'évaluation.

Sans doute dû à une différence entre flottant et décimal codé binaire, qu'en pensez vous ? Que faire ?
(après rien ne dit que j'aurais finaliser ma version "rusée" avant dimanche)
Découvrez mon projet principal : Casio Basic Web Interpreter, le basic Casio dans votre navigateur web !
User avatar
Krevo_Premium
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 89.3%
 
Posts: 39
Joined: 06 Oct 2019, 17:32
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: Krevo_
GitHub: Krevo

Re: Outils communautaires de programmation fx-92 SC+

Unread postby critor » 15 Oct 2019, 12:08

Le problème vient initialement du Lexer utilisé, qui détecte les nombres décimaux et les stocke en virgule flottante, soit avec des écarts par rapport à la saisie décimale.

Quel script Python de conversion utilises-tu ?
Le mien ou celui de Pavel ?
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 50.4%
 
Posts: 42146
Images: 16490
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: Outils communautaires de programmation fx-92 SC+

Unread postby Krevo_ » 15 Oct 2019, 12:09

critor wrote:Le problème vient initialement du Lexer utilisé, qui stocke les nombres décimaux en virgule flottante.

Quel script Python de conversion utilises-tu ?
Le mien ou celui de Pavel ?


Le tien.
Découvrez mon projet principal : Casio Basic Web Interpreter, le basic Casio dans votre navigateur web !
User avatar
Krevo_Premium
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 89.3%
 
Posts: 39
Joined: 06 Oct 2019, 17:32
Location: Lyon
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: Krevo_
GitHub: Krevo

Re: Outils communautaires de programmation fx-92 SC+

Unread postby Pavel » 15 Oct 2019, 12:10

Krevo_ wrote:Que faire ?


Je viens de vérifier l'URL avec mon script et cela fonctionne sans problème. Si c'est urgent, tu pourrais essayer d'utiliser mon script avant que le problème soit résolu.
User avatar
PavelPremium
Niveau 7: EP (Espèce Protégée: geek)
Niveau 7: EP (Espèce Protégée: geek)
Level up: 83.6%
 
Posts: 107
Joined: 19 Sep 2018, 10:50
Gender: Male
Calculator(s):
MyCalcs profile

Re: Outils communautaires de programmation fx-92 SC+

Unread postby critor » 15 Oct 2019, 12:26

J'ai mis à jour le script lié en 1er post :
viewtopic.php?p=246387#p246387

Voici la dernière version qui marche avec ,3484525421→M, changé une décimale dans la détection d'erreurs d'approximation :
Code: Select all
#!/usr/bin/python3.7


import sys
import getopt

from lexer import UrlLexer, TextLexer, T

#---
# Main program
#---

usage_string = """
usage: {} <in_url> <out_file> <[options...]

Input mode:
Input is a wes.casio.com URL ("https://...F908313200333500")

#""".format(sys.argv[0]).strip()

E_KEYPRESS=1
E_LEFTCLIC=2
E_WAIT    =3

events=[]

K_F1   =112
K_F2   =113
K_F3   =114
K_F4   =115
K_F5   =116
K_F6   =117
K_F7   =118
K_F8   =119
K_F9   =120
K_F10  =121
K_F11  =122
K_F12  =123
K_LEFT = 37
K_RIGHT= 39
K_UP   = 38
K_DOWN = 40
K_0    = 96
K_1    = 97
K_2    = 98
K_3    = 99
K_4    =100
K_5    =101
K_6    =102
K_7    =103
K_8    =104
K_9    =105
K_DEC  =110
K_PLUS =107
K_MINUS=109
K_STAR =106
K_SLASH=111
K_LP   = 53
K_RP   =219
K_EQUAL=187
K_X    = 88
K_Y    = 89
K_ENTER= 13

def usage(exitcode=None):
    print(usage_string, file=sys.stderr)

    if exitcode is not None:
        sys.exit(exitcode)

def i2leb(v,n):
    v=int(v)
    data=bytearray([])
    while(v):
        data.append(v%256)
        v>>=8
        n-=1
    while(n>0):
      data.append(0)
      n-=1
    return data

def a2leb(a,n):
    data=bytearray([])
    for k in a:
        data.extend(i2leb(k,n))
    return data

def s2utf16(s):
    data=bytearray([])
    for k in range(len(s)):
        data.extend(i2leb(ord(s[k]),2))
    return data

s_window="fx-92+ Speciale College Emulator.exe|fx-92+ Spéciale Collège Emulator|#32770"
s_end=i2leb(4*2,4)+s2utf16("$END")
d_delay=100

def addclick(x,y):
    events.append([E_LEFTCLIC,x,y])
    addwait(d_delay)

def addwait(t):
    events.append([E_WAIT,t])

def addkey(k):
    events.append([E_KEYPRESS,k])
    addwait(d_delay)

def addkeys(a):
    for k in a:
      addkey(k)

def lexer2keys(lex):
    addkey(K_F4)
    addclick(30,40)
    addclick(80,65)
    addwait(2000)
    addkeys([K_F3,K_1])
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(65,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(105,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(145,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(180,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(220,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(260,445)
    addkeys([K_9,K_F1,K_DEC])
    addclick(65,475)
    addclick(260,475)
    addkeys([K_F3,K_8])
    addkeys([K_F1,K_F3,K_DOWN,K_4,K_1,K_4])
    stack=[]
    iparam=0
    while not lex.at_end():
        t=lex.lex()
        # script instructions
        if(t.type==T.FORWARD):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_1])
        elif(t.type==T.ROTATE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_2])
        elif(t.type==T.ORIENT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_3])
        elif(t.type==T.GOTO):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_4])
        elif(t.type==T.PENDOWN):
            addkeys([K_F5,K_DOWN,K_1])
        elif(t.type==T.PENUP):
            addkeys([K_F5,K_DOWN,K_2])
        elif(t.type==T.SETVAR):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_3])
        elif(t.type==T.INPUT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_4])
        elif(t.type==T.MESSAGE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_DOWN,K_1])
        elif(t.type==T.PRINT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_DOWN,K_2])
        elif(t.type==T.STYLE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_DOWN,K_DOWN,K_3])
        elif(t.type==T.WAIT):
            addkeys([K_F5,K_DOWN,K_DOWN,K_4])
        elif(t.type==T.REPEAT):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_1])
        elif(t.type==T.REPEAT_END):
            stack.append(t.type)
            stack=stack[:-1]
            addkey(K_DOWN)
        elif(t.type==T.WHILE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_2])
        elif(t.type==T.WHILE_END):
            stack=stack[:-1]
            (K_DOWN)
        elif(t.type==T.IF):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_3])
        elif(t.type==T.IF_END):
            stack=stack[:-1]
            addkey(K_DOWN)
        elif(t.type==T.IFELSE):
            stack.append(t.type)
            iparam=0
            addkeys([K_F5,K_UP,K_UP,K_4])
        elif(t.type==T.ELSE):
            addkey(K_DOWN)
        elif(t.type==T.IFELSE_END):
            stack=stack[:-1]
            addkey(K_DOWN)
        # instructions separator bytes
        elif(t.type==T.NOP):
            addkeys([K_F5,K_UP,K_3])
        elif(t.type==T.EOL):
            pass
        elif(t.type==T.END):
            pass
        elif(t.type==T.PARAM):
            tin=stack[len(stack)-1]
            if(tin in [T.REPEAT,T.WHILE,T.IF,T.IFELSE]):
                addkeys([K_ENTER,K_ENTER])
            if(tin in [T.FORWARD,T.ROTATE,T.ORIENT,T.PRINT]):
                addkeys([K_ENTER,K_ENTER])
                stack=stack[:-1]
            if(tin==T.GOTO):
                iparam+=1
                if(iparam==2):
                    addkeys([K_ENTER,K_ENTER])
                    stack=stack[:-1]
                else:
                    addkey(K_ENTER)
            if(tin==T.INPUT):
                addkey(K_ENTER)
                stack=stack[:-1]
            if(tin==T.SETVAR):
                iparam+=1
                if(iparam==2):
                    addkey(K_ENTER)
                    stack=stack[:-1]
                else:
                    addkey(K_ENTER)
        # numeric values
        elif(t.type==T.CONST):
            if(stack[len(stack)-1] in [T.MESSAGE,T.STYLE]):
                addkey(K_1+t.args[0]-1)
            else:
              if(t.args[0]==3.141592653589793):
                addkey(K_F1)
                addclick(160,635)
              else:
                s=""
                d=0
                n=t.args[0]
                if(n<0):
                    addkey(K_F1)
                    addclick([65,445])
                    s+="[(-)]"
                n=abs(n)
                ni=n//1
                nd=n%1
                if(not(ni) and not(nd)):
                    addkey(K_0)
                    s+="[0]"
                else :
                    if(ni):
                        ss=""
                        tevents=bytearray()
                        while(ni):
                            tevents.append(K_0+int(ni%10))
                            ss="["+str(int(ni%10))+"]"+ss
                            ni//=10
                        tevents.reverse()
                        addkeys(tevents)
                        s+=ss
                    if(nd):
                       addkey(K_DEC)
                       s+="[,]"
                       while(nd):
                           d=int(10*nd)
                           if(abs((round(10*nd)-10*nd)/nd)<0.00001):
                               d=round(10*nd)
                               nd=0
                           addkey(K_0+d)
                           s+="["+str(d)+"]"
                           nd=10*nd%1
        # variables
        elif(t.type==T.VAR):
            if(stack[len(stack)-1]==T.SETVAR and iparam==1 or stack[len(stack)-1]==T.INPUT):
                addkeys([K_RIGHT,K_1+"ABCDEFM".index(t.args[0])])
            else:
                if(t.args[0]=="theta"):
                    addkeys([K_F5,K_UP,K_UP,K_1])
                elif(t.args[0] in "xy"):
                    addkey(t.args[0]=="x" and K_X or K_Y)
                else:
                    addkey(K_F2)
                    k="ABCDEFM".index(t.args[0])
                    addclick([65,105,145,180,220,260,260][k],[445,445,445,445,445,445,475][k])
        # operators
        elif(t.type==T.PLUS):
            addkey(K_PLUS)
        elif(t.type==T.MINUS):
            addkey(K_MINUS)
        elif(t.type==T.STAR):
            addkey(K_STAR)
        elif(t.type==T.SLASH):
            addkey(K_SLASH)
        elif(t.type==T.EXP):
            addclick(260,380)
        # relations
        elif(t.type==T.EQUAL):
            addkey(K_EQUAL)
        elif(t.type==T.REL):
            addkeys([K_F5,K_2+["!=",">","<",">=","<="].index(t.args[0])])
        # separator chars
        elif(t.type==T.LPAR):
            addkey(K_LP)
        elif(t.type==T.RPAR):
            addkey(K_RP)
        elif(t.type==T.SEMI):
            addkeys([K_F1,K_3])
        # functions
        elif(t.type==T.FUN):
            # with only keys
            if(t.args[0]=='Ent'):
                addkeys([K_F1,K_STAR])
            elif(t.args[0]=='EntEx'):
                addkeys([K_F1,K_SLASH])
            elif(t.args[0]=='Rnd'):
                addkeys([K_F1,K_0])
            elif(t.args[0]=='Arond'):
                addkeys([K_F2,K_0])
            elif(t.args[0]=='RanInt'):
                addkeys([K_F2,K_DEC])
            # with mouse click
            elif(t.args[0]=='sqrt'):
                addkey(K_F1)
                addclick(105,380)
            elif(t.args[0]=='cbrt'):
                addkey(K_F1)
                addclick(220,380)
            elif(t.args[0]=='GCD'):
                addkey(K_F1)
                addclick(65,410)
            elif(t.args[0]=='LCM'):
                addkey(K_F1)
                addclick(105,410)
            elif(t.args[0] in ['log10','exp10']):
                if t.args[0]=='exp10':
                    addkey(K_F1)
                addclick(220,410)
            elif(t.args[0] in ['log','exp']):
                if t.args[0]=='exp':
                    addkey(K_F1)
                addclick(260,410)
            elif(t.args[0]=='Abs'):
                addclick(145,445)
            elif(t.args[0] in ['sin','asin']):
                if t.args[0]=='asin':
                    addkey(K_F1)
                addclick(180,445)
            elif(t.args[0] in ['cos','acos']):
                if t.args[0]=='acos':
                    addkey(K_F1)
                addclick(220,445)
            elif(t.args[0] in ['tan','atan']):
                if t.args[0]=='atan':
                    addkey(K_F1)
                addclick(260,445)
            else:
                print(t,"WARNING : UNKNOWN FUNCTION")
        else:
            print(t,"WARNING : UNKNOWN TOKEN")

def main():
    # Read command-line arguments
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], "hus",
            ["help"])
        opts = dict(opts)

        if len(sys.argv) == 1 or "-h" in opts or "--help" in opts:
            usage(0)

        if len(args) < 2:
            usage(1)

    except getopt.GetoptError as e:
        print("error:", e, file=sys.stderr)
        print("Try '{} --help' for details.".format(sys.argv[0]), file=sys.stderr)
        sys.exit(1)

    program = args[0]
    file = args[1]

    lex = UrlLexer(program)

    lex.rewind()
    lexer2keys(lex)

    datab=a2leb([0x1E848A,0x0F4275,0x01,0x00,0x00,0x0640,0x0384,0x0640,0x0384,0x3F800000],4)
    datab.extend(i2leb(1+len(events),4))
    datab.extend(a2leb([0x64,0x01010101,0x03340101,0x00,0x01,0x07B1DE00],4))
    datab.extend(a2leb([0x08,0x030078,0x00,0x00,0x0152,0x02CA,0x00,0x01,0x00],4))
    datab.extend(i2leb(2*len(s_window),4))
    datab.extend(s2utf16(s_window))
    datab.extend(i2leb(0x00,4))
    datab.extend(i2leb(2*5,4)+s2utf16("$NEXT"))
    datab.extend(s_end)
    for k in events:
        if(k[0]==E_KEYPRESS):
            datab.extend(a2leb([0x05,0x32,k[1],0xFF,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x00],4))
            datab.extend(s_end)
        elif(k[0]==E_WAIT):
            datab.extend(a2leb([0x07,k[1],k[1],0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00],4))
            datab.extend(s_end)
        elif(k[0]==E_LEFTCLIC):
            datab.extend(a2leb([0x03,0x32,0x01,0x01,k[1],k[2],0x00,0x01,0x00,0x00,0x00,0x00],4))
            datab.extend(s_end)
    f=open(file,"wb+")
    f.write(datab)
    f.close()

    return 0

if __name__ == "__main__":
    sys.exit(main())
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 50.4%
 
Posts: 42146
Images: 16490
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

PreviousNext

Return to Casio (fx-82/83/85/92/95/115/300/350/500/570/991, Collège)

Who is online

Users browsing this forum: ClaudeBot [spider] and 0 guests

-
Search
-
Social TI-Planet
-
Featured topics
Grand Concours 2024-2025 - Programmation Python
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
12345
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
644 utilisateurs:
>619 invités
>19 membres
>6 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)