TI-84 Python edition – hybrid programming
The Texas Instruments TI-84 Plus CE-T calculator has a special edition called “Python Edition”
It’s easy to develop Python programs for this system.
I’m developing like this:
I develop the programs like normal python programs on a PC with an editor (in my case PyCharm and Notepad++).
To be able to test the program on a PC (multi-platform, hybrid) I’ve made the following design.
1. conditional support for imports from TI libraries, like this:
try:
from ti_system import *
except Exception as e:
print (“no module ti_system”)
2. read and write data wrapped in functions with a hybrid implementation
For reading data TI uses recall_list
For writing data TI uses store_list
On a “normal” system without the ti_system library this will not work.
So, I made wrapper functions with exception handling, e.g.
def saveeuro(ieuro):
xlist=[]
xlist.append(ieuro)
try:
store_list(“1”,xlist)
except NameError as e:
saveEuroToFile(ieuro)
return
See github for the sourcecode (or see EUROCHF.py below):
github.com/edleijnse/ti84python
EUROCHF.py
sample program to convert currencies (in sample from CHF TO EURO)
The EURO currency is stored and can be changed anytime.
On the TI-84 you can read (or set) the currency with STAT and L1
try:
from ti_system import *
except Exception as e:
print ("no module ti_system")
def euro2chf(initeuro):
print("")
try:
neweuro = float(input("new euro value? (" + '{:.2f}'.format(initeuro) + "): "))
except Exception as e:
neweuro=initeuro
euro= neweuro
print("euro: " + '{:.2f}'.format(euro))
print("")
eurocount=float(input("amount euros "))
print("amount euros: ", eurocount)
chf=euro*eurocount
print ("costs in CHF: " + '{:.2f}'.format(chf))
return neweuro
def getEuroFromFile():
try:
file1 = open("eurostore.txt","r")
storedeuro = file1.read()
storedeuro = int(storedeuro)
file1.close()
except Exception as e:
storedeuro = .95
return storedeuro
def geteuro():
try:
xlist=recall_list("1")
storedeuro = float(xlist[0])
except NameError as e:
storedeuro=getEuroFromFile()
except Exception as e:
storedeuro = .83
saveeuro(storedeuro)
return storedeuro
def saveEuroToFile(iEuro):
file1 = open("eurostore.txt","w")
file1.write(str(iEuro))
file1.close()
def saveeuro(ieuro):
xlist=[]
xlist.append(ieuro)
try:
store_list("1",xlist)
except NameError as e:
saveEuroToFile(ieuro)
return
initeuro=geteuro()
while True:
try:
stopnow = input("stop program (1=y)? ")
if stopnow == "1":
break
initeuro = euro2chf(initeuro)
saveeuro(initeuro)
except Exception as e:
print(e)
LINKS TI-PYTHON articles
https://www.tomshardware.com/news/circuitpython-powers-ti-84-calculator