Post Reply 
Casio Python updates
04-07-2020, 08:19 PM (This post was last modified: 04-09-2020 12:39 AM by ijabbott.)
Post: #1
Casio Python updates
The firmware updates promised for April 2020 are out now.
  • OS Ver. 3.40 for fx-CG50, fx-CG50 AU, and Graph 90+E
  • OS Ver. 3.30 for Graph 35+E II

Correction: OS Ver. 3.30 has not been released for fx-9860GIII as of 2020-04-07. Maybe it will be released later?

The MicroPython has a new "casioplot" module for drawing stuff.

I must say that the list of functions in the casioplot module is not very extensive:
  • show_screen() – shows (or refreshes) the drawing screen.
  • set_pixel(x, y[, color]) – draws a pixel with optional color (defaults to black).
  • get_pixel(x, y) – gets color of a pixel.
  • draw_string(x, y, s[, color[, size]]) – draws a text string with optional color (defaults to black) and size (defaults to "medium").

EDIT: There appears to be an additional, undocumented function:
  • clear_screen() – clears the drawing screen.

Drawing updates are not shown until the next call to show_screen(). The drawing screen is cleared (to all white pixels) when the SHELL is initialized (e.g. by running a .py script).

On the monochrome calculators (Graph 35+E II and fx-9860GIII is it is ever supported), RGB color values between (248,252,248) and (255,255,255) show as white; all other RGB color values show as black.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
04-08-2020, 02:53 AM (This post was last modified: 04-08-2020 11:12 AM by toml_12953.)
Post: #2
RE: Casio Python updates
(04-07-2020 08:19 PM)ijabbott Wrote:  The firmware updates promised for April 2020 are out now.
  • OS Ver. 3.40 for fx-CG50, fx-CG50 AU, and Graph 90+E
  • OS Ver. 3.30 for Graph 35+E II

The MicroPython has a new "casioplot" module for drawing stuff.

Here's an example of the new drawing functions on the fx-CG50:
Code:
from math import *
from casioplot import *
def hat():
  p=192; q=100
  xp=144; xr=1.5*3.1415927
  yp=56; yr=1; zp=64
  xf=xr/xp; yf=yp/yr; zf=xr/zp
  for y in range(0,192):
    for x in range(0,384):
      set_pixel(x,y)
  for zi in range(-q,q):
    if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      for xi in range(-xl,xl+1):
        xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
        yy=(sin(xt)+.4*sin(3*xt))*yf
        x1=int(xx+zz+p)
        y1=192-int(yy-zz+q)
        set_pixel(x1,y1,(0,255,0))
        show_screen()
        for m in range(y1+1,192):
          set_pixel(x1,m)

It draws the infamous green hat.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-08-2020, 08:44 PM (This post was last modified: 04-08-2020 08:45 PM by ijabbott.)
Post: #3
RE: Casio Python updates
(04-08-2020 02:53 AM)toml_12953 Wrote:  Here's an example of the new drawing functions on the fx-CG50:
Code:
from math import *
from casioplot import *
def hat():
  p=192; q=100
  xp=144; xr=1.5*3.1415927
  yp=56; yr=1; zp=64
  xf=xr/xp; yf=yp/yr; zf=xr/zp
  for y in range(0,192):
    for x in range(0,384):
      set_pixel(x,y)
  for zi in range(-q,q):
    if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      for xi in range(-xl,xl+1):
        xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
        yy=(sin(xt)+.4*sin(3*xt))*yf
        x1=int(xx+zz+p)
        y1=192-int(yy-zz+q)
        set_pixel(x1,y1,(0,255,0))
        show_screen()
        for m in range(y1+1,192):
          set_pixel(x1,m)

It draws the infamous green hat.

Thanks! I got bored waiting for it to finish, so I tweaked it a little bit.
Code:
from math import *
from casioplot import *
def hat():
  p=192; q=100
  xp=144; xr=1.5*3.1415927
  yp=56; yr=1; zp=64
  xf=xr/xp; yf=yp/yr; zf=xr/zp
  for y in range(0,192):
    for x in range(0,384):
      set_pixel(x,y)
  for zi in range(-q,q):
    if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      for xi in range(-xl,xl+1):
        xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
        yy=(sin(xt)+.4*sin(3*xt))*yf
        x1=int(xx+zz+p)
        y1=192-int(yy-zz+q)
        set_pixel(x1,y1,(0,255,0))
        for m in range(y1+1,y1+10):
          set_pixel(x1,m)
      show_screen()

— Ian Abbott
Find all posts by this user
Quote this message in a reply
04-08-2020, 09:37 PM
Post: #4
RE: Casio Python updates
(04-08-2020 08:44 PM)ijabbott Wrote:  
(04-08-2020 02:53 AM)toml_12953 Wrote:  Here's an example of the new drawing functions on the fx-CG50:
Code:
from math import *
from casioplot import *
def hat():
  p=192; q=100
  xp=144; xr=1.5*3.1415927
  yp=56; yr=1; zp=64
  xf=xr/xp; yf=yp/yr; zf=xr/zp
  for y in range(0,192):
    for x in range(0,384):
      set_pixel(x,y)
  for zi in range(-q,q):
    if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      for xi in range(-xl,xl+1):
        xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
        yy=(sin(xt)+.4*sin(3*xt))*yf
        x1=int(xx+zz+p)
        y1=192-int(yy-zz+q)
        set_pixel(x1,y1,(0,255,0))
        show_screen()
        for m in range(y1+1,192):
          set_pixel(x1,m)

It draws the infamous green hat.

Thanks! I got bored waiting for it to finish, so I tweaked it a little bit.
Code:
from math import *
from casioplot import *
def hat():
  p=192; q=100
  xp=144; xr=1.5*3.1415927
  yp=56; yr=1; zp=64
  xf=xr/xp; yf=yp/yr; zf=xr/zp
  for y in range(0,192):
    for x in range(0,384):
      set_pixel(x,y)
  for zi in range(-q,q):
    if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      for xi in range(-xl,xl+1):
        xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
        yy=(sin(xt)+.4*sin(3*xt))*yf
        x1=int(xx+zz+p)
        y1=192-int(yy-zz+q)
        set_pixel(x1,y1,(0,255,0))
        for m in range(y1+1,y1+10):
          set_pixel(x1,m)
      show_screen()

You don't want to see it drawn? Smile

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-08-2020, 10:40 PM
Post: #5
RE: Casio Python updates
Matplotlib and Turtle are also available.
Links to these modules are provided at the bottom of this post:
https://tiplanet.org/forum/viewtopic.php?f=51&t=23670

Jean-Charles
Find all posts by this user
Quote this message in a reply
04-09-2020, 12:03 AM (This post was last modified: 04-09-2020 12:06 AM by ijabbott.)
Post: #6
RE: Casio Python updates
(04-08-2020 09:37 PM)toml_12953 Wrote:  
(04-08-2020 08:44 PM)ijabbott Wrote:  Thanks! I got bored waiting for it to finish, so I tweaked it a little bit.
Code:
from math import *
from casioplot import *
def hat():
  p=192; q=100
  xp=144; xr=1.5*3.1415927
  yp=56; yr=1; zp=64
  xf=xr/xp; yf=yp/yr; zf=xr/zp
  for y in range(0,192):
    for x in range(0,384):
      set_pixel(x,y)
  for zi in range(-q,q):
    if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      for xi in range(-xl,xl+1):
        xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
        yy=(sin(xt)+.4*sin(3*xt))*yf
        x1=int(xx+zz+p)
        y1=192-int(yy-zz+q)
        set_pixel(x1,y1,(0,255,0))
        for m in range(y1+1,y1+10):
          set_pixel(x1,m)
      show_screen()

You don't want to see it drawn? Smile

It still shows it being drawn, but a whole section at a time (including hidden line removal) instead of a single point at a time. The main speed increase comes from only blanking 10 pixels below the curve for hidden line removal instead of blanking all the way to the bottom.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
04-09-2020, 12:15 AM
Post: #7
RE: Casio Python updates
(04-08-2020 10:40 PM)Helix Wrote:  Matplotlib and Turtle are also available.
Links to these modules are provided at the bottom of this post:
https://tiplanet.org/forum/viewtopic.php?f=51&t=23670

Fantastic! The fx-CG50 gets better and better.
Thanks for the heads-up.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-09-2020, 12:35 AM
Post: #8
RE: Casio Python updates
(04-08-2020 10:40 PM)Helix Wrote:  Matplotlib and Turtle are also available.
Links to these modules are provided at the bottom of this post:
https://tiplanet.org/forum/viewtopic.php?f=51&t=23670

Nice! I didn't mention them because they're not built-in. I see they use an undocumented built-in function clear_screen(). (It would be nice if that could take an optional color parameter.)

— Ian Abbott
Find all posts by this user
Quote this message in a reply
04-09-2020, 12:54 AM
Post: #9
RE: Casio Python updates
(04-09-2020 12:35 AM)ijabbott Wrote:  
(04-08-2020 10:40 PM)Helix Wrote:  Matplotlib and Turtle are also available.
Links to these modules are provided at the bottom of this post:
https://tiplanet.org/forum/viewtopic.php?f=51&t=23670

Nice! I didn't mention them because they're not built-in. I see they use an undocumented built-in function clear_screen(). (It would be nice if that could take an optional color parameter.)

Yeah, it would save me a bit of time in my hat program to be able to clear the screen to black with a built-in command.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-11-2020, 03:40 PM
Post: #10
RE: Casio Python updates
Very interesting to see that.
I'd wonder when we can hope that that update will arrive in the shops (except that because of the lock down the local calculator shop in the uk is shut)?

None of the websites seem to sell a particular version, and I saw a YouTube video suggesting that you can only update an older cg50 if you have a PC (I have an android).

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
04-11-2020, 04:09 PM
Post: #11
RE: Casio Python updates
(04-09-2020 12:03 AM)ijabbott Wrote:  It still shows it being drawn, but a whole section at a time (including hidden line removal) instead of a single point at a time. The main speed increase comes from only blanking 10 pixels below the curve for hidden line removal instead of blanking all the way to the bottom.

The program I ported it from had a built-in line command it used to draw from just below the current point to the bottom of the screen. I blindly followed that. Your method of only clearing as many pixels as necessary is great! Thanks.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-11-2020, 04:31 PM
Post: #12
RE: Casio Python updates
(04-11-2020 03:40 PM)StephenG1CMZ Wrote:  Very interesting to see that.
I'd wonder when we can hope that that update will arrive in the shops (except that because of the lock down the local calculator shop in the uk is shut)?

None of the websites seem to sell a particular version, and I saw a YouTube video suggesting that you can only update an older cg50 if you have a PC (I have an android).

If there's no WINE for Android, you'll have to find a friend with a PC to update the Casio. You really have NO access to a PC, laptop or other Windows or Linux machine?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-11-2020, 07:31 PM
Post: #13
RE: Casio Python updates
No PC, both broke a while ago and I'm deterred from splashing out on a new laptop in case the cat sits on my lap Sad.
It seems there is a Wine for android, but I haven't yet pinpointed it amongst all the more social wine apps.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
04-11-2020, 08:38 PM
Post: #14
RE: Casio Python updates
(04-11-2020 07:31 PM)StephenG1CMZ Wrote:  It seems there is a Wine for android, but I haven't yet pinpointed it amongst all the more social wine apps.

I couldn't live without WINE and wine! Big Grin

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-12-2020, 03:53 PM
Post: #15
RE: Casio Python updates
For standard Python users, here's a version that runs on cPython:
Code:
from math import *
from time import *
from graphics import *
t0 = monotonic() # Save the current clock count for timing program
# Define graphics screen
win=GraphWin("Green Hat", 320, 200)
win.setCoords(0,0,319,199)
win.setBackground("black")
# Start program proper
p=160; q=100
xp=144; xr=1.5*3.1415927
yp=56; yr=1; zp=64
xf=xr/xp; yf=yp/yr; zf=xr/zp
for zi in range(-q,q):
  if zi>=-zp and zi<=zp:
    zt=zi*xp/zp; zz=zi
    xl=int(.5+sqrt(xp*xp-zt*zt))
    # Draw one cross-section of figure
    for xi in range(-xl,xl+1):
      xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
      yy=(sin(xt)+.4*sin(3*xt))*yf
      x1=round(xx+zz+p)
      y1=round(yy-zz+q)
      win.plot(x1,y1,"green")
      if y1!=0:
        lin=Line(Point(x1,y1-1),Point(x1,y1-10)) # Erase points below current point
        lin.draw(win)
print(monotonic() - t0,"seconds")
# Wait for mouse click and close window
win.getMouse()
win.close()

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
01-23-2021, 06:17 PM
Post: #16
RE: Casio Python updates
January 23, 2021.

Upgraded my Casio fx-9760GIII to 3.40.3200 using the “fx-9860GIII Series OS Ver.3.40 Update.exe” file (dated: 2020-09-30). Works very well. Python is 3 times faster than Basic and includes casioplot module. I have adapted the “hat.py” for the lower screen resolution by tweaking some constants. Here it is:

Code:

from math import *
from casioplot import *
blk=(0,0,0)
wht=(255,255,255)
p=64; q=32
xp=55; xr=1.8*3.14159265358
yp=20; yr=3; zp=20
xf=xr/xp; yf=yp/yr; zf=xr/zp
for zi in range(-q,q):
  if zi>=-zp and zi<=zp:
    zt=zi*xp/zp; zz=zi
    xl=int(.5+sqrt(xp*xp-zt*zt))
    for xi in range(-xl,xl+1):
      xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
      yy=(sin(xt)+.4*sin(3*xt))*yf
      x1=int(xx+zz+p)
      y1=192-int(yy-zz+q)
      set_pixel(x1,y1,(0,255,0))
      for m in range(y1+1,y1+10):
        set_pixel(x1,m)
    show_screen()
The results are beautiful and fast!
Find all posts by this user
Quote this message in a reply
01-24-2021, 12:51 PM
Post: #17
RE: Casio Python updates
(01-23-2021 06:17 PM)Benoit Morissette Wrote:  January 23, 2021.

Upgraded my Casio fx-9760GIII to 3.40.3200 using the “fx-9860GIII Series OS Ver.3.40 Update.exe” file (dated: 2020-09-30). Works very well. Python is 3 times faster than Basic and includes casioplot module. I have adapted the “hat.py” for the lower screen resolution by tweaking some constants. Here it is:

Code:

from math import *
from casioplot import *
blk=(0,0,0)
wht=(255,255,255)
p=64; q=32
xp=55; xr=1.8*3.14159265358
yp=20; yr=3; zp=20
xf=xr/xp; yf=yp/yr; zf=xr/zp
for zi in range(-q,q):
  if zi>=-zp and zi<=zp:
    zt=zi*xp/zp; zz=zi
    xl=int(.5+sqrt(xp*xp-zt*zt))
    for xi in range(-xl,xl+1):
      xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
      yy=(sin(xt)+.4*sin(3*xt))*yf
      x1=int(xx+zz+p)
      y1=192-int(yy-zz+q)
      set_pixel(x1,y1,(0,255,0))
      for m in range(y1+1,y1+10):
        set_pixel(x1,m)
    show_screen()
The results are beautiful and fast!

What are the variables blk and wht for? I don't see them used anywhere after being initialized.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
01-24-2021, 02:06 PM
Post: #18
RE: Casio Python updates
Oops, i forgot them!
They are "black" and "white", just in case i would have needed them.. sorry
Find all posts by this user
Quote this message in a reply
01-24-2021, 03:22 PM (This post was last modified: 01-24-2021 03:24 PM by StephenG1CMZ.)
Post: #19
RE: Casio Python updates
Blk and wht are clearly intended to be black and white rgb colours (perhaps a remnant of a monochrome version if unused).
Benoit, what version of Python did the Casio 9760giiii have out of the box prior to your update? Did it have casio plot?

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
01-24-2021, 04:56 PM
Post: #20
RE: Casio Python updates
I received it new 3 days ago from EBay. It had the OS version 03.21.3200. I don't know if it had casioplot. I upgraded it almost immediately to 3.40.3200 from the Casio web site. Downloaded the latest manual too. I paid only 62CAN$ including shipping. You can't get a better calc. for that price!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)