Omnimaga

Calculator Community => HP Calculators => Topic started by: XiiDraco on October 21, 2013, 10:45:39 pm

Title: Hp Prime Questions and Help
Post by: XiiDraco on October 21, 2013, 10:45:39 pm
I've made this new topic here, to share knowledge and ask questions about the HP Prime, It's language (Prime BASIC?), and ways to go about certain things.

For Ex.

I have a question (seriously), How would I go about drawing text, sprites, and other objects to the screen?

Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 21, 2013, 11:41:32 pm
Have you checked the on-calc help by the way? The HP Prime wiki could be useful too http://tiplanet.org/hpwiki/index.php?title=HP_Prime/HP-BASIC , although it's incomplete. Just go to the commands menus then when hovering over a command with the arrows, press the Help button. They all have the syntax there.

However, in case you already checked that and it didn't work, could you share what troubles you had (source code)?

Sprites can be rather tricky because of the format. You need to convert images to HP Prime data using one of the converters there: http://ourl.ca/19398 (my favorite is Tim Wessman's because it has a GUI, but I like Jim Bauwens' too). To create one 16x16 sprite the code would look like this:

DIMGROB_P(G1, 16, 16, {#200420002000200:64h ,#200020002000200:64h ,#200020002000200:64h ,#200420002000200:64h ,#2007FE0020003E0:64h ,#200420002004200:64h ,#4200020002006378:64h ,#2007FE002000200:64h ,#2007FE0020003E0:64h ,#200020002000200:64h ,#20003E002000200:64h , #2007FE002000200:64h ,#200020002000200:64h ,#4200000002000210:64h ,#20003E002000200:64h ,#200020063780200:64h ,#200000002007FE0:64h ,#2000000020003E0:64h ,#200020002000200:64h ,#200021002000200:64h ,#200000002007FE0:64h ,#2000210020003E0:64h ,#20002007FE00200:64h , #200020003E00200:64h ,#6378020002000200:64h ,#20003E002000200:64h ,#420002007FE00200:64h ,#6378020003E00200:64h ,#200020042000200:64h ,#20003E002000200:64h ,#200020002000200:64h ,#200020002000000:64h ,#2007FE003E00200:64h ,#7FE0020042000200:64h ,#200020002000200:64h , #200020002000000:64h ,#2007FE003E00200:64h ,#7FE0020002000200:64h ,#3E0020063780200:64h ,#200420002000200:64h ,#200020002000200:64h ,#200020002006378:64h ,#3E0020002000000:64h ,#200020002000200:64h ,#200020003E00200:64h ,#200020002007FE0:64h ,#2007FE002000000:64h , #200420002000200:64h ,#200020003E00200:64h ,#3E0021002007FE0:64h ,#2007FE002000200:64h ,#200020003E00200:64h ,#200420002000200:64h ,#3E0020002000200:64h ,#200420002000200:64h ,#200020003E00200:64h ,#200021063780200:64h ,#200020042000200:64h ,#4200020002000200:64h , #200021002000200:64h ,#200020002000200:64h ,#200020002000200:64h ,#200020002000200:64h ,#200020002000200:64h });


To display it somewhere on the screen you need to do something like BLIT_P(G0,100,100,116,116,G1,0,0,16,16);
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 21, 2013, 11:44:31 pm
Ok sweet that's really helpful. + I didn't know you could use the help section on the cmds. XD

Expect Abandoned for Hp Prime :P
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 21, 2013, 11:52:00 pm
Oh also btw you can store as many sprites as you want in one GROB, but you can only store about 15 at once in one DIMGROB_P command. It's possible to have more than that by creating a massive GROB (for example, using DIMGROB_P(G2,16,1024); ) then creating one set of sprite in G1, copying it in G2, creating another in G1, copying it after the other, and so on.


As for transparency, for example if you use red, you should setup the 2nd GROB like this:
DIMGROB_P(G2,16,1024,RGB(255,0,0,128));

Basically it sets the background color to red, but transparent. Do not use White, though, else it won't work.


Here's some code example at http://ourl.ca/19698/362793 but I might use those sprites in a game.

As for Abandoned it would probably be possible, but try to keep your graphics small and have no rotation. It's best to start with smaller projects too in case, and experiment.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 22, 2013, 01:15:03 am
You lost me pretty quick. XD Anyway ya, I'm probably going to keep small sprites, finite worlds, no multiplayer, and no sprite rotation.
Title: Re: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 22, 2013, 02:53:49 pm
Btw one trick to create small games is also to just use a 160x120 screen area with 8x8 sprites then once you updated the display content in a GROB/buffer, you just copy that buffer scaled up to twice its size. It causes some minor slowdowns, though. There is a rotation routine somewhere but it's slow, so to use rotated sprites you have to pre-render them before the game starts.
Title: Re: Hp Prime Questions and Help
Post by: Ryleh on October 28, 2013, 09:25:19 am
Can't help but feel this is a stupid question but what are you guys using to program in?
I'm just typing into the calculator directly through the connectivity kit in the most 'agnostic' way I can since it doesn't support all of the same symbols/input as the calculator (and vice-versa).

Additionally, are there any well defined resources further describing the language functions and their usage? A better explanation of the syntax would be particularly beneficial as that is what is holding me back the most. Any general help on how to approach programming on this thing would be great. Something tells me I'm doing something wrong if I have a dozen end statements at the end of some of my programs. Decent at C/C++(academic and extracurricular) but my TI-Basic was hack-ish at best(bulky and far from efficient). Started work on a cheat sheet but outside of the integer stuff, it is limited to what I can piece together from the 600-ish page manual.
Cheat sheet:
Spoiler For Spoiler:
########################################################################################################
   ____ ___  __  __ __  __    _    _   _ ____  ____ 
  / ___/ _ \|  \/  |  \/  |  / \  | \ | |  _ \/ ___|
 | |  | | | | |\/| | |\/| | / _ \ |  \| | | | \___ \
 | |__| |_| | |  | | |  | |/ ___ \| |\  | |_| |___) |
  \____\___/|_|  |_|_|  |_/_/   \_\_| \_|____/|____/
 
########################################################################################################
List of inputs:

A - ) Strings
   01a - ASC
   02a - ROTATE
   03a - MID
   04a - RIGHT
   05a - STRINGFROMID
   06a - LEFT
   07a - STRING
   08a - EXPR
   09a - DIM

B.) Drawing
   01b - C->PX
   02b - DRAWMENU
   03b - FREEZE
   04b - PX->C
   05b - RGB
   06b - Pixels
      - ARC_P
      - BLIT_P
      - DIMGROB_P
      - GETPIX_P
      - GROBH_P
      - GROBW_P
      - INVERT_P
      - LINE_P
      - PIXOFF_P
      - PIXON_P
      - RECT_P
      - SUBGROB_P
      - TEXTOUT_P
   7b - Cartesian
      - ARC
      - BLIT
      - DIMGROB
      - GETPIX
      - GROBH
      - GROBW
      - INVERT
      - LINE
      - PIXOFF
      - PIXON
      - RECT
      - SUBGROB
      - TEXTOUT

C.) Matrix
   01c. - ADDCOL
   02c. - ADDROW
   03c. - DELCOL
   04c. - EDIMAT
   05c. - REDIM
   06c. - REPLACE
   07c. - SCALE
   08c. - SCALEADD
   09c. - SUB
   10c. - SWAPCOL
   11c. - SWAPROW
D.) App Functions
   01d. - CHECK
   02d. - STARTAPP
   03d. - STARTVIEW
   04d. - UNCHECK
   05d. - VIEW

E.) Integer
   01e - BITAND
   02e - BITNOT
   03e - BITOR
   04e - BITSL
   05e - BITSR
   06e - BITXOR
   07e - B->R
   08e - GETBASE
   09e - GETBITS
   10e - R->B
   11e - SETBASE
   12e - SETBITS
   
F.) I/O
   01f - CHOOSE
   02f - EDITLIST
   03f - EDITMAT
   04f - GETKEY
   05f - INPUT
   06f - ISKEYDOWN
   07f - MOUSE
   08f - MSGBOX
   09f - PRINT
   10f - WAIT
   
G.) More
   01g - %CHANGE
   02g - %TOTAL
   03g - CAS
   04g - EVALLIST
   05g - EXECON
   06g - ->HMS
   07g - HMS->
   08g - ITERATE
   09g - TICKS
   10g - TIME
   11g - TYPE
########################################################################################################
  ____  ____   ___   ____ ____      _    __  __    ____ ___  __  __ __  __    _    _   _ ____  ____ 
 |  _ \|  _ \ / _ \ / ___|  _ \    / \  |  \/  |  / ___/ _ \|  \/  |  \/  |  / \  | \ | |  _ \/ ___|
 | |_) | |_) | | | | |  _| |_) |  / _ \ | |\/| | | |  | | | | |\/| | |\/| | / _ \ |  \| | | | \___ \
 |  __/|  _ <| |_| | |_| |  _ <  / ___ \| |  | | | |__| |_| | |  | | |  | |/ ___ \| |\  | |_| |___) |
 |_|   |_| \_\\___/ \____|_| \_\/_/   \_\_|  |_|  \____\___/|_|  |_|_|  |_/_/   \_\_| \_|____/|____/
 
########################################################################################################

H.) Block
   01h - BEGIN END
   02h - RETURN
   03h - KILL
   
I.) Branch
   01i - IF THEN
   02i - IF THEN ELSE
   03i - CASE
   04i - IFERR
   05i - IFERR ELSE

J.) Loop
   01j - FOR
   02j - FOR STEP
   03j - FOR DOWN
   04j - FOR DOWN STEP
   05j - WHILE
   06j - REPEAT
   07j - BREAK
   08j - CONTINUE

K.) Variable
   01k - LOCAL
   02k - EXPORT

L.) Function
   01l - EXPORT
   02l - VIEW
   03l - KEY


Looking to do the definition usage stuff later today. Wondering if there is already something along this vein before I up and do it myself. Mind the messed up ANSI words. The TI-Planet wiki thing doesn't seem to have much more then the drawing done.
Title: Re: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 28, 2013, 02:01:34 pm
I personally used the guide book, as well as the on-calc help and the HP Prime wiki on TI-Planet for reference. It did the job decently, but I had to ask on the forums for clarification. In general, for now it's best to ask on the forums if you can't find what you need.

Also I prefer programming using the connectivity kit. For weird symbols I always have some code containing them nearby that I can copy/paste from anyway. I sometimes use the emulator too, but the random crashes are annoying with the resulting progress loss and on the real calc, if my program code is very long in terms of width, typing is very slow.
Title: Re: Hp Prime Questions and Help
Post by: Ryleh on October 28, 2013, 02:16:32 pm
Didn't come to mind to manually enter the codes. I'll have to make a list of common things I use that don't display properly.
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 28, 2013, 03:15:17 pm
Which ones do you use in particular by the way? I tend to only use the Sto character.
Title: Re: Hp Prime Questions and Help
Post by: Ryleh on October 28, 2013, 03:52:43 pm
Which ones do you use in particular by the way? I tend to only use the Sto character.
Tau(т), Pi(π), Theta(Σ) and that weird u with the front tail come to mind. Forgot to mention it but I am also typing out notes so sometimes I want the actual character.

I have a few more questions...

Are any of the following things possible:
-Programs with multiple drop downs (Concurrently)
-Program with multiple entry boxes where it doesn't need submitted(results are displayed as more information is added)
-Make it access the cas/traditional view where it calculates math normally but with acceptance for additional characters(who serve as their own variables, ex. 12m being 12E-3 or 12x10^3)
-Practically display drawn objects on the graphing view (or with similar functionality at least)
-Use of checkmark like stuff for checking

Would like to know ahead of time if any of these things are not possible to do for whatever arbitrary reason before I invest to much time in trying to do it that way. Understand there are workarounds to all of the above things but I'd like to do it as elegantly as possible since I'd like to work on making it as user-friendly as possible.



Here are some of the ideas I had on things I'd like to do(in no order of actual interest or likelihood of actually doing them):
-Resistor rating calculator(with drop downs for different colors/tolerance)
-Karnaugh Map Generator
-Boolean logic simplifier
-Ohm's Law solver
-Capacitor/Inductance solver
-Boolean truth table
-Circuit truth table
-KVL/KCL/Nodal Analysis
-General area for manually computing EE related stuff(more easily for less-well acquainted users of the calculator)
-IC searcher (means of searching for very specific IC chip names)


Thanks again in advance for any prior or future advice. :P
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 28, 2013, 07:19:16 pm
I'm pretty sure that (Σ) is Sigma...
Isn't Theta (Θ)?

Anyway, I'm pretty sure that all of these would be entirely possible.
Title: Re: Hp Prime Questions and Help
Post by: Ryleh on October 28, 2013, 09:18:22 pm
I'm pretty sure that (Σ) is Sigma...
Isn't Theta (Θ)?

Anyway, I'm pretty sure that all of these would be entirely possible.

You're right on both accounts. Silly mistake on my end. x_x

Glad to hear you think those things are possible. Thanks.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 28, 2013, 09:45:14 pm
Been playing around with my prime for a bit. Although I should get back to my C# game. Does anyone know what "mouse" does? By the description it looks like it gives you touch variables in a list.

For example {x1,x2,originalx,originaly,type} for type the following include: drag, swipe, hold, press, etc.

I think this is enough to assume touch control is definitely programmable. So for anyone who is wondering...PROJECT ABANDONED PRIME IS A GO! ;D(http://www.omnimaga.org/Themes/default/images/gpbp_arrow_up.gif) ;)
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 28, 2013, 10:39:33 pm
I definitively think that the mouse command is for the touchscreen. And wow I didn't realize it also had complex commands such as drag and swipe O.O. It would make certain strategy games possible for sure. My only concern would be slowdowns resulting from AI if a strategy game has collision detection to take into account. Unless it was made as dumb as Warcraft 2 AI.


On a side note, anyone know if it's possible to permanently save lists and other kind of variables? I know that the calc has some lists vars but I heard that they get deleted when the calc is turned OFF.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 29, 2013, 12:02:05 am
Wait why would the variable get deleted when the calc turns off? It's a sort of sleep isn't it? So there is no reason to delete them right? Unfortunately I don't know what you could use...
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 29, 2013, 12:06:28 am
I know that GROB vars does and some other vars. It's possible that this is how HP calcs works. I just hope that there's at least something that can be kept in memory, so that games such as RPGs don't need to use password-based saving features like in some NES and SNES games. Typing passwords or writing them down was annoying.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 29, 2013, 01:34:41 am
That's what notes section on the prime is for :P. Anyway, so DJ do you know how to use the Mouse command? Like what exactly does it return and how do you use it?
If you don't know that's K.

EDIT: It looks like List and Matrices stay the same. Even after the calc is "reset". Just don't accidentally overwrite one when using graphs or something...
Lists are deleted when the calc is reset but not by turning it off. Matrices are invincible.
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 29, 2013, 02:00:21 am
Ah I see. Now if only we could create as many custom-named lists as we want, there would be no risk of accidentally overwriting out highscores or something x.x

Also I didn't try the mouse command because I was focusing on learning xLIBC lately.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 29, 2013, 02:01:50 am
I'll look more into it... I would really like that...

I think it's funny how we say stuff in the IRC then say exactly what we just said in the post. #facepalm
Title: Re: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on October 29, 2013, 11:27:51 am
True, although in some cases I think it's better that some calc help goes on the forums, in case someone needs it later.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on October 30, 2013, 12:01:28 am
I answered my comment when I wrote it. Thought about that just afterward but decided not to post it. XP
Title: Re: Hp Prime Questions and Help
Post by: MacBernick on December 03, 2013, 11:44:17 am
Got one question please, I don't see how to programmatically set angle unit to degrees. Thank you !
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on December 03, 2013, 07:21:46 pm
If you can't find something, check the catalog. Unfortunately my Hp Prime is dead and I lost my charger cable. :'(
I would help if I could.
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on December 03, 2013, 07:27:45 pm
Do you mean it's bricked? O.O Or has it just run out of batteries? You could maybe use a phone cable or something, but be careful to not destroy the link port, since it's kinda loose (the official HP cable has that rectangular thing at the end of it that holds it in place more).

As for the angle question, I can't help, sadly, since I haven't checked yet. D:
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on December 04, 2013, 07:16:19 pm
Ran out of batteries and got now charger, and I'm not willing to make a makeshift cable, I'm a software guy not hardware. :(
Title: Re: Hp Prime Questions and Help
Post by: timwessman on December 04, 2013, 07:34:33 pm
Ran out of batteries and got now charger, and I'm not willing to make a makeshift cable, I'm a software guy not hardware. :(

And you don't have any micro usb cable sitting around? I can count on 1 hand the times I've used the "official" charger. It will charge just as well from any usb port...
Title: Re: Hp Prime Questions and Help
Post by: Hexatron on December 04, 2013, 09:03:01 pm
This is my question: What are the advantages of the HP PRIME in relative to the TI-NSPIRE and CASIO PRIZM?
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on December 05, 2013, 12:29:10 am
Ran out of batteries and got now charger, and I'm not willing to make a makeshift cable, I'm a software guy not hardware. :(

And you don't have any micro usb cable sitting around? I can count on 1 hand the times I've used the "official" charger. It will charge just as well from any usb port...
The Hp Prime does not use a micro usb cable, it is a very specific port made for an Hp Prime cable only. I would have tried that already I have more than 50 micro usb cable.

This is my question: What are the advantages of the HP PRIME in relative to the TI-NSPIRE and CASIO PRIZM?
Hp Prime basic is VERY fast, as far as I know if any sort of assembly were to be made, it would be even faster?
Not to even mention the much higher resolution, 2-finger touch display, and easy to learn BASIC language.
Title: Re: Hp Prime Questions and Help
Post by: sailerboy on December 05, 2013, 12:52:53 am
Ran out of batteries and got now charger, and I'm not willing to make a makeshift cable, I'm a software guy not hardware. :(

And you don't have any micro usb cable sitting around? I can count on 1 hand the times I've used the "official" charger. It will charge just as well from any usb port...
The Hp Prime does not use a micro usb cable, it is a very specific port made for an Hp Prime cable only. I would have tried that already I have more than 50 micro usb cable.

Dude, it's a microusb. Tim Wessman works for HP on the prime, he would know exactly what the prime uses...
Title: Re: Hp Prime Questions and Help
Post by: timwessman on December 05, 2013, 01:00:20 am
Yup, it is definitely a micro USB. Pretty much any phone/tablet charger you might have will work just fine.

What is probably messing you up is that it is a micro-A. In other words, it can also act as a host. The normal cable you are thinking about is the micro-B. A micro B cable can go into a micro-A, as can also the host end of a micro AB cable. Here's a picture and some more info http://en.wikipedia.org/wiki/Micro_USB#Mini_and_Micro_connectors (http://en.wikipedia.org/wiki/Micro_USB#Mini_and_Micro_connectors).

I believe unless I am remembering wrong that the nspire uses a mini-A on the calculator, so a similar thing would happen if you compared those with the common (now deprecated) mini-B.

Got one question please, I don't see how to programmatically set angle unit to degrees. Thank you !

HAngle:=1 or HAngle:=0   (home angle)  Take a look in your VARS->HOME->SETTINGS for others.
Title: Re: Hp Prime Questions and Help
Post by: XiiDraco on December 05, 2013, 02:02:37 am
OH, I thought we were talking about mini not micro, lol sorry! I've got tons of those! :D
Title: Re: Hp Prime Questions and Help
Post by: critor on December 05, 2013, 06:13:05 am
The TI-Nspire calculators have a mini-AB connector.
Title: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on December 05, 2013, 09:08:52 am
This is my question: What are the advantages of the HP PRIME in relative to the TI-NSPIRE and CASIO PRIZM?
Less locked down and its on-calc language is much more complete and faster than the disaster that is TI-Nspire Basic. The Nspire has Lua, although to program it on-calc you need to use a third-party tool and Lua isn't as fast for certain things (except filled shape rotation, but now that the Prime has triangle and polygon support, I bet that rotation could be implemented through those).
Title: Re: Hp Prime Questions and Help
Post by: JosJuice on December 05, 2013, 10:07:07 am
This is my question: What are the advantages of the HP PRIME in relative to the TI-NSPIRE and CASIO PRIZM?
Less locked down and its on-calc language is much more complete and faster than the disaster that is TI-Nspire Basic.
Much faster than the disaster that is graphics in Prizm Casio-BASIC too :)
Title: Re: Hp Prime Questions and Help
Post by: MacBernick on December 05, 2013, 07:01:17 pm
Yup, it is definitely a micro USB. Pretty much any phone/tablet charger you might have will work just fine.

What is probably messing you up is that it is a micro-A. In other words, it can also act as a host. The normal cable you are thinking about is the micro-B. A micro B cable can go into a micro-A, as can also the host end of a micro AB cable. Here's a picture and some more info http://en.wikipedia.org/wiki/Micro_USB#Mini_and_Micro_connectors (http://en.wikipedia.org/wiki/Micro_USB#Mini_and_Micro_connectors).

I believe unless I am remembering wrong that the nspire uses a mini-A on the calculator, so a similar thing would happen if you compared those with the common (now deprecated) mini-B.

Got one question please, I don't see how to programmatically set angle unit to degrees. Thank you !

HAngle:=1 or HAngle:=0   (home angle)  Take a look in your VARS->HOME->SETTINGS for others.

I tried that but it didn't work in the first place. Trying again...
EDIT : Now it works. I must have miss something the first time. Or maybe I was drunk.
Thank you ^^
Title: Re: Re: Hp Prime Questions and Help
Post by: DJ Omnimaga on December 05, 2013, 09:22:35 pm
Btw could someone help me with the polygon commands? i made a topic about it a few days ago, but I still have the issue. D: